# HG changeset patch # User jlarmour # Date 967224758 0 # Node ID 6ed91473a1cd7b6a8249a228e8362b826afda207 # Parent 5ad2b71d525ec0fff8f037b91e41f3748970160d Merge from eCos master repository on 2000-08-21-22:40:54-BST diff --git a/host/ChangeLog b/host/ChangeLog --- a/host/ChangeLog +++ b/host/ChangeLog @@ -1,3 +1,11 @@ +2000-08-18 Bart Veer + + * configure.in: + Allow cross-compilation + + * Makefile.in, configure: + Regenerate + 2000-03-13 John Dallway * README: diff --git a/host/Makefile.in b/host/Makefile.in --- a/host/Makefile.in +++ b/host/Makefile.in @@ -240,7 +240,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ if test -f $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/host/configure b/host/configure --- a/host/configure +++ b/host/configure @@ -53,6 +53,7 @@ program_suffix=NONE program_transform_name=s,x,x, silent= site= +sitefile= srcdir= target=NONE verbose= @@ -167,6 +168,7 @@ Configuration: --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages + --site-file=FILE use FILE as the site file --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX @@ -337,6 +339,11 @@ EOF -site=* | --site=* | --sit=*) site="$ac_optarg" ;; + -site-file | --site-file | --site-fil | --site-fi | --site-f) + ac_prev=sitefile ;; + -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*) + sitefile="$ac_optarg" ;; + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) @@ -502,12 +509,16 @@ 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" +if test -z "$sitefile"; then + 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 +else + CONFIG_SITE="$sitefile" fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then @@ -572,7 +583,7 @@ else { echo "configure: error: can not r fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:576: checking host system type" >&5 +echo "configure:587: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -604,7 +615,7 @@ echo "$ac_t""$host" 1>&6 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:608: checking for a BSD compatible install" >&5 +echo "configure:619: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -657,7 +668,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCR test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:661: checking whether build environment is sane" >&5 +echo "configure:672: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -714,7 +725,7 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:718: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:729: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -753,7 +764,7 @@ fi missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:757: checking for working aclocal" >&5 +echo "configure:768: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -766,7 +777,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:770: checking for working autoconf" >&5 +echo "configure:781: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -779,7 +790,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:783: checking for working automake" >&5 +echo "configure:794: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -792,7 +803,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:796: checking for working autoheader" >&5 +echo "configure:807: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -805,7 +816,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:809: checking for working makeinfo" >&5 +echo "configure:820: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -819,7 +830,7 @@ fi echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:823: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:834: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -843,7 +854,7 @@ fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:847: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:858: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -870,12 +881,12 @@ else fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:874: checking for Cygwin environment" >&5 +echo "configure:885: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:901: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -905,7 +916,7 @@ test "$ac_cv_cygwin" = yes && CYGWIN=yes # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:909: checking for $ac_word" >&5 +echo "configure:920: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -935,7 +946,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:939: checking for $ac_word" >&5 +echo "configure:950: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -986,7 +997,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:990: checking for $ac_word" >&5 +echo "configure:1001: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1018,7 +1029,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1022: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1033: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1029,12 +1040,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1033 "configure" +#line 1044 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1038: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1049: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1060,12 +1071,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1064: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1075: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1069: checking whether we are using GNU C" >&5 +echo "configure:1080: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1074,7 +1085,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1078: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1089: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1093,7 +1104,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1097: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1108: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1129,7 +1140,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1133: checking for $ac_word" >&5 +echo "configure:1144: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1161,7 +1172,7 @@ test -n "$CXX" || CXX="gcc" echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1165: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 +echo "configure:1176: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1172,12 +1183,12 @@ cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext << EOF -#line 1176 "configure" +#line 1187 "configure" #include "confdefs.h" int main(){return(0);} EOF -if { (eval echo configure:1181: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1192: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cxx_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1203,12 +1214,12 @@ if test $ac_cv_prog_cxx_works = no; then { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1207: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1218: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 cross_compiling=$ac_cv_prog_cxx_cross echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 -echo "configure:1212: checking whether we are using GNU C++" >&5 +echo "configure:1223: checking whether we are using GNU C++" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1217,7 +1228,7 @@ else yes; #endif EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1221: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1232: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gxx=yes else ac_cv_prog_gxx=no @@ -1236,7 +1247,7 @@ ac_test_CXXFLAGS="${CXXFLAGS+set}" ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS= echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 -echo "configure:1240: checking whether ${CXX-g++} accepts -g" >&5 +echo "configure:1251: checking whether ${CXX-g++} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1268,13 +1279,13 @@ else fi echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:1272: checking for object suffix" >&5 +echo "configure:1283: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:1278: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1289: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -1292,19 +1303,19 @@ OBJEXT=$ac_cv_objext ac_objext=$ac_cv_objext echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:1296: checking for mingw32 environment" >&5 +echo "configure:1307: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1319: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -1323,7 +1334,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=y echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1327: checking for executable suffix" >&5 +echo "configure:1338: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1333,7 +1344,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj | *.ilk | *.pdb) ;; @@ -1358,7 +1369,7 @@ ac_exeext=$EXEEXT echo $ac_n "checking "for Visual C++"""... $ac_c" 1>&6 -echo "configure:1362: checking "for Visual C++"" >&5 +echo "configure:1373: checking "for Visual C++"" >&5 MSVC="no"; if test "${CC}" = "cl" ; then MSVC="yes" @@ -1378,17 +1389,13 @@ fi echo "$ac_t""${MSVC}" 1>&6 -if test "${cross_compiling}" = "yes"; then - { echo "configure: error: cross-compilation of this package is not supported" 1>&2; exit 1; } -fi - echo $ac_n "checking "the default compiler flags"""... $ac_c" 1>&6 -echo "configure:1392: checking "the default compiler flags"" >&5 +echo "configure:1399: checking "the default compiler flags"" >&5 cygflags_enable_debug="no" # Check whether --enable-debug or --disable-debug was given. @@ -1582,7 +1589,7 @@ fi echo $ac_n "checking for Tcl version""... $ac_c" 1>&6 -echo "configure:1586: checking for Tcl version" >&5 +echo "configure:1593: checking for Tcl version" >&5 # Check whether --with-tcl-version or --without-tcl-version was given. if test "${with_tcl_version+set}" = set; then withval="$with_tcl_version" @@ -1607,7 +1614,7 @@ echo "$ac_t""${cyg_ac_tcl_version}" 1>&6 echo $ac_n "checking for Tcl installation""... $ac_c" 1>&6 -echo "configure:1611: checking for Tcl installation" >&5 +echo "configure:1618: checking for Tcl installation" >&5 # Check whether --with-tcl or --without-tcl was given. if test "${with_tcl+set}" = set; then withval="$with_tcl" diff --git a/host/configure.in b/host/configure.in --- a/host/configure.in +++ b/host/configure.in @@ -56,13 +56,6 @@ AC_OBJEXT AC_EXEEXT CYG_AC_PROG_MSVC -dnl The eCos host-side only supports native builds, not cross-compilation. -dnl Cross-compilation should not be impossible, but various macros -dnl including testing for 64-bit require the ability to run code. -if test "${cross_compiling}" = "yes"; then - AC_MSG_ERROR(cross-compilation of this package is not supported) -fi - dnl Allow the usual assertion and trace related options. CYG_AC_ARG_INFRASTRUCTURE diff --git a/host/infra/ChangeLog b/host/infra/ChangeLog --- a/host/infra/ChangeLog +++ b/host/infra/ChangeLog @@ -1,3 +1,11 @@ +2000-08-18 Bart Veer + + * acinclude.m4, configure.in: + Allow cross-compilation + + * aclocal.m4, configure, Makefile.in, testsuite/Makefile.in + Regenerate + 1999-08-12 Bart Veer * configure: diff --git a/host/infra/Makefile.in b/host/infra/Makefile.in --- a/host/infra/Makefile.in +++ b/host/infra/Makefile.in @@ -83,10 +83,20 @@ AUTOMAKE_OPTIONS = 1.3 cygnus SUBDIRS = testsuite noinst_LIBRARIES = libcyginfra.a -libcyginfra_a_SOURCES = assert.cxx trace.cxx checkdata.cxx testcase.cxx +libcyginfra_a_SOURCES = assert.cxx \ + trace.cxx \ + checkdata.cxx \ + testcase.cxx -copies = cyg/infra/cyg_type.h cyg/infra/cyg_ass.h cyg/infra/cyg_trac.h cyg/infra/testcase.h cyg/hal/basetype.h pkgconf/infra.h pkgconf/hostinfra.h hosttest.exp +copies = cyg/infra/cyg_type.h \ + cyg/infra/cyg_ass.h \ + cyg/infra/cyg_trac.h \ + cyg/infra/testcase.h \ + cyg/hal/basetype.h \ + pkgconf/infra.h \ + pkgconf/hostinfra.h \ + hosttest.exp noinst_HEADERS = $(copies) @@ -367,7 +377,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ if test -f $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/host/infra/acinclude.m4 b/host/infra/acinclude.m4 --- a/host/infra/acinclude.m4 +++ b/host/infra/acinclude.m4 @@ -55,6 +55,12 @@ dnl dnl A better implementation would check whether or not AC_PROG_CC and dnl AC_PROG_CXX have been invoked and only test the appropriate dnl compiler. +dnl +dnl When cross-compiling, default to long long on the assumption that +dnl gcc/g++ must be used and long long is likely to be the 64 bit data +dnl type. This is not guaranteed, but sufficiently likely to meet +dnl the requirements for the time being. The CHECK_SIZEOF() macro +dnl might be another way to get the desired information. AC_DEFUN(CYG_AC_TYPE_64bit, [ AC_REQUIRE([AC_PROG_CC]) @@ -68,13 +74,13 @@ AC_DEFUN(CYG_AC_TYPE_64bit, [ main() { return 8 != sizeof($type); } - ],ctype_64bit=$type,ctype_64bit="unknown",ctype_64bit="unknown") + ],ctype_64bit=$type,ctype_64bit="unknown",ctype_64bit="long long") AC_LANG_CPLUSPLUS AC_TRY_RUN([ int main(int argc, char ** argv) { return 8 != sizeof($type); } - ],cxxtype_64bit=$type,cxxtype_64bit="unknown",cxxtype_64bit="unknown") + ],cxxtype_64bit=$type,cxxtype_64bit="unknown",cxxtype_64bit="long long") AC_LANG_RESTORE if test "${ctype_64bit}" = "${type}" -a "${cxxtype_64bit}" = "${type}"; then cyg_ac_cv_type_64bit="${type}" diff --git a/host/infra/aclocal.m4 b/host/infra/aclocal.m4 --- a/host/infra/aclocal.m4 +++ b/host/infra/aclocal.m4 @@ -67,6 +67,12 @@ dnl dnl A better implementation would check whether or not AC_PROG_CC and dnl AC_PROG_CXX have been invoked and only test the appropriate dnl compiler. +dnl +dnl When cross-compiling, default to long long on the assumption that +dnl gcc/g++ must be used and long long is likely to be the 64 bit data +dnl type. This is not guaranteed, but sufficiently likely to meet +dnl the requirements for the time being. The CHECK_SIZEOF() macro +dnl might be another way to get the desired information. AC_DEFUN(CYG_AC_TYPE_64bit, [ AC_REQUIRE([AC_PROG_CC]) @@ -80,13 +86,13 @@ AC_DEFUN(CYG_AC_TYPE_64bit, [ main() { return 8 != sizeof($type); } - ],ctype_64bit=$type,ctype_64bit="unknown",ctype_64bit="unknown") + ],ctype_64bit=$type,ctype_64bit="unknown",ctype_64bit="long long") AC_LANG_CPLUSPLUS AC_TRY_RUN([ int main(int argc, char ** argv) { return 8 != sizeof($type); } - ],cxxtype_64bit=$type,cxxtype_64bit="unknown",cxxtype_64bit="unknown") + ],cxxtype_64bit=$type,cxxtype_64bit="unknown",cxxtype_64bit="long long") AC_LANG_RESTORE if test "${ctype_64bit}" = "${type}" -a "${cxxtype_64bit}" = "${type}"; then cyg_ac_cv_type_64bit="${type}" diff --git a/host/infra/configure b/host/infra/configure --- a/host/infra/configure +++ b/host/infra/configure @@ -41,6 +41,7 @@ program_suffix=NONE program_transform_name=s,x,x, silent= site= +sitefile= srcdir= target=NONE verbose= @@ -155,6 +156,7 @@ Configuration: --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages + --site-file=FILE use FILE as the site file --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX @@ -325,6 +327,11 @@ EOF -site=* | --site=* | --sit=*) site="$ac_optarg" ;; + -site-file | --site-file | --site-fil | --site-fi | --site-f) + ac_prev=sitefile ;; + -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*) + sitefile="$ac_optarg" ;; + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) @@ -490,12 +497,16 @@ 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" +if test -z "$sitefile"; then + 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 +else + CONFIG_SITE="$sitefile" fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then @@ -562,7 +573,7 @@ else { echo "configure: error: can not r fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:566: checking host system type" >&5 +echo "configure:577: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -595,7 +606,7 @@ echo "$ac_t""$host" 1>&6 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:599: checking for a BSD compatible install" >&5 +echo "configure:610: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -648,7 +659,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCR test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:652: checking whether build environment is sane" >&5 +echo "configure:663: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -705,7 +716,7 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:709: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:720: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -744,7 +755,7 @@ fi missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:748: checking for working aclocal" >&5 +echo "configure:759: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -757,7 +768,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:761: checking for working autoconf" >&5 +echo "configure:772: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -770,7 +781,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:774: checking for working automake" >&5 +echo "configure:785: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -783,7 +794,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:787: checking for working autoheader" >&5 +echo "configure:798: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -796,7 +807,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:800: checking for working makeinfo" >&5 +echo "configure:811: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -818,7 +829,7 @@ EOF echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:822: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:833: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -842,7 +853,7 @@ fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:846: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:857: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -871,7 +882,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:875: checking for $ac_word" >&5 +echo "configure:886: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -901,7 +912,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:905: checking for $ac_word" >&5 +echo "configure:916: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -952,7 +963,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:956: checking for $ac_word" >&5 +echo "configure:967: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -984,7 +995,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:988: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:999: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -995,12 +1006,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 999 "configure" +#line 1010 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1004: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1026,12 +1037,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1030: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1041: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1035: checking whether we are using GNU C" >&5 +echo "configure:1046: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1040,7 +1051,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1044: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1055: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1059,7 +1070,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1063: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1074: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1095,7 +1106,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1099: checking for $ac_word" >&5 +echo "configure:1110: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1127,7 +1138,7 @@ test -n "$CXX" || CXX="gcc" echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1131: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 +echo "configure:1142: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1138,12 +1149,12 @@ cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext << EOF -#line 1142 "configure" +#line 1153 "configure" #include "confdefs.h" int main(){return(0);} EOF -if { (eval echo configure:1147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1158: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cxx_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1169,12 +1180,12 @@ if test $ac_cv_prog_cxx_works = no; then { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1173: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1184: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 cross_compiling=$ac_cv_prog_cxx_cross echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 -echo "configure:1178: checking whether we are using GNU C++" >&5 +echo "configure:1189: checking whether we are using GNU C++" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1183,7 +1194,7 @@ else yes; #endif EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1187: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1198: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gxx=yes else ac_cv_prog_gxx=no @@ -1202,7 +1213,7 @@ ac_test_CXXFLAGS="${CXXFLAGS+set}" ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS= echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 -echo "configure:1206: checking whether ${CXX-g++} accepts -g" >&5 +echo "configure:1217: checking whether ${CXX-g++} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1236,7 +1247,7 @@ fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1240: checking for $ac_word" >&5 +echo "configure:1251: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1264,13 +1275,13 @@ else fi echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:1268: checking for object suffix" >&5 +echo "configure:1279: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:1274: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1285: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -1288,12 +1299,12 @@ OBJEXT=$ac_cv_objext ac_objext=$ac_cv_objext echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:1292: checking for Cygwin environment" >&5 +echo "configure:1303: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1319: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -1321,19 +1332,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:1325: checking for mingw32 environment" >&5 +echo "configure:1336: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1348: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -1352,7 +1363,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=y echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1356: checking for executable suffix" >&5 +echo "configure:1367: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1362,7 +1373,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj | *.ilk | *.pdb) ;; @@ -1387,7 +1398,7 @@ ac_exeext=$EXEEXT echo $ac_n "checking "for Visual C++"""... $ac_c" 1>&6 -echo "configure:1391: checking "for Visual C++"" >&5 +echo "configure:1402: checking "for Visual C++"" >&5 MSVC="no"; if test "${CC}" = "cl" ; then MSVC="yes" @@ -1412,7 +1423,7 @@ fi echo $ac_n "checking "the default compiler flags"""... $ac_c" 1>&6 -echo "configure:1416: checking "the default compiler flags"" >&5 +echo "configure:1427: checking "the default compiler flags"" >&5 cygflags_enable_debug="no" # Check whether --enable-debug or --disable-debug was given. @@ -1457,19 +1468,15 @@ fi echo "$ac_t""done" 1>&6 -if test ${cross_compiling} = yes; then - { echo "configure: error: cross-compilation of this package is not supported" 1>&2; exit 1; } -fi - echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:1466: checking whether byte ordering is bigendian" >&5 +echo "configure:1473: checking whether byte ordering is bigendian" >&5 if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. cat > conftest.$ac_ext < #include @@ -1480,11 +1487,11 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:1484: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1491: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # It does; now see whether it defined to BIG_ENDIAN or not. cat > conftest.$ac_ext < #include @@ -1495,7 +1502,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:1499: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1506: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -1515,7 +1522,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_bigendian=no else @@ -1557,7 +1564,7 @@ fi echo $ac_n "checking "for a 64 bit data type"""... $ac_c" 1>&6 -echo "configure:1561: checking "for a 64 bit data type"" >&5 +echo "configure:1568: checking "for a 64 bit data type"" >&5 if eval "test \"`echo '$''{'cyg_ac_cv_type_64bit'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1572,10 +1579,10 @@ ac_link='${CC-cc} -o conftest${ac_exeext cross_compiling=$ac_cv_prog_cc_cross if test "$cross_compiling" = yes; then - ctype_64bit="unknown" + ctype_64bit="long long" else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ctype_64bit=$type else @@ -1603,10 +1610,10 @@ ac_link='${CXX-g++} -o conftest${ac_exee cross_compiling=$ac_cv_prog_cxx_cross if test "$cross_compiling" = yes; then - cxxtype_64bit="unknown" + cxxtype_64bit="long long" else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then cxxtype_64bit=$type else @@ -1662,7 +1669,7 @@ EOF echo $ac_n "checking size of int *""... $ac_c" 1>&6 -echo "configure:1666: checking size of int *" >&5 +echo "configure:1673: checking size of int *" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_int_p'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1670,7 +1677,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -1681,7 +1688,7 @@ main() exit(0); } EOF -if { (eval echo configure:1685: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1692: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_int_p=`cat conftestval` else @@ -1701,7 +1708,7 @@ EOF echo $ac_n "checking size of long""... $ac_c" 1>&6 -echo "configure:1705: checking size of long" >&5 +echo "configure:1712: checking size of long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1709,7 +1716,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -1720,7 +1727,7 @@ main() exit(0); } EOF -if { (eval echo configure:1724: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1731: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long=`cat conftestval` else @@ -1745,7 +1752,7 @@ EOF echo $ac_n "checking "for __PRETTY_FUNCTION__ support"""... $ac_c" 1>&6 -echo "configure:1749: checking "for __PRETTY_FUNCTION__ support"" >&5 +echo "configure:1756: checking "for __PRETTY_FUNCTION__ support"" >&5 if eval "test \"`echo '$''{'cyg_ac_cv_c_pretty_function'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1759,14 +1766,14 @@ ac_link='${CC-cc} -o conftest${ac_exeext cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext < int main() { puts(__PRETTY_FUNCTION__); ; return 0; } EOF -if { (eval echo configure:1770: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* c_ok="yes" else @@ -1785,14 +1792,14 @@ ac_link='${CXX-g++} -o conftest${ac_exee cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext < int main() { puts(__PRETTY_FUNCTION__); ; return 0; } EOF -if { (eval echo configure:1796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cxx_ok="yes" else @@ -1832,7 +1839,7 @@ EOF echo $ac_n "checking for Tcl version""... $ac_c" 1>&6 -echo "configure:1836: checking for Tcl version" >&5 +echo "configure:1843: checking for Tcl version" >&5 # Check whether --with-tcl-version or --without-tcl-version was given. if test "${with_tcl_version+set}" = set; then withval="$with_tcl_version" @@ -1857,7 +1864,7 @@ echo "$ac_t""${cyg_ac_tcl_version}" 1>&6 echo $ac_n "checking for Tcl installation""... $ac_c" 1>&6 -echo "configure:1861: checking for Tcl installation" >&5 +echo "configure:1868: checking for Tcl installation" >&5 # Check whether --with-tcl or --without-tcl was given. if test "${with_tcl+set}" = set; then withval="$with_tcl" diff --git a/host/infra/configure.in b/host/infra/configure.in --- a/host/infra/configure.in +++ b/host/infra/configure.in @@ -70,11 +70,6 @@ AC_EXEEXT CYG_AC_PROG_MSVC CYG_AC_PROG_STANDARD_COMPILER_FLAGS -dnl This package cannot be cross-compiled yet. -if test ${cross_compiling} = yes; then - AC_MSG_ERROR(cross-compilation of this package is not supported) -fi - dnl Work out the endianness. The standard macro for this is used dnl even though it will give warnings at autoconf time. AC_C_BIGENDIAN diff --git a/host/infra/testsuite/Makefile.in b/host/infra/testsuite/Makefile.in --- a/host/infra/testsuite/Makefile.in +++ b/host/infra/testsuite/Makefile.in @@ -113,7 +113,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ if test -f $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/host/libcdl/ChangeLog b/host/libcdl/ChangeLog --- a/host/libcdl/ChangeLog +++ b/host/libcdl/ChangeLog @@ -1,3 +1,18 @@ +2000-08-18 Bart Veer + + * configure.in: + Allow cross-compilation. + + * configure, Makefile.in, testsuite/Makefile.in: + Regenerate. + + * base.cxx, build.cxx, cdl.hxx, cdlcore.hxx, component.cxx, + config.cxx, database.cxx, dialog.cxx, expr.cxx, interface.cxx, + interp.cxx, option.cxx, package.cxx, parse.cxx, value.cxx, + wizard.cxx + Remove C++ exception specifications, because they cause problems + with some versions of the tools. + 2000-07-06 Bart Veer * conflict.cxx (get_explanation): diff --git a/host/libcdl/Makefile.in b/host/libcdl/Makefile.in --- a/host/libcdl/Makefile.in +++ b/host/libcdl/Makefile.in @@ -88,13 +88,36 @@ INCLUDES = @INCLUDES@ include_HEADERS = cdlcore.hxx cdl.hxx -sources := interp.cxx expr.cxx refer.cxx cdlmisc.cxx conflict.cxx property.cxx parse.cxx base.cxx value.cxx build.cxx dialog.cxx wizard.cxx interface.cxx transact.cxx infer.cxx database.cxx config.cxx package.cxx component.cxx option.cxx +sources := interp.cxx \ + expr.cxx \ + refer.cxx \ + cdlmisc.cxx \ + conflict.cxx \ + property.cxx \ + parse.cxx \ + base.cxx \ + value.cxx \ + build.cxx \ + dialog.cxx \ + wizard.cxx \ + interface.cxx \ + transact.cxx \ + infer.cxx \ + database.cxx \ + config.cxx \ + package.cxx \ + component.cxx \ + option.cxx noinst_LIBRARIES = libcdl.a libcdl_a_SOURCES = $(sources) -infra_headers := $(cyg_ac_infra_incdir)/cyg/infra/cyg_ass.h $(cyg_ac_infra_incdir)/cyg/infra/cyg_trac.h $(cyg_ac_infra_incdir)/pkgconf/infra.h $(cyg_ac_infra_incdir)/pkgconf/hostinfra.h $(cyg_ac_infra_incdir)/cyg/infra/cyg_type.h +infra_headers := $(cyg_ac_infra_incdir)/cyg/infra/cyg_ass.h \ + $(cyg_ac_infra_incdir)/cyg/infra/cyg_trac.h \ + $(cyg_ac_infra_incdir)/pkgconf/infra.h \ + $(cyg_ac_infra_incdir)/pkgconf/hostinfra.h \ + $(cyg_ac_infra_incdir)/cyg/infra/cyg_type.h cdlcore_headers := cdlconfig.h cdlcore.hxx @@ -369,7 +392,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ if test -f $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/host/libcdl/base.cxx b/host/libcdl/base.cxx --- a/host/libcdl/base.cxx +++ b/host/libcdl/base.cxx @@ -549,7 +549,6 @@ CdlNodeBody::update(CdlTransaction trans void CdlNodeBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlNode::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); @@ -934,7 +933,6 @@ CdlContainerBody::update(CdlTransaction void CdlContainerBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlContainer::save"); CYG_REPORT_FUNCARG4XV(this, interp, chan, indentation); @@ -2582,7 +2580,6 @@ CdlToplevelBody::add_savefile_subcommand void CdlToplevelBody::save_command_details(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlToplevel::save_command_details"); CYG_REPORT_FUNCARG4XV(this, interp, chan, indentation); @@ -2903,7 +2900,6 @@ CdlToplevelBody::savefile_handle_unsuppo // file that was not recognised. void CdlToplevelBody::save_unsupported_commands(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlToplevelBody::save_unsupported_commands"); CYG_REPORT_FUNCARG3XV(this, interp, chan); @@ -3018,7 +3014,6 @@ CdlToplevelBody::get_savefile_version(Cd // ---------------------------------------------------------------------------- void CdlToplevelBody::save_conflicts(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlToplevel::save_conflicts"); CYG_REPORT_FUNCARG4XV(this, interp, chan, indentation); @@ -3064,7 +3059,6 @@ CdlToplevelBody::save_conflicts(CdlInter // ---------------------------------------------------------------------------- void CdlToplevelBody::save_separator(CdlInterpreter interp, Tcl_Channel chan, std::string msg, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlToplevel::save_separator"); CYG_REPORT_FUNCARG1XV(interp); @@ -3386,7 +3380,6 @@ CdlUserVisibleBody::parse_doc(CdlInterpr void CdlUserVisibleBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlUserVisible::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); diff --git a/host/libcdl/build.cxx b/host/libcdl/build.cxx --- a/host/libcdl/build.cxx +++ b/host/libcdl/build.cxx @@ -1532,7 +1532,6 @@ CdlDefinableBody::parse_if_define(CdlInt void CdlDefinableBody::generate_config_header(Tcl_Channel this_hdr, Tcl_Channel system_h) const - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlDefinable::generate_config_header"); CYG_REPORT_FUNCARG1XV(this); @@ -1821,7 +1820,6 @@ CdlDefineLoadableBody::parse_define_head // ---------------------------------------------------------------------------- void CdlDefineLoadableBody::generate_config_header(Tcl_Channel this_hdr, Tcl_Channel system_h) const - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlDefineLoadable::generate_config_header"); CYG_REPORT_FUNCARG1XV(this); @@ -2020,7 +2018,6 @@ if {$data1 == $data2} { void CdlToplevelBody::generate_config_headers(std::string directory) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlToplevel::generate_config_headers"); CYG_REPORT_FUNCARG1XV(this); @@ -2229,7 +2226,6 @@ CdlToplevelBody::get_config_headers(std: void CdlToplevelBody::generate_build_tree(std::string build_tree, std::string install_tree) - throw(CdlInputOutputException, std::bad_alloc) { } diff --git a/host/libcdl/cdl.dsp b/host/libcdl/cdl.dsp --- a/host/libcdl/cdl.dsp +++ b/host/libcdl/cdl.dsp @@ -64,8 +64,8 @@ MTL=midl.exe # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 -# PROP Output_Dir "V:\cdl\Debug" -# PROP Intermediate_Dir "V:\cdl\Debug\build" +# PROP Output_Dir "v:\cdl\Debug" +# PROP Intermediate_Dir "v:\cdl\Debug\build" # PROP Target_Dir "" !ELSEIF "$(CFG)" == "cdl - Win32 ANSI Release" @@ -158,8 +158,8 @@ BuildCmds= \ !ELSEIF "$(CFG)" == "cdl - Win32 ANSI Debug" # Begin Custom Build - Performing Custom Build Step for libCDL -IntDir=V:\cdl\Debug\build -OutDir=V:\cdl\Debug +IntDir=v:\cdl\Debug\build +OutDir=v:\cdl\Debug InputPath=.\ChangeLog BuildCmds= \ diff --git a/host/libcdl/cdl.hxx b/host/libcdl/cdl.hxx --- a/host/libcdl/cdl.hxx +++ b/host/libcdl/cdl.hxx @@ -117,9 +117,8 @@ class CdlPackagesDatabaseBody { public: static CdlPackagesDatabase make(std::string = "", CdlDiagnosticFnPtr /* error */ = 0, - CdlDiagnosticFnPtr /* warn */ = 0) - throw(CdlInputOutputException,std::bad_alloc); - bool update(void) throw(CdlInputOutputException,std::bad_alloc); + CdlDiagnosticFnPtr /* warn */ = 0); + bool update(void); ~CdlPackagesDatabaseBody(); std::string get_component_repository() const; @@ -163,8 +162,7 @@ class CdlPackagesDatabaseBody { // The only valid constructor gets invoked from the make() member function. // The argument should be a pathname for the component repository. The // constructor is responsible for reading in the whole packages file. - CdlPackagesDatabaseBody(std::string, CdlDiagnosticFnPtr, CdlDiagnosticFnPtr) - throw(CdlInputOutputException,std::bad_alloc); + CdlPackagesDatabaseBody(std::string, CdlDiagnosticFnPtr, CdlDiagnosticFnPtr); std::string component_repository; std::vector package_names; @@ -311,11 +309,9 @@ class CdlConfigurationBody : public virt // A version argument of "" implies the most recent version. void load_package(std::string /* name */, std::string /* version */, - CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true); void load_package(CdlTransaction, std::string /* name */, std::string /* version */, - CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true); void unload_package(std::string /* name */, bool /* limbo */ = true); void unload_package(CdlPackage, bool /* limbo */ = true); @@ -323,18 +319,14 @@ class CdlConfigurationBody : public virt void unload_package(CdlTransaction, CdlPackage, bool /* limbo */ = true); void change_package_version(std::string /*name*/, std::string /*version*/, - CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true); void change_package_version(CdlPackage, std::string /*version*/, CdlDiagnosticFnPtr /* error */, - CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true); void change_package_version(CdlTransaction, std::string /*name*/, std::string /*version*/, - CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true); void change_package_version(CdlTransaction, CdlPackage, std::string /*version*/, CdlDiagnosticFnPtr /* error */, - CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true); // Loading a savefile is different in that it creates a new // toplevel. Since transactions can only be created if the @@ -342,40 +334,31 @@ class CdlConfigurationBody : public virt // per-transaction load() operation. It is possible to have // a per-transaction add() operation. static CdlConfiguration load(std::string /* filename */, CdlPackagesDatabase, CdlInterpreter, - CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */); void add(std::string /* filename */, - CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */); void add(CdlTransaction, std::string /* filename */, - CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */); // As with packages, a version of "" implies the most recent. void set_template(std::string, std::string /* version */, - CdlDiagnosticFnPtr, CdlDiagnosticFnPtr /* warn */,bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr, CdlDiagnosticFnPtr /* warn */,bool /* limbo */ = true); void set_template_file(std::string, - CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true); void set_template(CdlTransaction, std::string, std::string /* version */, - CdlDiagnosticFnPtr, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true); void set_template_file(CdlTransaction, std::string, - CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true); void unload_template(bool /* limbo */ = true); void unload_template(CdlTransaction, bool /* limbo */ = true); std::string get_template() const; void set_template_name(std::string); // Intended for library use only void set_hardware(std::string, - CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true); void set_hardware(CdlTransaction, std::string, - CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc); + CdlDiagnosticFnPtr /* error */, CdlDiagnosticFnPtr /* warn */, bool /* limbo */ = true); void unload_hardware(bool /* limbo */ = true); void unload_hardware(CdlTransaction, bool /* limbo */ = true); std::string get_hardware() const; @@ -383,7 +366,7 @@ class CdlConfigurationBody : public virt // ---------------------------------------------------------------------------- // Save a configuration to a file - void save(std::string, bool /* minimal */ = false) throw(CdlInputOutputException,std::bad_alloc); + void save(std::string, bool /* minimal */ = false); void initialize_savefile_support(); std::string get_save_file() const; @@ -401,7 +384,7 @@ class CdlConfigurationBody : public virt CdlConfigurationBody(std::string, CdlPackagesDatabase, CdlInterpreter); // The internal implementation of the persistence support - virtual void save(CdlInterpreter, Tcl_Channel, int, bool) throw(CdlInputOutputException, std::bad_alloc); + virtual void save(CdlInterpreter, Tcl_Channel, int, bool); static int savefile_configuration_command(CdlInterpreter, int, char**); static int savefile_description_command(CdlInterpreter, int, char**); static int savefile_hardware_command(CdlInterpreter, int, char**); @@ -476,7 +459,7 @@ class CdlPackageBody : public virtual Cd virtual void update(CdlTransaction, CdlUpdate); // Persistence support. - virtual void save(CdlInterpreter, Tcl_Channel, int, bool) throw(CdlInputOutputException, std::bad_alloc); + virtual void save(CdlInterpreter, Tcl_Channel, int, bool); static void initialize_savefile_support(CdlToplevel); static int savefile_package_command(CdlInterpreter, int, char**); @@ -535,7 +518,7 @@ class CdlComponentBody : public virtual virtual void update(CdlTransaction, CdlUpdate); // Persistence support. - virtual void save(CdlInterpreter, Tcl_Channel, int, bool) throw(CdlInputOutputException, std::bad_alloc); + virtual void save(CdlInterpreter, Tcl_Channel, int, bool); static void initialize_savefile_support(CdlToplevel); static int savefile_component_command(CdlInterpreter, int, char**); @@ -580,7 +563,7 @@ class CdlOptionBody : public virtual Cdl static int parse_option(CdlInterpreter, int, char**); // Persistence support. - virtual void save(CdlInterpreter, Tcl_Channel, int, bool) throw(CdlInputOutputException, std::bad_alloc); + virtual void save(CdlInterpreter, Tcl_Channel, int, bool); static void initialize_savefile_support(CdlToplevel); static int savefile_option_command(CdlInterpreter, int, char**); diff --git a/host/libcdl/cdlcore.hxx b/host/libcdl/cdlcore.hxx --- a/host/libcdl/cdlcore.hxx +++ b/host/libcdl/cdlcore.hxx @@ -1137,7 +1137,7 @@ class CdlInterpreterBody static std::string extend_comment(const std::string&, int, int = 0); // Write some data to a savefile, throwing an exception on error - void write_data(Tcl_Channel, std::string) throw(CdlInputOutputException); + void write_data(Tcl_Channel, std::string); // File-related utilities. void locate_subdirs(std::string, std::vector&); @@ -2191,8 +2191,7 @@ class CdlExpressionBody { // parse operation there should be no further data. The result // will either be a new expression object or a parsing exception // to be caught by higher level code. - static CdlExpression parse(std::string) - throw(CdlParseException,std::bad_alloc); + static CdlExpression parse(std::string); // This is used when parsing list expressions, which involve a // sequence of ordinary expressions and possibly range operators. @@ -2201,8 +2200,7 @@ class CdlExpressionBody { // parsing should begin. It is also useful to return details of // the token that caused parsing to terminate (EOD, Range, or // the start of something else). - static CdlExpression parse(std::string, int&, CdlExprOp&, int&) - throw(CdlParseException, std::bad_alloc); + static CdlExpression parse(std::string, int&, CdlExprOp&, int&); // A goal expression is derived from an ordinary expression but // has somewhat different rules for evaluating. Parsing a goal @@ -2213,8 +2211,7 @@ class CdlExpressionBody { // // NOTE: possibly this should should be a protected member, since // its main use is in parsing goal expressions. - static void continue_parse(CdlExpression, std::string, int&, CdlExprOp&, int&) - throw(CdlParseException, std::bad_alloc); + static void continue_parse(CdlExpression, std::string, int&, CdlExprOp&, int&); // Evaluating expressions. Note that this may fail at run-time // because of errors that cannot be caught sensibly when the @@ -2226,10 +2223,8 @@ class CdlExpressionBody { // eval() is the public interface, and manages // CdlConflict_EvalException objects. eval_internal() is for use // by list and goal expressions. - void eval(CdlEvalContext&, CdlSimpleValue&) - throw(CdlEvalException, std::bad_alloc); - void eval_internal(CdlEvalContext&, CdlSimpleValue&) - throw(CdlEvalException, std::bad_alloc); + void eval(CdlEvalContext&, CdlSimpleValue&); + void eval_internal(CdlEvalContext&, CdlSimpleValue&); // The full original expression is useful for diagnostics purposes std::string get_original_string() const; @@ -2290,24 +2285,18 @@ class CdlListExpressionBody { // Parsing. This involves taking a single string, typically from // a CDL script, and parsing one or more ordinary expressions. - static CdlListExpression parse(std::string) - throw(CdlParseException, std::bad_alloc); + static CdlListExpression parse(std::string); // Evaluation support. A list expression evaluates to a list value. - void eval(CdlEvalContext&, CdlListValue&) - throw(CdlEvalException, std::bad_alloc); + void eval(CdlEvalContext&, CdlListValue&); // More commonly client code is going to be interested in whether // or not a particular value is a legal member. The result // cache ensures that it is possible to - bool is_member(CdlEvalContext&, CdlSimpleValue&) - throw(CdlEvalException, std::bad_alloc); - bool is_member(CdlEvalContext&, std::string) - throw(CdlEvalException, std::bad_alloc); - bool is_member(CdlEvalContext&, cdl_int) - throw(CdlEvalException, std::bad_alloc); - bool is_member(CdlEvalContext&, double) - throw(CdlEvalException, std::bad_alloc); + bool is_member(CdlEvalContext&, CdlSimpleValue&); + bool is_member(CdlEvalContext&, std::string); + bool is_member(CdlEvalContext&, cdl_int); + bool is_member(CdlEvalContext&, double); // The full original expression is useful for diagnostics purposes std::string get_original_string() const; @@ -2324,8 +2313,7 @@ class CdlListExpressionBody { CdlListExpressionBody(); CdlListExpressionBody& operator=(const CdlListExpressionBody&); - void eval_internal(CdlEvalContext&, CdlListValue&) throw(CdlEvalException, std::bad_alloc); - + void eval_internal(CdlEvalContext&, CdlListValue&); std::string expression_string; enum { @@ -2353,16 +2341,13 @@ class CdlGoalExpressionBody : private Cd public: virtual ~CdlGoalExpressionBody(); - static CdlGoalExpression parse(std::string) - throw(CdlParseException, std::bad_alloc); + static CdlGoalExpression parse(std::string); // A few variants of the eval() member, with a choice of returning // by value or by reference. The latter provide consistency with the // other expression classes. - bool eval(CdlEvalContext&) - throw(CdlEvalException, std::bad_alloc); - void eval(CdlEvalContext&, bool&) - throw(CdlEvalException, std::bad_alloc); + bool eval(CdlEvalContext&); + void eval(CdlEvalContext&, bool&); // Provide public access to the underlying expression object, // useful for the inference engine @@ -2382,7 +2367,7 @@ class CdlGoalExpressionBody : private Cd CdlGoalExpressionBody(); CdlGoalExpressionBody& operator=(const CdlGoalExpressionBody&); - void eval_internal(CdlEvalContext&, bool&) throw(CdlEvalException, std::bad_alloc); + void eval_internal(CdlEvalContext&, bool&); std::string expression_string; @@ -3240,8 +3225,7 @@ class CdlParse { static std::string construct_diagnostic(CdlInterpreter, std::string /* classification */, std::string /* sub-identifier */, std::string /* message */); - static void report_error(CdlInterpreter, std::string /* sub-identifier */, std::string /* message */) - throw(CdlParseException, std::bad_alloc); + static void report_error(CdlInterpreter, std::string /* sub-identifier */, std::string /* message */); static void report_warning(CdlInterpreter, std::string /* sub-identifier */, std::string /* message */); static void clear_error_count(CdlInterpreter); static int get_error_count(CdlInterpreter); @@ -3251,10 +3235,8 @@ class CdlParse { static int unknown_command(CdlInterpreter, int, char**); // Property-related utilities - static void report_property_parse_error(CdlInterpreter, std::string, std::string) - throw(CdlParseException, std::bad_alloc); - static void report_property_parse_error(CdlInterpreter, CdlProperty, std::string) - throw(CdlParseException, std::bad_alloc); + static void report_property_parse_error(CdlInterpreter, std::string, std::string); + static void report_property_parse_error(CdlInterpreter, CdlProperty, std::string); static void report_property_parse_warning(CdlInterpreter, std::string, std::string); static void report_property_parse_warning(CdlInterpreter, CdlProperty, std::string); @@ -3375,7 +3357,7 @@ class CdlNodeBody { // Configuration save files are Tcl scripts, so it seems // appropriate to handle the I/O via the Tcl library and // to have a TCL interpreter available. - virtual void save(CdlInterpreter, Tcl_Channel, int, bool) throw(CdlInputOutputException, std::bad_alloc); + virtual void save(CdlInterpreter, Tcl_Channel, int, bool); bool has_additional_savefile_information() const; // Mainly for diagnostics code, what is the actual name for this @@ -3484,7 +3466,7 @@ class CdlContainerBody : virtual public virtual void update(CdlTransaction, CdlUpdate); // Persistence support. - virtual void save(CdlInterpreter, Tcl_Channel, int, bool) throw(CdlInputOutputException, std::bad_alloc); + virtual void save(CdlInterpreter, Tcl_Channel, int, bool); virtual std::string get_class_name() const; bool check_this(cyg_assert_class_zeal = cyg_quick) const; @@ -3715,11 +3697,9 @@ class CdlToplevelBody : virtual public C // even if they are not always applicable void get_build_info(CdlBuildInfo&); void get_all_build_info(CdlBuildInfo&); - void generate_config_headers(std::string) - throw(CdlInputOutputException, std::bad_alloc); + void generate_config_headers(std::string); void get_config_headers(std::vector&); - void generate_build_tree(std::string, std::string = "") - throw(CdlInputOutputException, std::bad_alloc); + void generate_build_tree(std::string, std::string = ""); // Values can be stored in limbo. This is useful when unloading // and reloading packages, e.g. when changing a version the @@ -3737,19 +3717,16 @@ class CdlToplevelBody : virtual public C void add_savefile_subcommand(std::string, std::string, CdlSaveCallback, CdlInterpreterCommand); void get_savefile_commands(std::vector&); void get_savefile_subcommands(std::string, std::vector&); - void save_command_details(CdlInterpreter, Tcl_Channel, int, bool) - throw(CdlInputOutputException, std::bad_alloc); + void save_command_details(CdlInterpreter, Tcl_Channel, int, bool); static int savefile_handle_command(CdlInterpreter, int, char**); static int savefile_handle_unsupported(CdlInterpreter, int, char**); static int savefile_handle_unknown(CdlInterpreter, int, char**); - void save_unsupported_commands(CdlInterpreter, Tcl_Channel, int, bool) - throw(CdlInputOutputException, std::bad_alloc); + void save_unsupported_commands(CdlInterpreter, Tcl_Channel, int, bool); static cdl_int get_library_savefile_version(); static int savefile_handle_version(CdlInterpreter, int, char**); static cdl_int get_savefile_version(CdlInterpreter); - void save_conflicts(CdlInterpreter, Tcl_Channel, int, bool) throw(CdlInputOutputException, std::bad_alloc); - static void save_separator(CdlInterpreter, Tcl_Channel, std::string, bool) - throw(CdlInputOutputException, std::bad_alloc); + void save_conflicts(CdlInterpreter, Tcl_Channel, int, bool); + static void save_separator(CdlInterpreter, Tcl_Channel, std::string, bool); virtual std::string get_class_name() const; bool check_this(cyg_assert_class_zeal = cyg_quick) const; @@ -3831,7 +3808,7 @@ class CdlUserVisibleBody : virtual publi // Persistence support. The save code simply outputs some comments // corresponding to the display, doc and description properties. - virtual void save(CdlInterpreter, Tcl_Channel, int, bool) throw(CdlInputOutputException, std::bad_alloc); + virtual void save(CdlInterpreter, Tcl_Channel, int, bool); virtual std::string get_class_name() const; bool check_this(cyg_assert_class_zeal = cyg_quick) const; @@ -4193,8 +4170,7 @@ class CdlValuableBody : virtual public C static void wizard_update_handler(CdlTransaction, CdlNode, CdlProperty, CdlNode, CdlUpdate); // Persistence suppot - void save(CdlInterpreter, Tcl_Channel, int, bool /* modifiable */, bool /* minimal */) - throw(CdlInputOutputException, std::bad_alloc); + void save(CdlInterpreter, Tcl_Channel, int, bool /* modifiable */, bool /* minimal */); bool value_savefile_entry_needed() const; static void initialize_savefile_support(CdlToplevel, std::string); static int savefile_value_source_command(CdlInterpreter, int, char**); @@ -5107,7 +5083,6 @@ class CdlLocalTransaction { // There is another library call for step (4): // // config->generate_config_headers(std::string directory) -// throw(CdlInputOutputException, std::bad_alloc); // // This will create or update the header files appropriate to // the current configuration. Temporary files will be generated, @@ -5422,8 +5397,7 @@ class CdlDefineLoadableBody : virtual pu // Update the header file for this loadable. The first argument // is a channel to the loadable-specific header file. The second // argument is a channel to the global header file. - void generate_config_header(Tcl_Channel, Tcl_Channel) const - throw(CdlInputOutputException, std::bad_alloc); + void generate_config_header(Tcl_Channel, Tcl_Channel) const; // What header file should be generated for this loadable? virtual std::string get_config_header() const; @@ -5470,8 +5444,7 @@ class CdlDefinableBody : virtual public // Update the header file for this definable. The loadable's Tcl // interpreter will already have channels cdl_header and // cdl_system_header set up appropriately. - void generate_config_header( Tcl_Channel, Tcl_Channel) const - throw(CdlInputOutputException, std::bad_alloc); + void generate_config_header( Tcl_Channel, Tcl_Channel) const; // Add property parsers and validation code. static void add_property_parsers(std::vector& parsers); @@ -5541,7 +5514,7 @@ class CdlDialogBody : // Persistence support. Dialogs should just be ignored when it // comes to saving and restoring files. - virtual void save(CdlInterpreter, Tcl_Channel, int, bool) throw(CdlInputOutputException, std::bad_alloc); + virtual void save(CdlInterpreter, Tcl_Channel, int, bool); virtual std::string get_class_name() const; bool check_this(cyg_assert_class_zeal = cyg_quick) const; @@ -5600,7 +5573,7 @@ class CdlWizardBody : // Persistence support. Wizards should just be ignored when it // comes to saving and restoring files. - virtual void save(CdlInterpreter, Tcl_Channel, int, bool) throw(CdlInputOutputException, std::bad_alloc); + virtual void save(CdlInterpreter, Tcl_Channel, int, bool); virtual std::string get_class_name() const; bool check_this(cyg_assert_class_zeal = cyg_quick) const; @@ -5649,7 +5622,7 @@ class CdlInterfaceBody : public virtual // by users, it is all calculated. However it is useful to have the // interface data present in the saved file so that users can examine // dependencies etc. - virtual void save(CdlInterpreter, Tcl_Channel, int, bool) throw(CdlInputOutputException, std::bad_alloc); + virtual void save(CdlInterpreter, Tcl_Channel, int, bool); static void initialize_savefile_support(CdlToplevel); static int savefile_interface_command(CdlInterpreter, int, char**); diff --git a/host/libcdl/component.cxx b/host/libcdl/component.cxx --- a/host/libcdl/component.cxx +++ b/host/libcdl/component.cxx @@ -371,7 +371,6 @@ CdlComponentBody::initialize_savefile_su void CdlComponentBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlComponent::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); diff --git a/host/libcdl/config.cxx b/host/libcdl/config.cxx --- a/host/libcdl/config.cxx +++ b/host/libcdl/config.cxx @@ -289,7 +289,6 @@ CdlConfigurationBody::get_class_name() c void CdlConfigurationBody::load_package(std::string name, std::string version, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::load_package"); CYG_REPORT_FUNCARG1XV(this); @@ -350,7 +349,6 @@ CdlConfigurationBody::unload_package(Cdl void CdlConfigurationBody::change_package_version(std::string name, std::string version, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::change_package_version"); CYG_REPORT_FUNCARG1XV(this); @@ -365,7 +363,6 @@ CdlConfigurationBody::change_package_ver void CdlConfigurationBody::change_package_version(CdlPackage package, std::string version, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::change_package_version"); CYG_REPORT_FUNCARG1XV(this); @@ -380,7 +377,6 @@ CdlConfigurationBody::change_package_ver void CdlConfigurationBody::change_package_version(CdlTransaction transaction, std::string name, std::string new_version, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::change_package_version"); CYG_REPORT_FUNCARG2XV(this, transaction); @@ -408,7 +404,6 @@ CdlConfigurationBody::change_package_ver void CdlConfigurationBody::add(std::string filename, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::add"); CYG_REPORT_FUNCARG1XV(this); @@ -423,7 +418,6 @@ CdlConfigurationBody::add(std::string fi void CdlConfigurationBody::set_template(std::string name, std::string version, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::set_template"); CYG_REPORT_FUNCARG1XV(this); @@ -438,7 +432,6 @@ CdlConfigurationBody::set_template(std:: void CdlConfigurationBody::set_template_file(std::string filename, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::set_template_file"); CYG_REPORT_FUNCARG1XV(this); @@ -453,7 +446,6 @@ CdlConfigurationBody::set_template_file( void CdlConfigurationBody::set_template(CdlTransaction transaction, std::string template_name, std::string version, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::set_template"); CYG_REPORT_FUNCARG2XV(this, transaction); @@ -495,7 +487,6 @@ CdlConfigurationBody::unload_template(bo void CdlConfigurationBody::set_hardware(std::string name, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::set_hardware"); CYG_REPORT_FUNCARG1XV(this); @@ -735,7 +726,6 @@ class CdlConfiguration_CommitCancelTempl void CdlConfigurationBody::load_package(CdlTransaction transaction, std::string name, std::string version, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::load_package"); CYG_REPORT_FUNCARG1XV(this); @@ -989,7 +979,6 @@ CdlConfigurationBody::unload_package(Cdl void CdlConfigurationBody::change_package_version(CdlTransaction transaction, CdlPackage package, std::string new_version, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::change_package_version"); CYG_REPORT_FUNCARG3XV(this, transaction, package); @@ -1042,7 +1031,6 @@ CdlConfigurationBody::change_package_ver void CdlConfigurationBody::set_hardware(CdlTransaction transaction, std::string target_name, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::set_hardware"); CYG_REPORT_FUNCARG2XV(this, transaction); @@ -1247,7 +1235,6 @@ CdlConfigurationBody::unload_hardware(Cd void CdlConfigurationBody::set_template_file(CdlTransaction transaction, std::string filename, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn, bool limbo) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::set_template_file"); CYG_REPORT_FUNCARG3XV(this, transaction, limbo); @@ -1404,7 +1391,6 @@ CdlConfigurationBody::initialize_savefil void CdlConfigurationBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); @@ -1481,7 +1467,6 @@ CdlConfigurationBody::save(CdlInterprete void CdlConfigurationBody::save(std::string filename, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::save"); CYG_REPORT_FUNCARG2XV(this, minimal); @@ -1564,7 +1549,6 @@ CdlConfigurationBody::save(std::string f CdlConfiguration CdlConfigurationBody::load(std::string filename, CdlPackagesDatabase db, CdlInterpreter interp, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("CdlConfiguration::load", "result %p"); CYG_REPORT_FUNCARG4XV(db, interp, error_fn, warn_fn); @@ -1593,7 +1577,6 @@ CdlConfigurationBody::load(std::string f void CdlConfigurationBody::add(CdlTransaction transaction, std::string filename, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn) - throw(CdlInputOutputException, CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlConfiguration::add"); CYG_REPORT_FUNCARG3XV(this, error_fn, warn_fn); diff --git a/host/libcdl/configure b/host/libcdl/configure --- a/host/libcdl/configure +++ b/host/libcdl/configure @@ -55,6 +55,7 @@ program_suffix=NONE program_transform_name=s,x,x, silent= site= +sitefile= srcdir= target=NONE verbose= @@ -169,6 +170,7 @@ Configuration: --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages + --site-file=FILE use FILE as the site file --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX @@ -339,6 +341,11 @@ EOF -site=* | --site=* | --sit=*) site="$ac_optarg" ;; + -site-file | --site-file | --site-fil | --site-fi | --site-f) + ac_prev=sitefile ;; + -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*) + sitefile="$ac_optarg" ;; + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) @@ -504,12 +511,16 @@ 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" +if test -z "$sitefile"; then + 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 +else + CONFIG_SITE="$sitefile" fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then @@ -576,7 +587,7 @@ else { echo "configure: error: can not r fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:580: checking host system type" >&5 +echo "configure:591: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -609,7 +620,7 @@ echo "$ac_t""$host" 1>&6 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:613: checking for a BSD compatible install" >&5 +echo "configure:624: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -662,7 +673,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCR test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:666: checking whether build environment is sane" >&5 +echo "configure:677: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -719,7 +730,7 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:723: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:734: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -765,7 +776,7 @@ EOF missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:769: checking for working aclocal" >&5 +echo "configure:780: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -778,7 +789,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:782: checking for working autoconf" >&5 +echo "configure:793: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -791,7 +802,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:795: checking for working automake" >&5 +echo "configure:806: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -804,7 +815,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:808: checking for working autoheader" >&5 +echo "configure:819: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -817,7 +828,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:821: checking for working makeinfo" >&5 +echo "configure:832: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -839,7 +850,7 @@ EOF echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:843: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:854: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -863,7 +874,7 @@ fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:867: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:878: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -892,7 +903,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:896: checking for $ac_word" >&5 +echo "configure:907: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -922,7 +933,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:926: checking for $ac_word" >&5 +echo "configure:937: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -973,7 +984,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:977: checking for $ac_word" >&5 +echo "configure:988: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1005,7 +1016,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1009: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1020: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1016,12 +1027,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1020 "configure" +#line 1031 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1025: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1036: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1047,12 +1058,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1051: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1062: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1056: checking whether we are using GNU C" >&5 +echo "configure:1067: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1061,7 +1072,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1065: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1076: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1080,7 +1091,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1084: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1095: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1116,7 +1127,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1120: checking for $ac_word" >&5 +echo "configure:1131: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1148,7 +1159,7 @@ test -n "$CXX" || CXX="gcc" echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1152: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 +echo "configure:1163: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1159,12 +1170,12 @@ cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext << EOF -#line 1163 "configure" +#line 1174 "configure" #include "confdefs.h" int main(){return(0);} EOF -if { (eval echo configure:1168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cxx_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1190,12 +1201,12 @@ if test $ac_cv_prog_cxx_works = no; then { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1194: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1205: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 cross_compiling=$ac_cv_prog_cxx_cross echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 -echo "configure:1199: checking whether we are using GNU C++" >&5 +echo "configure:1210: checking whether we are using GNU C++" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1204,7 +1215,7 @@ else yes; #endif EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1208: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1219: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gxx=yes else ac_cv_prog_gxx=no @@ -1223,7 +1234,7 @@ ac_test_CXXFLAGS="${CXXFLAGS+set}" ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS= echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 -echo "configure:1227: checking whether ${CXX-g++} accepts -g" >&5 +echo "configure:1238: checking whether ${CXX-g++} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1257,7 +1268,7 @@ fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1261: checking for $ac_word" >&5 +echo "configure:1272: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1285,13 +1296,13 @@ else fi echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:1289: checking for object suffix" >&5 +echo "configure:1300: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:1295: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1306: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -1309,12 +1320,12 @@ OBJEXT=$ac_cv_objext ac_objext=$ac_cv_objext echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:1313: checking for Cygwin environment" >&5 +echo "configure:1324: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1340: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -1342,19 +1353,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:1346: checking for mingw32 environment" >&5 +echo "configure:1357: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1369: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -1373,7 +1384,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=y echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1377: checking for executable suffix" >&5 +echo "configure:1388: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1383,7 +1394,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1387: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1398: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj | *.ilk | *.pdb) ;; @@ -1408,7 +1419,7 @@ ac_exeext=$EXEEXT echo $ac_n "checking "for Visual C++"""... $ac_c" 1>&6 -echo "configure:1412: checking "for Visual C++"" >&5 +echo "configure:1423: checking "for Visual C++"" >&5 MSVC="no"; if test "${CC}" = "cl" ; then MSVC="yes" @@ -1433,7 +1444,7 @@ fi echo $ac_n "checking "the default compiler flags"""... $ac_c" 1>&6 -echo "configure:1437: checking "the default compiler flags"" >&5 +echo "configure:1448: checking "the default compiler flags"" >&5 cygflags_enable_debug="no" # Check whether --enable-debug or --disable-debug was given. @@ -1479,10 +1490,6 @@ fi -if test ${cross_compiling} = yes; then - { echo "configure: error: cross-compilation of this package is not supported" 1>&2; exit 1; } -fi - @@ -1633,7 +1640,7 @@ fi echo $ac_n "checking for Tcl version""... $ac_c" 1>&6 -echo "configure:1637: checking for Tcl version" >&5 +echo "configure:1644: checking for Tcl version" >&5 # Check whether --with-tcl-version or --without-tcl-version was given. if test "${with_tcl_version+set}" = set; then withval="$with_tcl_version" @@ -1658,7 +1665,7 @@ echo "$ac_t""${cyg_ac_tcl_version}" 1>&6 echo $ac_n "checking for Tcl installation""... $ac_c" 1>&6 -echo "configure:1662: checking for Tcl installation" >&5 +echo "configure:1669: checking for Tcl installation" >&5 # Check whether --with-tcl or --without-tcl was given. if test "${with_tcl+set}" = set; then withval="$with_tcl" @@ -1714,7 +1721,7 @@ fi echo $ac_n "checking for infrastructure files""... $ac_c" 1>&6 -echo "configure:1718: checking for infrastructure files" >&5 +echo "configure:1725: checking for infrastructure files" >&5 # Check whether --with-infra or --without-infra was given. if test "${with_infra+set}" = set; then withval="$with_infra" diff --git a/host/libcdl/configure.in b/host/libcdl/configure.in --- a/host/libcdl/configure.in +++ b/host/libcdl/configure.in @@ -70,11 +70,6 @@ CYG_AC_PROG_STANDARD_COMPILER_FLAGS dnl AM_DISABLE_SHARED dnl AM_PROG_LIBTOOL -dnl This package cannot be cross-compiled yet. -if test ${cross_compiling} = yes; then - AC_MSG_ERROR(cross-compilation of this package is not supported) -fi - dnl Allow the usual assertion and trace related options. CYG_AC_ARG_INFRASTRUCTURE diff --git a/host/libcdl/database.cxx b/host/libcdl/database.cxx --- a/host/libcdl/database.cxx +++ b/host/libcdl/database.cxx @@ -700,7 +700,6 @@ CdlDbParser::target_set_value(CdlInterpr CdlPackagesDatabase CdlPackagesDatabaseBody::make(std::string repo, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("CdlPackagesDatabase::make", "database %p"); @@ -732,7 +731,6 @@ CdlPackagesDatabaseBody::make(std::strin // ---------------------------------------------------------------------------- CdlPackagesDatabaseBody::CdlPackagesDatabaseBody(std::string repo, CdlDiagnosticFnPtr error_fn, CdlDiagnosticFnPtr warn_fn) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlPackagesDatabase:: constructor"); CYG_PRECONDITIONC("" != repo); diff --git a/host/libcdl/dialog.cxx b/host/libcdl/dialog.cxx --- a/host/libcdl/dialog.cxx +++ b/host/libcdl/dialog.cxx @@ -300,7 +300,6 @@ CdlDialogBody::parse_update_proc(CdlInte void CdlDialogBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlDialog::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); diff --git a/host/libcdl/expr.cxx b/host/libcdl/expr.cxx --- a/host/libcdl/expr.cxx +++ b/host/libcdl/expr.cxx @@ -459,7 +459,6 @@ token_to_string() // allowing for backslash escapes. static void process_string() - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("process_string"); CYG_ASSERTC('"' == current_char); @@ -584,7 +583,6 @@ process_string() // which checks number completion and throws an exception if // necessary. static void check_number_termination() - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("check_number_termination"); @@ -609,7 +607,6 @@ static void check_number_termination() static void process_number() - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("process_number"); @@ -738,7 +735,6 @@ process_number() // valid as far as the preprocessor is concerned. static void process_reference() - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("process_reference"); @@ -764,7 +760,6 @@ process_reference() // strings, integers, doubles, and references. static void next_token() - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("next_token", "token %d"); @@ -1025,7 +1020,7 @@ initialise_tokenisation(std::string data // There are separate functions for each of these terms. // A forward declaration, needed for bracketed subexpressions. -static void parse_expression(CdlExpression) throw(CdlParseException, std::bad_alloc); +static void parse_expression(CdlExpression); // A utility to add a reference to the current expression, returning // the index. @@ -1070,7 +1065,6 @@ current_subexpression(CdlExpression expr static void parse_unary(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_operand"); CYG_REPORT_FUNCARG1XV(expr); @@ -1225,7 +1219,6 @@ parse_unary(CdlExpression expr) static void parse_multiply(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_multiply"); @@ -1250,7 +1243,6 @@ parse_multiply(CdlExpression expr) static void parse_add(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_add"); @@ -1273,7 +1265,6 @@ parse_add(CdlExpression expr) static void parse_shift(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_shift"); @@ -1296,7 +1287,6 @@ parse_shift(CdlExpression expr) static void parse_comparison(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_comparison"); @@ -1323,7 +1313,6 @@ parse_comparison(CdlExpression expr) static void parse_equals(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_equals"); @@ -1346,7 +1335,6 @@ parse_equals(CdlExpression expr) static void parse_bitand(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_bitand"); @@ -1369,7 +1357,6 @@ parse_bitand(CdlExpression expr) static void parse_bitxor(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_bitxor"); @@ -1392,7 +1379,6 @@ parse_bitxor(CdlExpression expr) static void parse_bitor(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_bitor"); @@ -1415,7 +1401,6 @@ parse_bitor(CdlExpression expr) static void parse_and(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_and"); parse_bitor(expr); @@ -1437,7 +1422,6 @@ parse_and(CdlExpression expr) static void parse_or(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_or"); @@ -1460,7 +1444,6 @@ parse_or(CdlExpression expr) static void parse_conditional(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_conditional"); @@ -1490,7 +1473,6 @@ parse_conditional(CdlExpression expr) static void parse_expression(CdlExpression expr) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("parse_expression"); @@ -1503,7 +1485,6 @@ parse_expression(CdlExpression expr) // The entry point. void CdlExpressionBody::continue_parse(CdlExpression expr, std::string data, int& index, CdlExprOp& token, int& token_end) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlExpression::continue_parse"); CYG_REPORT_FUNCARG1XV(expr); @@ -1540,7 +1521,6 @@ CdlExpressionBody::continue_parse(CdlExp static void evaluate_subexpr(CdlEvalContext& context, CdlExpression expr, int subexpr_index, CdlSimpleValue& result) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAME("evaluate_subexpr"); CYG_REPORT_FUNCARG2XV(expr, subexpr_index); @@ -2076,7 +2056,6 @@ evaluate_subexpr(CdlEvalContext& context // ---------------------------------------------------------------------------- void CdlExpressionBody::eval_internal(CdlEvalContext& context, CdlSimpleValue& result) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlExpression::eval_internal)"); CYG_REPORT_FUNCARG3XV(this, &context, &result); @@ -2233,7 +2212,6 @@ CdlExpressionBody::~CdlExpressionBody() CdlExpression CdlExpressionBody::parse(std::string data) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("CdlExpression::parse", "result %p"); @@ -2260,7 +2238,6 @@ CdlExpressionBody::parse(std::string dat CdlExpression CdlExpressionBody::parse(std::string data, int& index, CdlExprOp& next_token, int& token_end) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("CdlExpression::parse", "result %d"); @@ -2401,7 +2378,6 @@ CdlExpressionBody::update(CdlTransaction void CdlExpressionBody::eval(CdlEvalContext& context, CdlSimpleValue& result) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlExpression::eval"); @@ -2596,7 +2572,6 @@ CdlListExpressionBody::check_this(cyg_as CdlListExpression CdlListExpressionBody::parse(std::string data) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("CdlListExpression::parse", "result %p"); @@ -2729,7 +2704,6 @@ CdlListExpressionBody::update(CdlTransac void CdlListExpressionBody::eval(CdlEvalContext& context, CdlListValue& result) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlListExpression::eval"); CYG_REPORT_FUNCARG3XV(this, &context, &result); @@ -2748,7 +2722,6 @@ CdlListExpressionBody::eval(CdlEvalConte void CdlListExpressionBody::eval_internal(CdlEvalContext& context, CdlListValue& result) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlListExpression::eval_internal"); CYG_REPORT_FUNCARG2XV(this, &context); @@ -2834,7 +2807,6 @@ CdlListExpressionBody::eval_internal(Cdl bool CdlListExpressionBody::is_member(CdlEvalContext& context, CdlSimpleValue& val) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("CdlListExpression::is_member (value)", "result %d"); CYG_REPORT_FUNCARG3XV(this, &context, &val); @@ -2852,7 +2824,6 @@ CdlListExpressionBody::is_member(CdlEval bool CdlListExpressionBody::is_member(CdlEvalContext& context, std::string val) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("CdlListExpression::is_member (string)", "result %d"); CYG_REPORT_FUNCARG2XV(this, &context); @@ -2870,7 +2841,6 @@ CdlListExpressionBody::is_member(CdlEval bool CdlListExpressionBody::is_member(CdlEvalContext& context, cdl_int val) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("CdlListExpression::is_member (int)", "result %d"); CYG_REPORT_FUNCARG3XV(this, &context, (int) val); @@ -2888,7 +2858,6 @@ CdlListExpressionBody::is_member(CdlEval bool CdlListExpressionBody::is_member(CdlEvalContext& context, double val) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("CdlListExpression::is_member (double)", "result %d"); CYG_REPORT_FUNCARG2XV(this, &context); @@ -2980,7 +2949,6 @@ CdlGoalExpressionBody::~CdlGoalExpressio CdlGoalExpression CdlGoalExpressionBody::parse(std::string data) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("CdlGoalExpression::parse", "result %p"); @@ -3018,7 +2986,6 @@ CdlGoalExpressionBody::parse(std::string // ---------------------------------------------------------------------------- void CdlGoalExpressionBody::eval(CdlEvalContext& context, bool& result) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlGoalExpression::eval"); CYG_REPORT_FUNCARG2XV(this, &context); @@ -3032,7 +2999,6 @@ CdlGoalExpressionBody::eval(CdlEvalConte bool CdlGoalExpressionBody::eval(CdlEvalContext& context) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAMETYPE("CdlGoalExpression::eval", "result %d"); CYG_REPORT_FUNCARG2XV(this, &context); @@ -3095,7 +3061,6 @@ CdlGoalExpressionBody::get_original_stri void CdlGoalExpressionBody::eval_internal(CdlEvalContext& context, bool& result) - throw(CdlEvalException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlGoalExpression::eval_internal"); CYG_REPORT_FUNCARG2XV(this, &context); diff --git a/host/libcdl/interface.cxx b/host/libcdl/interface.cxx --- a/host/libcdl/interface.cxx +++ b/host/libcdl/interface.cxx @@ -324,7 +324,6 @@ CdlInterfaceBody::initialize_savefile_su void CdlInterfaceBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlInterface::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); diff --git a/host/libcdl/interp.cxx b/host/libcdl/interp.cxx --- a/host/libcdl/interp.cxx +++ b/host/libcdl/interp.cxx @@ -1300,7 +1300,6 @@ CdlInterpreterBody::locate_all_files(std void CdlInterpreterBody::write_data(Tcl_Channel chan, std::string data) - throw(CdlInputOutputException) { CYG_REPORT_FUNCNAME("CdlInterpreter::write_data"); CYG_REPORT_FUNCARG2XV(this, chan); diff --git a/host/libcdl/option.cxx b/host/libcdl/option.cxx --- a/host/libcdl/option.cxx +++ b/host/libcdl/option.cxx @@ -274,7 +274,6 @@ CdlOptionBody::initialize_savefile_suppo void CdlOptionBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlOption::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); diff --git a/host/libcdl/package.cxx b/host/libcdl/package.cxx --- a/host/libcdl/package.cxx +++ b/host/libcdl/package.cxx @@ -464,7 +464,6 @@ CdlPackageBody::initialize_savefile_supp void CdlPackageBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlPackage::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); diff --git a/host/libcdl/parse.cxx b/host/libcdl/parse.cxx --- a/host/libcdl/parse.cxx +++ b/host/libcdl/parse.cxx @@ -583,7 +583,6 @@ CdlParse::get_error_count(CdlInterpreter void CdlParse::report_error(CdlInterpreter interp, std::string sub_id, std::string message) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlParse::report_error"); CYG_REPORT_FUNCARG1("interp %p", interp); @@ -658,7 +657,6 @@ CdlParse::unknown_command(CdlInterpreter // A variant of report_parse_error() which also adds the property prefix. void CdlParse::report_property_parse_error(CdlInterpreter interp, std::string argv0, std::string msg) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlPase::report_property_parse_error"); @@ -681,7 +679,6 @@ CdlParse::report_property_parse_error(Cd void CdlParse::report_property_parse_error(CdlInterpreter interp, CdlProperty prop, std::string msg) - throw(CdlParseException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlParse::report_property_parse_error"); report_property_parse_error(interp, (prop->get_argv())[0], msg); diff --git a/host/libcdl/testsuite/Makefile.in b/host/libcdl/testsuite/Makefile.in --- a/host/libcdl/testsuite/Makefile.in +++ b/host/libcdl/testsuite/Makefile.in @@ -116,7 +116,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ if test -f $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/host/libcdl/value.cxx b/host/libcdl/value.cxx --- a/host/libcdl/value.cxx +++ b/host/libcdl/value.cxx @@ -3695,7 +3695,6 @@ follow_expr_references(CdlProperty prope void CdlValuableBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool modifiable, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlValuable::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); diff --git a/host/libcdl/wizard.cxx b/host/libcdl/wizard.cxx --- a/host/libcdl/wizard.cxx +++ b/host/libcdl/wizard.cxx @@ -366,7 +366,6 @@ CdlWizardBody::parse_screen(CdlInterpret void CdlWizardBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal) - throw(CdlInputOutputException, std::bad_alloc) { CYG_REPORT_FUNCNAME("CdlWizard::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); diff --git a/host/tools/Utils/ChangeLog b/host/tools/Utils/ChangeLog --- a/host/tools/Utils/ChangeLog +++ b/host/tools/Utils/ChangeLog @@ -1,3 +1,10 @@ +2000-08-01 Jonathan Larmour + + * common/eCosSerial.h: + * common/eCosSerial.cpp: + Add support for setting RTSCTS, DSRDTR and XONXOFF flow control + for both win32 and unix + 2000-04-14 Simon FitzMaurice * common\Subprocess.cpp common\Subprocess.h diff --git a/host/tools/Utils/common/eCosSerial.cpp b/host/tools/Utils/common/eCosSerial.cpp --- a/host/tools/Utils/common/eCosSerial.cpp +++ b/host/tools/Utils/common/eCosSerial.cpp @@ -50,6 +50,9 @@ CeCosSerial::CeCosSerial(): m_pHandle(0), m_nDataBits(8), m_nStopBits(ONE_STOP_BIT), + m_bXONXOFFFlowControl(0), + m_bRTSCTSFlowControl(0), + m_bDSRDTRFlowControl(0), m_bParity(false), m_nBaud(0), m_nTotalReadTimeout(10*1000), @@ -70,6 +73,9 @@ CeCosSerial::CeCosSerial(LPCTSTR pszPort m_pHandle(0), m_nDataBits(8), m_nStopBits(ONE_STOP_BIT), + m_bXONXOFFFlowControl(0), + m_bRTSCTSFlowControl(0), + m_bDSRDTRFlowControl(0), m_bParity(false), m_nTotalReadTimeout(10*1000), m_nTotalWriteTimeout(10*1000), @@ -110,6 +116,24 @@ bool CeCosSerial:: SetStopBits(StopBitsT return 0==m_pHandle || !bApplySettingsNow || ApplySettings(); } +bool CeCosSerial:: SetXONXOFFFlowControl(bool b,bool bApplySettingsNow/*=true*/) +{ + m_bXONXOFFFlowControl=b; + return 0==m_pHandle || !bApplySettingsNow || ApplySettings(); +} + +bool CeCosSerial:: SetRTSCTSFlowControl(bool b,bool bApplySettingsNow/*=true*/) +{ + m_bRTSCTSFlowControl=b; + return 0==m_pHandle || !bApplySettingsNow || ApplySettings(); +} + +bool CeCosSerial:: SetDSRDTRFlowControl(bool b,bool bApplySettingsNow/*=true*/) +{ + m_bDSRDTRFlowControl=b; + return 0==m_pHandle || !bApplySettingsNow || ApplySettings(); +} + bool CeCosSerial:: SetReadTimeOuts(int nTotal,int nBetweenChars,bool bApplySettingsNow/*=true*/) // mSec { m_nTotalReadTimeout=nTotal; @@ -185,15 +209,37 @@ bool CeCosSerial::ApplySettings() arpszStopbits[dcb.StopBits], dcb.ByteSize); - // No control over the following yet - dcb.fDtrControl=DTR_CONTROL_ENABLE; + if (m_bDSRDTRFlowControl) { + dcb.fDtrControl = DTR_CONTROL_HANDSHAKE; + dcb.fOutxDsrFlow = 1; + } else { + dcb.fDtrControl = DTR_CONTROL_ENABLE; + dcb.fOutxDsrFlow = 0; + } + + if (m_bRTSCTSFlowControl) { + dcb.fRtsControl = RTS_CONTROL_HANDSHAKE; + dcb.fOutxCtsFlow = 1; + } else { + dcb.fRtsControl = RTS_CONTROL_ENABLE; + dcb.fOutxCtsFlow = 0; + } + dcb.fTXContinueOnXoff=1; - dcb.fRtsControl=RTS_CONTROL_ENABLE; - dcb.fAbortOnError=1; - dcb.XonLim=2048; - dcb.XoffLim=512; dcb.XonChar=17; dcb.XoffChar=19; + if (m_bXONXOFFFlowControl) { + dcb.XonLim=512; + dcb.XoffLim=512; + dcb.fOutX=1; + dcb.fInX=1; + } else { + dcb.XonLim=2048; + dcb.XoffLim=512; + dcb.fOutX=0; + dcb.fInX=0; + } + dcb.fAbortOnError=1; HANDLE hCom=(HANDLE)m_pHandle; if (!SetCommState(hCom, &dcb)) { @@ -422,6 +468,33 @@ bool CeCosSerial::ApplySettings() if (m_bParity) // even parity. buf.c_cflag |= PARENB; } + + // Set flow control + { + buf.c_iflag &= ~(IXON|IXOFF); +#ifdef CRTSCTS + buf.c_cflag &= ~CRTSCTS; +#endif + if ( m_bXONXOFFFlowControl ) { + buf.c_iflag |= (IXON|IXOFF); + } + if ( m_bRTSCTSFlowControl ) { +#ifdef CRTSCTS + buf.c_cflag |= CRTSCTS; +#else + return false; +#endif + } + if ( m_bDSRDTRFlowControl ) { +#ifdef CDSRDTR + buf.c_cflag |= CDSRDTR; +#else + return false; +#endif + } + + + } // Set the new settings if (tcsetattr((int) m_pHandle, TCSADRAIN, &buf)) { @@ -468,6 +541,15 @@ bool CeCosSerial::Read (void *pBuf,unsig return false; } nRead = n; +#if 0 + if (n>0) { + unsigned int i; + fprintf(stderr, "%d:", nRead); + for (i = 0; i < nRead; i++) + fprintf(stderr, "%02x!", ((unsigned char *)pBuf)[i]); + fprintf(stderr, "\n"); + } +#endif return true; } @@ -497,9 +579,18 @@ bool CeCosSerial::Read (void *pBuf,unsig ERROR(_T("Read failed: %d\n"), errno); return false; // FAILED } - nRead += n; - pData += n; - nSize -= n; + else if (n > 0) { +#if 0 + unsigned int i; + fprintf(stderr, "%d:", nRead); + for (i = 0; i < nRead; i++) + fprintf(stderr, "%02x!", ((unsigned char *)pBuf)[i]); + fprintf(stderr, "\n"); +#endif + nRead += n; + pData += n; + nSize -= n; + } // Now use inter-char timeout. tv.tv_sec = m_nInterCharReadTimeout / 1000; diff --git a/host/tools/Utils/common/eCosSerial.h b/host/tools/Utils/common/eCosSerial.h --- a/host/tools/Utils/common/eCosSerial.h +++ b/host/tools/Utils/common/eCosSerial.h @@ -69,6 +69,9 @@ public: bool SetParity(bool bParityOn,bool bApplySettingsNow=true); bool SetDataBits(int n,bool bApplySettingsNow=true); bool SetStopBits(StopBitsType n,bool bApplySettingsNow=true); + bool SetXONXOFFFlowControl(bool b,bool bApplySettingsNow=true); + bool SetRTSCTSFlowControl(bool b,bool bApplySettingsNow=true); + bool SetDSRDTRFlowControl(bool b,bool bApplySettingsNow=true); bool SetReadTimeOuts(int nTotal,int nBetweenChars,bool bApplySettingsNow=true); // Times are in mSec bool SetWriteTimeOuts(int nTotal,int nBetweenChars,bool bApplySettingsNow=true); // Times are in mSec @@ -78,6 +81,9 @@ public: int GetParity() const { return m_bParity; } int GetDataBits() const { return m_nDataBits; } StopBitsType GetStopBits() const { return m_nStopBits; } + bool GetXONXOFFFlowControl() const { return m_bXONXOFFFlowControl; } + bool GetRTSCTSFlowControl() const { return m_bRTSCTSFlowControl; } + bool GetDSRDTRFlowControl() const { return m_bDSRDTRFlowControl; } unsigned int GetBaud() const { return m_nBaud; } bool GetReadTimeOuts(int &nTotal,int &nBetweenChars) const {nTotal=m_nTotalReadTimeout; nBetweenChars=m_nInterCharReadTimeout; return true; }// mSec bool GetWriteTimeOuts(int &nTotal,int &nBetweenChars) const {nTotal=m_nTotalWriteTimeout; nBetweenChars=m_nInterCharWriteTimeout; return true; }// mSec @@ -123,6 +129,9 @@ protected: void *m_pHandle; int m_nDataBits; StopBitsType m_nStopBits; + bool m_bXONXOFFFlowControl; + bool m_bRTSCTSFlowControl; + bool m_bDSRDTRFlowControl; bool m_bParity; unsigned int m_nBaud; int m_nTotalReadTimeout,m_nTotalWriteTimeout; diff --git a/host/tools/configtool/ChangeLog b/host/tools/configtool/ChangeLog --- a/host/tools/configtool/ChangeLog +++ b/host/tools/configtool/ChangeLog @@ -1,3 +1,14 @@ +2000-08-15 Jonathan Larmour + + * common/win32/memmap.cpp (export_files): In header file, wrap parts + that aren't ASM safe in "#ifndef __ASSEMBLER__" + (export_sections): Ditto + +2000-07-25 Jonathan Larmour + + * common/win32/memmap.cpp (export_sections): + Use CYG_LABEL_DEFN to define linker symbols + 2000-07-18 John Dallaway * standalone/win32/Configtool.rc: diff --git a/host/tools/configtool/common/win32/memmap.cpp b/host/tools/configtool/common/win32/memmap.cpp --- a/host/tools/configtool/common/win32/memmap.cpp +++ b/host/tools/configtool/common/win32/memmap.cpp @@ -1170,17 +1170,17 @@ bool mem_map::export_sections (FILE * sc { // output section symbol if (section_view->section->final_location->anchor == absolute) // an absolute VMA - fprintf (script_stream, " __%s = %#lx;", section_view->section->name.c_str (), section_view->section->final_location->address); + fprintf (script_stream, " CYG_LABEL_DEFN(__%s) = %#lx;", section_view->section->name.c_str (), section_view->section->final_location->address); else // a relative VMA - fprintf (script_stream, " __%s = ALIGN (%#lx);", section_view->section->name.c_str (), section_view->section->alignment); + fprintf (script_stream, " CYG_LABEL_DEFN(__%s) = ALIGN (%#lx);", section_view->section->name.c_str (), section_view->section->alignment); // update current location pointer if (section_view->section->size != 0) // size is known - fprintf (script_stream, " . = __%s + %#lx;", section_view->section->name.c_str (), section_view->section->size); + fprintf (script_stream, " . = CYG_LABEL_DEFN(__%s) + %#lx;", section_view->section->name.c_str (), section_view->section->size); // output reference to symbol in header file - fprintf (header_stream, "extern char CYG_LABEL_NAME (_%s) [];\n", section_view->section->name.c_str ()); - fprintf (header_stream, "#define CYGMEM_SECTION_%s (CYG_LABEL_NAME (_%s))\n", section_view->section->name.c_str (), section_view->section->name.c_str ()); + fprintf (header_stream, "#ifndef __ASSEMBLER__\nextern char CYG_LABEL_NAME (__%s) [];\n#endif\n", section_view->section->name.c_str ()); + fprintf (header_stream, "#define CYGMEM_SECTION_%s (CYG_LABEL_NAME (__%s))\n", section_view->section->name.c_str (), section_view->section->name.c_str ()); if (section_view->section->size == 0) // a section of unknown size { mem_address section_end_address; @@ -1192,7 +1192,7 @@ bool mem_map::export_sections (FILE * sc section_end_address = section_view->section->final_location->address; --section_view; // move back to previous section view - fprintf (header_stream, "#define CYGMEM_SECTION_%s_SIZE (%#lx - (size_t) CYG_LABEL_NAME (_%s))\n", section_view->section->name.c_str (), section_end_address, section_view->section->name.c_str ()); + fprintf (header_stream, "#define CYGMEM_SECTION_%s_SIZE (%#lx - (size_t) CYG_LABEL_NAME (__%s))\n", section_view->section->name.c_str (), section_end_address, section_view->section->name.c_str ()); } else // a section of known size fprintf (header_stream, "#define CYGMEM_SECTION_%s_SIZE (%#lx)\n", section_view->section->name.c_str (), section_view->section->size); @@ -1245,12 +1245,15 @@ bool mem_map::export_files (LPCTSTR scr time (&export_time); struct tm * local = localtime (&export_time); fprintf (script_stream, "// eCos memory layout - %s\n%s\n\n", asctime (local), MLT_GENERATED_WARNING); + fprintf (script_stream, "#include \n\n"); // output the header file header fprintf (header_stream, "// eCos memory layout - %s\n%s\n\n", asctime (local), MLT_GENERATED_WARNING); + fprintf (header_stream, "#ifndef __ASSEMBLER__\n"); fprintf (header_stream, "#include \n"); // for the CYG_LABEL_NAME macro definition fprintf (header_stream, "#include \n\n"); // for size_t + fprintf (header_stream, "#endif\n"); // output the MEMORY block diff --git a/host/tools/ecostest/ChangeLog b/host/tools/ecostest/ChangeLog --- a/host/tools/ecostest/ChangeLog +++ b/host/tools/ecostest/ChangeLog @@ -1,3 +1,39 @@ +2000-08-16 Jonathan Larmour + + * common/ser_filter.cpp (main): Clean up warning + +2000-08-08 Jonathan Larmour + + * common/eCosTestSerialFilter.h: Update flow_cfg_t values for correct + target settings + +2000-08-01 Jonathan Larmour + + * common/eCosTestSerialFilter.cpp (PrintHex): Print out more printable + chars + (SetConfig): Support flow control + (ParseConfig): Support target setting of flow control + (CMD_TestBinary): Don't output XON/XOFF. Output 255 chars not 256 + to make buffer problems more obvious. + + * common/eCosTestDownloadFilter.h: Allow SET_VALUE to set optional args + * common/eCosTestSerialFilter.h: Allow SET_VALUE to set optional args + Also add flow_cfg_t type and flags member in ser_cfg_t for flow control + +2000-07-24 Jonathan Larmour + + * common/eCosTestSerialFilter.cpp (FilterFunctionProper): + Store output for tracing up so it is output a packet at a time. + As well as clarifying the output, it is required when sending to + GDB to prevent the trace 'O' packets in the middle of target packets. + (CMD_TestBinary): Delay to allow target to read in checksum. This + prevents overruns before finishing reading the checksum masking + the real cause of the problem. + (CeCosTestSerialFilter): Initialise stored trace buffer members + + * common/eCosTestSerialFilter.h: Add trace buffer members for above + to CeCosTestSerialFilter + 2000-06-19 John Dallaway * unix/Makefile: diff --git a/host/tools/ecostest/common/eCosTestDownloadFilter.h b/host/tools/ecostest/common/eCosTestDownloadFilter.h --- a/host/tools/ecostest/common/eCosTestDownloadFilter.h +++ b/host/tools/ecostest/common/eCosTestDownloadFilter.h @@ -50,7 +50,20 @@ #define INIT_VALUE(__args) unsigned int v; char *__ptr1, *__ptr2 = (__args) -#define SET_VALUE(__type, __slot) { __ptr1 = strchr(__ptr2, (int) ':'); if (__ptr1) *__ptr1 = 0; v = atoi(__ptr2); __ptr2 = __ptr1+1; (__slot) = (__type) v; } +#define SET_VALUE(__type, __slot) { \ + __ptr1 = strchr(__ptr2, (int) ':'); \ + if (*__ptr2 == '\0') \ + (__slot) = (__type)-1; \ + else { \ + if (__ptr1) \ + *__ptr1 = 0; \ + else \ + __ptr1 = strchr( __ptr2, 0) - 1; \ + v = atoi(__ptr2); \ + __ptr2 = __ptr1+1; \ + (__slot) = (__type) v; \ + } \ +} #define SET_STRING(__slot) { __ptr1 = strchr(__ptr2, (int) ':'); if (__ptr1) *__ptr1 = 0; __slot = __ptr2; __ptr2 = __ptr1+1; } diff --git a/host/tools/ecostest/common/eCosTestSerialFilter.cpp b/host/tools/ecostest/common/eCosTestSerialFilter.cpp --- a/host/tools/ecostest/common/eCosTestSerialFilter.cpp +++ b/host/tools/ecostest/common/eCosTestSerialFilter.cpp @@ -66,6 +66,8 @@ CeCosTestSerialFilter::CeCosTestSerialFi m_xUnreadBuffer(NULL), m_nUnreadBufferIndex(0), m_nUnreadBufferSize(0), + m_xStoredTraceBuffer(NULL), + m_nStoredTraceBufferSize(0), m_bNullFilter(false), m_nCmdIndex(0), m_bCmdFlag(false), @@ -214,7 +216,7 @@ CeCosTestSerialFilter::PrintHex(const un p += sprintf(p, "'"); for (i = 0; i < count; i++) { int c = d1[i]; - if (' ' >= c || 'z' <= c) + if (' ' > c || 'z' < c) c = '.'; p += sprintf(p, "%c", c); } @@ -289,7 +291,6 @@ CeCosTestSerialFilter::TargetRead(CeCosS } __total_read += __read; - unsigned int i; for (i = 0; i < __read; i++) { if ('$' == buffer[i]) { @@ -363,16 +364,24 @@ CeCosTestSerialFilter::SetConfig(CeCosSe const ser_cfg_t* new_cfg, ser_cfg_t* old_cfg) { + // Note that for flow control, we assume that *both* receive and transmit + // flow control are set or not set if (old_cfg) { old_cfg->baud_rate = pSer.GetBaud(); old_cfg->parity = (0 != pSer.GetParity()) ? true : false; old_cfg->data_bits = pSer.GetDataBits(); old_cfg->stop_bits = pSer.GetStopBits(); + old_cfg->flags = pSer.GetXONXOFFFlowControl() ? FLOW_XONXOFF_RX : 0; + old_cfg->flags |= pSer.GetRTSCTSFlowControl() ? FLOW_RTSCTS_RX : 0; + old_cfg->flags |= pSer.GetDSRDTRFlowControl() ? FLOW_DSRDTR_RX : 0; } pSer.SetBaud(new_cfg->baud_rate, false); pSer.SetParity(new_cfg->parity, false); pSer.SetDataBits(new_cfg->data_bits, false); + pSer.SetXONXOFFFlowControl((new_cfg->flags&FLOW_XONXOFF_RX) != 0, false); + pSer.SetRTSCTSFlowControl((new_cfg->flags&FLOW_RTSCTS_RX) != 0, false); + pSer.SetDSRDTRFlowControl((new_cfg->flags&FLOW_DSRDTR_RX) != 0, false); return pSer.SetStopBits(new_cfg->stop_bits, true); // apply settings } @@ -533,7 +542,8 @@ CeCosTestSerialFilter::CMD_DefaultConfig void CeCosTestSerialFilter::ParseConfig(char* args, ser_cfg_t* new_cfg) { - int ecos_parity, ecos_stop_bits, ecos_baud_rate; + int ecos_parity, ecos_stop_bits, ecos_baud_rate, ecos_flags; + CeCosSerial::StopBitsType t2h_stop_bits[3] = { CeCosSerial::ONE_STOP_BIT, CeCosSerial::ONE_POINT_FIVE_STOP_BITS, @@ -544,10 +554,17 @@ CeCosTestSerialFilter::ParseConfig(char* SET_VALUE(int, new_cfg->data_bits); SET_VALUE(int, ecos_stop_bits); SET_VALUE(int, ecos_parity); + SET_VALUE(int, ecos_flags); new_cfg->parity = (ecos_parity != 0) ? true : false; new_cfg->stop_bits = t2h_stop_bits[ecos_stop_bits - 1]; + // flags is an optional field + if ( -1 == ecos_flags ) + new_cfg->flags = FLOW_NONE; + else + new_cfg->flags = ecos_flags; + // eCos->human translation of serial baud rate. This table must // match the one in io/serial/current/include/serialio.h static const int tt_baud_rate[] = { @@ -585,6 +602,14 @@ CeCosTestSerialFilter::ParseConfig(char* Trace("Parsed Config baud=%d, bParity=%d, stopbits=%d, databits=%d\n", new_cfg->baud_rate, (int) new_cfg->parity, new_cfg->stop_bits, new_cfg->data_bits); + Trace("Parsed Config xonxoff_rx=%d,tx=%d, rtscts_rx=%d,tx=%d, " + "dsrdtr_rx=%d,tx=%d\n", + (new_cfg->flags & FLOW_XONXOFF_RX) != 0, + (new_cfg->flags & FLOW_XONXOFF_TX) != 0, + (new_cfg->flags & FLOW_RTSCTS_RX) != 0, + (new_cfg->flags & FLOW_RTSCTS_TX) != 0, + (new_cfg->flags & FLOW_DSRDTR_RX) != 0, + (new_cfg->flags & FLOW_DSRDTR_TX) != 0); } // Always make sure CRC fits in 31 bits. Bit of a hack, but we want @@ -713,9 +738,13 @@ CeCosTestSerialFilter::CMD_TestBinary(Ce } for (i = 0; i < size; i++) { static int count = 0; - unsigned char c = (unsigned char) (count++ & 0xff); - // don't allow $s and @s in the data, nor 0x03 (GDB C-c) - if ('$' == c || '@' == c || 0x03 == c) + // Output 255 chars, not 256 so that we aren't a multiple/factor of the + // likely buffer sizes in the system, this can mask problems as I've + // found to my cost! + unsigned char c = (unsigned char) (count++ % 255); + // don't allow $s and @s in the data, nor 0x03 (GDB C-c), nor flow + // control chars + if ('$' == c || '@' == c || 0x03 == c || 0x11 == c || 0x13 == c) c = (unsigned char) '*'; data_out[i] = c; } @@ -726,6 +755,9 @@ CeCosTestSerialFilter::CMD_TestBinary(Ce // Send checksum to target. SendChecksum(pSer, crc); + // Give the target 1/10th of a sec to digest it + CeCosThreadUtils::Sleep(100); + switch (mode) { case MODE_NO_ECHO: { @@ -739,6 +771,7 @@ CeCosTestSerialFilter::CMD_TestBinary(Ce int in_crc; TargetWrite(pSer, data_out, size); + Trace("Finished write, waiting for target echo.\n"); // Expect target to echo the data TargetRead(pSer, data_in, size); @@ -957,17 +990,47 @@ CeCosTestSerialFilter::FilterFunctionPro // Allows trace to be called without a reference to the socket... m_cGDBSocket = &socket; - // Output the serial data if option enabled - but only if dumping - // state to the console or after the first command has been seen - // from the filter. GDB gets confused by O-packets if they appear - // when it's trying to connect. - if (m_bOptSerDebug && (m_bOptConsoleOutput || m_bFirstCommandSeen)) - PrintHex((unsigned char*) buffer, nRead); + // Put in trace buffer in case we have to leave it because the packet + // is incomplete + m_xStoredTraceBuffer = (unsigned char *) + realloc( m_xStoredTraceBuffer, m_nStoredTraceBufferSize + nRead ); + if ( NULL == m_xStoredTraceBuffer ) + throw "Could not allocate stored trace buffer"; + memcpy( m_xStoredTraceBuffer + m_nStoredTraceBufferSize, buffer, nRead ); + m_nStoredTraceBufferSize += nRead; + + // Now search for distinct packets, delimited by '@' (filter commands) + // and '$' (GDB packets) + unsigned int i, newStart=0; + for (i=0; i + + * ecos.db: Added CYGPKG_FS_RAM package. + +2000-08-14 Hugo Tyson + + * ecos.db: Minor changes... + Arrange for hardware flash drivers to be "hardware" and + referenced in their associated targets, and for the common flash + code to be not-hardware and not in any target. + Arrange for hardware PCMCIA drivers to be "hardware" and + referenced in their associated targets, and for the common PCMCIA + code to be not-hardware and not in any target. + Not sure what to do about the "PCMCIA (Compact Flash) ethernet + drivers" CYGPKG_DEVS_ETH_CF - arguably this should be "hardware" + and mentioned in all targets that can use PCMCIA, right? But it + is not hardware specific, and you might want to use PCMCIA without + using the net at all. So I left it a plain package. + +2000-08-14 Gary Thomas + + * ecos.db: Add flash driver for EDB7xxx. + +2000-08-10 Hugo Tyson + + * ecos.db (CYGPKG_IO_ETH_DRIVERS): Since this package is now + included in all releases, re-organize it so that it is exported + in ecos.db always. (Same package as change 2000-08-03) + +2000-08-03 Gary Thomas + + * ecos.db: Ethernet [logical] drivers package moved to "io". + +2000-08-01 Gary Thomas + + * ecos.db: + Reorg FLASH packages to have architecture layer. + +2000-08-01 Gary Thomas + + * ecos.db: + Reorg PCMCIA packages to have architecture layer. + +2000-07-26 Gary Thomas + + * ecos.db: Adding FLASH package - FLASH memory support. + +2000-07-14 Gary Thomas + + * ecos.db: Add RedBoot package. + +2000-07-07 Gary Thomas + + * ecos.db: Add PCMCIA (Compact Flash) ethernet driver. + +2000-07-06 Gary Thomas + + * ecos.db: Add initial PCMCIA (Compact Flash) package(s). + 2000-07-07 Jesper Skov * ecos.db: Removed 'enable' statements from SH targets. Moved to @@ -37,10 +96,18 @@ 2000-05-26 Jesper Skov + + * ecos.db: Added CYGPKG_IO_FILEIO package. + 2000-05-25 John Dallaway * ecos.db: Tidy V850-related display strings. +2000-05-16 Nick Garnett + + * ecos.db: Fixed naming bug in CYGPKG_LIBC_SETJMP entry. + 2000-04-26 Jesper Skov * ecos.db: ceb_v850 - include serial driver. @@ -101,6 +168,10 @@ 2000-04-05 Jesper Skov + + * ecos.db: Added POSIX package. + 2000-03-24 Jonathan Larmour * ecosrelease.tcl: Allow running if cygtclsh80 is the tcl shell, as diff --git a/packages/NEWS b/packages/NEWS --- a/packages/NEWS +++ b/packages/NEWS @@ -1,3 +1,66 @@ +* Move logical ethernet "driver" into io/eth where the interface can be shared + between multiple implementations, e.g. BSD TCP/IP and Red Boot's TCP/IP + stacks. +* RedBoot - the Red Hat Bootstrap ROM monitor has been added, initially + supporting ARM-EDB7xxx, ARM-EBSA285, and ARM-Assabet boards. Provides + serial and ethernet GDB debugging support, flash image management and flash + booting, BOOTP/DHCP and TFTP boot support and a CLI interface. +* Added PCMCIA and Compact Flash support, including drivers for the ARM-Assabet + board. +* Added generic FLASH memory support +* Added flash memory support for ARM-EBSA285 and ARM-EDB7xxx boards +* Added Compact Flash Ethernet driver +* Hitachi SH7707a variant support added. +* Support added for both software and hardware flow control (the latter + initially only for the ARM PID board) +* Loopback serial device driver added +* POSIX termios support added for EL/IX level 1 compatibility +* Improved dynamic memory management support in the memory allocator + package. Existing dynamic memory support in the kernel (fixed and variable + block allocators) and in libc (malloc, etc.) has been moved to this + package, located at services/memalloc/common. It is now possible to support + memory pools occupying all of remaining memory (as determined by the MLT). + New memory allocators can be "plugged in", and an example of Doug Lea's + malloc (dlmalloc) has been included. +* Plug-in filesystem support added, with a POSIX 1003.1 compatible API, found + in the io/fileio package, and integrated with the C library. +* An initial example filesystem implementation is provided in fs/ram. This + is a RAM filesystem that attempts to both be a useful tool in its own + right and an example of how to write a filesystem that plugs into the + fileio infrastructure. + The source of the filesystem is in fs/ram/VERSION/src/ramfs.c and is + intended to be largely self documenting. The General Description at + the beginning of the file gives an overview of the structure of the + system, and comments within the code explain specific points. This + code should be read in conjunction with the description of the fileio + infrastructure. +* Support added for POSIX 1003.1 threads, mutexes, semaphores, message queues, + condition variables, clocks, timers and real-time signals in the POSIX + compatibility package (part of the EL/IX compatibility initiative) found at + compat/posix. +* Kernel enhanced with Asynchronous Service Routines (ASRs) which are routines + called back at the point a thread is scheduled. +* Added (configurably) priority ceilings for kernel mutexes +* Support sorted thread queues in kernel, rather than LIFO, controlled by the + CYGIMP_KERNEL_SCHED_SORTED_QUEUES option. +* The Kernel C API functions cyg_semaphore_wait() and cyg_cond_wait() now + return booleans to indicate if the wait failed. +* Added enhanced form of kernel message queue which is more flexible at runtime + than mboxes - available in +* Add a generic interface in to allow tables of + data, particularly initialization data, to be included in an application + image. This replaces the previous __DEVTAB__ and __NETDEVTAB__ references + in linker scripts. +* Most standard top-level header files now controlled by the "isoinfra" + package +* C library package split into separate packages on functional boundaries: + i18n, setjmp, signals, startup, stdio, stdlib, time +* Most targets now implement a standard form of "virtual vectors" - a + mechanism to allow enhanced co-operation between ROM monitors and running + applications. This allows the application to leave to the ROM things that + the ROM supports rather than duplicating. It also will permit network + debugging in future. To take advantage of this, new GDB stub + images/CygMon images should be programmed onto boards. * DHCP support has been added to the TCP/IP support, in addition to the existing BOOTP support * CDL now supports type bool and booldata for interfaces diff --git a/packages/compat/posix/current/ChangeLog b/packages/compat/posix/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/ChangeLog @@ -0,0 +1,461 @@ +2000-08-08 Jonathan Larmour + + * include/limits.h: Don't define SSIZE_MAX here, leave it to the + isoinfra default. + +2000-07-27 Jonathan Larmour + + * tests/signal2.c: NA if no setjmp/longjmp + +2000-07-26 Nick Garnett + + * include/pthread.h: + * src/pthread.cxx (pthread_testcancel): Reversed addition of cyg_ + to this symbol. + +2000-07-25 Jonathan Larmour + + * src/pthread.cxx: Define main_stack and main_thread as static + Rename pthread_canceled -> cyg_pthread_canceled - pthread_ may be + a reserved name space but this makes explicit it is implementation- + and not standard-defined + (PTHREAD_ENTRY_VOID): Define for funcs that take no args + (pthread_testcancel): Call PTHREAD_ENTRY_VOID() + + * include/pthread.h: Rename pthread_canceled -> cyg_pthread_canceled + +2000-07-20 Jonathan Larmour + + * src/pthread.cxx: Use isoinfra to determine presence of malloc() + Define pthread_malloc() and pthread_free() as inlines + + * cdl/posix.cdl: Shouldn't define _POSIX_MESSAGE_PASSING at all - that + happens in isoinfra. + +2000-07-20 Nick Garnett + + * cdl/posix.cdl: Added misc.cxx to compile list. Added option to + define _POSIX_MESSAGE_PASSING. Added configury for utsname + structure. + + * include/utsname.h: Added this file to define struct utsname and + uname() function prototype. + + * include/mqueue.h: Moved definition of _POSIX_MESSAGE_PASSING to + CDL. + + * include/limits.h: Added NGROUPS_MAX definition. + + * src/pthread.cxx: + Added support for malloced() thread stacks. + Added implementations of pthread_mutex_setprioceiling() and + pthread_mutex_getprioceiling(). + Changed implementations of pthread_mutex_destroy(), + pthread_mutex_lock() and pthread_mutex_trylock() to conform more + closely to the standard. + Changed pthread_key_create() to assign NULL to all valid thread + slots that correspond to a newly allocated key. + + * src/pprivate.h: Added freestack and stackmem members to manage + malloced thread stacks. + + * src/misc.cxx: Added this file to contain functions that do not + belong in any other files. Currently contains uname() and + sysconf(). + +2000-07-19 Jonathan Larmour + + * src/startup.cxx: Remove unnecessary includes + Use dummy object constructor to do initialization + + * cdl/posix.cdl: + Don't need main.cxx any more + Build startup.cxx into extras.o (via libextras.a) + + * cdl/pthread.cdl (CYGPKG_POSIX_MAIN_THREAD): + Integrate with CYGPKG_LIBC_STARTUP - tell CYGPKG_LIBC_STARTUP to + let pthreads set up main thread + + * src/pthread.cxx: Integrate with CYGPKG_LIBC_STARTUP rather than + calling main() directly. + Track number of threads waiting to be joined, so we can tell in + pthread_exit() if this is the last thread, and therefore whether + to call exit() + + * src/main.cxx: obsolete, removed + +2000-07-13 Nick Garnett + + * src/signal.cxx: Added ISO C compatibility functions signal() and + raise(). + +2000-06-21 Nick Garnett + + * src/pthread.cxx: Added for(;;) loop to end of pthread_exit(). + pthread_exit() is marked with the noreturn attribute, and without + this some compilers generate a call to abort() here in case + Cyg_Thread::exit() returns. The loop avoids this. + +2000-06-06 Jonathan Larmour + + * src/mqueue.cxx (mq_receive): Fix non-portable treatment of mode flags + (mq_send): Ditto + * tests/mqueue2.c (main): Ditto + +2000-05-24 Nick Garnett + + * tests/pthread2.c: Added this program to test per-thread data + handling. + + * tests/pthread3.c: Added this program to test execution of + cancellation handler. + + * src/pthread.cxx: Fixed some bugs revealed by new test programs. + + * cdl/posix.cdl: Added two new pthread tests. + +2000-05-22 Jonathan Larmour + + * cdl/posix.cdl (CYGPKG_POSIX): Require + CYGIMP_KERNEL_SCHED_SORTED_QUEUES + +2000-05-20 Jonathan Larmour + + * tests/mqueue1.c (cyg_user_start): Define correctly + * tests/mqueue2.c (cyg_user_start): Likewise + + * src/pprivate.h (cyg_sigqueue): Make struct sigevent * arg const since + it is, and it prevents warnings elsewhere + * src/signal.cxx (cyg_sigqueue): ditto + + * tests/signal2.c: Use CYG_TEST_NA, not CYG_TEST_INFO (otherwise + the test farm may fail the tests because there are no PASSes or NAs) + + * cdl/posix.cdl (CYGPKG_POSIX): We need errno and error codes, so + require them + Move some of the package implements into the components + Add message queue configuration, build mqueue.cxx and the mqueue1 and + mqueue2 tests + Move some calculated options into isoinfra, implemented as interfaces + so that unistd.h and limits.h can get the values + + * include/limits.h: Move _POSIX_* macros into isoinfra limits.h + since they are implementation independent + + * src/mqueue.cxx: Add POSIX message queue implementation + * tests/mqueue1.c, tests/mqueue2.c: and tests + +2000-05-18 Nick Garnett + + * src/pprivate.h: + * src/pthread.cxx: + * src/signal.cxx: + * src/time.cxx: + Added prioritization of static kernel objects. + +2000-05-17 Nick Garnett + + * src/pthread.cxx: + To reduce the static memory required by this code, the + pthread_info structure for a pthread is now allocated in the stack + memory for that thread, and not in a static table. The table is + now just an array of pointers. The per-thread data array is now + also allocated onto the stack only when first required. + + * include/pthread.h: Removed some redundant code. + + * include/limits.h: Added PTHREAD_STACK_OVERHEAD to record + management overhead imposed on POSIX threads stacks. This is added + to the HAL minimum requirement to generate PTHREAD_STACK_MIN. + + * src/pprivate.h (pthread_info): + * include/types.h (pthread_attr_t): Converted a number of integer + state and boolean fields to bitfields. + + * cdl/pthread.cdl: + Added requirement for CYGFUN_KERNEL_THREADS_STACK_LIMIT. + +2000-05-16 Nick Garnett + + * include/types.h: Added stacksize_valid to pthread_attr_t + structure. + + * include/signal.h: + Added SI_EXCEPT to mark any signals that were caused by an + exception. Removed conditions around SIGBUS. + + * src/startup.cxx (cyg_posix_start): + Added call to cyg_posix_exception_start(). + + * src/signal.cxx: + Rearranged cyg_deliver_signals() so that it is possible to + longjmp() out of a signal handler without leaving signal handling + code in an inconsistent state. + Added handling of SIG_IGN in sigaction(). + + * src/pthread.cxx: Added setting and checking of stacksize_valid. + + * src/pprivate.h: Added cyg_deliver_signals() as an export of + signal system. Added exports from except.cxx. + + * src/except.cxx: Added this file to handle delivery of exceptions + into the POSIX signal mechanism. + + * cdl/posix.cdl: Added except.cxx to compile list, added signal2 + to tests. Added requirement on kernel exception processing. + + * tests/tm_basic.cxx: Tidied up a compilation warning. + + * tests/signal2.c: Added this test for exception signal generation. + + * tests/mutex3.c: Fixed stupid bug. + +2000-05-10 Nick Garnett + + * src/pprivate.h: Added cyg_posix_clock_start() prototype. + + * src/startup.cxx: Added call to cyg_posix_clock_start(). + + * src/time.cxx: Added startup routine to initialize + converters. Fixed error result bug in timer_delete(). + + * include/signal.h: Removed some configuration tests which are now + done in CDL. + + * cdl/posix.cdl: Added configury for the signals component. Added + tm_basic to tests. + + * tests/tm_basic.cxx: + Added this POSIXized version of the tm_basic test. Note that this + has not been entirely converted. While the code being tested is + POSIX, the timing infrastructure remains a mish-mash of kernel, + KAPI and HAL code. + +2000-05-04 Nick Garnett + + * src/time.cxx: + Many changes to implement the delivery of signals on timer expiry. + Also added timer_delete(). + + * src/signal.cxx: + cyg_sigqueue() and cyg_deliver_signals() may now only be called + from within the context of a POSIX thread, either from an API call + or an ASR. + cyg_deliver_signals() can now cope with a signal that has + SA_SIGINFO set but no signals queued. It also determines + dynamically whether to lock the signal_mutex. + cyg_deliver_signals() is no longer called implicitly from + cyg_sigqueue() - so a number of expicit calls have been added. + + * src/sched.cxx: + Added this file to implement scheduling API. + + * src/pthread.cxx: + Moved priority translation macros to pprivate.h. + Removed errno handling, now done in isoinfra package. + Added iterative calls to per-thread data destructors. + + * src/pprivate.h: + Removed error field from pthread_info structure. + Moved priority translation macros here. + Removed prototype for cyg_deliver_signals(). + Added prototype for cyg_posix_timer_asr(). + + * include/time.h: Added timer_delete() which was mysteriously + omitted. + + * cdl/posix.cdl: Added sched.cxx to compile list and timer1.c to + tests. + + * tests/signal1.c: + * tests/pthread1.c: + Fixed bug in use of stack sizes. + + * tests/timer1.c: + Added test for use of timers. + +2000-05-02 Jonathan Larmour + + * include/sched.h: No longer needed - just use the default definition + in isoinfra + + * include/errno.h: No longer needed - errno provision now comes from + CYGPKG_ERROR + + * include/sys/types.h: Moved to include/types.h + + * cdl/posix.cdl, cdl/pthread.cdl: Put include files in cyg/posix, and + configure CYGPKG_ISOINFRA to include the appropriate headers + + * include/semaphore.h: Don't need to check kernel - including + pkgconf/kernel.h would already fail + Give SEM_FAILED a type so casting behaves in C++ + + * include/signal.h: This uses pid_t etc., so include + Add signal() and raise() prototypes (to allow libc compilation, even + though they aren't implemented yet) + + * include/time.h: Remove unnecessary includes. Move clockid_t and + timer_t definitions here from sys/types.h since this is where the + standard says they must live. + + * src/pprivate.h: Include signal.h and limits.h since their contents + are used later in the file. + +2000-04-28 Nick Garnett + + * src/signal.cxx: + Added implementations of alarm(), pause() and sleep(). + Modified cyg_sigqueue() so that it could be called from an ASR. + Added cyg_posix_signal_asr() to do signal processing in ASRs. + Miscellaneous bug fixes. + + * src/pthread.cxx: + Added pthread_count to count number of threads created. + Added call to signal ASR function in main ASR. + Added cyg_posix_pthread_release_thread() to seek out and kick a + thread to which a given set of signals may be delivered. + + * src/pprivate.h: + Added some more functions that are shared between POSIX + subsystems. + + * include/signal.h: + Added alarm(), pause() and sleep() prototypes. + + * tests/signal1.c: Added this test for various aspects of signal + handling. + + * cdl/posix.cdl: Added signal1 test. + +2000-04-20 Nick Garnett + + * src/signal.cxx: Added this file to contain signal handling code. + + * src/time.cxx: Made tick<->timespec converters exported to + rest of POSIX subsystem. Enabled interface to signal mechanism for + notifying timer expiration. + + * src/pthread.cxx: + Made pthread_mutex exported to rest of POSIX subsystem. + Exported pthread_info_id(). + Added thread init and destroy functions for signal subsystem. + + * src/startup.cxx: Added call to cyg_posix_signal_start(). + + * src/pprivate.h: Added signal handling fields support to + pthread_info structure. Added extra internal interfaces to support + signal handling code. + + * include/signal.h: Added _how_ argument values for the sigmask + functions. + + * cdl/posix.cdl: Added signal.cxx to compile list. + +2000-04-13 Nick Garnett + + * include/time.h: + * src/time.cxx: + Added implementation of clock and timer functions. These are + currently untested since they need working signals. + +2000-04-12 Nick Garnett + + * src/pprivate.h: Added cancellation support fields to + pthread_info structure. Made pthread_self_info() exported. + + * include/semaphore.h: Added SEM_FAILED plus misc. tidies. + + * include/pthread.h: Added PTHREAD_CANCELED. + + * include/errno.h: Fixed cyg_pthread_errno_p() return type. + + * src/pthread.cxx: + Added pthread_reap() to clean up exited threads. + Added support for cancellation. + Added cyg_posix_errno_p(). + + * src/time.cxx: + Added this file to implement time functionality. At present only + nanosleep() is actually implemented. + + * src/sem.cxx: + Added this file to implement semaphore functionality. + + * cdl/pthread.cdl: + Added some extra configuration requirements. + + * cdl/posix.cdl: + Added some more files to compile. + Added semaphore configuration. + + * tests/mutex3.c: + Added this test program. This is actually a POSIXized version of + Hugo's splendid kernel test of the same name. It exercises quite a + lot of the pthread infrastructure and is thus a good test to run. + + * tests/pthread1.c: + Added proper comment headers and added full testing stuff. + +2000-04-10 Nick Garnett + + * src/pprivate.h: + * src/pthread.cxx: + Added per-thread data support. + +2000-04-06 Nick Garnett + + * src/pthread.cxx: + Filled in implementations of lots of functions. + + * src/main.cxx: + Added this file to contain a default main. This is currenly just a + duplicate of the same file from the C library. Work is needed to + combine these. + + * include/sys/types.h: + Modified pthread_mutex_t to conform to kernel structure. + + * cdl/pthread.cdl: + Added support for main thread. + + * cdl/posix.cdl: + Added main.cxx to compile list. + +2000-03-31 Nick Garnett + + * cdl/pthread.cdl: + * cdl/posix.cdl: + Added CDL files to configure POSIX subsystem. + + * src/pprivate.h: + * src/pthread.cxx: + * src/startup.cxx: + Added these files to begin implementation of POSIX package. + + * include/pthread.h: + * include/sched.h: + * include/signal.h: + * include/time.h: + * include/sys/types.h: + Many changes needed by implementation work. + + * include/limits.h: + * include/errno.h: + Added these header files. + +2000-03-24 Nick Garnett + + * include/sys/types.h: + * include/time.h: + * include/sched.h: + * include/pthread.h: + * include/signal.h: + * include/semaphore.h: + * include/mqueue.h: + Roughed out (most of) the set of POSIX headers for the + functionality we are currently going to support. These files are + currently neither fully standard conformant nor implementation + ready. Much work is still needed to make them so. Watch this + space. + diff --git a/packages/compat/posix/current/cdl/posix.cdl b/packages/compat/posix/current/cdl/posix.cdl new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/cdl/posix.cdl @@ -0,0 +1,244 @@ +# ==================================================================== +# +# posix.cdl +# +# POSIX layer configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): nickg +# Contributors: +# Date: 2000-3-28 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_POSIX { + display "POSIX compatibility layer" + description "This package enables the POSIX compatibility + layer that implements IEEE 1003.1." + include_dir cyg/posix + + requires CYGPKG_KERNEL + requires CYGPKG_ISOINFRA + requires CYGPKG_ERROR + requires CYGINT_ISO_ERRNO + requires CYGINT_ISO_ERRNO_CODES + requires CYGIMP_KERNEL_SCHED_SORTED_QUEUES + + implements CYGINT_ISO_SCHED_IMPL + implements CYGINT_ISO_SIGNAL_NUMBERS + implements CYGINT_ISO_SIGNAL_IMPL + implements CYGINT_ISO_POSIX_LIMITS + requires { CYGBLD_ISO_SIGNAL_NUMBERS_HEADER == \ + "" } + requires { CYGBLD_ISO_SIGNAL_IMPL_HEADER == \ + "" } + requires { CYGBLD_ISO_POSIX_LIMITS_HEADER == \ + "" } + + compile pthread.cxx mqueue.cxx sem.cxx time.cxx signal.cxx \ + sched.cxx except.cxx misc.cxx + compile -library=libextras.a startup.cxx + + # ---------------------------------------------------------------- + # Scheduling component + + cdl_component CYGPKG_POSIX_SCHED { + display "POSIX scheduling configuration" + flavor bool + default_value 1 + description "This component provides controls over scheduling + in POSIX." + + cdl_option _POSIX_PRIORITY_SCHEDULING { + display "POSIX priority scheduling feature test macro" + flavor bool + calculated 1 + requires CYGSEM_KERNEL_SCHED_MLQUEUE + description "This option defines the POSIX feature test macro + that indicates that priority scheduling is present. + This should not be undefined." + } + } + + # ---------------------------------------------------------------- + # Pthreads component + + cdl_component CYGPKG_POSIX_PTHREAD { + display "POSIX pthread configuration" + flavor bool + default_value 1 + requires CYGPKG_POSIX_SCHED + description "This component provides configuration controls for + the POSIX pthreads package." + + script pthread.cdl + } + + # ---------------------------------------------------------------- + # Timers component + + cdl_option CYGPKG_POSIX_TIMERS { + display "POSIX timers" + flavor bool + default_value 1 + implements CYGINT_ISO_POSIX_TIMER_TYPES + implements CYGINT_ISO_POSIX_TIMERS + requires { CYGBLD_ISO_POSIX_TIMER_TYPES_HEADER == \ + "" } + requires { CYGBLD_ISO_POSIX_TIMERS_HEADER == \ + "" } + description "This component provides configuration controls for + the POSIX timers." + } + + # ---------------------------------------------------------------- + # Semaphores component + + cdl_option CYGPKG_POSIX_SEMAPHORES { + display "POSIX semaphores" + flavor bool + default_value 1 + implements CYGINT_ISO_SEMAPHORES + requires { CYGBLD_ISO_SEMAPHORES_HEADER == \ + "" } + description "This component provides configuration controls for + POSIX semaphores." + } + + # ---------------------------------------------------------------- + # Message queues component + + cdl_component CYGPKG_POSIX_MQUEUES { + display "POSIX message queues" + flavor bool + default_value 1 + implements CYGINT_ISO_MQUEUE + requires CYGPKG_KERNEL + requires CYGINT_ISO_MALLOC + requires CYGINT_ISO_ERRNO + requires CYGINT_ISO_STRING_STRFUNCS + description "This component provides configuration controls for + POSIX message queues." + + cdl_option CYGNUM_POSIX_MQUEUE_OPEN_MAX { + display "Maximum number of message queues" + flavor data + default_value 8 + legal_values 1 to 999999 + } + + cdl_option CYGIMP_POSIX_MQUEUE_VALIDATE_DESCRIPTOR { + display "Validate queue descriptors" + flavor bool + default_value 1 + description " + This option turns on checking that message queue descriptors + (of type mqd_t) passed into mq_* functions are valid. If so, + the functions will fail with EBADF, as POSIX 1003.1 mandates. + If this option is disabled, if an invalid descriptor is used, + random corruption may occur, or the system may crash. If + you are confident invalid descriptors will not be used, + you may wish to be disable this to save some per-instance + memory and execution time." + } + + cdl_option CYGFUN_POSIX_MQUEUE_NOTIFY { + display "Allow empty queue notification" + flavor bool + requires CYGPKG_POSIX_SIGNALS + default_value CYGPKG_POSIX_SIGNALS + description " + Enabling this option adds the function mq_notify() to the + API. Without it, some code and per-message queue descriptor + space is saved, as well as no longer requiring POSIX realtime + signal support." + } + } + + # ---------------------------------------------------------------- + # Signals component + + cdl_component CYGPKG_POSIX_SIGNALS { + display "POSIX signals configuration" + flavor bool + default_value 1 + requires CYGPKG_KERNEL_EXCEPTIONS + implements CYGINT_POSIX_REALTIME_SIGNALS + description "This component provides configuration controls for + the POSIX signals." + } + + # ---------------------------------------------------------------- + # uname structure component + + cdl_component CYGPKG_POSIX_UTSNAME { + display "POSIX utsname configuration" + flavor bool + default_value 1 + requires { CYGBLD_ISO_UTSNAME_HEADER == \ + "" } + description "This component provides configuration controls for + the POSIX utsname structure and the uname() function." + + cdl_option CYG_POSIX_UTSNAME_LENGTH { + display "Length of name strings in utsname structure" + flavor data + default_value 65 + legal_values 1 to 99999999 + } + + cdl_option CYG_POSIX_UTSNAME_NODENAME_LENGTH { + display "Length of nodename string in utsname structure" + flavor data + default_value { CYG_POSIX_UTSNAME_LENGTH } + legal_values 1 to 99999999 + } + + } + + # ---------------------------------------------------------------- + # Tests + + cdl_option CYGPKG_POSIX_TESTS { + display "POSIX tests" + flavor data + no_define + calculated { "tests/pthread1 tests/pthread2 tests/pthread3 tests/mutex3 tests/signal1 tests/timer1 tests/tm_basic tests/signal2 tests/mqueue1 tests/mqueue2" } + description " + This option specifies the set of tests for the POSIX package." + } + +} + +# ==================================================================== +# End of posix.cdl + + diff --git a/packages/compat/posix/current/cdl/pthread.cdl b/packages/compat/posix/current/cdl/pthread.cdl new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/cdl/pthread.cdl @@ -0,0 +1,219 @@ +# ==================================================================== +# +# pthread.cdl +# +# POSIX pthread configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): nickg +# Contributors: jlarmour +# Date: 2000-3-28 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_option CYGPKG_POSIX_PTHREAD_REQUIREMENTS { + display "Generic requirements of pthread package" + flavor bool + calculated 1 + implements CYGINT_ISO_PTHREADTYPES + implements CYGINT_ISO_PTHREAD_IMPL + requires CYGPKG_POSIX_SCHED + requires CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE + requires CYGSEM_KERNEL_SCHED_ASR_SUPPORT + requires CYGSEM_KERNEL_SCHED_ASR_GLOBAL + requires !CYGSEM_KERNEL_SCHED_ASR_DATA_GLOBAL + requires CYGFUN_KERNEL_THREADS_STACK_LIMIT + requires { CYGBLD_ISO_PTHREADTYPES_HEADER == \ + "" } + requires { CYGBLD_ISO_PTHREAD_IMPL_HEADER == \ + "" } + description "This option exists merely to carry the pthread + package requirements." + +} + +cdl_option _POSIX_THREAD_PRIO_INHERIT { + display "POSIX mutex priority inheritance feature test macro" + flavor bool + default_value 1 + requires CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT + description "This option defines the POSIX feature test macro + for supporting priority inheritance protocol in mutexes." +} + +cdl_option _POSIX_THREAD_PRIO_PROTECT { + display "POSIX mutex priority ceiling feature test macro" + flavor bool + default_value 1 + requires CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + description "This option defines the POSIX feature test macro + for supporting priority ceiling protocol in mutexes." +} + +# ==================================================================== + +cdl_component CYGPKG_POSIX_PTHREAD_VALUES { + display "Constant values used in pthread package" + flavor bool + calculated 1 + description "These are values that are either configurable, or derived + from system parameters." + + cdl_option CYGNUM_POSIX_PTHREAD_DESTRUCTOR_ITERATIONS { + display "Maximum number of iterations of key destructors" + flavor data + legal_values 4 to 100 + default_value 4 + description "Maximum number of iterations of key destructors allowed." + } + + cdl_option CYGNUM_POSIX_PTHREAD_KEYS_MAX { + display "Maximum number of per-thread data keys allowed" + flavor data + legal_values 128 to 65535 + default_value 128 + description "Number of per-thread data keys supported." + } + + cdl_option CYGNUM_POSIX_PTHREAD_THREADS_MAX { + display "Maximum number of threads allowed" + flavor data + legal_values 64 to 1024 + default_value 64 + description "Maximum number of threads supported." + } + +} + +# ==================================================================== + +cdl_component CYGPKG_POSIX_PTHREAD_FEATURES { + display "Fixed Feature test macros for POSIX" + flavor bool + calculated 1 + description "These options define POSIX feature test macros that + describe the eCos implementation of pthreads. These + are not changeable configuration options." + + cdl_option _POSIX_THREADS { + display "POSIX thread support feature test macro" + flavor bool + calculated 1 + requires CYGSEM_KERNEL_SCHED_TIMESLICE + requires CYGVAR_KERNEL_THREADS_DATA + description "This option defines the POSIX feature test macro + for thread support." + } + + cdl_option _POSIX_THREAD_PRIORITY_SCHEDULING { + display "POSIX thread priority scheduling feature test macro" + flavor bool + calculated 1 + requires CYGSEM_KERNEL_SCHED_MLQUEUE + requires _POSIX_THREADS + description "This option defines the POSIX feature test macro + for thread priority scheduling support." + } + + cdl_option _POSIX_THREAD_ATTR_STACKADDR { + display "POSIX stack address attribute feature test macro" + flavor bool + calculated 1 + description "This option defines the POSIX feature test macro + for supporting the thread stack address in the thread + attribute object." + } + + cdl_option _POSIX_THREAD_ATTR_STACKSIZE { + display "POSIX stack size attribute feature test macro" + flavor bool + calculated 1 + description "This option defines the POSIX feature test macro + for supporting the thread stack size in the thread + attribute object." + } + + cdl_option _POSIX_THREAD_PROCESS_SHARED { + display "POSIX process shared attribute feature test macro" + flavor bool + calculated 0 + description "This option defines the POSIX feature test macro + for supporting process shared mutexes. Since eCos + does not have processes, this attribute is undefined." + } + +} + +# ==================================================================== + +cdl_component CYGPKG_POSIX_MAIN_THREAD { + display "Main thread configuration" + flavor bool + calculated 1 + requires { 0 != CYGPKG_LIBC_STARTUP } + requires CYGSEM_LIBC_STARTUP_MAIN_OTHER + description "These options control the thread used to + run the main() application entry routine." + + cdl_option CYGNUM_POSIX_MAIN_DEFAULT_STACK_SIZE { + display "main()'s default thread stack size" + flavor data + legal_values 16 to 0x7fffffff + default_value 8192 + description " + POSIX compatibility requires that the application's + main() function be invoked in a thread. + This option controls the size of that thread's + stack, which is allocated in the BSS. It + must be a multiple of 8. Note, a low number + here may be overriden by the HAL if there is + a minimum requirement to process interrupts + etc." + } + + cdl_option CYGNUM_POSIX_MAIN_DEFAULT_PRIORITY { + display "main()'s default thread priority" + flavor data + legal_values 0 to 31 + default_value 30 + description " + POSIX compatibility requires that the application's + main() function be invoked in a thread. + This option controls the priority of that thread. Its + default value makes it the second highest priority in + the system." + } +} + +# ==================================================================== +# End of pthread.cdl + + diff --git a/packages/compat/posix/current/include/limits.h b/packages/compat/posix/current/include/limits.h new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/include/limits.h @@ -0,0 +1,132 @@ +#ifndef CYGONCE_LIMITS_H +#define CYGONCE_LIMITS_H +//============================================================================= +// +// limits.h +// +// POSIX limits header +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-03-17 +// Purpose: POSIX limits header +// Description: This file contains the compile time definitions that describe +// the minima and current values of various values and defined +// in POSIX.1 section 2.8. +// +// Usage: +// #include +// ... +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include +#include +#include + +//----------------------------------------------------------------------------- +// Runtime invariants +// These are all equal to or greater than the minimum values defined above. + +// From table 2-4 + +#define NGROUPS_MAX _POSIX_NGROUPS_MAX + +// From table 2-5 + +#define AIO_LISTIO_MAX _POSIX_AIO_LISTIO_MAX + +#define AIO_MAX _POSIX_AIO_MAX + +#define AIO_PRIO_DELTA_MAX 0 + +#define ARG_MAX _POSIX_ARG_MAX + +#define CHILD_MAX _POSIX_CHILD_MAX + +#define DELAYTIMER_MAX _POSIX_DELAYTIMER_MAX + +#define LOGIN_NAME_MAX _POSIX_LOGIN_NAME_MAX + +#define OPEN_MAX _POSIX_OPEN_MAX + +#define PAGESIZE 1 + +#define PTHREAD_DESTRUCTOR_ITERATIONS CYGNUM_POSIX_PTHREAD_DESTRUCTOR_ITERATIONS + +#define PTHREAD_KEYS_MAX CYGNUM_POSIX_PTHREAD_KEYS_MAX + +// Minimum size needed on a pthread stack to contain its per-thread control +// structures and per-thread data. Since we cannot include all the headers +// necessary to calculate this value here, the following is a generous estimate. +#define PTHREAD_STACK_OVERHEAD (0x180+(PTHREAD_KEYS_MAX*sizeof(void *))) + +#define PTHREAD_STACK_MIN (CYGNUM_HAL_STACK_SIZE_MINIMUM+PTHREAD_STACK_OVERHEAD) + +#define PTHREAD_THREADS_MAX CYGNUM_POSIX_PTHREAD_THREADS_MAX + +#define RTSIG_MAX _POSIX_RTSIG_MAX + +#define SEM_NSEMS_MAX _POSIX_SEM_NSEMS_MAX + +#define SEM_VALUE_MAX _POSIX_SEM_VALUE_MAX + +#define SIGQUEUE_MAX _POSIX_SIGQUEUE_MAX + +#define STREAM_MAX _POSIX_STREAM_MAX + +#define TIMER_MAX _POSIX_TIMER_MAX + +#define TTY_NAME_MAX _POSIX_TTY_NAME_MAX + +#define TZNAME_MAX _POSIX_TZNAME_MAX + + +// From table 2-6. + +#define LINK_MAX _POSIX_LINK_MAX + +#define MAX_CANON _POSIX_MAX_CANON + +#define MAX_INPUT _POSIX_MAX_INPUT + +#define NAME_MAX _POSIX_NAME_MAX + +#define PATH_MAX _POSIX_PATH_MAX + +#define PIPE_BUF _POSIX_PIPE_BUF + + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_LIMITS_H +// End of limits.h diff --git a/packages/compat/posix/current/include/pthread.h b/packages/compat/posix/current/include/pthread.h new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/include/pthread.h @@ -0,0 +1,413 @@ +#ifndef CYGONCE_PTHREAD_H +#define CYGONCE_PTHREAD_H +//============================================================================= +// +// pthread.h +// +// POSIX pthread header +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-03-17 +// Purpose: POSIX pthread header +// Description: This header contains all the definitions needed to support +// pthreads under eCos. The reader is referred to the POSIX +// standard or equivalent documentation for details of the +// functionality contained herein. +// +// Usage: +// #include +// ... +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include +#include +#include + +#include + +#include // CYGNUM_HAL_STACK_SIZE_MINIMUM + +#include // NULL, size_t + +#include + +#include + +#include // SCHED_* + +//============================================================================= +// General thread operations + +//----------------------------------------------------------------------------- +// Thread creation and management. + +// Create a thread. +externC int pthread_create ( pthread_t *thread, + const pthread_attr_t *attr, + void *(*start_routine) (void *), + void *arg); + +// Get current thread id. +externC pthread_t pthread_self ( void ); + +// Compare two thread identifiers. +externC int pthread_equal (pthread_t thread1, pthread_t thread2); + +// Terminate current thread. +externC void pthread_exit (void *retval) CYGBLD_ATTRIB_NORET; + +// Wait for the thread to terminate. If thread_return is not NULL then +// the retval from the thread's call to pthread_exit() is stored at +// *thread_return. +externC int pthread_join (pthread_t thread, void **thread_return); + +// Set the detachstate of the thread to "detached". The thread then does not +// need to be joined and its resources will be freed when it exits. +externC int pthread_detach (pthread_t thread); + +//----------------------------------------------------------------------------- +// Thread attribute handling. + +// Initialize attributes object with default attributes: +// detachstate == PTHREAD_JOINABLE +// scope == PTHREAD_SCOPE_SYSTEM +// inheritsched == PTHREAD_EXPLICIT_SCHED +// schedpolicy == SCHED_OTHER +// schedparam == unset +// stackaddr == unset +// stacksize == 0 +// +externC int pthread_attr_init (pthread_attr_t *attr); + +// Destroy thread attributes object +externC int pthread_attr_destroy (pthread_attr_t *attr); + + +// Set the detachstate attribute +externC int pthread_attr_setdetachstate (pthread_attr_t *attr, + int detachstate); + +// Get the detachstate attribute +externC int pthread_attr_getdetachstate (const pthread_attr_t *attr, + int *detachstate); + + +// Set scheduling contention scope +externC int pthread_attr_setscope (pthread_attr_t *attr, int scope); + +// Get scheduling contention scope +externC int pthread_attr_getscope (const pthread_attr_t *attr, int *scope); + + +// Set scheduling inheritance attribute +externC int pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit); + +// Get scheduling inheritance attribute +externC int pthread_attr_getinheritsched (const pthread_attr_t *attr, + int *inherit); + + +// Set scheduling policy +externC int pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy); + +// Get scheduling policy +externC int pthread_attr_getschedpolicy (const pthread_attr_t *attr, + int *policy); + + +// Set scheduling parameters +externC int pthread_attr_setschedparam (pthread_attr_t *attr, + const struct sched_param *param); + +// Get scheduling parameters +externC int pthread_attr_getschedparam (const pthread_attr_t *attr, + struct sched_param *param); + + +// Set starting address of stack. Whether this is at the start or end of +// the memory block allocated for the stack depends on whether the stack +// grows up or down. +externC int pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr); + +// Get any previously set stack address. +externC int pthread_attr_getstackaddr (const pthread_attr_t *attr, + void **stackaddr); + + +// Set minimum creation stack size. +externC int pthread_attr_setstacksize (pthread_attr_t *attr, + size_t stacksize); + +// Get current minimal stack size. +externC int pthread_attr_getstacksize (const pthread_attr_t *attr, + size_t *stacksize); + +//----------------------------------------------------------------------------- +// Thread scheduling controls + +// Set scheduling policy and parameters for the thread +externC int pthread_setschedparam (pthread_t thread, + int policy, + const struct sched_param *param); + +// Get scheduling policy and parameters for the thread +externC int pthread_getschedparam (pthread_t thread, + int *policy, + struct sched_param *param); + + + +//============================================================================= +// Mutexes + +//----------------------------------------------------------------------------- +// Mutex attributes manipulation functions + +// Initialize attribute object +externC int pthread_mutexattr_init ( pthread_mutexattr_t *attr); + +// Destroy attribute object +externC int pthread_mutexattr_destroy ( pthread_mutexattr_t *attr); + +#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) + +// Set priority inversion protection protocol +externC int pthread_mutexattr_setprotocol ( pthread_mutexattr_t *attr, + int protocol); + +// Get priority inversion protection protocol +externC int pthread_mutexattr_getprotocol ( pthread_mutexattr_t *attr, + int *protocol); + +#if defined(_POSIX_THREAD_PRIO_PROTECT) + +// Set priority for priority ceiling protocol +externC int pthread_mutexattr_setprioceiling ( pthread_mutexattr_t *attr, + int prioceiling); + +// Get priority for priority ceiling protocol +externC int pthread_mutexattr_getprioceiling ( pthread_mutexattr_t *attr, + int *prioceiling); + +// Set priority ceiling of given thread, returning old ceiling. +externC int pthread_mutex_setprioceiling( pthread_mutex_t *mutex, + int prioceiling, + int *old_ceiling); + +// Get priority ceiling of given thread +externC int pthread_mutex_getprioceiling( pthread_mutex_t *mutex, + int *prioceiling); +#endif + +#endif + +//----------------------------------------------------------------------------- +// Mutex functions + +// Initialize mutex. If mutex_attr is NULL, use default attributes. +externC int pthread_mutex_init (pthread_mutex_t *mutex, + const pthread_mutexattr_t *mutex_attr); + +// Destroy mutex. +externC int pthread_mutex_destroy (pthread_mutex_t *mutex); + +// Lock mutex, waiting for it if necessary. +externC int pthread_mutex_lock (pthread_mutex_t *mutex); + +// Try to lock mutex. +externC int pthread_mutex_trylock (pthread_mutex_t *mutex); + + +// Unlock mutex. +externC int pthread_mutex_unlock (pthread_mutex_t *mutex); + + + +//============================================================================= +// Condition Variables + +//----------------------------------------------------------------------------- +// Attribute manipulation functions +// We do not actually support any attributes at present, so these do nothing. + +// Initialize condition variable attributes +externC int pthread_condattr_init (pthread_condattr_t *attr); + +// Destroy condition variable attributes +externC int pthread_condattr_destroy (pthread_condattr_t *attr); + +//----------------------------------------------------------------------------- +// Condition variable functions + +// Initialize condition variable. +externC int pthread_cond_init (pthread_cond_t *cond, + const pthread_condattr_t *attr); + +// Destroy condition variable. +externC int pthread_cond_destroy (pthread_cond_t *cond); + +// Wake up one thread waiting for condition variable +externC int pthread_cond_signal (pthread_cond_t *cond); + +// Wake up all threads waiting for condition variable +externC int pthread_cond_broadcast (pthread_cond_t *cond); + +// Block on condition variable until signalled. The mutex is +// assumed to be locked before this call, will be unlocked +// during the wait, and will be re-locked on wakeup. +externC int pthread_cond_wait (pthread_cond_t *cond, + pthread_mutex_t *mutex); + +// Block on condition variable until signalled, or the timeout expires. +externC int pthread_cond_timedwait (pthread_cond_t *cond, + pthread_mutex_t *mutex, + const struct timespec *abstime); + + + +//============================================================================= +// Dynamic package initialization + +// Initializer for pthread_once_t instances +#define PTHREAD_ONCE_INIT 0 + +// Call init_routine just the once per control variable. +externC int pthread_once (pthread_once_t *once_control, + void (*init_routine) (void)); + + + +//============================================================================= +//Thread specific data + +// Create a key to identify a location in the thread specific data area. +// Each thread has its own distinct thread-specific data area but all are +// addressed by the same keys. The destructor function is called whenever a +// thread exits and the value associated with the key is non-NULL. +externC int pthread_key_create (pthread_key_t *key, + void (*destructor) (void *)); + +// Delete key. +externC int pthread_key_delete (pthread_key_t key); + +// Store the pointer value in the thread-specific data slot addressed +// by the key. +externC int pthread_setspecific (pthread_key_t key, const void *pointer); + +// Retrieve the pointer value in the thread-specific data slot addressed +// by the key. +externC void *pthread_getspecific (pthread_key_t key); + + + +//============================================================================= +// Thread Cancellation + +//----------------------------------------------------------------------------- +// Data structure used to manage cleanup functions + +struct pthread_cleanup_buffer +{ + struct pthread_cleanup_buffer *prev; // Chain cleanup buffers + void (*routine) (void *); // Function to call + void *arg; // Arg to pass +}; + +//----------------------------------------------------------------------------- +// Thread cancelled return value. +// This is a value returned as the retval in pthread_join() of a +// thread that has been cancelled. By making it the address of a +// location we define we can ensure that it differs from NULL and any +// other valid pointer (as required by the standard). + +externC int pthread_canceled; + +#define PTHREAD_CANCELED ((void *)(&pthread_canceled)) + +//----------------------------------------------------------------------------- +// Cancelability enable and type + +#define PTHREAD_CANCEL_ENABLE 1 +#define PTHREAD_CANCEL_DISABLE 2 + +#define PTHREAD_CANCEL_ASYNCHRONOUS 1 +#define PTHREAD_CANCEL_DEFERRED 2 + +//----------------------------------------------------------------------------- +// Functions + +// Set cancel state of current thread to ENABLE or DISABLE. +// Returns old state in *oldstate. +externC int pthread_setcancelstate (int state, int *oldstate); + +// Set cancel type of current thread to ASYNCHRONOUS or DEFERRED. +// Returns old type in *oldtype. +externC int pthread_setcanceltype (int type, int *oldtype); + +// Cancel the thread. +externC int pthread_cancel (pthread_t thread); + +// Test for a pending cancellation for the current thread and terminate +// the thread if there is one. +externC void pthread_testcancel (void); + + +// Install a cleanup routine. +// Note that pthread_cleanup_push() and pthread_cleanup_pop() are macros that +// must be used in matching pairs and at the same brace nesting level. +#define pthread_cleanup_push(routine,arg) \ + { \ + struct pthread_cleanup_buffer _buffer_; \ + pthread_cleanup_push_inner (&_buffer_, (routine), (arg)); + +// Remove a cleanup handler installed by the matching pthread_cleanup_push(). +// If execute is non-zero, the handler function is called. +#define pthread_cleanup_pop(execute) \ + pthread_cleanup_pop_inner (&_buffer_, (execute)); \ + } + + +// These two functions actually implement the cleanup push and pop functionality. +externC void pthread_cleanup_push_inner (struct pthread_cleanup_buffer *buffer, + void (*routine) (void *), + void *arg); + +externC void pthread_cleanup_pop_inner (struct pthread_cleanup_buffer *buffer, + int execute); + + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_PTHREAD_H +// End of pthread.h diff --git a/packages/compat/posix/current/include/semaphore.h b/packages/compat/posix/current/include/semaphore.h new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/include/semaphore.h @@ -0,0 +1,118 @@ +#ifndef CYGONCE_SEMAPHORE_H +#define CYGONCE_SEMAPHORE_H +//============================================================================= +// +// semaphore.h +// +// POSIX semaphore header +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-03-17 +// Purpose: POSIX semaphore header +// Description: This header contains all the definitions needed to support +// semaphores under eCos. The reader is referred to the POSIX +// standard or equivalent documentation for details of the +// functionality contained herein. +// +// Usage: +// #include +// ... +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include +#include +#include + +#include // NULL, size_t + +#include + +#include + +//----------------------------------------------------------------------------- +// Semaphore object definition + +// This structure must exactly correspond in size and layout to the underlying +// eCos C++ class that implements this object. + +typedef struct +{ + CYG_WORD32 sem_value; + CYG_ADDRESS sem_queue; +} sem_t; + +//----------------------------------------------------------------------------- +// Semaphore functions + +// Initialize semaphore to value. +// pshared is not supported under eCos. +externC int sem_init (sem_t *sem, int pshared, unsigned int value); + +// Destroy the semaphore. +externC int sem_destroy (sem_t *sem); + +// Decrement value if >0 or wait for a post. +externC int sem_wait (sem_t *sem); + +// Decrement value if >0, return -1 if not. +externC int sem_trywait (sem_t *sem); + +// Increment value and wake a waiter if one is present. +externC int sem_post (sem_t *sem); + +// Get current value +externC int sem_getvalue (sem_t *sem, int *sval); + +//----------------------------------------------------------------------------- +// Named semaphore functions +// These are an optional feature under eCos + +// Open an existing named semaphore, or create it. +externC sem_t *sem_open (const char *name, int oflag, ...); + +// Close descriptor for semaphore. +externC int sem_close (sem_t *sem); + +// Remove named semaphore +externC int sem_unlink (const char *name); + +//----------------------------------------------------------------------------- +// Special return value for sem_open() + +#define SEM_FAILED ((sem_t *)NULL) + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_SEMAPHORE_H +// End of semaphore.h diff --git a/packages/compat/posix/current/include/signal.h b/packages/compat/posix/current/include/signal.h new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/include/signal.h @@ -0,0 +1,300 @@ +#ifndef CYGONCE_SIGNAL_H +#define CYGONCE_SIGNAL_H +//============================================================================= +// +// signal.h +// +// POSIX signal header +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg, jlarmour +// Contributors: +// Date: 2000-03-17 +// Purpose: POSIX signal header +// Description: This header contains all the definitions needed to support +// the POSIX signal API under eCos. +// +// Usage: This file can either be included directly, or indirectly via +// the C library signal.h header. +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include +#include +#include + +#include // NULL, size_t + +#include +#include + +//----------------------------------------------------------------------------- +// POSIX feature test macros + +// We do not support job control +#undef _POSIX_JOB_CONTROL + +//----------------------------------------------------------------------------- +// Manifest constants + +#ifdef _POSIX_REALTIME_SIGNALS +// For now we define the topmost 8 signals as realtime +#define SIGRTMIN 24 +#define SIGRTMAX 31 +#endif + +//----------------------------------------------------------------------------- +// forward references + +struct timespec; + +//----------------------------------------------------------------------------- +// Sigval structure + +union sigval +{ + int sival_int; // used when application-defined value is an int + void *sival_ptr; // used when application-defined value is a pointer +}; + +//----------------------------------------------------------------------------- +// Siginfo structure passed to an SA_SIGINFO style handler + +typedef struct +{ + int si_signo; // signal number + int si_code; // cause of signal + union sigval si_value; // signal value +} siginfo_t; + +// Values for si_code +# define SI_USER 1 +# define SI_QUEUE 2 +# define SI_TIMER 3 +# define SI_ASYNCIO 4 +# define SI_MESGQ 5 +# define SI_EXCEPT 6 // signal is result of an exception delivery + +//----------------------------------------------------------------------------- +// Basic types + +// Integral type that can be accessed atomically - from ISO C 7.7 +typedef cyg_atomic sig_atomic_t; + +// Type of signal handler functions +typedef void (*sa_sighandler_t)(int); + +// Type of signal handler used if SA_SIGINFO is set in sa_flags +typedef void (*sa_siginfoaction_t)(int signo, siginfo_t *info, + void *context); + +//----------------------------------------------------------------------------- +//Signal handlers for use with signal() and sigaction(). We avoid 0 +//because in an embedded system this may be start of ROM and thus +//a possible function pointer for reset. + +#define SIG_DFL ((sa_sighandler_t) 1) // Default action +#define SIG_IGN ((sa_sighandler_t) 2) // Ignore action +#define SIG_ERR ((sa_sighandler_t)-1) // Error return + +//----------------------------------------------------------------------------- +// Signal values + +#define SIGNULL 0 // Reserved signal - do not use (POSIX 3.3.1.1) +#define SIGHUP 1 // Hangup on controlling terminal (POSIX) +#define SIGINT 2 // Interactive attention (ISO C) +#define SIGQUIT 3 // Interactive termination (POSIX) +#define SIGILL 4 // Illegal instruction (not reset when caught) (ISO C) +#define SIGTRAP 5 // Trace trap (not reset when caught) +#define SIGIOT 6 // IOT instruction +#define SIGABRT 6 // Abnormal termination - used by abort() (ISO C) +#define SIGEMT 7 // EMT instruction +#define SIGFPE 8 // Floating Point Exception e.g. div by 0 (ISO C) +#define SIGKILL 9 // Kill (cannot be caught or ignored) (POSIX) +#define SIGBUS 10 // Bus error (POSIX) +#define SIGSEGV 11 // Invalid memory reference (ISO C) +#define SIGSYS 12 // Bad argument to system call (used by anything?) +#define SIGPIPE 13 // Write on a pipe with no one to read it (POSIX) +#define SIGALRM 14 // Alarm timeout (POSIX) +#define SIGTERM 15 // Software termination request (ISO C) +#define SIGUSR1 16 // Application-defined signal 1 (POSIX) +#define SIGUSR2 17 // Application-defined signal 2 (POSIX) + + +//----------------------------------------------------------------------------- +// Signal sets. +// At present we define a single 32 bit integer mask. We may need, at +// some future point, to extend this to 64 bits, or a structure +// containing an array of masks. + +typedef cyg_uint32 sigset_t; + +//----------------------------------------------------------------------------- +// struct sigaction describes the action to be taken when we get a signal + +struct sigaction +{ + sigset_t sa_mask; // Additional signals to be blocked + int sa_flags; // Special flags + union + { + sa_sighandler_t sa_handler; // signal handler + sa_siginfoaction_t sa_sigaction; // Function to call instead of + // sa_handler if SA_SIGINFO is + // set in sa_flags + } sa_sigactionhandler; +#define sa_handler sa_sigactionhandler.sa_handler +#define sa_sigaction sa_sigactionhandler.sa_sigaction +}; + +// sa_flag bits +#define SA_NOCLDSTOP 1 // Don't generate SIGCHLD when children stop +#define SA_SIGINFO 2 // Use the sa_siginfoaction_t style signal + // handler, instead of the single argument handler + +//----------------------------------------------------------------------------- +// Sigevent structure. + +struct sigevent +{ + int sigev_notify; + int sigev_signo; + union sigval sigev_value; + void (*sigev_notify_function) (union sigval); + pthread_attr_t *sigev_notify_attributes; +}; + +# define SIGEV_NONE 1 +# define SIGEV_SIGNAL 2 +# define SIGEV_THREAD 3 + +//----------------------------------------------------------------------------- +// Functions to generate signals + +// Deliver sig to a process. +// eCos only supports the value 0 for pid. +externC int kill (pid_t pid, int sig); + +externC int pthread_kill (pthread_t thread, int sig); + +//----------------------------------------------------------------------------- +// Functions to catch signals + +// Install signal handler for sig. +externC int sigaction (int sig, const struct sigaction *act, + struct sigaction *oact); + +// Queue signal to process with value. +externC int sigqueue (pid_t pid, int sig, const union sigval value); + +//----------------------------------------------------------------------------- +// Functions to deal with current blocked and pending masks + +// Set process blocked signal mask +externC int sigprocmask (int how, const sigset_t *set, sigset_t *oset); + +// Set calling thread's blocked signal mask +externC int pthread_sigmask (int how, const sigset_t *set, sigset_t *oset); + +// Get set of pending signals for this process +externC int sigpending (sigset_t *set); + +// Values for the how arguments: +#define SIG_BLOCK 1 +#define SIG_UNBLOCK 2 +#define SIG_SETMASK 3 + +//----------------------------------------------------------------------------- +// Wait for or accept signals + +// Block signals in set and wait for a signal +externC int sigsuspend (const sigset_t *set); + +// Wait for a signal in set to arrive +externC int sigwait (const sigset_t *set, int *sig); + +// Do the same as sigwait() except return a siginfo_t object too. +externC int sigwaitinfo (const sigset_t *set, siginfo_t *info); + +// Do the same as sigwaitinfo() but return anyway after timeout. +externC int sigtimedwait (const sigset_t *set, siginfo_t *info, + const struct timespec *timeout); + +//----------------------------------------------------------------------------- +// Signal sets + +// Clear all signals from set. +externC int sigemptyset (sigset_t *set); + +// Set all signals in set. +externC int sigfillset (sigset_t *set); + +// Add signo to set. +externC int sigaddset (sigset_t *set, int signo); + +// Remove signo from set. +externC int sigdelset (sigset_t *set, int signo); + +// Test whether signo is in set +externC int sigismember (const sigset_t *set, int signo); + +//----------------------------------------------------------------------------- +// alarm, pause and sleep + +// Generate SIGALRM after some number of seconds +externC unsigned int alarm( unsigned int seconds ); + +// Wait for a signal to be delivered. +externC int pause( void ); + +// Wait for a signal, or the given number of seconds +externC unsigned int sleep( unsigned int seconds ); + +//----------------------------------------------------------------------------- +// signal() - ISO C 7.7.1 // +// +// Installs a new signal handler for the specified signal, and returns +// the old handler +// + +externC sa_sighandler_t signal(int __sig, sa_sighandler_t __handler); + +// raise() - ISO C 7.7.2 // +// +// Raises the signal, which will cause the current signal handler for +// that signal to be called + +externC int raise(int __sig); + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_SIGNAL_H +// End of signal.h diff --git a/packages/compat/posix/current/include/time.h b/packages/compat/posix/current/include/time.h new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/include/time.h @@ -0,0 +1,130 @@ +#ifndef CYGONCE_POSIX_TIME_H +#define CYGONCE_POSIX_TIME_H +//============================================================================= +// +// time.h +// +// POSIX time header +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg, jlarmour +// Date: 2000-03-17 +// Purpose: POSIX time header +// Description: This header contains all the definitions needed to support +// the POSIX timer and timer API under eCos. +// +// Usage: Do not include this file directly - instead include +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include + +//----------------------------------------------------------------------------- +// Types for timers and clocks + +typedef int clockid_t; + +typedef int timer_t; + +// forward declaration - if the app uses it it will have to include +// signal.h anyway +struct sigevent; + +//----------------------------------------------------------------------------- +// Structures + +struct timespec +{ + time_t tv_sec; + long tv_nsec; +}; + +struct itimerspec +{ + struct timespec it_interval; + struct timespec it_value; +}; + +//----------------------------------------------------------------------------- +// Manifest constants + +#define CLOCK_REALTIME 0 + +#define TIMER_ABSTIME 1 + +//----------------------------------------------------------------------------- +// Clock functions + +// Set the clocks current time +externC int clock_settime( clockid_t clock_id, const struct timespec *tp); + +// Get the clocks current time +externC int clock_gettime( clockid_t clock_id, struct timespec *tp); + +// Get the clocks resolution +externC int clock_getres( clockid_t clock_id, struct timespec *tp); + + +//----------------------------------------------------------------------------- +// Timer functions + +// Create a timer based on the given clock. +externC int timer_create( clockid_t clock_id, + struct sigevent *evp, + timer_t *timer_id); + +// Delete the timer +externC int timer_delete( timer_t timer_id ); + +// Set the expiration time of the timer. +externC int timer_settime( timer_t timerid, int flags, + const struct itimerspec *value, + struct itimerspec *ovalue ); + +// Get current timer values +externC int timer_gettime( timer_t timerid, struct itimerspec *value ); + +// Get number of missed triggers +externC int timer_getoverrun( timer_t timerid ); + +//----------------------------------------------------------------------------- +// Nanosleep + +// Sleep for the given time. +externC int nanosleep( const struct timespec *rqtp, + struct timespec *rmtp); + + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_POSIX_TIME_H +// End of time.h diff --git a/packages/compat/posix/current/include/types.h b/packages/compat/posix/current/include/types.h new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/include/types.h @@ -0,0 +1,175 @@ +#ifndef CYGONCE_POSIX_TYPES_H +#define CYGONCE_POSIX_TYPES_H +//============================================================================= +// +// types.h +// +// POSIX types header +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-03-17 +// Purpose: POSIX types header +// Description: This header contains various POSIX type definitions. These types +// are implementation defined. +// +// Usage: #include +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include +#include +#include + +#include + +//----------------------------------------------------------------------------- +// Basic types. + +typedef cyg_uint32 pthread_t; +typedef int pthread_key_t; +typedef int pthread_once_t; + +//----------------------------------------------------------------------------- +// Scheduling parameters. At present only the priority is defined. +// Strictly this should be in , but the requirement for pthread_attr_t +// to contain a sched_param object means that it must be here. + +struct sched_param +{ + int sched_priority; +}; + +//----------------------------------------------------------------------------- +// Thread attribute structure. + +typedef struct pthread_attr_t +{ + unsigned int detachstate:2, + scope:2, + inheritsched:2, + schedpolicy:2, + stackaddr_valid:1, + stacksize_valid:1; + struct sched_param schedparam; + void *stackaddr; + size_t stacksize; +} pthread_attr_t; + +// Values for detachstate +#define PTHREAD_CREATE_JOINABLE 1 +#define PTHREAD_CREATE_DETACHED 2 + +// Values for scope +#define PTHREAD_SCOPE_SYSTEM 1 +#define PTHREAD_SCOPE_PROCESS 2 + +// Values for inheritsched +#define PTHREAD_INHERIT_SCHED 1 +#define PTHREAD_EXPLICIT_SCHED 2 + +//----------------------------------------------------------------------------- +// Mutex object +// This structure must exactly correspond in size and layout to the underlying +// eCos C++ class that implements this object. Because we have to support +// PTHREAD_MUTEX_INITIALIZER we cannot abstract this object very easily. + +typedef struct +{ + CYG_WORD32 locked; + CYG_ADDRESS owner; + CYG_ADDRESS queue; + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC + CYG_WORD32 protocol; // this mutex's protocol +#endif + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + CYG_WORD32 ceiling; // mutex priority ceiling +#endif + +} pthread_mutex_t; + +#if defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC) &&\ + defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING) +#define PTHREAD_MUTEX_INITIALIZER { 0, 0, 0, 0, 0 } +#elif defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC) ||\ + defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING) +#define PTHREAD_MUTEX_INITIALIZER { 0, 0, 0, 0 } +#else +#define PTHREAD_MUTEX_INITIALIZER { 0, 0, 0 } +#endif + +//----------------------------------------------------------------------------- +// Mutex attributes structure + +typedef struct +{ + int protocol; +#ifdef _POSIX_THREAD_PRIO_PROTECT + int prioceiling; +#endif +} pthread_mutexattr_t; + +// Values for protocol +#define PTHREAD_PRIO_NONE 1 +#if defined(_POSIX_THREAD_PRIO_INHERIT) +#define PTHREAD_PRIO_INHERIT 2 +#endif +#if defined(_POSIX_THREAD_PRIO_PROTECT) +#define PTHREAD_PRIO_PROTECT 3 +#endif + +//----------------------------------------------------------------------------- +// Condition Variable structure. +// Like mutexes, this must match the underlying eCos implementation class. + +typedef struct +{ + CYG_ADDRESS mutex; + CYG_ADDRESS queue; +} pthread_cond_t; + +#define PTHREAD_COND_INITIALIZER { 0, 0 } + +//----------------------------------------------------------------------------- +// Condition variable attributes structure + +typedef struct +{ + int dummy; +} pthread_condattr_t; + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_POSIX_TYPES_H +// End of types.h diff --git a/packages/compat/posix/current/include/utsname.h b/packages/compat/posix/current/include/utsname.h new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/include/utsname.h @@ -0,0 +1,89 @@ +#ifndef CYGONCE_UTSNAME_H +#define CYGONCE_UTSNAME_H +//============================================================================= +// +// utsname.h +// +// POSIX utsname header +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-03-17 +// Purpose: POSIX utsname header +// Description: This header contains all the definitions needed to support +// utsnames under eCos. The reader is referred to the POSIX +// standard or equivalent documentation for details of the +// functionality contained herein. +// +// Usage: +// #include +// ... +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include +#include +#include + +#include + +#include // CYGNUM_HAL_STACK_SIZE_MINIMUM + +#include // NULL, size_t + +#include + +#include + +#include // SCHED_* + +//============================================================================= +// UTSName structure + +struct utsname +{ + char sysname[CYG_POSIX_UTSNAME_LENGTH]; + char nodename[CYG_POSIX_UTSNAME_NODENAME_LENGTH]; + char release[CYG_POSIX_UTSNAME_LENGTH]; + char version[CYG_POSIX_UTSNAME_LENGTH]; + char machine[CYG_POSIX_UTSNAME_LENGTH]; +}; + +//============================================================================= +// uname() function + +__externC int uname( struct utsname *name ); + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_UTSNAME_H +// End of utsname.h diff --git a/packages/compat/posix/current/src/except.cxx b/packages/compat/posix/current/src/except.cxx new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/src/except.cxx @@ -0,0 +1,335 @@ +//========================================================================== +// +// except.cxx +// +// POSIX exception translation +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-03-27 +// Purpose: POSIX exception translation +// Description: This file contains code to translate eCos hardware +// exceptions into POSIX signals. +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include + +#include "pprivate.h" // POSIX private header + +#include // our header + +#include + +//========================================================================== +// Translation table from eCos exceptions to POSIX signals. + +static const struct +{ + cyg_code exception; + int signal; +} exception_signal_mapping[] = +{ +#ifdef CYGNUM_HAL_EXCEPTION_DATA_ACCESS + {CYGNUM_HAL_EXCEPTION_DATA_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_WRITE + {CYGNUM_HAL_EXCEPTION_DATA_WRITE, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_ACCESS + {CYGNUM_HAL_EXCEPTION_CODE_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_WRITE + {CYGNUM_HAL_EXCEPTION_CODE_WRITE, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_EXECUTE + {CYGNUM_HAL_EXCEPTION_CODE_EXECUTE, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_IO_ACCESS + {CYGNUM_HAL_EXCEPTION_IO_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_IO_WRITE + {CYGNUM_HAL_EXCEPTION_IO_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_ACCESS + {CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_ACCESS, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_WRITE + {CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_WRITE, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_TLBMISS_ACCESS + {CYGNUM_HAL_EXCEPTION_CODE_TLBMISS_ACCESS, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_TLBMISS_WRITE + {CYGNUM_HAL_EXCEPTION_CODE_TLBMISS_WRITE, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_TLBERROR_ACCESS + {CYGNUM_HAL_EXCEPTION_DATA_TLBERROR_ACCESS, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_TLBERROR_WRITE + {CYGNUM_HAL_EXCEPTION_DATA_TLBERROR_WRITE, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_TLBERROR_ACCESS + {CYGNUM_HAL_EXCEPTION_CODE_TLBERROR_ACCESS, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_TLBERROR_WRITE + {CYGNUM_HAL_EXCEPTION_CODE_TLBERROR_WRITE, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS + {CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_WRITE + {CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_WRITE, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_IO_UNALIGNED_ACCESS + {CYGNUM_HAL_EXCEPTION_IO_UNALIGNED_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_IO_UNALIGNED_WRITE + {CYGNUM_HAL_EXCEPTION_IO_UNALIGNED_WRITE, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION + {CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION, SIGILL}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_INTERRUPT + {CYGNUM_HAL_EXCEPTION_INTERRUPT, SIGINT}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_TRAP + {CYGNUM_HAL_EXCEPTION_TRAP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DIV_BY_ZERO + {CYGNUM_HAL_EXCEPTION_DIV_BY_ZERO, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_OVERFLOW + {CYGNUM_HAL_EXCEPTION_OVERFLOW, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_BOUNDS + {CYGNUM_HAL_EXCEPTION_BOUNDS, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_SINGLE_STEP + {CYGNUM_HAL_EXCEPTION_SINGLE_STEP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_INSTRUCTION_BP + {CYGNUM_HAL_EXCEPTION_INSTRUCTION_BP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_PERIPHERAL_BP + {CYGNUM_HAL_EXCEPTION_PERIPHERAL_BP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_BP + {CYGNUM_HAL_EXCEPTION_DATA_BP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DEVELOPMENT_BP + {CYGNUM_HAL_EXCEPTION_DEVELOPMENT_BP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_STACK_OVERFLOW + {CYGNUM_HAL_EXCEPTION_STACK_OVERFLOW, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_STACK_FAULT + {CYGNUM_HAL_EXCEPTION_STACK_FAULT, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_PARITY + {CYGNUM_HAL_EXCEPTION_PARITY, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_FPU + {CYGNUM_HAL_EXCEPTION_FPU, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_FPU_NOT_AVAIL + {CYGNUM_HAL_EXCEPTION_FPU_NOT_AVAIL, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_FPU_OVERFLOW + {CYGNUM_HAL_EXCEPTION_FPU_OVERFLOW, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_FPU_UNDERFLOW + {CYGNUM_HAL_EXCEPTION_FPU_UNDERFLOW, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_FPU_DIV_BY_ZERO + {CYGNUM_HAL_EXCEPTION_FPU_DIV_BY_ZERO, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_SYSTEM_CALL + {CYGNUM_HAL_EXCEPTION_SYSTEM_CALL, SIGSYS}, +#endif + {0, 0} // dummy value to ensure compiler is happy +}; + +//========================================================================== +// POSIX exception handler + +static void cyg_posix_exception_handler( + CYG_ADDRWORD data, // user supplied data == signal number + cyg_code exception_number, // exception being raised + CYG_ADDRWORD exception_info // any exception specific info + ) +{ + int signo = 0; +diag_printf("exh %d\n",exception_number); + pthread_info *self = pthread_self_info(); + + if( self == NULL ) + { + // Not a POSIX thread, just return + return; + } + +#ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE + + signo = data; + +#else + + for( int i = 0; exception_signal_mapping[i].signal != 0; i++ ) + { +diag_printf("exm %d -> %d\n",exception_signal_mapping[i].exception,exception_signal_mapping[i].signal); + if( exception_signal_mapping[i].exception == exception_number ) + { + signo = exception_signal_mapping[i].signal; + break; + } + } + +#endif +diag_printf("signo %d %08x\n",signo, self->sigmask); + if( sigismember( &self->sigmask, signo ) ) + { + // The signal is masked in the current thread. POSIX says that + // the behaviour is undefined here. We choose to ignore it. + + return; + } + + // The kernel exception handler may have disabled interrupts, so + // we (re-)enable them here. From this point on we are running in + // a context that is effectively just pushed onto the stack of the + // current thread. If we return we will unwind and resume + // execution from the excepting code. We can also, in theory, + // longjump out of the signal handler, and although that is + // deprecated, we make sure in cyg_deliver_signals() that it is + // possible to do it. + + HAL_ENABLE_INTERRUPTS(); + + struct sigevent sev; + + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = signo; + sev.sigev_value.sival_ptr = (void *)exception_info; + + // Generate the signal + cyg_sigqueue( &sev, SI_EXCEPT ); + + // And try to deliver it + cyg_deliver_signals(); +} + +//========================================================================== +// Install all the exception handlers + +static void install_handlers( Cyg_Thread *thread) +{ +#ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE + + // With decoded exceptions, we must install a separate exception + // handler for each supported exception. + + for( int i = 0; exception_signal_mapping[i].signal != 0; i++ ) + { + thread->register_exception( exception_signal_mapping[i].exception, + cyg_posix_exception_handler, + exception_signal_mapping[i].signal,, + NULL, + NULL); + } + +#else + + // Otherwise there is just one exception handler for all exceptions. + + thread->register_exception( CYGNUM_HAL_EXCEPTION_MIN, + cyg_posix_exception_handler, + 0, + NULL, + NULL); + +#endif + +} + +//========================================================================== +// Initialization + +externC void cyg_posix_exception_start() +{ +#ifdef CYGSEM_KERNEL_EXCEPTIONS_GLOBAL + + // With global exceptions, we only need to install a single static + // set of exception handlers. Note that by this point in system + // initialization the idle thread should be installed as the + // current thread, so we pass a pointer to that to + // install_handlers(). The identity of the thread passed is + // actually irrelevant in this case and is just used as a handle + // into the thread class. + + install_handlers( Cyg_Thread::self() ); + +#endif +} + +//========================================================================== +// Per thread exception initialization and destruction + +externC void cyg_pthread_exception_init(pthread_info *thread) +{ +#ifndef CYGSEM_KERNEL_EXCEPTIONS_GLOBAL + + // With non-global exceptions we must install a new set of handlers + // for each thread. + + install_handlers( thread->thread ); + +#endif +} + +externC void cyg_pthread_exception_destroy(pthread_info *thread) +{ + // Nothing to do at present. +} + +// ------------------------------------------------------------------------- +// EOF except.cxx diff --git a/packages/compat/posix/current/src/misc.cxx b/packages/compat/posix/current/src/misc.cxx new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/src/misc.cxx @@ -0,0 +1,320 @@ +//========================================================================== +// +// misc.cxx +// +// POSIX misc function implementations +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-07-18 +// Purpose: POSIX misc function implementation +// Description: This file contains the implementation of miscellaneous POSIX +// functions that do not belong elsewhere. +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include "pprivate.h" // POSIX private header + +#include +#include // My header +#include // strcpy +#include +#include + +// ------------------------------------------------------------------------- +// Supply some suitable values for constants that may not be present +// in all configurations. + +#ifndef MQ_OPEN_MAX +#define MQ_OPEN_MAX 0 +#endif +#ifndef MQ_PRIO_MAX +#define MQ_PRIO_MAX 0 +#endif + +// ------------------------------------------------------------------------- + +#define __string(_x) #_x +#define __xstring(_x) __string(_x) + +// ------------------------------------------------------------------------- +// utsname() + +__externC int uname( struct utsname *name ) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + + strcpy( name->sysname, "eCos" ); + strcpy( name->nodename, "" ); // should use gethostname() + strcpy( name->release, __xstring( CYGNUM_KERNEL_VERSION_MAJOR ) ); + strcpy( name->version, __xstring( CYGNUM_KERNEL_VERSION_MINOR ) ); + strcpy( name->machine, "" ); + + CYG_REPORT_RETVAL(0); + return 0; +} + +// ------------------------------------------------------------------------- +// sysconf() + +#define SC_CASE( _name, _val ) case _name: return _val + +__externC long sysconf( int name ) +{ + + switch( name ) + { + SC_CASE( _SC_AIO_LISTIO_MAX, AIO_LISTIO_MAX ); + SC_CASE( _SC_AIO_MAX, AIO_MAX ); + SC_CASE( _SC_AIO_PRIO_DELTA_MAX, AIO_PRIO_DELTA_MAX ); + SC_CASE( _SC_ARG_MAX, ARG_MAX ); + SC_CASE( _SC_CHILD_MAX, CHILD_MAX ); + SC_CASE( _SC_DELAYTIMER_MAX, DELAYTIMER_MAX ); + SC_CASE( _SC_GETGR_R_SIZE_MAX, 0 ); + SC_CASE( _SC_GETPW_R_SIZE_MAX, 0 ); + SC_CASE( _SC_LOGIN_NAME_MAX, LOGIN_NAME_MAX ); + SC_CASE( _SC_MQ_OPEN_MAX, MQ_OPEN_MAX ); + SC_CASE( _SC_MQ_PRIO_MAX, MQ_PRIO_MAX ); + SC_CASE( _SC_NGROUPS_MAX, NGROUPS_MAX ); + SC_CASE( _SC_OPEN_MAX, OPEN_MAX ); + SC_CASE( _SC_PAGESIZE, PAGESIZE ); + SC_CASE( _SC_RTSIG_MAX, RTSIG_MAX ); + SC_CASE( _SC_SEM_NSEMS_MAX, SEM_NSEMS_MAX ); + SC_CASE( _SC_SEM_VALUE_MAX, SEM_VALUE_MAX ); + SC_CASE( _SC_SIGQUEUE_MAX, SIGQUEUE_MAX ); + SC_CASE( _SC_STREAM_MAX, STREAM_MAX ); + SC_CASE( _SC_THREAD_DESTRUCTOR_ITERATIONS, PTHREAD_DESTRUCTOR_ITERATIONS ); + SC_CASE( _SC_THREAD_KEYS_MAX, PTHREAD_KEYS_MAX ); + SC_CASE( _SC_THREAD_STACK_MIN, PTHREAD_STACK_MIN ); + SC_CASE( _SC_THREAD_THREADS_MAX, PTHREAD_THREADS_MAX ); + SC_CASE( _SC_TIMER_MAX, TIMER_MAX ); + SC_CASE( _SC_TTY_NAME_MAX, TTY_NAME_MAX ); + SC_CASE( _SC_TZNAME_MAX, TZNAME_MAX ); + SC_CASE( _SC_VERSION, _POSIX_VERSION ); + + case _SC_CLK_TCK: + { + struct timespec ts; + ts.tv_sec = 1; + ts.tv_nsec = 0; + cyg_tick_count ticks = cyg_timespec_to_ticks( &ts ); + return ticks; + } + + case _SC_ASYNCHRONOUS_IO: + #ifdef _POSIX_ASYNCHRONOUS_IO + return 1; + #else + return 0; + #endif + + case _SC_FSYNC: + #ifdef _POSIX_FSYNC + return 1; + #else + return 0; + #endif + + case _SC_JOB_CONTROL: + #ifdef _POSIX_JOB_CONTROL + return 1; + #else + return 0; + #endif + + case _SC_MAPPED_FILES: + #ifdef _POSIX_MAPPED_FILES + return 1; + #else + return 0; + #endif + + case _SC_MEMLOCK: + #ifdef _POSIX_MEMLOCK + return 1; + #else + return 0; + #endif + + case _SC_MEMLOCK_RANGE: + #ifdef _POSIX_MEMLOCK_RANGE + return 1; + #else + return 0 ; + #endif + + case _SC_MEMORY_PROTECTION: + #ifdef _POSIX_MEMORY_PROTECTION + return 1; + #else + return 0; + #endif + + case _SC_MESSAGE_PASSING: + #ifdef _POSIX_MESSAGE_PASSING + return 1; + #else + return 0; + #endif + + case _SC_PRIORITIZED_IO: + #ifdef _POSIX_PRIORITIZED_IO + return 1; + #else + return 0; + #endif + + case _SC_PRIORITY_SCHEDULING: + #ifdef _POSIX_PRIORITY_SCHEDULING + return 1; + #else + return 0; + #endif + + case _SC_REALTIME_SIGNALS: + #ifdef _POSIX_REALTIME_SIGNALS + return 1; + #else + return 0; + #endif + + case _SC_SAVED_IDS: + #ifdef _POSIX_SAVED_IDS + return 1; + #else + return 0; + #endif + + case _SC_SEMAPHORES: + #ifdef _POSIX_SEMAPHORES + return 1; + #else + return 0; + #endif + + case _SC_SHARED_MEMORY_OBJECTS: + #ifdef _POSIX_SHARED_MEMORY_OBJECTS + return 1; + #else + return 0; + #endif + + case _SC_SYNCHRONIZED_IO: + #ifdef _POSIX_SYNCHRONIZED_IO + return 1; + #else + return 0; + #endif + + case _SC_THREADS: + #ifdef _POSIX_THREADS + return 1; + #else + return 0; + #endif + + case _SC_THREAD_ATTR_STACKADDR: + #ifdef _POSIX_THREAD_ATTR_STACKADDR + return 1; + #else + return 0; + #endif + + case _SC_THREAD_ATTR_STACKSIZE: + #ifdef _POSIX_THREAD_ATTR_STACKSIZE + return 1; + #else + return 0; + #endif + + case _SC_THREAD_PRIO_INHERIT: + #ifdef _POSIX_THREAD_PRIO_INHERIT + return 1; + #else + return 0; + #endif + + case _SC_THREAD_PRIO_PROTECT: + #ifdef _POSIX_THREAD_PRIO_PROTECT + return 1; + #else + return 0; + #endif + + case _SC_THREAD_PRIORITY_SCHEDULING: + #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + return 1; + #else + return 0; + #endif + + case _SC_THREAD_PROCESS_SHARED: + #ifdef _POSIX_THREAD_PROCESS_SHARED + return 1; + #else + return 0; + #endif + + case _SC_THREAD_SAFE_FUNCTIONS: + #ifdef _POSIX_THREAD_SAFE_FUNCTIONS + return 1; + #else + return 0; + #endif + + case _SC_TIMERS: + #ifdef _POSIX_TIMERS + return 1; + #else + return 0; + #endif + + + default: + errno = EINVAL; + return -1; + } +} + +// ------------------------------------------------------------------------- +// EOF misc.cxx diff --git a/packages/compat/posix/current/src/mqueue.cxx b/packages/compat/posix/current/src/mqueue.cxx new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/src/mqueue.cxx @@ -0,0 +1,786 @@ +/*======================================================================== +// +// mqueue.cxx +// +// Message queues tests +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-05-14 +// Purpose: This file provides the implementation for POSIX message +// queues +// Description: It uses eCos kernel mqueues as the underlying +// implementation +// Usage: +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include + +#ifdef CYGPKG_POSIX_MQUEUES + +#include + +/* INCLUDES */ + +#include // common types etc. +#include // Assertion support +#include // Tracing support +#include // eCos Mqueue Header +#include // Cyg_Scheduler::lock() +#include // inlines for above +#include // Standard POSIX mqueue header +#include // mode_t, ssize_t +#include // PATH_MAX +#include // malloc, etc. +#include // errno +#include // O_* +#include // varargs +#include // mutexes +#include // strncpy +#include // C++ new +#ifdef CYGFUN_POSIX_MQUEUE_NOTIFY +# include +# include "pprivate.h" // cyg_sigqueue() +#endif + + +/* CONSTANTS */ + +#define MQ_VALID_MAGIC 0x6db256c1 + +/* TYPE DEFINITIONS */ + +struct mqtabent; + +// this is a queue user - each one of these corresponds to a mqd_t +struct mquser { + int flags; // O_RDONLY, O_WRONLY, O_RDWR, O_NONBLOCK + struct mqtabent *tabent; // back pointer to table entry + struct mquser *next; + bool notifieruser; // POSIX sucks so bad. It requires a mq_close + // to only deregister the notification if it + // was done via this descriptor. So we have to + // know if it was this one +#ifdef CYGIMP_POSIX_MQUEUE_VALIDATE_DESCRIPTOR + cyg_uint32 magic; // magic number: MQ_VALID_MAGIC if valid +#endif +}; + +struct mqtabent { + char name[ PATH_MAX ]; // ascii name - set to "" when unused + Cyg_Mqueue *mq; // the underlying queue object + long maxmsg; // as set on creation + long msgsize; // as set on creation + bool unlinkme; // unlink when final user closes? + struct mquser *users; // each user + +#ifdef CYGFUN_POSIX_MQUEUE_NOTIFY + const struct sigevent *sigev; // notification event +#endif +}; + +/* GLOBALS */ + +static struct mqtabent mqtab[ CYGNUM_POSIX_MQUEUE_OPEN_MAX ]; +static pthread_mutex_t mqtab_mut = PTHREAD_MUTEX_INITIALIZER; + +/* LOCAL FUNCTIONS */ + +//------------------------------------------------------------------------ + +// Deallocation callback from Cyg_Mqueue +static void +my_free( void *ptr, size_t ) +{ + free( ptr ); +} + +//------------------------------------------------------------------------ + +// Do the actual "unlink" of a queue, i.e. mark it invalid in the table. +// The table mutex is assumed to be locked +static void +do_mq_unlink( struct mqtabent *tabent ) +{ + CYG_REPORT_FUNCTION(); + CYG_CHECK_DATA_PTRC( tabent ); + + tabent->name[0] = '\0'; // won't match anything the user sends now + tabent->mq->~Cyg_Mqueue(); + free( tabent->mq ); + + CYG_REPORT_RETURN(); +} + +//------------------------------------------------------------------------ + +#ifdef CYGFUN_POSIX_MQUEUE_NOTIFY + +static void +notifyme( Cyg_Mqueue &q, CYG_ADDRWORD data ) +{ + CYG_REPORT_FUNCTION(); + struct mquser *user = (struct mquser *)data; + CYG_CHECK_DATA_PTRC( user ); + struct mqtabent *tabent = user->tabent; + CYG_CHECK_DATA_PTRC( tabent ); + + Cyg_Scheduler::lock(); + // we may have been pre-empted before this, so check there's still a + // notification to do + + if ( NULL == tabent->sigev ) { + Cyg_Scheduler::unlock(); + CYG_REPORT_RETURN(); + return; + } // if + + const struct sigevent *ev = tabent->sigev; + + // first deregister + q.setnotify( NULL, 0 ); + tabent->sigev = NULL; + user->notifieruser = false; // not any more + + // now the rest of the world can go + Cyg_Scheduler::unlock(); + + // queue event. If it fails... nothing we can do :-( so ignore return code + cyg_sigqueue( ev, SI_MESGQ ); + + cyg_deliver_signals(); + + CYG_REPORT_RETURN(); +} + +#endif // ifdef CYGFUN_POSIX_MQUEUE_NOTIFY + +//------------------------------------------------------------------------ + +/* EXPORTED FUNCTIONS */ + +externC mqd_t +mq_open( const char *name, int oflag, ... ) +{ + CYG_REPORT_FUNCTYPE( "returning %08x" ); + CYG_REPORT_FUNCARG2( "name=%08x, oflag=%d", name, oflag ); + CYG_CHECK_DATA_PTRC( name ); + + if ( ((oflag & O_RDONLY) != O_RDONLY) && + ((oflag & O_WRONLY) != O_WRONLY) && + ((oflag & O_RDWR) != O_RDWR)) { + // user didn't specify mode + errno = EINVAL; + CYG_REPORT_RETVAL( -1 ); + return (mqd_t)-1; + } // if + + mqd_t retval; + cyg_ucount32 i; + struct mqtabent *qtabent=NULL; + int interr; + + interr = pthread_mutex_lock( &mqtab_mut ); + // should never fail + CYG_ASSERT( interr == 0, "internal lock failed!" ); + + // find if a matching entry exists first + // FIXME: Should check for length and return ENAMETOOLONG + for ( i=0; i < CYGNUM_POSIX_MQUEUE_OPEN_MAX; i++ ) { + if ( 0 == strncmp(name, mqtab[i].name, PATH_MAX) ) { + qtabent = &mqtab[i]; + break; + } // if + } // for + + if ( (NULL != qtabent) && (O_EXCL == (oflag & O_EXCL)) ) { + errno = EEXIST; + retval = (mqd_t)-1; + goto exit_unlock; + } + + if ( (NULL == qtabent) && (O_CREAT != (oflag & O_CREAT)) ) { + errno = ENOENT; + retval = (mqd_t)-1; + goto exit_unlock; + } + + // so if we didn't find something, we must be being asked to create it + if (NULL == qtabent) { + mode_t mode; // FIXME: mode ignored for now + const struct mq_attr *attr; + const struct mq_attr default_attr = { 0, MQ_OPEN_MAX, 128 }; + va_list args; + + va_start( args, oflag ); + mode = va_arg( args, mode_t ); + attr = va_arg( args, struct mq_attr * ); + va_end( args ); + + // find an empty table entry + for ( i=0; i < CYGNUM_POSIX_MQUEUE_OPEN_MAX; i++ ) { + if ( NULL == mqtab[i].mq ) + break; + } + + // if not found, table is full + if ( i == CYGNUM_POSIX_MQUEUE_OPEN_MAX ) { + errno = ENFILE; + retval = (mqd_t)-1; + goto exit_unlock; + } + + Cyg_Mqueue::qerr_t qerr; + + // user can specify NULL attr, which means arbitrary message queue + // size! Duh. + if ( NULL == attr ) + attr = &default_attr; + else { + // if they do supply one, POSIX says we're meant to check it + if (attr->mq_maxmsg <= 0 || attr->mq_msgsize <= 0) { + errno = EINVAL; + retval = (mqd_t)-1; + goto exit_unlock; + } + } // else + + // allocate the underlying queue + Cyg_Mqueue *mqholder = (Cyg_Mqueue *)malloc( sizeof(Cyg_Mqueue) ); + if ( NULL == mqholder ) { + errno = ENOSPC; + retval = (mqd_t)-1; + goto exit_unlock; + } + + // construct it with placement new + mqtab[i].mq = new (mqholder) Cyg_Mqueue( attr->mq_maxmsg, + attr->mq_msgsize, + &malloc, &my_free, &qerr ); + + switch (qerr) { + case Cyg_Mqueue::OK: + break; + case Cyg_Mqueue::NOMEM: + free( mqholder ); + errno = ENOSPC; + retval = (mqd_t)-1; + goto exit_unlock; + default: + CYG_FAIL("Unhandled Cyg_Mqueue constructor return error"); + break; + } // switch + + mqtab[i].users = (struct mquser *) malloc( sizeof(struct mquser) ); + if ( NULL == mqtab[i].users ) { + mqtab[i].mq->~Cyg_Mqueue(); + free( mqholder ); + errno = ENOSPC; + retval = (mqd_t)-1; + goto exit_unlock; + } + + // initialize mqtab[i] + mqtab[i].maxmsg = attr->mq_maxmsg; + mqtab[i].msgsize = attr->mq_msgsize; + mqtab[i].unlinkme = false; + mqtab[i].sigev = NULL; + strncpy( mqtab[i].name, name, PATH_MAX ); + + // initialize first mqtab[i].users + mqtab[i].users->next = NULL; + // set the mode for later, but also note that O_NONBLOCK can + // be set in oflags *or* the attr the user passed + mqtab[i].users->flags = oflag | (attr->mq_flags & O_NONBLOCK); + + // set back pointer so that message queue handle can find actual queue + mqtab[i].users->tabent = &mqtab[i]; + + mqtab[i].users->notifieruser = false; + +#ifdef CYGIMP_POSIX_MQUEUE_VALIDATE_DESCRIPTOR + mqtab[i].users->magic = MQ_VALID_MAGIC; // now valid +#endif + + retval=(mqd_t)mqtab[i].users; + + goto exit_unlock; + } // if (NULL == qtabent) + + // so we're not creating, and we have a valid qtabent + + // But this qtabent may be being unlinked. If so, we are permitted + // to return an error, so we will. (see under mq_unlink() in POSIX) + // Which error though? EINVAL seems best, but POSIX doesn't say :-/ + + if (true == qtabent->unlinkme) { + errno = EINVAL; + retval = (mqd_t)-1; + goto exit_unlock; + } + + // now we have a usable qtabent + + struct mquser *user; + user = (struct mquser *) malloc( sizeof(struct mquser) ); + if ( NULL == user ) { + errno = ENOSPC; + retval = (mqd_t)-1; + goto exit_unlock; + } + + // prepend to qtab user list + user->next = qtabent->users; + qtabent->users = user; + + // set back pointer so that message queue handle can find actual queue + user->tabent = qtabent; + + user->flags = oflag; + +#ifdef CYGIMP_POSIX_MQUEUE_VALIDATE_DESCRIPTOR + user->magic = MQ_VALID_MAGIC; // now valid +#endif + + retval=(mqd_t)user; + + exit_unlock: + interr = pthread_mutex_unlock( &mqtab_mut ); + // should never fail + CYG_ASSERT( interr == 0, "internal lock failed!" ); + CYG_REPORT_RETVAL( retval ); + return retval; +} // mq_open() + +//------------------------------------------------------------------------ + +// NOTE: It is the *user*'s responsibility to ensure that nothing is +// blocked in mq_send() or mq_receive() when closing the queue with +// that descriptor. The standard does not specify the behaviour, so that's +// what I am assuming + +externC int +mq_close( mqd_t mqdes ) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_REPORT_FUNCARG1XV( mqdes ); + + struct mquser *user = (struct mquser *)mqdes; + +#ifdef CYGIMP_POSIX_MQUEUE_VALIDATE_DESCRIPTOR + if ( user->magic != MQ_VALID_MAGIC ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return -1; + } +#endif + + int interr; + + interr = pthread_mutex_lock( &mqtab_mut ); + // should never fail + CYG_ASSERT( interr == 0, "internal lock failed!" ); + + struct mqtabent *tabent = user->tabent; + struct mquser *usertmp; + + // perhaps should return EBADF instead of assert? + CYG_ASSERT( tabent->users != NULL, "Null message queue user list" ); + + // deregister notification iff this was the message queue descriptor + // that was used to register it (POSIX says) + if ( true == user->notifieruser ) { + tabent->mq->setnotify( NULL, 0 ); + tabent->sigev = NULL; + // not worth clearing notifieruser + } + + // find in the list for this queue and remove - sucks a bit, but seems + // best over all - the list shouldn't be too long + if ( tabent->users == user ) { + tabent->users = user->next; // remove + } else { + for ( usertmp=tabent->users; + NULL != usertmp->next; + usertmp = usertmp->next ) { + if ( usertmp->next == user ) + break; + } // for + + // perhaps should return EBADF instead of assert? + CYG_ASSERT( usertmp->next != NULL, "Couldn't find message queue user" ); + + usertmp->next = user->next; // remove + } // else + +#ifdef CYGIMP_POSIX_MQUEUE_VALIDATE_DESCRIPTOR + user->magic = 0; // invalidate +#endif + + // free it up + free( user ); + + if ( (true == tabent->unlinkme) && (NULL == tabent->users) ) { + do_mq_unlink( tabent ); + } // if + + interr = pthread_mutex_unlock( &mqtab_mut ); + // should never fail + CYG_ASSERT( interr == 0, "internal lock failed!" ); + CYG_REPORT_RETVAL( 0 ); + return 0; +} // mq_close() + + +//------------------------------------------------------------------------ + +externC int +mq_unlink( const char *name ) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_REPORT_FUNCARG1( "name=%s", name ); + + int retval, interr; + cyg_ucount32 i; + struct mqtabent *qtabent=NULL; + + interr = pthread_mutex_lock( &mqtab_mut ); + // should never fail + CYG_ASSERT( interr == 0, "internal lock failed!" ); + + // find the entry first + // FIXME: Should check for length and return ENAMETOOLONG + for ( i=0; i < CYGNUM_POSIX_MQUEUE_OPEN_MAX; i++ ) { + if ( 0 == strncmp(name, mqtab[i].name, PATH_MAX) ) { + qtabent = &mqtab[i]; + break; + } // if + } // for + + if ( NULL == qtabent ) { // not found + errno = ENOENT; + retval = -1; + goto exit_unlock; + } + + if ( NULL != qtabent->users ) { // still in use + qtabent->unlinkme = true; // so mark it as pending deletion + } else { + do_mq_unlink( qtabent ); + } // else + + retval = 0; + + exit_unlock: + interr = pthread_mutex_unlock( &mqtab_mut ); + // should never fail + CYG_ASSERT( interr == 0, "internal lock failed!" ); + CYG_REPORT_RETVAL( retval ); + return retval; +} // mq_unlink() + +//------------------------------------------------------------------------ + +externC int +mq_send( mqd_t mqdes, const char *msg_ptr, size_t msg_len, + unsigned int msg_prio ) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_REPORT_FUNCARG4( "mqdes=%08x, msg_ptr=%08x, msg_len=%u, msg_prio=%u", + mqdes, msg_ptr, msg_len, msg_prio ); + CYG_CHECK_DATA_PTRC( msg_ptr ); + + struct mquser *user = (struct mquser *)mqdes; + struct mqtabent *tabent = user->tabent; + +#ifdef CYGIMP_POSIX_MQUEUE_VALIDATE_DESCRIPTOR + if ( user->magic != MQ_VALID_MAGIC ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return -1; + } +#endif + + if ( msg_len > (size_t)tabent->msgsize ) { + errno = EMSGSIZE; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + if ( msg_prio > MQ_PRIO_MAX ) { + errno = EINVAL; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + if ( (O_WRONLY != (user->flags & O_WRONLY)) && + (O_RDWR != (user->flags & O_RDWR)) ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + // go for it + Cyg_Mqueue::qerr_t err; + err = tabent->mq->put( msg_ptr, msg_len, msg_prio, + ((user->flags & O_NONBLOCK) != O_NONBLOCK) ); + switch (err) { + + case Cyg_Mqueue::INTR: + errno = EINTR; + CYG_REPORT_RETVAL( -1 ); + return -1; + + case Cyg_Mqueue::WOULDBLOCK: + CYG_ASSERT( (user->flags & O_NONBLOCK) == O_NONBLOCK, + "Message queue assumed non-blocking when blocking requested" + ); + errno = EAGAIN; + CYG_REPORT_RETVAL( -1 ); + return -1; + + case Cyg_Mqueue::OK: + CYG_REPORT_RETVAL( 0 ); + return 0; + + default: + CYG_FAIL( "unhandled message queue return code" ); + return -1; // keep compiler happy + } // switch +} // mq_send() + +//------------------------------------------------------------------------ + + +externC ssize_t +mq_receive( mqd_t mqdes, char *msg_ptr, size_t msg_len, + unsigned int *msg_prio ) +{ + CYG_REPORT_FUNCTYPE( "returning %ld" ); + CYG_REPORT_FUNCARG4( "mqdes=%08x, msg_ptr=%08x, msg_len=%u, msg_prio=%08x", + mqdes, msg_ptr, msg_len, msg_prio ); + CYG_CHECK_DATA_PTRC( msg_ptr ); + CYG_CHECK_DATA_PTRC( msg_ptr+msg_len-1 ); + if ( NULL != msg_prio ) + CYG_CHECK_DATA_PTRC( msg_prio ); + + + struct mquser *user = (struct mquser *)mqdes; + struct mqtabent *tabent = user->tabent; + +#ifdef CYGIMP_POSIX_MQUEUE_VALIDATE_DESCRIPTOR + if ( user->magic != MQ_VALID_MAGIC ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return (ssize_t)-1; + } +#endif + + if ( (O_RDONLY != (user->flags & O_RDONLY)) && + (O_RDWR != (user->flags & O_RDWR)) ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return (ssize_t)-1; + } + + if ( msg_len < (size_t)tabent->msgsize ) { + errno = EMSGSIZE; + CYG_REPORT_RETVAL( -1 ); + return (ssize_t)-1; + } + + // go for it + Cyg_Mqueue::qerr_t err; + err = tabent->mq->get( msg_ptr, &msg_len, msg_prio, + ((user->flags & O_NONBLOCK) != O_NONBLOCK) ); + switch (err) { + + case Cyg_Mqueue::INTR: + errno = EINTR; + CYG_REPORT_RETVAL( -1 ); + return (ssize_t)-1; + + case Cyg_Mqueue::WOULDBLOCK: + CYG_ASSERT( (user->flags & O_NONBLOCK) == O_NONBLOCK, + "Message queue assumed non-blocking when blocking requested" + ); + errno = EAGAIN; + CYG_REPORT_RETVAL( -1 ); + return (ssize_t)-1; + + case Cyg_Mqueue::OK: + CYG_ASSERT( msg_len <= (size_t)tabent->msgsize, + "returned message too long" ); + if ( NULL != msg_prio ) + CYG_ASSERT( *msg_prio <= MQ_PRIO_MAX, + "returned message has invalid priority" ); + CYG_REPORT_RETVAL( msg_len ); + return (ssize_t)msg_len; + + default: + CYG_FAIL( "unhandled message queue return code" ); + return (ssize_t)-1; // keep compiler happy + } // switch + +} // mq_receive() + +//------------------------------------------------------------------------ + +#ifdef CYGFUN_POSIX_MQUEUE_NOTIFY + +externC int +mq_notify( mqd_t mqdes, const struct sigevent *notification ) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_REPORT_FUNCARG2( "mqdes=%08x, notification=%08x", mqdes, notification ); + if ( NULL != notification ) + CYG_CHECK_DATA_PTRC( notification ); + + struct mquser *user = (struct mquser *)mqdes; + struct mqtabent *tabent = user->tabent; + +#ifdef CYGIMP_POSIX_MQUEUE_VALIDATE_DESCRIPTOR + if ( user->magic != MQ_VALID_MAGIC ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return -1; + } +#endif + + // lock scheduler since we test and set non-atomically + Cyg_Scheduler::lock(); + + // we are being told to clear the notification function + if ( NULL == notification ) { + tabent->mq->setnotify( NULL, 0 ); + tabent->sigev = NULL; + Cyg_Scheduler::unlock(); + CYG_REPORT_RETVAL( 0 ); + return 0; + } // if + + if ( NULL != tabent->sigev ) { // already registered + Cyg_Scheduler::unlock(); + errno = EBUSY; + CYG_REPORT_RETVAL( -1 ); + return -1; + } // if + + tabent->sigev = notification; + user->notifieruser = true; // Used for deciding about whether to + // deregister in mq_close() + tabent->mq->setnotify( ¬ifyme, (CYG_ADDRWORD) user ); + Cyg_Scheduler::unlock(); + + CYG_REPORT_RETVAL( 0 ); + return 0; +} // mq_notify() + +#endif // ifdef CYGFUN_POSIX_MQUEUE_NOTIFY + +//------------------------------------------------------------------------ + +externC int +mq_setattr( mqd_t mqdes, const struct mq_attr *mqstat, + struct mq_attr *omqstat ) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_REPORT_FUNCARG3( "mqdes=%08x, mqstat=%08x, omqstat=%08x", + mqdes, mqstat, omqstat ); + CYG_CHECK_DATA_PTRC( mqstat ); + + struct mquser *user = (struct mquser *)mqdes; + +#ifdef CYGIMP_POSIX_MQUEUE_VALIDATE_DESCRIPTOR + if ( user->magic != MQ_VALID_MAGIC ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return -1; + } +#endif + + if ( NULL != omqstat ) { + CYG_CHECK_DATA_PTRC( omqstat ); + mq_getattr( mqdes, omqstat ); + } // if + + // Two-stage update, so lock sched since it's quick + Cyg_Scheduler::lock(); + user->flags &= ~O_NONBLOCK; // clear + if ( (mqstat->mq_flags & O_NONBLOCK) == O_NONBLOCK ) { + user->flags |= O_NONBLOCK; + } // if + Cyg_Scheduler::unlock(); + + CYG_REPORT_RETVAL( 0 ); + return 0; +} // mq_setattr() + +//------------------------------------------------------------------------ + +externC int +mq_getattr( mqd_t mqdes, struct mq_attr *mqstat ) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_REPORT_FUNCARG2( "mqdes=%08x, mqstat=%08x", mqdes, mqstat ); + CYG_CHECK_DATA_PTRC( mqstat ); + + struct mquser *user = (struct mquser *)mqdes; + struct mqtabent *tabent = user->tabent; + +#ifdef CYGIMP_POSIX_MQUEUE_VALIDATE_DESCRIPTOR + if ( user->magic != MQ_VALID_MAGIC ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return -1; + } +#endif + + mqstat->mq_flags = user->flags; + mqstat->mq_maxmsg = tabent->maxmsg; + mqstat->mq_msgsize = tabent->msgsize; + mqstat->mq_curmsgs = tabent->mq->count(); + + CYG_REPORT_RETVAL( 0 ); + return 0; +} // mq_getattr() + + +//------------------------------------------------------------------------ + +#endif // ifdef CYGPKG_POSIX_MQUEUES + +/* EOF mqueue.cxx */ diff --git a/packages/compat/posix/current/src/pprivate.h b/packages/compat/posix/current/src/pprivate.h new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/src/pprivate.h @@ -0,0 +1,199 @@ +#ifndef CYGONCE_PPRIVATE_H +#define CYGONCE_PPRIVATE_H +//============================================================================= +// +// pprivate.h +// +// POSIX types header +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-03-17 +// Purpose: POSIX private header +// Description: This header contains various POSIX type definitions that are +// shared between the various parts of the POSIX package. +// +// Usage: #include +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include +#include +#include + +#include // NULL, size_t + +#include +#include +#include +#include // error codes +#include // sigset_t +#include // PTHREAD_KEYS_MAX + +#include // thread definitions +#include // mutex definitions + +//============================================================================= +// Constructor prioritization + +// Prioritization for POSIX library support objects +#define CYGBLD_POSIX_INIT CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_COMPAT) + +// Prioritization for POSIX library startup initialization. This must +// come after CYGBLD_POSIX_INIT constructors. +#define CYGBLD_POSIX_START CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_COMPAT+5) + +//============================================================================= +// Thread control data structure + +// Per-thread information needed by POSIX +// This is pointed to by the CYGNUM_KERNEL_THREADS_DATA_POSIX entry of the +// per-thread data. + +typedef struct +{ + unsigned int state:4, // Thread state + cancelstate:2, // Cancel state of thread + canceltype:2, // Cancel type of thread + cancelpending:1, // pending cancel flag + freestack:1; // stack malloced, must be freed + + pthread_t id; // My thread ID + Cyg_Thread *thread; // pointer to eCos thread object + pthread_attr_t attr; // Current thread attributes + void *retval; // return value + void *(*start_routine)(void *); // start routine + void *start_arg; // argument to start routine + char name[20]; // name string for debugging + Cyg_Condition_Variable *joiner; // joining threads wait here + CYG_ADDRWORD stackmem; // base of stack memory area + // only valid if freestack == true + + struct pthread_cleanup_buffer *cancelbuffer; // stack of cleanup buffers + + sigset_t sigpending; // Set of pending signals + sigset_t sigmask; // Thread's signal mask + + // The following is space for the eCos thread object that underlies + // this POSIX thread. It is allocated like this to avoid constructing + // it on startup. + cyg_uint8 thread_obj[sizeof(Cyg_Thread)]; + + // And the same for the joiner condition variable. + cyg_uint8 joiner_obj[sizeof(Cyg_Condition_Variable)]; + + // Per-thread data table pointer + void **thread_data; + +} pthread_info; + + +// Values for the state field. These are solely concerned with the +// states visible to POSIX. The thread's run state is stored in the +// eCos thread object. + +#define PTHREAD_STATE_FREE 0 // This structure is free for reuse +#define PTHREAD_STATE_DETACHED 1 // The thread is running but detached +#define PTHREAD_STATE_RUNNING 2 // The thread is running and will wait + // to join when it exits +#define PTHREAD_STATE_JOIN 3 // The thread has exited and is waiting + // to be joined +#define PTHREAD_STATE_EXITED 4 // The thread has exited and is ready to + // be reaped +//----------------------------------------------------------------------------- +// Priority translation. +// eCos priorities run from 0 as the highest to 31 as the lowest. POSIX priorities +// run in the opposite direction. The following macros translate between the two +// priority ranges. + +#define PTHREAD_ECOS_PRIORITY(pri) (CYG_THREAD_MIN_PRIORITY-(pri)) + +#define PTHREAD_POSIX_PRIORITY(pri) (CYG_THREAD_MIN_PRIORITY-(pri)) + +//----------------------------------------------------------------------------- +// Global data structures + +// Mutex for locking access to pthread_info structures +extern Cyg_Mutex pthread_mutex; + +//----------------------------------------------------------------------------- +// Functions exported by pthread.cxx to the other parts of the POSIX subsystem. + +externC void cyg_posix_pthread_start( void ); + +externC pthread_info *pthread_self_info(void); + +externC pthread_info *pthread_info_id( pthread_t id ); + +externC void cyg_posix_pthread_release_thread( sigset_t *mask ); + +//----------------------------------------------------------------------------- +// Functions exported by signal.cxx to the other parts of the POSIX subsystem. + +externC void cyg_posix_signal_start(); + +externC void cyg_posix_signal_asr(pthread_info *self); + +externC cyg_bool cyg_sigqueue( const struct sigevent *sev, int code, + pthread_info *thread = NULL ); + +externC cyg_bool cyg_deliver_signals(); + +externC void cyg_posix_thread_siginit( pthread_info *thread ); + +externC void cyg_posix_thread_sigdestroy( pthread_info *thread ); + +//----------------------------------------------------------------------------- +// Functions exported by time.cxx to other parts of the POSIX subsystem. + +externC void cyg_posix_clock_start(); + +externC cyg_tick_count cyg_timespec_to_ticks( const struct timespec *tp, + cyg_bool roundup = false); + +externC void cyg_ticks_to_timespec( cyg_tick_count ticks, struct timespec *tp ); + +externC void cyg_posix_timer_asr( pthread_info *self ); + +//----------------------------------------------------------------------------- +// Functions exported by except.cxx + +externC void cyg_posix_exception_start(); + +externC void cyg_pthread_exception_init(pthread_info *thread); + +externC void cyg_pthread_exception_destroy(pthread_info *thread); + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_PPRIVATE_H +// End of pprivate.h diff --git a/packages/compat/posix/current/src/pthread.cxx b/packages/compat/posix/current/src/pthread.cxx new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/src/pthread.cxx @@ -0,0 +1,2021 @@ +//========================================================================== +// +// pthread.cxx +// +// POSIX pthreads implementation +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg, jlarmour +// Date: 2000-03-27 +// Purpose: POSIX pthread implementation +// Description: This file contains the implementation of the POSIX pthread +// functions. +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include "pprivate.h" // POSIX private header + +#include // malloc(), free() + +#include // scheduler definitions +#include // thread definitions +#include // mutex definitions +#include // clock definitions + +#include // scheduler inlines + +//----------------------------------------------------------------------------- +// First check that the configuration contains the elements we need + +#ifndef CYGPKG_KERNEL +#error POSIX pthread need eCos kernel +#endif + +#ifndef CYGSEM_KERNEL_SCHED_MLQUEUE +#error POSIX pthreads need MLQ scheduler +#endif + +#ifndef CYGSEM_KERNEL_SCHED_TIMESLICE +#error POSIX pthreads need timeslicing +#endif + +#ifndef CYGVAR_KERNEL_THREADS_DATA +#error POSIX pthreads need per-thread data +#endif + +//----------------------------------------------------------------------------- +// Internal definitions + +// Handle entry to a pthread package function. +#define PTHREAD_ENTRY() CYG_REPORT_FUNCTYPE( "returning %d" ) + +// Handle entry to a pthread package function with no args. +#define PTHREAD_ENTRY_VOID() CYG_REPORT_FUNCTION() + +// Do a pthread package defined return. This requires the error code to be +// returned as the result of the function. This also gives us a place to +// put any generic tidyup handling needed for things like signal delivery +// and cancellation. +#define PTHREAD_RETURN(err) \ +CYG_MACRO_START \ + CYG_REPORT_RETVAL( err ); \ + return err; \ +CYG_MACRO_END + +// A void variant of the above. +#define PTHREAD_RETURN_VOID \ +CYG_MACRO_START \ + CYG_REPORT_RETURN(); \ + return; \ +CYG_MACRO_END + +// Check that a pointer passed in as an argument is valid and return +// EINVAL if it is not. This should be used to check pointers that are +// required to be valid. Pointers that may optionally be NULL should +// be checked within the function. +#define PTHREAD_CHECK(ptr) if( (ptr) == NULL ) PTHREAD_RETURN(EINVAL); + + +//============================================================================= +// Internal data structures + +// Mutex for controlling access to shared data structures +Cyg_Mutex pthread_mutex CYGBLD_POSIX_INIT; + +// Array of pthread control structures. A pthread_t object is +// "just" an index into this array. +static pthread_info *thread_table[CYGNUM_POSIX_PTHREAD_THREADS_MAX]; + +// Count of number of threads in table. +static int pthread_count = 0; + +// Count of number of threads that have exited and not been reaped. +static int pthreads_exited; + +// Count of number of threads that are waiting to be joined +static int pthreads_tobejoined; + +// Per-thread key allocation. This key map has a 1 bit set for each +// key that is free, zero if it is allocated. +#define KEY_MAP_TYPE cyg_uint32 +#define KEY_MAP_TYPE_SIZE (sizeof(KEY_MAP_TYPE)*8) // in BITS! +static KEY_MAP_TYPE thread_key[PTHREAD_KEYS_MAX/KEY_MAP_TYPE_SIZE]; +static void (*key_destructor[PTHREAD_KEYS_MAX]) (void *); + +// Index of next pthread_info to allocate from thread_table array. +static int thread_info_next = 0; + +// This is used to make pthread_t values unique even when reusing +// a table slot. This allows CYGNUM_POSIX_PTHREAD_THREADS_MAX to range +// up to 1024. +#define THREAD_ID_COOKIE_INC 0x00000400 +#define THREAD_ID_COOKIE_MASK (THREAD_ID_COOKIE_INC-1) +static pthread_t thread_id_cookie = THREAD_ID_COOKIE_INC; + +//----------------------------------------------------------------------------- +// Main thread. + +static char main_stack[CYGNUM_POSIX_MAIN_DEFAULT_STACK_SIZE]; + +// Thread ID of main thread. +static pthread_t main_thread; + +//============================================================================= +// Exported variables + +int pthread_canceled; // pointed to by PTHREAD_CANCELED + +//============================================================================= +// Internal functions + +//----------------------------------------------------------------------------- +// Private version of pthread_self() that returns a pointer to our internal +// control structure. + +pthread_info *pthread_self_info(void) +{ + Cyg_Thread *thread = Cyg_Thread::self(); + + CYG_CHECK_DATA_PTR(thread, "Illegal current thread"); + + pthread_info *info = (pthread_info *)thread->get_data(CYGNUM_KERNEL_THREADS_DATA_POSIX); + +// CYG_CHECK_DATA_PTR(info, "Not a POSIX thread!!!"); + + return info; +} + +externC pthread_info *pthread_info_id( pthread_t id ) +{ + pthread_t index = id & THREAD_ID_COOKIE_MASK; + + pthread_info *info = thread_table[index]; + + // Check for a valid entry + if( info == NULL ) + return NULL; + + // Check that this is a valid entry + if ( info->state == PTHREAD_STATE_FREE || + info->state == PTHREAD_STATE_EXITED ) + return NULL; + + // Check that the entry matches the id + if( info->id != id ) return NULL; + + // Return the pointer + return info; +} + +//----------------------------------------------------------------------------- +// new operator to allow us to invoke the Cyg_Thread constructor on the +// pthread_info.thread_obj array. + +inline void *operator new(size_t size, cyg_uint8 *ptr) { return (void *)ptr; }; + +//----------------------------------------------------------------------------- +// Optional memory allocation functions for pthread stacks. +// If there is an implementation of malloc() available, define pthread_malloc() +// and pthread_free() to use it. Otherwise define them to do nothing. +// In the future we may want to add configuration here to permit thread stacks +// to be allocated in a nominated memory pool separate from the standard malloc() +// pool. Hence the (currently redundant) encapsulation of these functions. + +#if CYGINT_ISO_MALLOC + +static __inline__ CYG_ADDRWORD pthread_malloc( CYG_ADDRWORD size ) +{ + return (CYG_ADDRWORD)malloc( size ); +} + +static __inline__ void pthread_free( CYG_ADDRWORD m ) +{ + free( (void *)m ); +} + +#define PTHREAD_MALLOC + +#else + +#define pthread_malloc(_x_) (0) + +#define pthread_free(_x_) + +#endif + +//----------------------------------------------------------------------------- +// pthread entry function. +// does some housekeeping and then calls the user's start routine. + +static void pthread_entry(CYG_ADDRWORD data) +{ + pthread_info *self = (pthread_info *)data; + + void *retval = self->start_routine(self->start_arg); + + pthread_exit( retval ); +} + +//----------------------------------------------------------------------------- +// Main entry function. +// This is set as the start_routine of the main thread. It invokes main() +// and if it returns, shuts down the system. + +externC void cyg_libc_invoke_main( void ); + +static void *call_main( void * ) +{ + cyg_libc_invoke_main(); + return NULL; // placate compiler +} + +//----------------------------------------------------------------------------- +// POSIX ASR +// This is installed as the ASR for all POSIX threads. + +static void posix_asr( CYG_ADDRWORD data ) +{ + pthread_info *self = (pthread_info *)data; + + // Call into timer subsystem to deliver any pending + // timer expirations. + cyg_posix_timer_asr(self); + + // Call signal subsystem to deliver any signals + cyg_posix_signal_asr(self); + + // Check for cancellation + if( self->cancelpending && + self->cancelstate == PTHREAD_CANCEL_ENABLE && + self->canceltype == PTHREAD_CANCEL_ASYNCHRONOUS ) + { + // If we have a pending cancellation, cancellations are + // enabled and we are in asynchronous mode, then we can do the + // cancellation processing. Since pthread_exit() does + // everything we need to do, we just call that here. + + pthread_exit(PTHREAD_CANCELED); + } +} + +//----------------------------------------------------------------------------- +// The (Grim) Reaper. +// This function is called to tidy up and dispose of any threads that have +// exited. This work must be done from a thread other than the one exiting. +// Note: this function _must_ be called with pthread_mutex locked. + +static void pthread_reap() +{ + int i; + + // Loop over the thread table looking for exited threads. The + // pthreads_exited counter springs us out of this once we have + // found then all (and keeps us out if there are none to do). + + for( i = 0; pthreads_exited && i < CYGNUM_POSIX_PTHREAD_THREADS_MAX ; i++ ) + { + pthread_info *thread = thread_table[i]; + + if( thread != NULL && thread->state == PTHREAD_STATE_EXITED ) + { + // The thread has exited, so it is a candidate for being + // reaped. We have to make sure that the eCos thread has + // also reached EXITED state before we can tidy it up. + + while( thread->thread->get_state() != Cyg_Thread::EXITED ) + { + // The eCos thread has not yet exited. This is + // probably because its priority is too low to allow + // it to complete. We fix this here by raising its + // priority to equal ours and then yielding. This + // should eventually get it into exited state. + + Cyg_Thread *self = Cyg_Thread::self(); + + // Set thread's priority to our current dispatching priority. + thread->thread->set_priority( self->get_current_priority() ); + + // Yield, yield + self->yield(); + + // and keep looping until he exits. + } + + // At this point we have a thread that we can reap. + + // destroy the eCos thread + thread->thread->~Cyg_Thread(); + + // destroy the joiner condvar + thread->joiner->~Cyg_Condition_Variable(); + + // Destroy signal handling fields + cyg_posix_thread_sigdestroy( thread ); + + // Free the stack if we allocated it + if( thread->freestack ) + pthread_free( thread->stackmem ); + + // Finally, set the thread table entry to NULL so that it + // may be reused. + thread_table[i] = NULL; + + pthread_count--; + pthreads_exited--; + } + } +} + +//============================================================================= +// Functions exported to rest of POSIX subsystem. + +//----------------------------------------------------------------------------- +// Create the main() thread. + +externC void cyg_posix_pthread_start( void ) +{ + + // Initialize the per-thread data key map. + + for( cyg_ucount32 i = 0; i < (PTHREAD_KEYS_MAX/KEY_MAP_TYPE_SIZE); i++ ) + { + thread_key[i] = ~0; + } + + // Create the main thread + pthread_attr_t attr; + struct sched_param schedparam; + + schedparam.sched_priority = CYGNUM_POSIX_MAIN_DEFAULT_PRIORITY; + + pthread_attr_init( &attr ); + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setstackaddr( &attr, &main_stack[CYGNUM_POSIX_MAIN_DEFAULT_STACK_SIZE] ); + pthread_attr_setstacksize( &attr, CYGNUM_POSIX_MAIN_DEFAULT_STACK_SIZE ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + pthread_attr_setschedparam( &attr, &schedparam ); + + pthread_create( &main_thread, &attr, call_main, NULL ); +} + +//----------------------------------------------------------------------------- +// Look for a thread that can accept delivery of any of the signals in +// the mask and release it from any wait it is in. Since this may be +// called from a DSR, it cannot use any locks internally - any locking +// should be done before the call. + +externC void cyg_posix_pthread_release_thread( sigset_t *mask ) +{ + int i; + int count = pthread_count; + + // Loop over the thread table looking for a thread that has a + // signal mask that does not mask all the signals in mask. + // FIXME: find a more efficient way of doing this. + + for( i = 0; count > 0 && i < CYGNUM_POSIX_PTHREAD_THREADS_MAX ; i++ ) + { + pthread_info *thread = thread_table[i]; + + if( (thread != NULL) && + (thread->state == PTHREAD_STATE_RUNNING) && + ((*mask & ~thread->sigmask) != 0) ) + { + // This thread can service at least one of the signals in + // *mask. Knock it out of its wait and make its ASR pending. + + thread->thread->set_asr_pending(); + thread->thread->release(); + break; + } + + if( thread->state != PTHREAD_STATE_FREE ) + count--; + } +} + +//============================================================================= +// General thread operations + +//----------------------------------------------------------------------------- +// Thread creation and management. + +// Create a thread. +externC int pthread_create ( pthread_t *thread, + const pthread_attr_t *attr, + void *(*start_routine) (void *), + void *arg) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(thread); + PTHREAD_CHECK(start_routine); + + pthread_info *self = pthread_self_info(); + + pthread_attr_t use_attr; + + // Set use_attr to the set of attributes we are going to + // actually use. Either those passed in, or the default set. + + if( attr == NULL ) + pthread_attr_init( &use_attr ); + else use_attr = *attr; + + // Adjust the attributes to cope with the setting of inheritsched. + + if( use_attr.inheritsched == PTHREAD_INHERIT_SCHED ) + { + use_attr.schedpolicy = self->attr.schedpolicy; + use_attr.schedparam = self->attr.schedparam; + } + + CYG_ADDRWORD stackbase, stacksize; + cyg_bool freestack = false; + CYG_ADDRWORD stackmem = 0; + + // If the stack size is not valid, we can assume that it is at + // least PTHREAD_STACK_MIN bytes. + + if( use_attr.stacksize_valid ) + stacksize = use_attr.stacksize; + else stacksize = PTHREAD_STACK_MIN; + + if( use_attr.stackaddr_valid ) + { + // Set up stack base and size from supplied arguments. + + // Calculate stack base from address and size. + // FIXME: Falling stack assumed in pthread_create(). + stackmem = stackbase = (CYG_ADDRWORD)use_attr.stackaddr-stacksize; + } + else + { +#ifdef PTHREAD_MALLOC + + stackmem = stackbase = pthread_malloc( stacksize ); + + if( stackmem == 0 ) + PTHREAD_RETURN( EAGAIN ); + + freestack = true; +#else + PTHREAD_RETURN(EINVAL); +#endif + + } + + // Get sole access to data structures + + pthread_mutex.lock(); + + // Dispose of any dead threads + pthread_reap(); + + // Find a free slot in the thread table + + pthread_info *nthread; + int thread_next = thread_info_next; + + while( thread_table[thread_next] != NULL ) + { + thread_next++; + if( thread_next >= CYGNUM_POSIX_PTHREAD_THREADS_MAX ) + thread_next = 0; + + // check for wrap, and return error if no slots left + if( thread_next == thread_info_next ) + { + pthread_mutex.unlock(); + if( freestack ) + pthread_free( stackmem ); + PTHREAD_RETURN(ENOMEM); + } + } + + nthread = (pthread_info *)stackbase; + + stackbase += sizeof(pthread_info); + stacksize -= sizeof(pthread_info); + + thread_table[thread_next] = nthread; + + // Set new next index + thread_info_next = thread_next; + + // step the cookie + thread_id_cookie += THREAD_ID_COOKIE_INC; + + // Initialize the table entry + nthread->state = use_attr.detachstate == PTHREAD_CREATE_JOINABLE ? + PTHREAD_STATE_RUNNING : PTHREAD_STATE_DETACHED; + nthread->id = thread_next+thread_id_cookie; + nthread->attr = use_attr; + nthread->retval = 0; + nthread->start_routine = start_routine; + nthread->start_arg = arg; + + nthread->freestack = freestack; + nthread->stackmem = stackmem; + + nthread->cancelstate = PTHREAD_CANCEL_ENABLE; + nthread->canceltype = PTHREAD_CANCEL_DEFERRED; + nthread->cancelbuffer = NULL; + nthread->cancelpending = false; + + nthread->thread_data = NULL; + +#ifdef CYGVAR_KERNEL_THREADS_NAME + // generate a name for this thread + + char *name = nthread->name; + static char *name_template = "pthread.00000000"; + pthread_t id = nthread->id; + + for( int i = 0; name_template[i]; i++ ) name[i] = name_template[i]; + + // dump the id, in hex into the name. + for( int i = 15; i >= 8; i-- ) + { + name[i] = "0123456789ABCDEF"[id&0xF]; + id >>= 4; + } + +#endif + + // Initialize the joiner condition variable + + nthread->joiner = new(nthread->joiner_obj) Cyg_Condition_Variable( pthread_mutex ); + + // Initialize signal specific fields. + cyg_posix_thread_siginit( nthread ); + + // create the underlying eCos thread + + nthread->thread = new(&nthread->thread_obj[0]) + Cyg_Thread ( PTHREAD_ECOS_PRIORITY(use_attr.schedparam.sched_priority), + pthread_entry, + (CYG_ADDRWORD)nthread, + name, + stackbase, + stacksize); + + // Put pointer to pthread_info into eCos thread's per-thread data. + nthread->thread->set_data( CYGNUM_KERNEL_THREADS_DATA_POSIX, (CYG_ADDRWORD)nthread ); + + // Set timeslice enable according to scheduling policy. + if( use_attr.schedpolicy == SCHED_FIFO ) + nthread->thread->timeslice_disable(); + else nthread->thread->timeslice_enable(); + + // set up ASR and data + nthread->thread->set_asr( posix_asr, (CYG_ADDRWORD)nthread, NULL, NULL ); + + // return thread ID + *thread = nthread->id; + + pthread_count++; + + pthread_mutex.unlock(); + + // finally, set the thread going + nthread->thread->resume(); + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Get current thread id. + +externC pthread_t pthread_self ( void ) +{ + PTHREAD_ENTRY(); + + pthread_info *info = pthread_self_info(); + + CYG_CHECK_DATA_PTR(info, "Not a POSIX thread!!!"); + + return info->id; +} + +//----------------------------------------------------------------------------- +// Compare two thread identifiers. + +externC int pthread_equal (pthread_t thread1, pthread_t thread2) +{ + PTHREAD_ENTRY(); + + return thread1 == thread2; +} + +//----------------------------------------------------------------------------- +// Terminate current thread. + +externC void exit(int) CYGBLD_ATTRIB_NORET; + +externC void pthread_exit (void *retval) +{ + PTHREAD_ENTRY(); + + pthread_info *self = pthread_self_info(); + + // Call cancellation handlers. We eat up the buffers as we go in + // case any of the routines calls pthread_exit() itself. + while( self->cancelbuffer != NULL ) + { + struct pthread_cleanup_buffer *buffer = self->cancelbuffer; + + self->cancelbuffer = buffer->prev; + + buffer->routine(buffer->arg); + } + + if( self->thread_data != NULL ) + { + // Call per-thread key destructors. + // The specification of this is that we must continue to call the + // destructor functions until all the per-thread data values are NULL or + // we have done it PTHREAD_DESTRUCTOR_ITERATIONS times. + + cyg_bool destructors_called; + int destructor_iterations = 0; + + do + { + destructors_called = false; + + for( cyg_ucount32 key = 0; key < PTHREAD_KEYS_MAX; key++ ) + { + // Skip unallocated keys + if( thread_key[key/KEY_MAP_TYPE_SIZE] & 1<<(key%KEY_MAP_TYPE_SIZE) ) + continue; + + // Skip NULL destructors + if( key_destructor[key] == NULL ) continue; + + // Skip NULL data values + if( self->thread_data[key] == NULL ) continue; + + // If it passes all that, call the destructor + key_destructor[key]((void *)(self->thread_data[key])); + + // Record that we called a destructor + destructors_called = true; + } + + // Count the iteration + destructor_iterations++; + + } while( destructors_called && + (destructor_iterations <= PTHREAD_DESTRUCTOR_ITERATIONS)); + + } + + pthread_mutex.lock(); + + // Set the retval for any joiner + self->retval = retval; + + // If we are already detached, go to EXITED state, otherwise + // go into JOIN state. + + if ( PTHREAD_STATE_DETACHED == self->state ) { + self->state = PTHREAD_STATE_EXITED; + pthreads_exited++; + } else { + self->state = PTHREAD_STATE_JOIN; + pthreads_tobejoined++; + } + + // Kick any waiting joiners + self->joiner->broadcast(); + + cyg_bool call_exit=false; + + // if this is the last thread (other than threads waiting to be joined) + // then we need to call exit() later + if ( pthreads_exited + pthreads_tobejoined == pthread_count ) + call_exit=true; + + pthread_mutex.unlock(); + + // Finally, call the exit function; this will not return. + if ( call_exit ) + ::exit(0); + else + self->thread->exit(); + + // This loop keeps some compilers happy. pthread_exit() is marked + // with the noreturn attribute, and without this they generate a + // call to abort() here in case Cyg_Thread::exit() returns. + + for(;;) continue; +} + +//----------------------------------------------------------------------------- +// Wait for the thread to terminate. If thread_return is not NULL then +// the retval from the thread's call to pthread_exit() is stored at +// *thread_return. + +externC int pthread_join (pthread_t thread, void **thread_return) +{ + PTHREAD_ENTRY(); + + pthread_mutex.lock(); + + // Dispose of any dead threads + pthread_reap(); + + pthread_info *self = pthread_self_info(); + pthread_info *joinee = pthread_info_id( thread ); + + if( joinee == NULL ) + { + pthread_mutex.unlock(); + PTHREAD_RETURN(ESRCH); + } + + if( joinee == self ) + { + pthread_mutex.unlock(); + PTHREAD_RETURN(EDEADLK); + } + + switch ( joinee->state ) + { + case PTHREAD_STATE_RUNNING: + // The thread is still running, we must wait for it. + while( joinee->state == PTHREAD_STATE_RUNNING ) + joinee->joiner->wait(); + + // check that the thread is still joinable + if( joinee->state == PTHREAD_STATE_JOIN ) + break; + + // The thread has become unjoinable while we waited, so we + // fall through to complain. + + case PTHREAD_STATE_FREE: + case PTHREAD_STATE_DETACHED: + case PTHREAD_STATE_EXITED: + // None of these may be joined. + pthread_mutex.unlock(); + PTHREAD_RETURN(EINVAL); + + case PTHREAD_STATE_JOIN: + break; + } + + // here, we know that joinee is a thread that has exited and is + // ready to be joined. + + // Get the retval + + if( thread_return != NULL ) + *thread_return = joinee->retval; + + // set state to exited. + joinee->state = PTHREAD_STATE_EXITED; + pthreads_exited++; + pthreads_tobejoined--; + + // Dispose of any dead threads + pthread_reap(); + + pthread_mutex.unlock(); + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Set the detachstate of the thread to "detached". The thread then does not +// need to be joined and its resources will be freed when it exits. + +externC int pthread_detach (pthread_t thread) +{ + PTHREAD_ENTRY(); + + int ret = 0; + + pthread_mutex.lock(); + + pthread_info *detachee = pthread_info_id( thread ); + + if( detachee == NULL ) + ret = ESRCH; // No such thread + else if( detachee->state == PTHREAD_STATE_DETACHED ) + ret = EINVAL; // Already detached! + else + { + // Set state to detached and kick any joinees to + // make them return. + detachee->state = PTHREAD_STATE_DETACHED; + detachee->joiner->broadcast(); + } + + // Dispose of any dead threads + pthread_reap(); + + pthread_mutex.unlock(); + + PTHREAD_RETURN(ret); +} + + +//----------------------------------------------------------------------------- +// Thread attribute handling. + +//----------------------------------------------------------------------------- +// Initialize attributes object with default attributes: +// detachstate == PTHREAD_CREATE_JOINABLE +// scope == PTHREAD_SCOPE_SYSTEM +// inheritsched == PTHREAD_INHERIT_SCHED +// schedpolicy == SCHED_OTHER +// schedparam == unset +// stackaddr == unset +// stacksize == 0 +// + +externC int pthread_attr_init (pthread_attr_t *attr) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + attr->detachstate = PTHREAD_CREATE_JOINABLE; + attr->scope = PTHREAD_SCOPE_SYSTEM; + attr->inheritsched = PTHREAD_INHERIT_SCHED; + attr->schedpolicy = SCHED_OTHER; + attr->schedparam.sched_priority = 0; + attr->stackaddr_valid = 0; + attr->stackaddr = NULL; + attr->stacksize_valid = 0; + attr->stacksize = 0; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Destroy thread attributes object + +externC int pthread_attr_destroy (pthread_attr_t *attr) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + // Nothing to do here... + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Set the detachstate attribute + +externC int pthread_attr_setdetachstate (pthread_attr_t *attr, + int detachstate) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( detachstate == PTHREAD_CREATE_JOINABLE || + detachstate == PTHREAD_CREATE_DETACHED ) + { + attr->detachstate = detachstate; + PTHREAD_RETURN(0); + } + + PTHREAD_RETURN(EINVAL); +} + +//----------------------------------------------------------------------------- +// Get the detachstate attribute +externC int pthread_attr_getdetachstate (const pthread_attr_t *attr, + int *detachstate) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( detachstate != NULL ) + *detachstate = attr->detachstate; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Set scheduling contention scope + +externC int pthread_attr_setscope (pthread_attr_t *attr, int scope) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( scope == PTHREAD_SCOPE_SYSTEM || + scope == PTHREAD_SCOPE_PROCESS ) + { + if( scope == PTHREAD_SCOPE_PROCESS ) + PTHREAD_RETURN(ENOTSUP); + + attr->scope = scope; + + PTHREAD_RETURN(0); + } + + PTHREAD_RETURN(EINVAL); +} + +//----------------------------------------------------------------------------- +// Get scheduling contention scope + +externC int pthread_attr_getscope (const pthread_attr_t *attr, int *scope) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( scope != NULL ) + *scope = attr->scope; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Set scheduling inheritance attribute + +externC int pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( inherit == PTHREAD_INHERIT_SCHED || + inherit == PTHREAD_EXPLICIT_SCHED ) + { + attr->inheritsched = inherit; + + PTHREAD_RETURN(0); + } + + PTHREAD_RETURN(EINVAL); +} + +//----------------------------------------------------------------------------- +// Get scheduling inheritance attribute + +externC int pthread_attr_getinheritsched (const pthread_attr_t *attr, + int *inherit) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( inherit != NULL ) + *inherit = attr->inheritsched; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Set scheduling policy + +externC int pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( policy == SCHED_OTHER || + policy == SCHED_FIFO || + policy == SCHED_RR ) + { + attr->schedpolicy = policy; + + PTHREAD_RETURN(0); + } + + PTHREAD_RETURN(EINVAL); +} + +//----------------------------------------------------------------------------- +// Get scheduling policy + +externC int pthread_attr_getschedpolicy (const pthread_attr_t *attr, + int *policy) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( policy != NULL ) + *policy = attr->schedpolicy; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Set scheduling parameters +externC int pthread_attr_setschedparam (pthread_attr_t *attr, + const struct sched_param *param) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + PTHREAD_CHECK(param); + + attr->schedparam = *param; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Get scheduling parameters + +externC int pthread_attr_getschedparam (const pthread_attr_t *attr, + struct sched_param *param) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( param != NULL ) + *param = attr->schedparam; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Set starting address of stack. Whether this is at the start or end of +// the memory block allocated for the stack depends on whether the stack +// grows up or down. + +externC int pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + attr->stackaddr = stackaddr; + attr->stackaddr_valid = 1; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Get any previously set stack address. + +externC int pthread_attr_getstackaddr (const pthread_attr_t *attr, + void **stackaddr) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( stackaddr != NULL ) + { + if( attr->stackaddr_valid ) + { + *stackaddr = attr->stackaddr; + PTHREAD_RETURN(0); + } + // Stack address not set, return EINVAL. + else PTHREAD_RETURN(EINVAL); + } + + PTHREAD_RETURN(0); +} + + +//----------------------------------------------------------------------------- +// Set minimum creation stack size. + +externC int pthread_attr_setstacksize (pthread_attr_t *attr, + size_t stacksize) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + CYG_ASSERT( stacksize > PTHREAD_STACK_MIN, "Inadequate stack size supplied"); + + // Reject inadequate stack sizes + if( stacksize < PTHREAD_STACK_MIN ) + PTHREAD_RETURN(EINVAL); + + attr->stacksize_valid = 1; + attr->stacksize = stacksize; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Get current minimal stack size. + +externC int pthread_attr_getstacksize (const pthread_attr_t *attr, + size_t *stacksize) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + // Reject attempts to get a stack size when one has not been set. + if( !attr->stacksize_valid ) + PTHREAD_RETURN(EINVAL); + + if( stacksize != NULL ) + *stacksize = attr->stacksize; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Thread scheduling controls + +//----------------------------------------------------------------------------- +// Set scheduling policy and parameters for the thread + +externC int pthread_setschedparam (pthread_t thread_id, + int policy, + const struct sched_param *param) +{ + PTHREAD_ENTRY(); + + if( policy != SCHED_OTHER && + policy != SCHED_FIFO && + policy != SCHED_RR ) + PTHREAD_RETURN(EINVAL); + + PTHREAD_CHECK(param); + + // The parameters seem OK, change the thread... + + pthread_mutex.lock(); + + pthread_info *thread = pthread_info_id( thread_id ); + + if( thread == NULL ) + { + pthread_mutex.unlock(); + PTHREAD_RETURN(ESRCH); + } + + thread->attr.schedpolicy = policy; + thread->attr.schedparam = *param; + + if ( policy == SCHED_FIFO ) + thread->thread->timeslice_disable(); + else thread->thread->timeslice_enable(); + + thread->thread->set_priority( PTHREAD_ECOS_PRIORITY( param->sched_priority )); + + pthread_mutex.unlock(); + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Get scheduling policy and parameters for the thread + +externC int pthread_getschedparam (pthread_t thread_id, + int *policy, + struct sched_param *param) +{ + PTHREAD_ENTRY(); + + pthread_mutex.lock(); + + pthread_info *thread = pthread_info_id( thread_id ); + + if( thread == NULL ) + { + pthread_mutex.unlock(); + PTHREAD_RETURN(ESRCH); + } + + if( policy != NULL ) + *policy = thread->attr.schedpolicy; + + if( param != NULL ) + *param = thread->attr.schedparam; + + pthread_mutex.unlock(); + + PTHREAD_RETURN(0); +} + + +//============================================================================= +// Mutexes + +//----------------------------------------------------------------------------- +// Mutex attributes manipulation functions + +//----------------------------------------------------------------------------- +// Initialize attribute object + +externC int pthread_mutexattr_init ( pthread_mutexattr_t *attr) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + attr->protocol = PTHREAD_PRIO_NONE; + attr->prioceiling = 0; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Destroy attribute object + +externC int pthread_mutexattr_destroy ( pthread_mutexattr_t *attr) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + // Nothing to do here... + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Optional functions depending on priority inversion protection options. + +#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) + +// Set priority inversion protection protocol +externC int pthread_mutexattr_setprotocol ( pthread_mutexattr_t *attr, + int protocol) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + switch( protocol ) + { + case PTHREAD_PRIO_NONE: +#if defined(_POSIX_THREAD_PRIO_INHERIT) + case PTHREAD_PRIO_INHERIT: +#endif +#if defined(_POSIX_THREAD_PRIO_PROTECT) + case PTHREAD_PRIO_PROTECT: +#endif + attr->protocol = protocol; + PTHREAD_RETURN(0); + + default: + PTHREAD_RETURN(EINVAL); + } + + PTHREAD_RETURN(0); +} + +// Get priority inversion protection protocol +externC int pthread_mutexattr_getprotocol ( pthread_mutexattr_t *attr, + int *protocol) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( protocol != NULL ) + *protocol = attr->protocol; + + PTHREAD_RETURN(0); +} + +#if defined(_POSIX_THREAD_PRIO_PROTECT) + +// Set priority for priority ceiling protocol +externC int pthread_mutexattr_setprioceiling ( pthread_mutexattr_t *attr, + int prioceiling) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + + attr->prioceiling = prioceiling; + + PTHREAD_RETURN(0); +} + +// Get priority for priority ceiling protocol +externC int pthread_mutexattr_getprioceiling ( pthread_mutexattr_t *attr, + int *prioceiling) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + if( prioceiling != NULL ) + *prioceiling = attr->prioceiling; + + PTHREAD_RETURN(0); +} + +// Set priority ceiling of given mutex, returning old ceiling. +externC int pthread_mutex_setprioceiling( pthread_mutex_t *mutex, + int prioceiling, + int *old_ceiling) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(mutex); + + pthread_mutex_lock( mutex ); + + Cyg_Mutex *mx = (Cyg_Mutex *)mutex; + + if( old_ceiling != NULL ) + *old_ceiling = mx->get_ceiling(); + + mx->set_ceiling( prioceiling ); + + pthread_mutex_unlock( mutex ); + + PTHREAD_RETURN(0); +} + +// Get priority ceiling of given mutex +externC int pthread_mutex_getprioceiling( pthread_mutex_t *mutex, + int *prioceiling) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(mutex); + + Cyg_Mutex *mx = (Cyg_Mutex *)mutex; + + if( prioceiling != NULL ) + *prioceiling = mx->get_ceiling(); + + PTHREAD_RETURN(0); +} + +#endif // defined(_POSIX_THREAD_PRIO_PROTECT) + +#endif // defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) + +//----------------------------------------------------------------------------- +// Mutex functions + +//----------------------------------------------------------------------------- +// Initialize mutex. If mutex_attr is NULL, use default attributes. + +externC int pthread_mutex_init (pthread_mutex_t *mutex, + const pthread_mutexattr_t *mutex_attr) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK( mutex ); + + pthread_mutexattr_t use_attr; + + // Set up the attributes we are going to use + if( mutex_attr == NULL ) + pthread_mutexattr_init( &use_attr ); + else use_attr = *mutex_attr; + + // Now translate the POSIX protocol identifier into the eCos one. + Cyg_Mutex::cyg_protcol protocol; + + switch( use_attr.protocol ) + { +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + case PTHREAD_PRIO_PROTECT: + protocol = Cyg_Mutex::CEILING; + break; +#endif +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT + case PTHREAD_PRIO_INHERIT: + protocol = Cyg_Mutex::INHERIT; + break; +#endif + case PTHREAD_PRIO_NONE: + protocol = Cyg_Mutex::NONE; + break; + + default: + PTHREAD_RETURN(EINVAL); + } + + Cyg_Mutex *mx = new((cyg_uint8 *)mutex) Cyg_Mutex( protocol ); + + if ( protocol == Cyg_Mutex::CEILING ) + mx->set_ceiling( use_attr.prioceiling ); + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Destroy mutex. + +externC int pthread_mutex_destroy (pthread_mutex_t *mutex) +{ + PTHREAD_ENTRY(); + + int err = ENOERR; + + PTHREAD_CHECK( mutex ); + + Cyg_Mutex *mx = (Cyg_Mutex *)mutex; + + if( mx->get_owner() != NULL ) + err = EBUSY; + else mx->~Cyg_Mutex(); + + PTHREAD_RETURN(err); +} + +//----------------------------------------------------------------------------- +// Lock mutex, waiting for it if necessary. + +externC int pthread_mutex_lock (pthread_mutex_t *mutex) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK( mutex ); + + Cyg_Mutex *mx = (Cyg_Mutex *)mutex; + + if( mx->get_owner() == Cyg_Thread::self() ) + PTHREAD_RETURN(EDEADLK); + + // Loop here until we acquire the mutex. Even if we are kicked out + // of the wait by a signal or release we must retry. + while( !mx->lock() ) + continue; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Try to lock mutex. + +externC int pthread_mutex_trylock (pthread_mutex_t *mutex) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK( mutex ); + + Cyg_Mutex *mx = (Cyg_Mutex *)mutex; + + if( mx->get_owner() == Cyg_Thread::self() ) + PTHREAD_RETURN(EDEADLK); + + if( mx->trylock() ) + PTHREAD_RETURN(0); + + PTHREAD_RETURN(EBUSY); +} + + +//----------------------------------------------------------------------------- +// Unlock mutex. + +externC int pthread_mutex_unlock (pthread_mutex_t *mutex) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK( mutex ); + + Cyg_Mutex *mx = (Cyg_Mutex *)mutex; + + mx->unlock(); + + PTHREAD_RETURN(0); +} + + +//============================================================================= +// Condition Variables + +//----------------------------------------------------------------------------- +// Attribute manipulation functions +// We do not actually support any attributes at present, so these do nothing. + +//----------------------------------------------------------------------------- +// Initialize condition variable attributes + +externC int pthread_condattr_init (pthread_condattr_t *attr) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + // There are no condition variable attributes at present + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Destroy condition variable attributes + +externC int pthread_condattr_destroy (pthread_condattr_t *attr) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK(attr); + + // nothing to do here... + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Condition variable functions + +//----------------------------------------------------------------------------- +// Initialize condition variable. + +externC int pthread_cond_init (pthread_cond_t *cond, + const pthread_condattr_t *attr) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK( cond ); + + Cyg_Condition_Variable *cv = + new((cyg_uint8 *)cond) Cyg_Condition_Variable(); + + cv = cv; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Destroy condition variable. + +externC int pthread_cond_destroy (pthread_cond_t *cond) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK( cond ); + + ((Cyg_Condition_Variable *)cond)->~Cyg_Condition_Variable(); + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Wake up one thread waiting for condition variable + +externC int pthread_cond_signal (pthread_cond_t *cond) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK( cond ); + + ((Cyg_Condition_Variable *)cond)->signal(); + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Wake up all threads waiting for condition variable + +externC int pthread_cond_broadcast (pthread_cond_t *cond) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK( cond ); + + ((Cyg_Condition_Variable *)cond)->broadcast(); + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Block on condition variable until signalled. The mutex is +// assumed to be locked before this call, will be unlocked +// during the wait, and will be re-locked on wakeup. + +externC int pthread_cond_wait (pthread_cond_t *cond, + pthread_mutex_t *mutex) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK( cond ); + PTHREAD_CHECK( mutex ); + + ((Cyg_Condition_Variable *)cond)->wait( *(Cyg_Mutex *)mutex ); + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Block on condition variable until signalled, or the timeout expires. + +externC int pthread_cond_timedwait (pthread_cond_t *cond, + pthread_mutex_t *mutex, + const struct timespec *abstime) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK( cond ); + PTHREAD_CHECK( mutex ); + PTHREAD_CHECK( abstime ); + + cyg_tick_count ticks; + struct Cyg_Clock::converter ns_converter, sec_converter; + + Cyg_Clock::real_time_clock->get_other_to_clock_converter( 1, &ns_converter ); + Cyg_Clock::real_time_clock->get_other_to_clock_converter( 1000000000, &sec_converter ); + + ticks = Cyg_Clock::convert( abstime->tv_sec, &sec_converter ); + ticks += Cyg_Clock::convert( abstime->tv_nsec, &ns_converter ); + + ((Cyg_Condition_Variable *)cond)->wait( *(Cyg_Mutex *)mutex, ticks ); + + PTHREAD_RETURN(0); +} + +//============================================================================= +// Dynamic package initialization +// Call init_routine just the once per control variable. + +externC int pthread_once (pthread_once_t *once_control, + void (*init_routine) (void)) +{ + PTHREAD_ENTRY(); + + PTHREAD_CHECK( once_control ); + PTHREAD_CHECK( init_routine ); + + pthread_once_t old; + + // Do a test and set on the once_control object. + pthread_mutex.lock(); + + old = *once_control; + *once_control = 1; + + pthread_mutex.unlock(); + + // If the once_control was zero, call the init_routine(). + if( !old ) init_routine(); + + PTHREAD_RETURN(0); +} + + +//============================================================================= +//Thread specific data + +//----------------------------------------------------------------------------- +// Create a key to identify a location in the thread specific data area. +// Each thread has its own distinct thread-specific data area but all are +// addressed by the same keys. The destructor function is called whenever a +// thread exits and the value associated with the key is non-NULL. + +externC int pthread_key_create (pthread_key_t *key, + void (*destructor) (void *)) +{ + PTHREAD_ENTRY(); + + pthread_key_t k = -1; + + pthread_mutex.lock(); + + // Find a key to allocate + for( cyg_ucount32 i = 0; i < (PTHREAD_KEYS_MAX/KEY_MAP_TYPE_SIZE); i++ ) + { + if( thread_key[i] != 0 ) + { + // We have a table slot with space available + + // Get index of ls set bit. + HAL_LSBIT_INDEX( k, thread_key[i] ); + + // clear it + thread_key[i] &= ~(1<thread_data != NULL ) + thread->thread_data[k] = NULL; + } + } + + pthread_mutex.unlock(); + + if( k == -1 ) PTHREAD_RETURN(EAGAIN); + + *key = k; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Delete key. + +externC int pthread_key_delete (pthread_key_t key) +{ + PTHREAD_ENTRY(); + + pthread_mutex.lock(); + + // Set the key bit to 1 to indicate it is free. + thread_key[key/KEY_MAP_TYPE_SIZE] |= 1<<(key%(KEY_MAP_TYPE_SIZE)); + + pthread_mutex.unlock(); + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Store the pointer value in the thread-specific data slot addressed +// by the key. + +externC int pthread_setspecific (pthread_key_t key, const void *pointer) +{ + PTHREAD_ENTRY(); + + if( thread_key[key/KEY_MAP_TYPE_SIZE] & 1<<(key%KEY_MAP_TYPE_SIZE) ) + PTHREAD_RETURN(EINVAL); + + pthread_info *self = pthread_self_info(); + + if( self->thread_data == NULL ) + { + // Allocate the per-thread data table + self->thread_data = + (void **)self->thread->increment_stack_limit( + PTHREAD_KEYS_MAX * sizeof(void *) ); + + // Clear out all entries + for( int i = 0; i < PTHREAD_KEYS_MAX; i++ ) + self->thread_data[i] = NULL; + } + + self->thread_data[key] = (void *)pointer; + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Retrieve the pointer value in the thread-specific data slot addressed +// by the key. + +externC void *pthread_getspecific (pthread_key_t key) +{ + void *val; + PTHREAD_ENTRY(); + + if( thread_key[key/KEY_MAP_TYPE_SIZE] & 1<<(key%KEY_MAP_TYPE_SIZE) ) + PTHREAD_RETURN(NULL); + + pthread_info *self = pthread_self_info(); + + if( self->thread_data == NULL ) + val = NULL; + else val = self->thread_data[key]; + + PTHREAD_RETURN(val); +} + +//============================================================================= +// Thread Cancellation Functions + +//----------------------------------------------------------------------------- +// Set cancel state of current thread to ENABLE or DISABLE. +// Returns old state in *oldstate. + +externC int pthread_setcancelstate (int state, int *oldstate) +{ + PTHREAD_ENTRY(); + + if( state != PTHREAD_CANCEL_ENABLE && + state != PTHREAD_CANCEL_DISABLE ) + PTHREAD_RETURN(EINVAL); + + pthread_mutex.lock(); + + pthread_info *self = pthread_self_info(); + + if( oldstate != NULL ) *oldstate = self->cancelstate; + + self->cancelstate = state; + + pthread_mutex.unlock(); + + // Note: This function may have made it possible for a pending + // cancellation to now be delivered. However the standard does not + // list this function as a cancellation point, so for now we do + // nothing. In future we might call pthread_testcancel() here. + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Set cancel type of current thread to ASYNCHRONOUS or DEFERRED. +// Returns old type in *oldtype. + +externC int pthread_setcanceltype (int type, int *oldtype) +{ + PTHREAD_ENTRY(); + + if( type != PTHREAD_CANCEL_ASYNCHRONOUS && + type != PTHREAD_CANCEL_DEFERRED ) + PTHREAD_RETURN(EINVAL); + + pthread_mutex.lock(); + + pthread_info *self = pthread_self_info(); + + if( oldtype != NULL ) *oldtype = self->canceltype; + + self->canceltype = type; + + pthread_mutex.unlock(); + + // Note: This function may have made it possible for a pending + // cancellation to now be delivered. However the standard does not + // list this function as a cancellation point, so for now we do + // nothing. In future we might call pthread_testcancel() here. + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Cancel the thread. + +externC int pthread_cancel (pthread_t thread) +{ + PTHREAD_ENTRY(); + + pthread_mutex.lock(); + + pthread_info *th = pthread_info_id(thread); + + if( th == NULL ) + { + pthread_mutex.unlock(); + PTHREAD_RETURN(ESRCH); + } + + th->cancelpending = true; + + if( th->cancelstate == PTHREAD_CANCEL_ENABLE && + th->canceltype == PTHREAD_CANCEL_ASYNCHRONOUS ) + { + // If the thread has cancellation enabled, and it is in + // asynchronous mode, set the eCos thread's ASR pending to + // deal with it when the thread wakes up. We also release the + // thread out of any current wait to make it wake up. + + th->thread->set_asr_pending(); + th->thread->release(); + } + // Otherwise the thread either has cancellation disabled, or is + // in deferred mode. In either case it is up to the thread to + // get into a state to deal with the pending cancellation. + + pthread_mutex.unlock(); + + + PTHREAD_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Test for a pending cancellation for the current thread and terminate +// the thread if there is one. + +externC void pthread_testcancel (void) +{ + PTHREAD_ENTRY_VOID(); + + pthread_info *self = pthread_self_info(); + + // Check whether there is a cancel pending and if so, whether + // cancellations are enabled. We do it in this order to reduce the + // number of tests in the common case - when no cancellations are + // pending. + + if( self->cancelpending && + self->cancelstate == PTHREAD_CANCEL_ENABLE ) + + { + // If we have cancellation enabled, and there is a cancellation + // pending, then go ahead and do the deed. + + // Exit now with special retval. pthread_exit() calls the + // cancellation handlers implicitly. + pthread_exit(PTHREAD_CANCELED); + } + + PTHREAD_RETURN_VOID; +} + +//----------------------------------------------------------------------------- +// These two functions actually implement the cleanup push and pop functionality. + +externC void pthread_cleanup_push_inner (struct pthread_cleanup_buffer *buffer, + void (*routine) (void *), + void *arg) +{ + PTHREAD_ENTRY(); + + pthread_info *self = pthread_self_info(); + + buffer->routine = routine; + buffer->arg = arg; + + buffer->prev = self->cancelbuffer; + + self->cancelbuffer = buffer; + + return; +} + +externC void pthread_cleanup_pop_inner (struct pthread_cleanup_buffer *buffer, + int execute) +{ + PTHREAD_ENTRY(); + + pthread_info *self = pthread_self_info(); + + CYG_ASSERT( self->cancelbuffer == buffer, "Stacking error in cleanup buffers"); + + if( self->cancelbuffer == buffer ) + { + // Remove the buffer from the stack + self->cancelbuffer = buffer->prev; + } + else + { + // If the top of the stack is not the buffer we expect, do not + // execute it. + execute = 0; + } + + if( execute ) buffer->routine(buffer->arg); + + return; +} + + +// ------------------------------------------------------------------------- +// EOF pthread.cxx diff --git a/packages/compat/posix/current/src/sched.cxx b/packages/compat/posix/current/src/sched.cxx new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/src/sched.cxx @@ -0,0 +1,226 @@ +//========================================================================== +// +// sched.cxx +// +// POSIX scheduler API implementation +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-03-27 +// Purpose: POSIX scheduler API implementation +// Description: This file contains the implementation of the POSIX scheduler +// functions. +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include "pprivate.h" // POSIX private header + +#include // scheduler definitions +#include // thread definitions + +#include // scheduler inlines +#include // thread inlines + +//========================================================================== +// Process scheduling functions. + +//-------------------------------------------------------------------------- +// Set scheduling parameters for given process. + +int sched_setparam (pid_t pid, const struct sched_param *param) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + + if( pid != 0 ) + { + errno = ESRCH; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + errno = ENOSYS; + CYG_REPORT_RETVAL( -1 ); + return -1; +} + +//-------------------------------------------------------------------------- +// Get scheduling parameters for given process. + +int sched_getparam (pid_t pid, struct sched_param *param) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + + if( pid != 0 ) + { + errno = ESRCH; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + errno = ENOSYS; + CYG_REPORT_RETVAL( -1 ); + return -1; +} + +//-------------------------------------------------------------------------- +// Set scheduling policy and/or parameters for given process. +int sched_setscheduler (pid_t pid, + int policy, + const struct sched_param *param) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + + if( pid != 0 ) + { + errno = ESRCH; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + errno = ENOSYS; + CYG_REPORT_RETVAL( -1 ); + return -1; +} + + +//-------------------------------------------------------------------------- +// Get scheduling policy for given process. + +int sched_getscheduler (pid_t pid) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + + if( pid != 0 ) + { + errno = ESRCH; + CYG_REPORT_RETVAL( 0 ); + return -1; + } + + errno = ENOSYS; + CYG_REPORT_RETVAL( -1 ); + return -1; +} + +//-------------------------------------------------------------------------- +// Force current thread to relinquish the processor. + +int sched_yield (void) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + + Cyg_Thread::yield(); + + CYG_REPORT_RETVAL( 0 ); + return 0; +} + + +//========================================================================== +// Scheduler parameter limits. + +//-------------------------------------------------------------------------- +// Get maximum priority value for a policy. + +int sched_get_priority_max (int policy) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + + if( policy != SCHED_FIFO && + policy != SCHED_RR && + policy != SCHED_OTHER ) + { + errno = EINVAL; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + int pri = PTHREAD_POSIX_PRIORITY( CYG_THREAD_MIN_PRIORITY ); + + CYG_REPORT_RETVAL( pri ); + return pri; +} + +//-------------------------------------------------------------------------- +// Get minimum priority value for a policy. + +int sched_get_priority_min (int policy) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + + if( policy != SCHED_FIFO && + policy != SCHED_RR && + policy != SCHED_OTHER ) + { + errno = EINVAL; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + int pri = PTHREAD_POSIX_PRIORITY( CYG_THREAD_MAX_PRIORITY ); + + CYG_REPORT_RETVAL( pri ); + return pri; +} + +//-------------------------------------------------------------------------- +// Get the SCHED_RR interval for the given process. + +int sched_rr_get_interval (pid_t pid, struct timespec *t) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + + if( pid != 0 ) + { + errno = ESRCH; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + cyg_ticks_to_timespec( CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS, t ); + + CYG_REPORT_RETVAL( 0 ); + return 0; +} + +// ------------------------------------------------------------------------- +// EOF sched.cxx diff --git a/packages/compat/posix/current/src/sem.cxx b/packages/compat/posix/current/src/sem.cxx new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/src/sem.cxx @@ -0,0 +1,227 @@ +//========================================================================== +// +// sem.cxx +// +// POSIX semaphore implementation +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-03-27 +// Purpose: POSIX semaphore implementation +// Description: This file contains the implementation of the POSIX semaphore +// functions. +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include // our header + +#include "pprivate.h" // POSIX private header + +#include // Kernel threads + +#include // Cyg_ThreadQueue::empty() + +#include // Kernel semaphores + +// ------------------------------------------------------------------------- +// Internal definitions + +// Handle entry to a pthread package function. +#define SEMA_ENTRY() CYG_REPORT_FUNCTYPE( "returning %d" ); + +// Do a semaphore package defined return. This requires the error code +// to be placed in errno, and if it is non-zero, -1 returned as the +// result of the function. This also gives us a place to put any +// generic tidyup handling needed for things like signal delivery and +// cancellation. +#define SEMA_RETURN(err) \ +CYG_MACRO_START \ + int __retval = 0; \ + if( err != 0 ) __retval = -1, errno = err; \ + CYG_REPORT_RETVAL( __retval ); \ + return __retval; \ +CYG_MACRO_END + +//----------------------------------------------------------------------------- +// new operator to allow us to invoke the Cyg_Thread constructor on the +// user's semaphore object. + +inline void *operator new(size_t size, void *ptr) { return (void *)ptr; }; + +// ------------------------------------------------------------------------- +// Initialize semaphore to value. +// pshared is not supported under eCos. + +externC int sem_init (sem_t *sem, int pshared, unsigned int value) +{ + SEMA_ENTRY(); + + if( value > SEM_VALUE_MAX ) + SEMA_RETURN(EINVAL); + + Cyg_Counting_Semaphore *sema; + + sema = new((void *)sem) Cyg_Counting_Semaphore(value); + + sema=sema; + + SEMA_RETURN(0); +} + +// ------------------------------------------------------------------------- +// Destroy the semaphore. + +externC int sem_destroy (sem_t *sem) +{ + SEMA_ENTRY(); + + Cyg_Counting_Semaphore *sema = (Cyg_Counting_Semaphore *)sem; + + // Check that the semaphore has no waiters + if( sema->waiting() ) + SEMA_RETURN(EBUSY); + + // Call the destructor + sema->~Cyg_Counting_Semaphore(); + + SEMA_RETURN(0); +} + +// ------------------------------------------------------------------------- +// Decrement value if >0 or wait for a post. + +externC int sem_wait (sem_t *sem) +{ + int retval = 0; + + SEMA_ENTRY(); + + Cyg_Counting_Semaphore *sema = (Cyg_Counting_Semaphore *)sem; + + if( !sema->wait() ) retval = EINTR; + + SEMA_RETURN(retval); +} + +// ------------------------------------------------------------------------- +// Decrement value if >0, return -1 if not. + +externC int sem_trywait (sem_t *sem) +{ + int retval = 0; + + SEMA_ENTRY(); + + Cyg_Counting_Semaphore *sema = (Cyg_Counting_Semaphore *)sem; + + if( !sema->trywait() ) retval = EAGAIN; + + SEMA_RETURN(0); +} + +// ------------------------------------------------------------------------- +// Increment value and wake a waiter if one is present. + +externC int sem_post (sem_t *sem) +{ + SEMA_ENTRY(); + + Cyg_Counting_Semaphore *sema = (Cyg_Counting_Semaphore *)sem; + + sema->post(); + + SEMA_RETURN(0); +} + + +// ------------------------------------------------------------------------- +// Get current value + +externC int sem_getvalue (sem_t *sem, int *sval) +{ + int retval; + + SEMA_ENTRY(); + + Cyg_Counting_Semaphore *sema = (Cyg_Counting_Semaphore *)sem; + + retval = sema->peek(); + + CYG_REPORT_RETVAL( retval ); + return retval; +} + +// ------------------------------------------------------------------------- +// Open an existing named semaphore, or create it. + +externC sem_t *sem_open (const char *name, int oflag, ...) +{ + SEMA_ENTRY(); + + errno = ENOSYS; + + CYG_REPORT_RETVAL( SEM_FAILED ); + return SEM_FAILED; +} + +// ------------------------------------------------------------------------- +// Close descriptor for semaphore. + +externC int sem_close (sem_t *sem) +{ + SEMA_ENTRY(); + + SEMA_RETURN(ENOSYS); +} + +// ------------------------------------------------------------------------- +// Remove named semaphore + +externC int sem_unlink (const char *name) +{ + SEMA_ENTRY(); + + SEMA_RETURN(ENOSYS); +} + +// ------------------------------------------------------------------------- +// EOF sem.cxx diff --git a/packages/compat/posix/current/src/signal.cxx b/packages/compat/posix/current/src/signal.cxx new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/src/signal.cxx @@ -0,0 +1,1051 @@ +//========================================================================== +// +// signal.cxx +// +// POSIX signal functions implementation +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-03-27 +// Purpose: POSIX signal functions implementation +// Description: This file contains the implementation of the POSIX signal +// functions. +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include "pprivate.h" // POSIX private header + +#include // our header + +#include + +#include + +// ------------------------------------------------------------------------- +// Internal definitions + +// Handle entry to a signal package function. +#define SIGNAL_ENTRY() CYG_REPORT_FUNCTYPE( "returning %d" ); + +// Do a signal package defined return. This requires the error code +// to be placed in errno, and if it is non-zero, -1 returned as the +// result of the function. This also gives us a place to put any +// generic tidyup handling needed for things like signal delivery and +// cancellation. +#define SIGNAL_RETURN(err) \ +CYG_MACRO_START \ + int __retval = 0; \ + if( err != 0 ) __retval = -1, errno = err; \ + CYG_REPORT_RETVAL( __retval ); \ + return __retval; \ +CYG_MACRO_END + +// Range check on a signal value. +#define SIGNAL_VALID(_sig_) (((_sig_) > 0) && ((_sig_) < ((int)sizeof(sigset_t)*8))) + +//========================================================================== +// Signal management structures + +typedef struct signal_info +{ + struct signal_info *next; // link in list of pending signals + siginfo_t si; // siginfo to pass to handler +} signal_info; + +typedef struct +{ + struct sigaction sa; // Sigaction defining what to do + signal_info *pending; // List of pending signals - this is + // a circular list with pending pointing + // to the tail element (or NULL if empty). +} signal_state; + +//========================================================================== +// Signal management variables + +// Lock used to protect signal management structures +Cyg_Mutex signal_mutex CYGBLD_POSIX_INIT; + +// Condition variable for all threads in sigsuspend() and sigwait() +// to wait on. +Cyg_Condition_Variable signal_sigwait( signal_mutex ) CYGBLD_POSIX_INIT; + +// Global pending signal set +sigset_t sig_pending; + +// Array controlling signal states +static signal_state sigstate[sizeof(sigset_t)*8]; + +// Array of available signal_info objects for queueing signals +static signal_info siginfo[SIGQUEUE_MAX]; + +// List of free signal_info objects +static signal_info *siginfo_next = NULL; + +//========================================================================== +// Variables used to support alarm() + +// Forward def of action function +static void sigalrm_action( Cyg_Alarm *alarm, CYG_ADDRWORD data ); + +// Kernel alarm object +static Cyg_Alarm sigalrm_alarm( Cyg_Clock::real_time_clock, sigalrm_action, 0 ) CYGBLD_POSIX_INIT; + +// Set true when alarm is armed +volatile cyg_bool sigalrm_armed = false; + +// Set true when alarm has fired and is waiting to be delivered +volatile cyg_bool sigalrm_pending = false; + +//========================================================================== +// Implementation functions. +// These are where the real work of the signal mechanism gets done. + +externC void cyg_posix_signal_start() +{ + // Chain all free signal_info objects together + for( int i = 0; i < SIGQUEUE_MAX; i++ ) + { + siginfo[i].next = siginfo_next; + siginfo_next = &siginfo[i]; + } + + // Clear the pending signal set + sigemptyset( &sig_pending ); +} + +// ------------------------------------------------------------------------- +// Generate a signal + +cyg_bool cyg_sigqueue( const struct sigevent *sev, int code, + pthread_info *thread ) +{ + if( sev->sigev_notify == SIGEV_NONE ) + { + // Do nothing + return true; + } + + if( sev->sigev_notify == SIGEV_THREAD ) + { + // create a thread to run the notification + // function. + // FIXME: implement SIGEV_THREAD + return true; + } + + // Otherwise we must have a SIGEV_SIGNAL notification + + // Find out whether the current thread already has the mutex + // locked. This is a distinct possibility if this function is + // called from the ASR while exiting the signal_sigwait condvar in + // pause() and sigtimedwait(). + + pthread_info *self = pthread_self_info(); + cyg_bool locked = (self != NULL) && (signal_mutex.get_owner() == self->thread); + + // Lock the mutex only if we do not already own it + if( !locked ) signal_mutex.lock(); + + int signo = sev->sigev_signo; + signal_state *ss = &sigstate[signo]; + + if( ss->sa.sa_flags & SA_SIGINFO ) + { + // We have a queuable signal, allocate a signal_info + // object and add it to the queue. + + if( siginfo_next == NULL ) + { + if( !locked ) signal_mutex.unlock(); + return false; + } + + signal_info *si = siginfo_next; + siginfo_next = si->next; + + si->si.si_signo = signo; + si->si.si_code = code; + si->si.si_value = sev->sigev_value; + + if( ss->pending == NULL ) + { + si->next = si; + } + else + { + si->next = ss->pending->next; + ss->pending->next = si; + } + + ss->pending = si; + } + // else A non-queuable signal, just set it pending + + if( thread != NULL ) + sigaddset( &thread->sigpending, signo ); + else sigaddset( &sig_pending, signo ); + + // Wake up any threads in sigsuspend() and sigwait(). + signal_sigwait.broadcast(); + + if( !locked ) signal_mutex.unlock(); + + return true; +} + +// ------------------------------------------------------------------------- +// Deliver any pending unblocked signals to the current thread +// Returns true if a signal handler was called. + +cyg_bool cyg_deliver_signals() +{ + cyg_bool res = false; + + pthread_info *self = pthread_self_info(); + + // If there is no pthread_info pointer for this thread then + // it is not a POSIX thread and cannot have signals delivered + // to it. + + if( self == NULL ) return false; + + // If there are no pending signals our work is done + if( sig_pending == 0 && self->sigpending == 0 ) + return false; + + // If there are no unmasked pending signals our + // work is also done + if( ((sig_pending | self->sigpending) & ~self->sigmask) == 0 ) + return false; + + // As with cyg_sigqueue(), this function can get called from an + // ASR where the signal_mutex is already locked. Check here to + // avoid relocking... + + cyg_bool locked = signal_mutex.get_owner() == self->thread; + + if( !locked ) signal_mutex.lock(); + + sigset_t todo; + + // Since a signal handler may raise another signal, or unmask an existing + // signal, we loop here while there are no more unblocked signals pending. + while( (todo = ((sig_pending | self->sigpending) & ~self->sigmask)) != 0 ) + { + // Here todo is a mask of the signals available for delivery + + int signo = 0; + + // This prioritizes low numbered signals + HAL_LSBIT_INDEX( signo, todo ); + + signal_state *ss = &sigstate[signo]; + sigset_t sigbit = 1L<sa.sa_handler != SIG_DFL && + ss->sa.sa_handler != SIG_IGN ) + { + sigset_t oldmask = self->sigmask; + siginfo_t lsi; + + if(ss->pending != NULL) + { + // There is a queued signal. Dequeue it and copy the + // siginfo object to a local copy. + + signal_info *si = ss->pending->next; + + // Make a local copy of the siginfo object + lsi = si->si; + + // Remove the head signal_info object from the + // circular list. + if( ss->pending == si ) + ss->pending = NULL; + else + ss->pending->next = si->next; + + // Return it to the free list + si->next = siginfo_next; + siginfo_next = si; + } + else + { + // There are no signals queued. Set up the local siginfo_t + // object with default values. + + lsi.si_signo = signo; + lsi.si_code = SI_USER; + lsi.si_value.sival_int = 0; + } + + // Clear the bit from the pending masks. If the pending + // queue is not empty, leave the bits set, otherwise clear + // them. Do this now so that if the signal handler longjumps + // out, the signal subsystem is clean. + + if( ss->pending == NULL ) + { + // Clear the bit in both masks regardless of which + // one it actually came from. This is cheaper than + // trying to find out. + sig_pending &= ~sigbit; + self->sigpending &= ~sigbit; + } + + // Add the mask set and the signal itself to the + // mask while we call the signal handler + self->sigmask = oldmask | ss->sa.sa_mask | sigbit; + + // Unlock now so that a longjmp out of the handler + // does the right thing. We do this even if we did not + // lock the mutex since it will only recently have been + // relocked and thus all data is still consistent. + + signal_mutex.unlock(); + + if( ss->sa.sa_flags & SA_SIGINFO ) + { + // A sigaction delivery + + ss->sa.sa_sigaction( signo, &lsi, NULL ); + } + else + { + // This is a standard signal delivery. + + ss->sa.sa_handler( signo ); + } + + // Relock the mutex + signal_mutex.lock(); + + // Restore original signal mask + self->sigmask = oldmask; + + // return that we have handled a signal + res = true; + } + } + + if( !locked ) signal_mutex.unlock(); + + return res; +} + +// ------------------------------------------------------------------------- +// Action routine called from kernel alarm to deliver the SIGALRM signal. +// We cannot call any signal delivery functions directly here, so we simply +// set a flag and schedule an ASR to be called. + +static void sigalrm_action( Cyg_Alarm *alarm, CYG_ADDRWORD data ) +{ + sigset_t mask; + sigalrm_armed = false; + sigalrm_pending = true; + sigemptyset( &mask ); + sigaddset( &mask, SIGALRM ); + cyg_posix_pthread_release_thread( &mask ); +} + +// ------------------------------------------------------------------------- +// signal ASR function. This is called from the general POSIX ASR to +// deal with any signal related issues. + +externC void cyg_posix_signal_asr(pthread_info *self) +{ + // If there is a pending SIGALRM, generate it + if( sigalrm_pending ) + { + sigalrm_pending = false; + + struct sigevent sev; + + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = SIGALRM; + sev.sigev_value.sival_int = 0; + + // generate the signal + cyg_sigqueue( &sev, SI_USER ); + } + + // Now call cyg_deliver_signals() to see if we can + // handle any signals now. + + cyg_deliver_signals(); + +} + +//========================================================================== +// Per-thread initialization and destruction + +externC void cyg_posix_thread_siginit( pthread_info *thread ) +{ + // Clear out signal masks + sigemptyset( &thread->sigpending ); + sigemptyset( &thread->sigmask ); + + cyg_pthread_exception_init( thread ); +} + +externC void cyg_posix_thread_sigdestroy( pthread_info *thread ) +{ + cyg_pthread_exception_destroy( thread ); +} + +//========================================================================== +// Functions to generate signals + +// ------------------------------------------------------------------------- +// Deliver sig to a process. +// eCos only supports the value 0 for pid. + +externC int kill (pid_t pid, int sig) +{ + SIGNAL_ENTRY(); + + if( !SIGNAL_VALID(sig) ) + SIGNAL_RETURN(EINVAL); + + if( pid != 0 ) + SIGNAL_RETURN(ESRCH); + + struct sigevent sev; + + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = sig; + sev.sigev_value.sival_int = 0; + + cyg_sigqueue( &sev, SI_USER ); + + cyg_deliver_signals(); + + SIGNAL_RETURN(0); +} + +// ------------------------------------------------------------------------- + +externC int pthread_kill (pthread_t threadid, int sig) +{ + SIGNAL_ENTRY(); + + if( !SIGNAL_VALID(sig) ) + SIGNAL_RETURN(EINVAL); + + struct sigevent sev; + + pthread_info *thread = pthread_info_id(threadid); + + if( thread == NULL ) + SIGNAL_RETURN(ESRCH); + + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = sig; + sev.sigev_value.sival_int = 0; + + cyg_sigqueue( &sev, SI_USER, thread ); + + cyg_deliver_signals(); + + SIGNAL_RETURN(0); +} + +//========================================================================== +// Functions to catch signals + +// ------------------------------------------------------------------------- +// Install signal handler for sig. + +externC int sigaction (int sig, const struct sigaction *act, + struct sigaction *oact) +{ + SIGNAL_ENTRY(); + + if( !SIGNAL_VALID(sig) ) + SIGNAL_RETURN(EINVAL); + + signal_state *ss = &sigstate[sig]; + + signal_mutex.lock(); + + if( oact != NULL ) + *oact = ss->sa; + + ss->sa = *act; + + if( ss->sa.sa_handler == SIG_IGN ) + { + // Setting the handler to SIG_IGN causes any pending + // signals to be discarded and any queued values to also + // be removed. + + pthread_info *self = pthread_self_info(); + sigset_t sigbit = 1<sigpending) & sigbit ) + { + // This signal is pending, clear it + + sig_pending &= ~sigbit; + self->sigpending &= ~sigbit; + + // Clean out any queued signal_info objects + while( ss->pending != NULL ) + { + signal_info *si = ss->pending->next; + + // Remove the head signal_info object from the + // circular list. + if( ss->pending == si ) + ss->pending = NULL; + else + ss->pending->next = si->next; + + // Return it to the free list + si->next = siginfo_next; + siginfo_next = si; + } + } + } + + cyg_deliver_signals(); + + signal_mutex.unlock(); + + SIGNAL_RETURN(0); +} + + +// ------------------------------------------------------------------------- +// Queue signal to process with value. + +externC int sigqueue (pid_t pid, int sig, const union sigval value) +{ + SIGNAL_ENTRY(); + + if( !SIGNAL_VALID(sig) ) + SIGNAL_RETURN(EINVAL); + + struct sigevent sev; + + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = sig; + sev.sigev_value = value; + + cyg_sigqueue( &sev, SI_QUEUE ); + + cyg_deliver_signals(); + + SIGNAL_RETURN(0); +} + +//========================================================================== +// Functions to deal with current blocked and pending masks + +// ------------------------------------------------------------------------- +// Set process blocked signal mask +// Map this onto pthread_sigmask(). + +externC int sigprocmask (int how, const sigset_t *set, sigset_t *oset) +{ + return pthread_sigmask( how, set, oset); +} + + +// ------------------------------------------------------------------------- +// Set calling thread's blocked signal mask + +externC int pthread_sigmask (int how, const sigset_t *set, sigset_t *oset) +{ + int err = 0; + + SIGNAL_ENTRY(); + + pthread_info *self = pthread_self_info(); + + // Save old set + if( oset != NULL ) + *oset = self->sigmask; + + if( set != NULL ) + { + switch( how ) + { + case SIG_BLOCK: + self->sigmask |= *set; + break; + + case SIG_UNBLOCK: + self->sigmask &= ~*set; + break; + + case SIG_SETMASK: + self->sigmask = *set; + break; + + default: + err = EINVAL; + break; + } + } + + // Deliver any newly unblocked signals + cyg_deliver_signals(); + + SIGNAL_RETURN(err); +} + +// ------------------------------------------------------------------------- +// Get set of pending signals for this process + +externC int sigpending (sigset_t *set) +{ + SIGNAL_ENTRY(); + + if( set == NULL ) + SIGNAL_RETURN(EINVAL); + + pthread_info *self = pthread_self_info(); + + *set = self->sigpending | sig_pending; + + SIGNAL_RETURN(0); +} + + +//========================================================================== +// Wait for or accept signals + +// ------------------------------------------------------------------------- +// Block signals in set and wait for a signal + +externC int sigsuspend (const sigset_t *set) +{ + SIGNAL_ENTRY(); + + pthread_info *self = pthread_self_info(); + + signal_mutex.lock(); + + // Save the old mask and set the current mask to + // the one supplied. + sigset_t old = self->sigmask; + self->sigmask = *set; + + // Loop until a signal gets delivered + while( !cyg_deliver_signals() ) + signal_sigwait.wait(); + + self->sigmask = old; + + signal_mutex.unlock(); + + SIGNAL_RETURN(EINTR); +} + + +// ------------------------------------------------------------------------- +// Wait for a signal in set to arrive +// Implement this as a variant on sigtimedwait(). + +externC int sigwait (const sigset_t *set, int *sig) +{ + SIGNAL_ENTRY(); + + siginfo_t info; + + int ret = sigtimedwait( set, &info, NULL ); + + if( ret == -1 ) + SIGNAL_RETURN(errno); + + *sig = ret; + + SIGNAL_RETURN(0); +} + +// ------------------------------------------------------------------------- +// Do the same as sigwait() except return a siginfo_t object too. +// Implement this as a variant on sigtimedwait(). + +externC int sigwaitinfo (const sigset_t *set, siginfo_t *info) +{ + SIGNAL_ENTRY(); + + int ret = sigtimedwait( set, info, NULL ); + + SIGNAL_RETURN(ret); +} + +// ------------------------------------------------------------------------- +// Wait either for a signal in the given set to become pending, or +// for the timeout to expire. If timeout is NULL, wait for ever. + +externC int sigtimedwait (const sigset_t *set, siginfo_t *info, + const struct timespec *timeout) +{ + SIGNAL_ENTRY(); + + int err = 0; + cyg_tick_count ticks; + + if( timeout == NULL ) ticks = 0; + else ticks = cyg_timespec_to_ticks( timeout ) + + Cyg_Clock::real_time_clock->current_value(); + + pthread_info *self = pthread_self_info(); + + signal_mutex.lock(); + + sigset_t todo; + + // Wait for a signal in the set to become pending + while( (todo = (*set & (sig_pending | self->sigpending))) == 0 ) + { + // If timeout is not NULL, do a timed wait on the + // sigwait condition variable. If it is NULL - wait + // until we are woken. + if( timeout ) + { + if( ticks == 0 || !signal_sigwait.wait(ticks) ) + { + // If the timeout is actually zero, or we have waited and + // timed out, then we must quit with an error. + err = EAGAIN; + break; + } + } + else signal_sigwait.wait(); + } + + if( err == 0 ) + { + // There is a signal in the set that is pending: deliver + // it. todo contains a mask of all the signals that could be + // delivered now, but we only want to deliver one of them. + + int signo = 0; + + // Select the lowest numbered signal from the todo mask + HAL_LSBIT_INDEX( signo, todo ); + + signal_state *ss = &sigstate[signo]; + sigset_t sigbit = 1L<sa.sa_flags & SA_SIGINFO) && (ss->pending != NULL) ) + { + // If the SA_SIGINFO bit is set, then there + // will be a signal_info object queued on the + // pending field. + + signal_info *si = ss->pending->next; + *info = si->si; + + // Remove the head signal_info object from the + // circular list. + if( ss->pending == si ) + ss->pending = NULL; + else + ss->pending->next = si->next; + + si->next = siginfo_next; + siginfo_next = si; + + } + else + { + // Not a queued signal, or there is no signal_info object + // on the pending queue: fill in info structure with + // default values. + info->si_signo = signo; + info->si_code = SI_USER; + info->si_value.sival_int = 0; + } + + // Clear the bit from the pending masks. If the pending + // queue is not empty, leave the bits set, otherwise clear + // them. + + if( ss->pending == NULL ) + { + // Clear the bit in both masks regardless of which + // one it actually came from. This is cheaper than + // trying to find out. + sig_pending &= ~sigbit; + self->sigpending &= ~sigbit; + } + + // all done + } + + signal_mutex.unlock(); + + SIGNAL_RETURN(err); +} + +//========================================================================== +// alarm, pause and sleep + +// ------------------------------------------------------------------------- +// Generate SIGALRM after some number of seconds + +externC unsigned int alarm( unsigned int seconds ) +{ + int res = 0; + struct timespec tv; + cyg_tick_count trigger, interval; + + SIGNAL_ENTRY(); + + signal_mutex.lock(); + + if( sigalrm_armed ) + { + sigalrm_alarm.disable(); + + sigalrm_alarm.get_times( &trigger, &interval ); + + // Convert trigger time back to interval + trigger -= Cyg_Clock::real_time_clock->current_value(); + + cyg_ticks_to_timespec( trigger, &tv ); + + res = tv.tv_sec; + + sigalrm_armed = false; + } + + if( seconds != 0 ) + { + // Here we know that the sigalrm_alarm is unarmed, set it up + // to trigger in the required number of seconds. + + tv.tv_sec = seconds; + tv.tv_nsec = 0; + + trigger = cyg_timespec_to_ticks( &tv ); + + // Convert trigger interval to absolute time + trigger += Cyg_Clock::real_time_clock->current_value(); + + sigalrm_alarm.initialize( trigger, 0 ); + + sigalrm_armed = true; + } + + signal_mutex.unlock(); + + CYG_REPORT_RETVAL(res); + + return res; +} + +// ------------------------------------------------------------------------- +// Wait for a signal to be delivered. + +externC int pause( void ) +{ + SIGNAL_ENTRY(); + + signal_mutex.lock(); + + // Check for any pending signals that can be delivered and + // if there are none, wait for a signal to be generated + if( !cyg_deliver_signals() ) + signal_sigwait.wait(); + + // Now check again for some signals to deliver + cyg_deliver_signals(); + + signal_mutex.unlock(); + + SIGNAL_RETURN(EINTR); +} + +// ------------------------------------------------------------------------- +// Wait for a signal, or the given number of seconds + +externC unsigned int sleep( unsigned int seconds ) +{ + SIGNAL_ENTRY(); + + struct timespec timeout; + + timeout.tv_sec = seconds; + timeout.tv_nsec = 0; + + if( nanosleep( &timeout, &timeout ) != 0 ) + { + CYG_REPORT_RETVAL(timeout.tv_sec); + return timeout.tv_sec; + } + + CYG_REPORT_RETVAL(0); + return 0; +} + +//========================================================================== +// Signal sets + +// ------------------------------------------------------------------------- +// Clear all signals from set. + +externC int sigemptyset (sigset_t *set) +{ + SIGNAL_ENTRY(); + + *set = 0; + + SIGNAL_RETURN(0); +} + + +// ------------------------------------------------------------------------- +// Set all signals in set. + +externC int sigfillset (sigset_t *set) +{ + SIGNAL_ENTRY(); + + *set = ~0; + + SIGNAL_RETURN(0); +} + + +// ------------------------------------------------------------------------- +// Add signo to set. + +externC int sigaddset (sigset_t *set, int signo) +{ + SIGNAL_ENTRY(); + + int err = 0; + + if( !SIGNAL_VALID(signo) ) + err = EINVAL; + else *set |= 1< + +#include +#include "pprivate.h" // POSIX private header + +// ------------------------------------------------------------------------- + +// define an object that will automatically initialize the POSIX subsystem + +class cyg_posix_startup_dummy_constructor_class { +public: + cyg_posix_startup_dummy_constructor_class() { + +#ifdef CYGPKG_POSIX_PTHREAD + cyg_posix_pthread_start(); +#endif +#ifdef CYGPKG_POSIX_SIGNALS + cyg_posix_signal_start(); + cyg_posix_exception_start(); +#endif +#ifdef CYGPKG_POSIX_TIMERS + cyg_posix_clock_start(); +#endif + + } +}; + +static cyg_posix_startup_dummy_constructor_class cyg_posix_startup_obj + CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_COMPAT); + +// ------------------------------------------------------------------------- +// EOF startup.cxx diff --git a/packages/compat/posix/current/src/time.cxx b/packages/compat/posix/current/src/time.cxx new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/src/time.cxx @@ -0,0 +1,648 @@ +//========================================================================== +// +// time.cxx +// +// POSIX time functions implementation +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-03-27 +// Purpose: POSIX time functions implementation +// Description: This file contains the implementation of the POSIX time +// functions. +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include "pprivate.h" // POSIX private header + +#include // our header + +#include +#include + +#include +#include + +// ------------------------------------------------------------------------- +// Internal definitions + +// Handle entry to a pthread package function. +#define TIME_ENTRY() CYG_REPORT_FUNCTYPE( "returning %d" ); + +// Do a time package defined return. This requires the error code +// to be placed in errno, and if it is non-zero, -1 returned as the +// result of the function. This also gives us a place to put any +// generic tidyup handling needed for things like signal delivery and +// cancellation. +#define TIME_RETURN(err) \ +CYG_MACRO_START \ + int __retval = 0; \ + if( err != 0 ) __retval = -1, errno = err; \ + CYG_REPORT_RETVAL( __retval ); \ + return __retval; \ +CYG_MACRO_END + +//========================================================================== +// Timer control structures + +typedef struct +{ + timer_t id; // id value for checking + Cyg_Alarm *alarm; // eCos alarm object + cyg_bool armed; // is alarm enabled? + cyg_bool pending; // is expiry pending? + int overrun; // Overrun count + struct sigevent sigev; // Sigevent to raise on expiry + + // Space for alarm object + cyg_uint8 alarm_obj[sizeof(Cyg_Alarm)]; + +} posix_timer; + +// Mutex for controlling access to shared data structures +static Cyg_Mutex timer_mutex CYGBLD_POSIX_INIT; + +// Array of timer objects +static posix_timer timer_table[_POSIX_TIMER_MAX]; + +// Index of next timer to allocate from array +static int timer_next = 0; + +// This is used to make timer_t values unique even when reusing +// a table slot. This allows _POSIX_TIMER_MAX to range +// up to 1024. +#define TIMER_ID_COOKIE_INC 0x00000400 +#define TIMER_ID_COOKIE_MASK (TIMER_ID_COOKIE_INC-1) +static timer_t timer_id_cookie = TIMER_ID_COOKIE_INC; + +//----------------------------------------------------------------------------- +// new operator to allow us to invoke the constructor on +// posix_timer.alarm_obj. + +inline void *operator new(size_t size, cyg_uint8 *ptr) { return (void *)ptr; }; + +//========================================================================== +// Time conversion variables +// These are used to interconvert between ticks and POSIX timespecs. + +// Converters from sec and ns to ticks +static struct Cyg_Clock::converter ns_converter, sec_converter; + +// Converters from ticks to sec and ns +static struct Cyg_Clock::converter ns_inverter, sec_inverter; + +// tickns is the number of nanoseconds per tick. +static cyg_tick_count tickns; + +static cyg_bool converters_initialized = false; + +//========================================================================== +// Local functions + +static void init_converters() +{ + if( !converters_initialized ) + { + + // Create the converters we need. + Cyg_Clock::real_time_clock->get_other_to_clock_converter( 1, &ns_converter ); + Cyg_Clock::real_time_clock->get_other_to_clock_converter( 1000000000, &sec_converter ); + Cyg_Clock::real_time_clock->get_clock_to_other_converter( 1, &ns_inverter ); + Cyg_Clock::real_time_clock->get_clock_to_other_converter( 1000000000, &sec_inverter ); + + tickns = Cyg_Clock::convert( 1, &ns_inverter ); + + converters_initialized = true; + } +} + +externC cyg_tick_count cyg_timespec_to_ticks( const struct timespec *tp, + cyg_bool roundup = false) +{ + init_converters(); + + // Short circuit zero timespecs + if( tp->tv_sec == 0 && tp->tv_nsec == 0 ) + { + return 0; + } + + // Convert the seconds field to ticks. + cyg_tick_count ticks = Cyg_Clock::convert( tp->tv_sec, &sec_converter ); + + if( roundup ) + { + // Convert the nanoseconds. We add (tickns-1) to round the value up + // to the next whole tick. + + ticks += Cyg_Clock::convert( (cyg_tick_count)tp->tv_nsec+tickns-1, &ns_converter ); + } + else + { + // Convert the nanoseconds. This will round down to nearest whole tick. + ticks += Cyg_Clock::convert( (cyg_tick_count)tp->tv_nsec, &ns_converter ); + } + + return ticks; +} + +externC void cyg_ticks_to_timespec( cyg_tick_count ticks, struct timespec *tp ) +{ + init_converters(); + + // short circuit zero ticks values + if( ticks == 0 ) + { + tp->tv_sec = 0; + tp->tv_nsec = 0; + return; + } + + // Calculate number of seconds + tp->tv_sec = Cyg_Clock::convert( ticks, &sec_inverter ); + + // Convert back and subtract from ticks to get fraction of second + ticks -= Cyg_Clock::convert( tp->tv_sec, &sec_converter ); + + // Convert fraction to nanoseconds + tp->tv_nsec = Cyg_Clock::convert( ticks, &ns_inverter ); + +} + +static cyg_bool valid_timespec( const struct timespec *tp ) +{ + // Fail a NULL pointer + if( tp == NULL ) return false; + + // Fail illegal nanosecond values + if( tp->tv_nsec < 0 || tp->tv_nsec > 1000000000 ) + return false; + + return true; +} + +//========================================================================== +// Startup routine. + +externC void cyg_posix_clock_start() +{ + init_converters(); +} + +//========================================================================== +// Alarm action routine +// This is called each time an alarm set up by a timer expires. + +static void alarm_action( Cyg_Alarm *alarm, CYG_ADDRWORD data ) +{ + posix_timer *timer = (posix_timer *)data; + + if( timer->pending ) + { + // If the pending flag is already set, count an overrun and + // do not bother to try and deliver the expiry. + + timer->overrun++; + } + else + { + if( timer->sigev.sigev_notify == SIGEV_SIGNAL ) + { + // Set the expiry pending and wake a thread to + // deliver the signal. + + timer->pending = true; + + sigset_t mask; + sigemptyset( &mask ); + sigaddset( &mask, timer->sigev.sigev_signo ); + cyg_posix_pthread_release_thread( &mask ); + } + else if( timer->sigev.sigev_notify == SIGEV_THREAD ) + { + // Thread style notification + // FIXME: implement SIGEV_THREAD + } + // else do nothing + } +} + +//========================================================================== +// Timer ASR routine + +externC void cyg_posix_timer_asr( pthread_info *self ) +{ + + // Loop over the timers looking for any that have an + // expiry pending and call cyg_sigqueue() for each. + + for( int i = 0; i < _POSIX_TIMER_MAX; i++ ) + { + posix_timer *timer = &timer_table[i]; + + if( timer->id != 0 && timer->pending ) + { + timer->pending = false; + + // Call into signal subsystem... + cyg_sigqueue( &timer->sigev, SI_TIMER ); + + timer->overrun = 0; + } + } +} + +//========================================================================== +// Clock functions + +//----------------------------------------------------------------------------- +// Set the clocks current time + +externC int clock_settime( clockid_t clock_id, const struct timespec *tp) +{ + TIME_ENTRY(); + + if( clock_id != CLOCK_REALTIME ) + TIME_RETURN(EINVAL); + + if( !valid_timespec( tp ) ) + TIME_RETURN(EINVAL); + + cyg_tick_count ticks = cyg_timespec_to_ticks( tp ); + + Cyg_Clock::real_time_clock->set_value( ticks ); + + TIME_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Get the clocks current time + +externC int clock_gettime( clockid_t clock_id, struct timespec *tp) +{ + TIME_ENTRY(); + + if( clock_id != CLOCK_REALTIME ) + TIME_RETURN(EINVAL); + + if( tp == NULL ) + TIME_RETURN(EINVAL); + + cyg_tick_count ticks = Cyg_Clock::real_time_clock->current_value(); + + cyg_ticks_to_timespec( ticks, tp ); + + TIME_RETURN(0); +} + + +//----------------------------------------------------------------------------- +// Get the clocks resolution + +externC int clock_getres( clockid_t clock_id, struct timespec *tp) +{ + TIME_ENTRY(); + + if( clock_id != CLOCK_REALTIME ) + TIME_RETURN(EINVAL); + + if( tp == NULL ) + TIME_RETURN(EINVAL); + + // Get the resolution of 1 tick + cyg_ticks_to_timespec( 1, tp ); + + TIME_RETURN(0); +} + + +//========================================================================== +// Timer functions + +//----------------------------------------------------------------------------- +// Create a timer based on the given clock. + +externC int timer_create( clockid_t clock_id, + struct sigevent *evp, + timer_t *timer_id) +{ + TIME_ENTRY(); + + if( clock_id != CLOCK_REALTIME ) + TIME_RETURN(EINVAL); + + timer_mutex.lock(); + + posix_timer *timer; + int next = timer_next; + + // Look for an unused slot in the table + while( timer_table[next].id != 0 ) + { + next++; + if( next >= _POSIX_TIMER_MAX ) + next = 0; + + if( next == timer_next ) + { + timer_mutex.unlock(); + TIME_RETURN(EAGAIN); + } + } + + timer = &timer_table[next]; + + timer_next = next; + + // Make sure we never allocate a zero timer id. + while( timer->id == 0 ) + { + timer_id_cookie += TIMER_ID_COOKIE_INC; + timer->id = next+timer_id_cookie; + } + + if( evp == NULL ) + { + // If no evp is supplied, set up the timer + // to use a default set. + timer->sigev.sigev_notify = SIGEV_SIGNAL; + timer->sigev.sigev_signo = SIGALRM; + timer->sigev.sigev_value.sival_int = timer->id; + } + else timer->sigev = *evp; + + timer->alarm = new( timer->alarm_obj ) + Cyg_Alarm( Cyg_Clock::real_time_clock, + alarm_action, + (CYG_ADDRWORD)timer ); + + timer->armed = false; + timer->overrun = 0; + + *timer_id = timer->id; + + timer_mutex.unlock(); + + TIME_RETURN(0); +} + +//----------------------------------------------------------------------------- +// Delete the timer + +externC int timer_delete( timer_t timerid ) +{ + int err = EINVAL; + TIME_ENTRY(); + + posix_timer *timer = &timer_table[timerid & TIMER_ID_COOKIE_MASK]; + + timer_mutex.lock(); + + if( timer->id == timerid ) + { + // This is a valid timer, disable the kernel + // alarm and delete it. + + // disable alarm + timer->alarm->disable(); + + // destroy it + timer->alarm->~Cyg_Alarm(); + + // Mark POSIX timer free + timer->id = 0; + + err = 0; + } + + timer_mutex.unlock(); + + TIME_RETURN( err ); +} + +//----------------------------------------------------------------------------- +// Set the expiration time of the timer. + +externC int timer_settime( timer_t timerid, int flags, + const struct itimerspec *value, + struct itimerspec *ovalue ) +{ + int err = EINVAL; + TIME_ENTRY(); + + if( value == NULL ) + TIME_RETURN(EINVAL); + + // convert trigger and interval values to ticks. + cyg_tick_count trigger = cyg_timespec_to_ticks( &value->it_value, true ); + cyg_tick_count interval = cyg_timespec_to_ticks( &value->it_interval, true ); + + posix_timer *timer = &timer_table[timerid & TIMER_ID_COOKIE_MASK]; + + timer_mutex.lock(); + + if( timer->id == timerid ) + { + // disable the timer + timer->alarm->disable(); + + if( ovalue != NULL ) + { + cyg_tick_count otrigger, ointerval; + + timer->alarm->get_times( &otrigger, &ointerval ); + + if( timer->armed ) + { + // convert absolute trigger time to interval until next trigger + otrigger -= Cyg_Clock::real_time_clock->current_value(); + } + else otrigger = 0; + + // convert ticks to timespecs + cyg_ticks_to_timespec( otrigger, &ovalue->it_value ); + cyg_ticks_to_timespec( ointerval, &ovalue->it_interval ); + } + + if( trigger == 0 ) + { + // Mark timer disarmed + timer->armed = false; + } + else + { + // If the ABSTIME flag is not set, add the current time + if( (flags & TIMER_ABSTIME) == 0 ) + trigger += Cyg_Clock::real_time_clock->current_value(); + + // Set the alarm running. + timer->alarm->initialize( trigger, interval ); + + // Mark timer armed + timer->armed = true; + + } + + err = 0; + } + + timer_mutex.unlock(); + + TIME_RETURN(err); +} + +//----------------------------------------------------------------------------- +// Get current timer values + +externC int timer_gettime( timer_t timerid, struct itimerspec *value ) +{ + int err = EINVAL; + + TIME_ENTRY(); + + if( value == NULL ) + TIME_RETURN(EINVAL); + + posix_timer *timer = &timer_table[timerid & TIMER_ID_COOKIE_MASK]; + + timer_mutex.lock(); + + if( timer->id == timerid ) + { + cyg_tick_count trigger, interval; + + timer->alarm->get_times( &trigger, &interval ); + + if( timer->armed ) + { + // convert absolute trigger time to interval until next trigger + trigger -= Cyg_Clock::real_time_clock->current_value(); + } + else trigger = 0; + + // convert ticks to timespecs + cyg_ticks_to_timespec( trigger, &value->it_value ); + cyg_ticks_to_timespec( interval, &value->it_interval ); + err = 0; + } + + timer_mutex.unlock(); + + TIME_RETURN(err); +} + +//----------------------------------------------------------------------------- +// Get number of missed triggers + +externC int timer_getoverrun( timer_t timerid ) +{ + int overrun = 0; + + TIME_ENTRY(); + + posix_timer *timer = &timer_table[timerid & TIMER_ID_COOKIE_MASK]; + + timer_mutex.lock(); + + if( timer->id == timerid ) + { + overrun = timer->overrun; + } + + timer_mutex.unlock(); + + CYG_REPORT_RETVAL(overrun); + return overrun; +} + +//========================================================================== +// Nanosleep +// Sleep for the given time. + +externC int nanosleep( const struct timespec *rqtp, + struct timespec *rmtp) +{ + cyg_tick_count ticks, now, then; + + TIME_ENTRY(); + + // Fail an invalid timespec + if( !valid_timespec( rqtp ) ) + TIME_RETURN(EINVAL); + + // Return immediately for a zero delay. + if( rqtp->tv_sec == 0 && rqtp->tv_nsec == 0 ) + TIME_RETURN(0); + + // Convert timespec to ticks + ticks = cyg_timespec_to_ticks( rqtp, true ); + + CYG_ASSERT( ticks != 0, "Zero tick count"); + + pthread_info *self = pthread_self_info(); + + + // Do the delay, keeping track of how long we actually slept for. + then = Cyg_Clock::real_time_clock->current_value(); + + self->thread->delay( ticks ); + + now = Cyg_Clock::real_time_clock->current_value(); + + + if( rmtp != NULL && (then+ticks) > now ) + { + // We woke up early, return the time left. + // FIXME: strictly we only need to do this if we were woken + // by a signal. + + // Calculate remaining number of ticks. + ticks -= (now-then); + + cyg_ticks_to_timespec( ticks, rmtp ); + } + + TIME_RETURN(0); +} + +// ------------------------------------------------------------------------- +// EOF time.cxx diff --git a/packages/compat/posix/current/tests/mqueue1.c b/packages/compat/posix/current/tests/mqueue1.c new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/tests/mqueue1.c @@ -0,0 +1,350 @@ +/*======================================================================== +// +// mqueue1.c +// +// POSIX Message queues tests +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-05-18 +// Purpose: This file provides tests for POSIX mqueues +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include + +#ifndef CYGPKG_POSIX_MQUEUES +# define NA_MSG "Message queues not configured" +#endif + +#ifdef NA_MSG +#include // test API +void +cyg_user_start(void) +{ + CYG_TEST_NA( NA_MSG ); +} + +#else + +/* INCLUDES */ + +#include // O_* +#include // errno +#include // file modes +#include // Mqueue Header +#include // test API + +/* FUNCTIONS */ + +static int +my_memcmp(const void *m1, const void *m2, size_t n) +{ + char *s1 = (char *)m1; + char *s2 = (char *)m2; + + while (n--) { + if (*s1 != *s2) + return *s1 - *s2; + s1++; + s2++; + } + return 0; +} // my_memcmp() + +//************************************************************************ + +int +main(void) +{ + mqd_t q1, q2; + char buf[20]; + ssize_t recvlen; + unsigned int prio; + struct mq_attr attr, oattr; + mode_t mode; + int err; + + CYG_TEST_INIT(); + CYG_TEST_INFO( "Starting POSIX message test 1" ); + + q1 = mq_open( "/mq1", O_RDWR ); + CYG_TEST_PASS_FAIL( q1 == (mqd_t)-1, "error for non-existent queue" ); + CYG_TEST_PASS_FAIL( ENOENT == errno, + "errno correct for non-existent queue" ); + + attr.mq_flags = 0; + attr.mq_maxmsg = 4; + attr.mq_msgsize = 20; + mode = S_IRWXU|S_IRWXG|S_IRWXO; // rwx for all + + q1 = mq_open( "/mq1", O_CREAT|O_NONBLOCK|O_WRONLY, mode, &attr ); + CYG_TEST_PASS_FAIL( q1 != (mqd_t)-1, "simple mq_open (write only)" ); + + err = mq_getattr( q1, &attr ); + CYG_TEST_PASS_FAIL( 0 == err, "simple mq_getattr" ); + CYG_TEST_PASS_FAIL( (4 == attr.mq_maxmsg) && + (20 == attr.mq_msgsize) && + (O_NONBLOCK == (attr.mq_flags & O_NONBLOCK)) && + (O_RDONLY != (attr.mq_flags & O_RDONLY)) && + (O_WRONLY == (attr.mq_flags & O_WRONLY)) && + (O_RDWR != (attr.mq_flags & O_RDWR)) && + (0 == attr.mq_curmsgs ), "getattr attributes correct" ); + + err = mq_send( q1, "Vik is brill", sizeof("Vik is brill"), 10 ); + + CYG_TEST_PASS_FAIL( 0 == err, "simple mq_send" ); + + err = mq_getattr( q1, &attr ); + CYG_TEST_PASS_FAIL( 0 == err, "simple mq_getattr after send" ); + CYG_TEST_PASS_FAIL( (4 == attr.mq_maxmsg) && + (20 == attr.mq_msgsize) && + (O_NONBLOCK == (attr.mq_flags & O_NONBLOCK)) && + (O_RDONLY != (attr.mq_flags & O_RDONLY)) && + (O_WRONLY == (attr.mq_flags & O_WRONLY)) && + (O_RDWR != (attr.mq_flags & O_RDWR)) && + (1 == attr.mq_curmsgs ), + "getattr attributes correct #2" ); + + q2 = mq_open( "/mq1", O_RDONLY|O_CREAT|O_EXCL ); + CYG_TEST_PASS_FAIL( q2 == (mqd_t)-1, + "error for exclusive open of existing queue" ); + CYG_TEST_PASS_FAIL( EEXIST == errno, + "errno correct for exclusive open of existing queue" ); + + q2 = mq_open( "/mq1", O_RDONLY ); + CYG_TEST_PASS_FAIL( q2 != (mqd_t)-1, "simple mq_open (read only)" ); + + err = mq_getattr( q2, &attr ); + CYG_TEST_PASS_FAIL( 0 == err, "simple mq_getattr, different mqd_t" ); + CYG_TEST_PASS_FAIL( (4 == attr.mq_maxmsg) && + (20 == attr.mq_msgsize) && + (O_NONBLOCK != (attr.mq_flags & O_NONBLOCK)) && + (O_RDONLY == (attr.mq_flags & O_RDONLY)) && + (O_WRONLY != (attr.mq_flags & O_WRONLY)) && + (O_RDWR != (attr.mq_flags & O_RDWR)) && + (1 == attr.mq_curmsgs ), + "getattr attributes correct #3" ); + + err = mq_close( q2 ); + CYG_TEST_PASS_FAIL( 0 == err, "simple mq_close" ); + + q2 = mq_open( "/mq1", O_RDONLY ); + CYG_TEST_PASS_FAIL( q2 != (mqd_t)-1, "mq_open reopen (read only)" ); + + err = mq_getattr( q2, &attr ); + CYG_TEST_PASS_FAIL( 0 == err, "simple mq_getattr, different mqd_t" ); + CYG_TEST_PASS_FAIL( (4 == attr.mq_maxmsg) && + (20 == attr.mq_msgsize) && + (O_NONBLOCK != (attr.mq_flags & O_NONBLOCK)) && + (O_RDONLY == (attr.mq_flags & O_RDONLY)) && + (O_WRONLY != (attr.mq_flags & O_WRONLY)) && + (O_RDWR != (attr.mq_flags & O_RDWR)) && + (1 == attr.mq_curmsgs ), + "getattr attributes correct #4" ); + + recvlen = mq_receive( q2, buf, sizeof(buf), &prio ); + CYG_TEST_PASS_FAIL( recvlen == sizeof("Vik is brill"), + "receive message length" ); + CYG_TEST_PASS_FAIL( 0 == my_memcmp( buf, "Vik is brill", + sizeof("Vik is brill")), + "received message data intact" ); + CYG_TEST_PASS_FAIL( 10 == prio, "received at correct priority" ); + + err = mq_getattr( q1, &attr ); + CYG_TEST_PASS_FAIL( 0 == err, "simple mq_getattr after send" ); + CYG_TEST_PASS_FAIL( (4 == attr.mq_maxmsg) && + (20 == attr.mq_msgsize) && + (O_NONBLOCK == (attr.mq_flags & O_NONBLOCK)) && + (O_RDONLY != (attr.mq_flags & O_RDONLY)) && + (O_WRONLY == (attr.mq_flags & O_WRONLY)) && + (O_RDWR != (attr.mq_flags & O_RDWR)) && + (0 == attr.mq_curmsgs ), + "getattr attributes correct #5" ); + + attr.mq_flags |= O_NONBLOCK; + err = mq_setattr( q2, &attr, &oattr ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_setattr O_NONBLOCK" ); + CYG_TEST_PASS_FAIL( (4 == oattr.mq_maxmsg) && + (20 == oattr.mq_msgsize) && + (O_NONBLOCK != (oattr.mq_flags & O_NONBLOCK)) && + (O_RDONLY == (oattr.mq_flags & O_RDONLY)) && + (O_WRONLY != (oattr.mq_flags & O_WRONLY)) && + (O_RDWR != (oattr.mq_flags & O_RDWR)) && + (0 == oattr.mq_curmsgs ), + "old attribute correct" ); + err = mq_getattr( q2, &attr ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_getattr after O_NONBLOCK" ); + CYG_TEST_PASS_FAIL( (4 == attr.mq_maxmsg) && + (20 == attr.mq_msgsize) && + (O_NONBLOCK == (attr.mq_flags & O_NONBLOCK)) && + (O_RDONLY == (attr.mq_flags & O_RDONLY)) && + (O_WRONLY != (attr.mq_flags & O_WRONLY)) && + (O_RDWR != (attr.mq_flags & O_RDWR)) && + (0 == attr.mq_curmsgs ), + "new attribute correct" ); + + recvlen = mq_receive( q2, buf, sizeof(buf), &prio ); + CYG_TEST_PASS_FAIL( recvlen == (ssize_t)-1, + "mq_receive, empty buffer, non-blocking" ); + CYG_TEST_PASS_FAIL( EAGAIN == errno, + "errno correct for non-blocking" ); + + err = mq_send( q2, "foo", sizeof("foo"), 1 ); + CYG_TEST_PASS_FAIL( -1 == err, "error on mq_send on read-only descriptor" ); + CYG_TEST_PASS_FAIL( EBADF == errno, + "errno correct for mq_send on r/o descriptor" ); + + err = mq_send( q2, "supercalifragilisticexpealidocious", 21, 2 ); + CYG_TEST_PASS_FAIL( -1 == err, "error on mq_send (message too long)" ); + CYG_TEST_PASS_FAIL( EMSGSIZE == errno, + "errno correct for mq_send (message too long)" ); + + err = mq_send( q1, "", sizeof(""), 5 ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_send \"\"" ); + + err = mq_send( q1, "I love Vik", sizeof("I love Vik"), 7 ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_send (different priority)" ); + + err = mq_send( q1, "a lot!", sizeof("a lot!"), 7 ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_send (same priority)" ); + + err = mq_send( q1, "Vik is a babe", sizeof("Vik is a babe"), 6 ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_send (middle priority)" ); + + err = mq_send( q1, "wibble", sizeof("wibble"), 6 ); + CYG_TEST_PASS_FAIL( -1 == err, "error on mq_send with full queue" ); + CYG_TEST_PASS_FAIL( EAGAIN == errno, + "errno correct for mq_send full queue" ); + + err = mq_getattr( q2, &attr ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_getattr after sends" ); + CYG_TEST_PASS_FAIL( (4 == attr.mq_maxmsg) && + (20 == attr.mq_msgsize) && + (O_NONBLOCK == (attr.mq_flags & O_NONBLOCK)) && + (O_RDONLY == (attr.mq_flags & O_RDONLY)) && + (O_WRONLY != (attr.mq_flags & O_WRONLY)) && + (O_RDWR != (attr.mq_flags & O_RDWR)) && + (4 == attr.mq_curmsgs ), + "getattr attributes correct #5" ); + + recvlen = mq_receive( q2, buf, sizeof(buf), &prio ); + CYG_TEST_PASS_FAIL( recvlen == sizeof("I love Vik"), + "receive message length (prioritized) #1" ); + CYG_TEST_PASS_FAIL( 0 == my_memcmp( buf, "I love Vik", + sizeof("I love Vik")), + "received message data intact (prioritized) #1" ); + CYG_TEST_PASS_FAIL( 7 == prio, + "received at correct priority (prioritized) #1" ); + + recvlen = mq_receive( q2, buf, sizeof(buf), &prio ); + CYG_TEST_PASS_FAIL( recvlen == sizeof("a lot!"), + "receive message length (prioritized) #2" ); + CYG_TEST_PASS_FAIL( 0 == my_memcmp( buf, "a lot!", + sizeof("a lot!")), + "received message data intact (prioritized) #2" ); + CYG_TEST_PASS_FAIL( 7 == prio, + "received at correct priority (prioritized) #2" ); + + recvlen = mq_receive( q2, buf, sizeof(buf), &prio ); + CYG_TEST_PASS_FAIL( recvlen == sizeof("Vik is a babe"), + "receive message length (prioritized) #3" ); + CYG_TEST_PASS_FAIL( 0 == my_memcmp( buf, "Vik is a babe", + sizeof("Vik is a babe")), + "received message data intact (prioritized) #3" ); + CYG_TEST_PASS_FAIL( 6 == prio, + "received at correct priority (prioritized) #3" ); + + recvlen = mq_receive( q2, buf, 0, &prio ); + CYG_TEST_PASS_FAIL( recvlen == (ssize_t)-1, + "mq_receive, zero-sized buffer" ); + + recvlen = mq_receive( q2, buf, sizeof(buf), &prio ); + CYG_TEST_PASS_FAIL( recvlen == sizeof(""), + "receive message length (prioritized) #4" ); + CYG_TEST_PASS_FAIL( 0 == my_memcmp( buf, "", + sizeof("")), + "received message data intact (prioritized) #4" ); + CYG_TEST_PASS_FAIL( 5 == prio, + "received at correct priority (prioritzed) #4" ); + + recvlen = mq_receive( q2, buf, sizeof(buf), &prio ); + CYG_TEST_PASS_FAIL( recvlen == (ssize_t)-1, + "mq_receive, empty buffer, non-blocking #2" ); + CYG_TEST_PASS_FAIL( EAGAIN == errno, + "errno correct for non-blocking #2" ); + + err = mq_send( q1, "12345678901234567890", 20, 15 ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_send (before closing)" ); + + err = mq_unlink( "/foo" ); + CYG_TEST_PASS_FAIL( -1 == err, "mq_unlink (wrong name)" ); + CYG_TEST_PASS_FAIL( ENOENT == errno, + "errno correct for mq_unlink (wrong name)" ); + + err = mq_unlink( "/mq1" ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_unlink (before closing)" ); + + err = mq_close( q1 ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_close (send descriptor)" ); + + recvlen = mq_receive( q2, buf, sizeof(buf), &prio ); + CYG_TEST_PASS_FAIL( recvlen == 20, + "receive message length (mid close)" ); + CYG_TEST_PASS_FAIL( 0 == my_memcmp( buf, "12345678901234567890", 20 ), + "received message data intact (mid close)" ); + CYG_TEST_PASS_FAIL( 15 == prio, + "received at correct priority (mid close)" ); + + err = mq_close( q2 ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_close (receive descriptor)" ); + + q1 = mq_open( "/mq1", O_RDONLY ); + CYG_TEST_PASS_FAIL( q1 == (mqd_t)-1, "error for non-existent queue" ); + CYG_TEST_PASS_FAIL( ENOENT == errno, + "errno correct for non-existent queue" ); + + CYG_TEST_EXIT("POSIX message test 1"); + + return 0; +} // main() + +//------------------------------------------------------------------------ + +#endif + +/* EOF mqueue1.c */ diff --git a/packages/compat/posix/current/tests/mqueue2.c b/packages/compat/posix/current/tests/mqueue2.c new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/tests/mqueue2.c @@ -0,0 +1,266 @@ +/*======================================================================== +// +// mqueue2.c +// +// POSIX Message queues tests - mq_notify +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-05-18 +// Purpose: This file provides tests for POSIX mqueue mq_notify +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include + +#ifndef CYGPKG_POSIX_MQUEUES +# define NA_MSG "Message queues not configured" +#elif !defined(CYGPKG_POSIX_SIGNALS) +# define NA_MSG "No POSIX signals configured" +#endif + +#ifdef NA_MSG +#include // test API +void +cyg_user_start(void) +{ + CYG_TEST_NA( NA_MSG ); +} + +#else + +/* INCLUDES */ + +#include // O_* +#include // errno +#include // file modes +#include // Mqueue Header +#include // test API +#include // signals + +/* GLOBALS */ +sig_atomic_t signals=0; +char buf[20]; +unsigned int prio; + + +/* FUNCTIONS */ + +static int +my_memcmp(const void *m1, const void *m2, size_t n) +{ + char *s1 = (char *)m1; + char *s2 = (char *)m2; + + while (n--) { + if (*s1 != *s2) + return *s1 - *s2; + s1++; + s2++; + } + return 0; +} // my_memcmp() + +static char * +my_strcpy(char *s1, const char *s2) +{ + char *s = s1; + while (*s2) { + *s1++ = *s2++; + } + return s; +} // my_strcpy() + +static size_t +my_strlen(const char *s) +{ + const char *start = s; + while (*s) + s++; + return (s - start); +} // my_strcpy() + + + +//************************************************************************ + +static void +sigusr1_handler( int signo, siginfo_t *info, void *context ) +{ + ssize_t recvlen; + char mybuf[20]; + unsigned int myprio; + mqd_t *q = (mqd_t *)info->si_value.sival_ptr; + + CYG_TEST_PASS_FAIL( SIGUSR1 == signo, "correct signal number #1" ); + CYG_TEST_PASS_FAIL( SIGUSR1 == info->si_signo, "correct signal number #2" ); + CYG_TEST_PASS_FAIL( SI_MESGQ == info->si_code, "correct signal code" ); + + signals++; + + // retrieve message and compare with buf + recvlen = mq_receive( *q, mybuf, sizeof(mybuf), &myprio ); + CYG_TEST_PASS_FAIL( recvlen == my_strlen(buf), + "receive message length" ); + CYG_TEST_PASS_FAIL( 0 == my_memcmp( buf, mybuf, my_strlen(buf)), + "received message data intact" ); + CYG_TEST_PASS_FAIL( prio == myprio, + "received at correct priority" ); +} + +//************************************************************************ + +int +main(void) +{ + mqd_t q1; + struct mq_attr attr; + mode_t mode; + int err; + ssize_t recvlen; + char mybuf[20]; + unsigned int myprio; + struct sigevent ev; + struct sigaction act; + + CYG_TEST_INIT(); + CYG_TEST_INFO( "Starting POSIX message test 2" ); + +#if 0 + if ( 0 != pthread_create( &thr, NULL, &thread, NULL ) ) { + CYG_TEST_FAIL_FINISH( "Couldn't create a helper thread" ); + } +#endif + + attr.mq_flags = 0; + attr.mq_maxmsg = 4; + attr.mq_msgsize = 20; + mode = S_IRWXU|S_IRWXG|S_IRWXO; // rwx for all + + q1 = mq_open( "/mq1", O_CREAT|O_NONBLOCK|O_RDWR, mode, &attr ); + CYG_TEST_PASS_FAIL( q1 != (mqd_t)-1, "simple mq_open (write only)" ); + + err = mq_getattr( q1, &attr ); + CYG_TEST_PASS_FAIL( 0 == err, "simple mq_getattr" ); + CYG_TEST_PASS_FAIL( (4 == attr.mq_maxmsg) && + (20 == attr.mq_msgsize) && + (O_NONBLOCK == (attr.mq_flags & O_NONBLOCK)) && + (O_RDWR == (attr.mq_flags & O_RDWR)) && + (0 == attr.mq_curmsgs ), "getattr attributes correct" ); + + + act.sa_sigaction = &sigusr1_handler; + sigfillset( &act.sa_mask ); // enable all signals + act.sa_flags = SA_SIGINFO; + + if ( 0 != sigaction( SIGUSR1, &act, NULL ) ) { + CYG_TEST_FAIL_FINISH( "Couldn't register signal handler" ); + } + + ev.sigev_notify = SIGEV_SIGNAL; + ev.sigev_signo = SIGUSR1; + ev.sigev_value.sival_ptr = (void *)&q1; + + err = mq_notify( q1, &ev ); + CYG_TEST_PASS_FAIL( 0 == err, "simple mq_notify" ); + + my_strcpy( buf, "Vik is the best" ); + prio = 7; + err = mq_send( q1, buf, my_strlen(buf), prio ); + + CYG_TEST_PASS_FAIL( 0 == err, "mq_send #1" ); + + CYG_TEST_PASS_FAIL( 1 == signals, "got notification" ); + + my_strcpy( buf, "Scrummy Vik" ); + prio = 6; + err = mq_send( q1, buf, my_strlen(buf), prio ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_send #2" ); + + CYG_TEST_PASS_FAIL( 1 == signals, "correctly didn't get notification" ); + + recvlen = mq_receive( q1, mybuf, sizeof(mybuf), &myprio ); + CYG_TEST_PASS_FAIL( recvlen == my_strlen(buf), + "receive message length" ); + CYG_TEST_PASS_FAIL( 0 == my_memcmp( buf, mybuf, my_strlen(buf)), + "received message data intact" ); + CYG_TEST_PASS_FAIL( prio == myprio, + "received at correct priority" ); + + err = mq_notify( q1, &ev ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_notify #2" ); + + err = mq_notify( q1, &ev ); + CYG_TEST_PASS_FAIL( -1 == err, "second mq_notify returns error" ); + CYG_TEST_PASS_FAIL( EBUSY == errno, + "errno correct for second mq_notify error" ); + + err = mq_notify( q1, NULL ); + CYG_TEST_PASS_FAIL( 0 == err, "clear notification" ); + + my_strcpy( buf, "Vik is k3wl" ); + prio = 8; + err = mq_send( q1, buf, my_strlen(buf), prio ); + + CYG_TEST_PASS_FAIL( 0 == err, "mq_send #2" ); + + CYG_TEST_PASS_FAIL( 1 == signals, "correctly didn't get notification #2" ); + + recvlen = mq_receive( q1, mybuf, sizeof(mybuf), &myprio ); + CYG_TEST_PASS_FAIL( recvlen == my_strlen(buf), + "receive message length" ); + CYG_TEST_PASS_FAIL( 0 == my_memcmp( buf, mybuf, my_strlen(buf)), + "received message data intact" ); + CYG_TEST_PASS_FAIL( prio == myprio, + "received at correct priority" ); + + err = mq_close( q1 ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_close" ); + + err = mq_unlink( "/mq1" ); + CYG_TEST_PASS_FAIL( 0 == err, "mq_unlink" ); + + CYG_TEST_EXIT("POSIX message test 2"); + + return 0; +} // main() + +//------------------------------------------------------------------------ + +#endif + +/* EOF mqueue2.c */ diff --git a/packages/compat/posix/current/tests/mutex3.c b/packages/compat/posix/current/tests/mutex3.c new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/tests/mutex3.c @@ -0,0 +1,645 @@ +//========================================================================== +// +// mutex3.cxx +// +// Mutex test 3 - priority inheritance +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): hmt +// Contributors: hmt, nickg +// Date: 2000-01-06 +// Description: Tests mutex priority inheritance. This is simply a translation +// of the similarly named kernel test to the POSIX API +//####DESCRIPTIONEND#### + +// ------------------------------------------------------------------------ + +#include +#include +#include +#include + + +#include + +#include +#include +#include // diag_printf + +#include // Some extras + + +// ------------------------------------------------------------------------ +// +// These checks should be enough; any other scheduler which has priorities +// should manifest as having no priority inheritance, but otherwise fine, +// so the test should work correctly. + +#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && \ + defined(_POSIX_THREAD_PRIO_INHERIT) + +// ------------------------------------------------------------------------ +// Management functions +// +// Stolen from testaux.hxx and copied in here because I want to be able to +// reset the world also. +// ... and subsequently POSIXized out of all similarly with its progenitors. + +#define NTHREADS 7 + +#define STACKSIZE (PTHREAD_STACK_MIN*2) + +static pthread_t thread[NTHREADS] = { 0 }; + +typedef CYG_WORD64 CYG_ALIGNMENT_TYPE; + +static CYG_ALIGNMENT_TYPE stack[NTHREADS] [ + (STACKSIZE+sizeof(CYG_ALIGNMENT_TYPE)-1) + / sizeof(CYG_ALIGNMENT_TYPE) ]; + +// Semaphores to halt execution of threads +static sem_t hold[NTHREADS]; + +// Flag to tell all threads to exit +static int all_exit; + +// Application thread data is passed here, the thread +// argument is +static CYG_ADDRWORD thread_data[NTHREADS]; + +static int nthreads = 0; + +// Sleep for 1 tick... +static struct timespec sleeptime; + + +static pthread_t new_thread( void *(*entry)(void *), + CYG_ADDRWORD data, + int priority, + int do_resume) +{ + pthread_attr_t attr; + + struct sched_param schedparam; + schedparam.sched_priority = priority; + + pthread_attr_init( &attr ); + pthread_attr_setstackaddr( &attr, (void *)((char *)(&stack[nthreads])+STACKSIZE) ); + pthread_attr_setstacksize( &attr, STACKSIZE ); + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + pthread_attr_setschedparam( &attr, &schedparam ); + + CYG_ASSERT(nthreads < NTHREADS, + "Attempt to create more than NTHREADS threads"); + + thread_data[nthreads] = data; + + sem_init( &hold[nthreads], 0, do_resume ? 1 : 0 ); + all_exit = 0; + + pthread_create( &thread[nthreads], + &attr, + entry, + (void *)nthreads); + + return thread[nthreads++]; +} + + +static void kill_threads( void ) +{ + CYG_ASSERT(nthreads <= NTHREADS, + "More than NTHREADS threads"); + CYG_ASSERT( pthread_equal(pthread_self(),thread[0]), + "kill_threads() not called from thread 0"); + all_exit = 1; + while ( nthreads > 1 ) { + nthreads--; + if ( 0 != thread[nthreads] ) { + sem_post( &hold[nthreads] ); + pthread_cancel( thread[nthreads] ); + pthread_join( thread[nthreads], NULL ); + thread[nthreads] = 0; + sem_destroy( &hold[nthreads] ); + } + } + CYG_ASSERT(nthreads == 1, + "No threads left"); +} + +// ------------------------------------------------------------------------ + +#define DELAYFACTOR 1 // for debugging + +// ------------------------------------------------------------------------ + +pthread_mutex_t mutex; + +// These are for reporting back to the master thread +volatile int got_it = 0; +volatile int t3ran = 0; +volatile int t3ended = 0; +volatile int extras[4] = {0,0,0,0}; + +volatile int go_flag = 0; // but this one controls thread 3 from thread 2 + +// ------------------------------------------------------------------------ +// 0 to 3 of these run generally to interfere with the other processing, +// to cause multiple prio inheritances, and clashes in any orders. + +static void *extra_thread( void *arg ) +{ +#define XINFO( z ) \ + do { z[13] = '0' + data; CYG_TEST_INFO( z ); } while ( 0 ) + + static char running[] = "Extra thread Xa running"; + static char exiting[] = "Extra thread Xa exiting"; + static char resumed[] = "Extra thread Xa resumed"; + static char locked[] = "Extra thread Xa locked"; + static char unlocked[] = "Extra thread Xa unlocked"; + + int id = (int)arg; + CYG_ADDRWORD data = thread_data[id]; + + CYG_ASSERT( (id >= 4 && id <= 6), "extra_thread invalid id" ); + + // Emulate resume behaviour + sem_wait( &hold[id] ); + if( all_exit ) return 0; + + XINFO( running ); + + sem_wait( &hold[id] ); + + XINFO( resumed ); + + pthread_mutex_lock( &mutex ); + + XINFO( locked ); + + pthread_mutex_unlock( &mutex ); + + XINFO( unlocked ); + + extras[ data ] ++; + + XINFO( exiting ); + +} + +// ------------------------------------------------------------------------ + +static void *t1( void *arg ) +{ + int id = (int)arg; + //CYG_ADDRWORD data = thread_data[id]; + + // Emulate resume behaviour + sem_wait( &hold[id] ); + if( all_exit ) return 0; + + CYG_TEST_INFO( "Thread 1 running" ); + + sem_wait( &hold[id] ); + + pthread_mutex_lock( &mutex ); + + got_it++; + + CYG_TEST_CHECK( 0 == t3ended, "T3 ended prematurely [T1,1]" ); + + pthread_mutex_unlock( &mutex ); + + CYG_TEST_CHECK( 0 == t3ended, "T3 ended prematurely [T1,2]" ); + + // That's all. + + CYG_TEST_INFO( "Thread 1 exit" ); + + return 0; +} + +// ------------------------------------------------------------------------ + +static void *t2( void *arg ) +{ + int i; + int id = (int)arg; + CYG_ADDRWORD data = thread_data[id]; + cyg_tick_count_t now, then; + + // Emulate resume behaviour + sem_wait( &hold[id] ); + if( all_exit ) return 0; + + CYG_TEST_INFO( "Thread 2 running" ); + + CYG_TEST_CHECK( 0 == (data & ~0x77), "Bad T2 arg: extra bits" ); + CYG_TEST_CHECK( 0 == (data & (data >> 4)), "Bad T2 arg: overlap" ); + + sem_wait( &hold[id] ); + + // depending on our config argument, optionally restart some of the + // extra threads to throw noise into the scheduler: + for ( i = 0; i < 3; i++ ) + if ( (1 << i) & data ) // bits 0-2 control + sem_post( &hold[i+4] ); // made sure extras are thread[4-6] + + // let those threads run + for( i = 0; i < DELAYFACTOR * 10; i++ ) + nanosleep( &sleeptime, NULL ); + + cyg_scheduler_lock(); // do this next lot atomically + + go_flag = 1; // unleash thread 3 + sem_post( &hold[1] ); // resume thread 1 + + // depending on our config argument, optionally restart some of the + // extra threads to throw noise into the scheduler at this later point: + for ( i = 4; i < 7; i++ ) + if ( (1 << i) & data ) // bits 4-6 control + sem_post( &hold[i] ); // made sure extras are thread[4-6] + + cyg_scheduler_unlock(); // let scheduling proceed + + // Need a delay (but not a CPU yield) to allow t3 to awaken and act on + // the go_flag, otherwise we check these details below too soon. + // Actually, waiting for the clock to tick a couple of times would be + // better, so that is what we will do. Must be a busy-wait. + then = cyg_current_time(); + do { + now = cyg_current_time(); + // Wait longer than the delay in t3 waiting on go_flag + } while ( now < (then + 3) ); + +#ifdef _POSIX_THREAD_PRIO_INHERIT + CYG_TEST_INFO( "Checking for mutex priority inheritance" ); + CYG_TEST_CHECK( 1 == t3ran, "Thread 3 did not run" ); + CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" ); +#else + CYG_TEST_INFO( "Checking for NO mutex priority inheritance" ); + CYG_TEST_CHECK( 0 == t3ran, "Thread 3 DID run" ); + CYG_TEST_CHECK( 0 == got_it, "Thread 1 DID get the mutex" ); +#endif + + CYG_TEST_CHECK( 0 == t3ended, "Thread 3 ended prematurely [T2,1]" ); + + for( i = 0; i < DELAYFACTOR * 20; i++ ) + nanosleep( &sleeptime, NULL ); // let those threads run + + CYG_TEST_CHECK( 1 == t3ran, "Thread 3 did not run" ); + CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" ); + CYG_TEST_CHECK( 1 == t3ended, "Thread 3 has not ended" ); + + for ( i = 0; i < 3; i++ ) + if ( (1 << i) & (data | data >> 4) ) // bits 0-2 and 4-6 control + CYG_TEST_CHECK( 1 == extras[i+1], "Extra thread did not run" ); + else + CYG_TEST_CHECK( 0 == extras[i+1], "Extra thread ran" ); + + CYG_TEST_PASS( "Thread 2 exiting, AOK" ); + // That's all: restart the control thread. + sem_post( &hold[0] ); + + return 0; +} + +// ------------------------------------------------------------------------ + +static void *t3( void *arg ) +{ + int i; + int id = (int)arg; + //CYG_ADDRWORD data = thread_data[id]; + + // Emulate resume behaviour + sem_wait( &hold[id] ); + if( all_exit ) return 0; + + CYG_TEST_INFO( "Thread 3 running" ); + + pthread_mutex_lock( &mutex ); + + for( i = 0; i < DELAYFACTOR * 5; i++ ) + nanosleep( &sleeptime, NULL ); // let thread 3a run + + sem_post( &hold[2] ); // resume thread 2 + + while ( 0 == go_flag ) + nanosleep( &sleeptime, NULL ); // wait until we are told to go + + t3ran ++; // record the fact + + CYG_TEST_CHECK( 0 == got_it, "Thread 1 claims to have got my mutex" ); + + pthread_mutex_unlock( &mutex ); + + t3ended ++; // record that we came back + + CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" ); + + CYG_TEST_INFO( "Thread 3 exit" ); + + return 0; +} + +// ------------------------------------------------------------------------ + +static void *control_thread( void *arg ) +{ + int i,z; + int id = (int)arg; + //CYG_ADDRWORD data = thread_data[id]; + + // Emulate resume behaviour + sem_wait( &hold[id] ); + if( all_exit ) return 0; + + // one tick sleep time + sleeptime.tv_nsec = 10000000; + sleeptime.tv_sec = 0; + + CYG_TEST_INIT(); + CYG_TEST_INFO( "Control Thread running" ); + + // Go through the 27 possibilitied of resuming the extra threads + // 0: not at all + // 1: early in the process + // 2: later on + // which are represented by bits 0-3 and 4-6 resp in the argument to + // thread 2 (none set means no resume at all). + for ( i = 0; i < 27; i++ ) { + static int xx[] = { 0, 1, 16 }; + int j = i % 3; + int k = (i / 3) % 3; + int l = (i / 9) % 3; + + int d = xx[j] | (xx[k]<<1) | (xx[l]<<2) ; + + if ( cyg_test_is_simulator && (0 != i && 13 != i && 26 != i) ) + continue; // 13 is 111 base 3, 26 is 222 base 3 + +#ifdef _POSIX_THREAD_PRIO_INHERIT + // If the simple scheme plus relay enhancement, or any other + // *complete* scheme, we can run all three ancillary threads no + // problem, so no special action here. + +#else + // If no priority inheritance at all, running threads 1a and 2a is + // OK, but not thread 3a; it blocks the world. + if ( l ) // Cannot run thread 3a if no + break; // priority inheritance at all. +#endif + + // Reinitialize mutex to provide priority inheritance + { + pthread_mutexattr_t attr; + pthread_mutexattr_init( &attr ); + pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT ); + pthread_mutex_init( &mutex, &attr ); + } + + got_it = 0; + t3ran = 0; + t3ended = 0; + for ( z = 0; z < 4; z++ ) extras[z] = 0; + go_flag = 0; + + new_thread( t1, 0, 15, 1 ); // Slot 1 + new_thread( t2, d, 10, 1 ); // Slot 2 + new_thread( t3, 0, 5, 1 ); // Slot 3 + + new_thread( extra_thread, 1, 17, j ); // Slot 4 + new_thread( extra_thread, 2, 12, k ); // Slot 5 + new_thread( extra_thread, 3, 8, l ); // Slot 6 + + { + static char *a[] = { "inactive", "run early", "run late" }; + diag_printf( "\n----- [%2d] New Cycle: 0x%02x, Threads 1a %s, 2a %s, 3a %s -----\n", + i, d, a[j], a[k], a[l] ); + } + + sem_wait( &hold[0] ); + + kill_threads(); + pthread_mutex_destroy( &mutex ); + } + CYG_TEST_EXIT( "Control Thread exit" ); + + return 0; +} + +// ------------------------------------------------------------------------ + +static sem_t main_sem; + +externC int +main( int argc, char **argv ) +{ + new_thread( control_thread, 0, 20, 1 ); + + // We have nothing for main to do here, so put it to sleep on + // its own semaphore. We cannot let it just exit since that + // will end the whole program. + + sem_init( &main_sem, 0, 0 ); + + for(;;) sem_wait( &main_sem ); +} + +#else // CYGVAR_KERNEL_COUNTERS_CLOCK &c + +externC int +main( int argc, char **argv ) +{ + CYG_TEST_INIT(); + CYG_TEST_PASS_FINISH("Mutex3 test requires:\n" + "CYGVAR_KERNEL_COUNTERS_CLOCK &&\n" + "(CYGNUM_KERNEL_SCHED_PRIORITIES > 20)\n"); +} +#endif // CYGVAR_KERNEL_COUNTERS_CLOCK &c + + +// ------------------------------------------------------------------------ +// Documentation: enclosed is the design of this test. +// +// It has been carefully constructed so that it does NOT use other kernel +// facilities (aside from delay-task) to test that priority inheritance is +// working, or not, as intended by the configuration. +// +// These notes describe the flow of control in one run of the test with the +// ancillary tasks optionally interspersed. The details of how those extra +// tasks are or are not allowed to run are not described. +// +// +// +// The only change in the test that depends on whether there is inheritance or +// not is the check in thread 2 on "3-ran" and "got it" flags marked **** +// +// +// volatile &c booleans: +// "got it" = FALSE +// "3-ran" = FALSE +// "3-ended" = FALSE +// "extras"[3] = FALSE +// +// thread 1. prio 5, self-suspend. +// +// thread 1a, prio 8, self-suspend. +// +// thread 2. prio 10, self-suspend. +// +// thread 2a, prio 12, self-suspend. +// +// thread 3. prio 15, runs, lock mutex, resume(2) +// +// thread 3a, prio 17, self-suspend. +// +// 2. runs, +// 2. resume(3a) +++OPTIONAL +// 2. resume(2a) +++OPTIONAL +// 2. resume(1a) +++OPTIONAL +// [1a lock-fail] thread 3->prio := 8 +// +// [3. runs maybe, does the looping thing] +// +// 2. sleep a while... +// +// [2a lock-fail] thread 3->prio := 12 +// +// [3. runs maybe, does the looping thing] +// +// [3a lock-fail] thread 3->prio unchanged +// +// [3. runs maybe, does the looping thing] +// +// 2. lock scheduler +// 2. set "go-flag" +// 2. resume(1) +// 2. resume(1a) +++OPTIONAL +// 2. resume(2a) +++OPTIONAL +// 2. resume(3a) +++OPTIONAL +// 2. unlock scheduler +// +// 1. runs, lock mutex - thread 3 has it locked +// +// 2. busy-waits a bit for thread 3 to come out of its delay() loop. +// This must be a *busy*wait so that 3 can only run via the +// inherited raised priority. +// +// [xa. all do the same: lock mutex, ] +// [xa. unlock mutex ] +// [xa. set a flag "extras"[x] to say we are done. ] +// [xa. exit ] +// +// +// +// INHERIT +// ------- +// +// thread 3->prio := 5 +// +// 3. runs, +// 3. set a flag to say "3-ran", +// 3. loop with a sleep(1) until "go-flag" is set. +// 3. check "got it" is false, +// 3. then unlock mutex, +// +// thread 3->prio := 15 +// +// 1. runs, set a flag to say "got it", +// 1. check "3-ended" flag is false +// 1. unlock mutex, +// 1. check "3-ended" flag is still false +// 1. exit. +// +// [1a locks, unlocks, exits] +// +// 2. runs, check "3-ran" and "got it" flags are TRUE **** +// 2. check "3-ended" flag is false +// 2. sleeps for a while so that... +// +// [2a locks, unlocks, exits] +// +// 3. runs, set "3-ended" flag, +// 3. check "3-ran" and "got it" flags +// 3. exit +// +// [3a locks, unlocks, exits] +// +// 2. awakens, checks all flags true, +// 2. check that all "extra" threads that we started have indeed run +// 2. end of test. +// +// +// +// +// NO-INHERIT +// ---------- +// thread 1 is waiting on the mutex +// +// [1a lock-fail] +// +// 2. runs, checks that "3-ran" and "got it" flags are FALSE **** +// 2. check "3-ended" flag is false +// 2. sleeps for a while so that... +// +// [2a. lock-fail] +// +// 3. runs, set a flag to say "3-ran", +// 3. check "got it" is false, +// 3. then unlock mutex, +// +// 1. runs, set a flag to say "got it", +// 1. check "3-ended" flag is false +// 1. unlock mutex, +// 1. check "3-ended" flag is still false +// 1. exit. +// +// [1a locks, unlocks, exits] +// [2a locks, unlocks, exits] +// +// 3. runs, set "3-ended" flag, +// 3. check "3-ran" and "got it" flags +// 3. exit +// +// [3a locks, unlocks, exits] +// +// 2. awakens, checks all flags true, +// 2. check that all "extra" threads that we started have indeed run +// 2. end of test. +// +// +// (the end) +// +// +// ------------------------------------------------------------------------ + +// EOF mutex3.cxx diff --git a/packages/compat/posix/current/tests/pthread1.c b/packages/compat/posix/current/tests/pthread1.c new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/tests/pthread1.c @@ -0,0 +1,94 @@ +//========================================================================== +// +// pthread1.cxx +// +// POSIX pthread test 1 +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-04-10 +// Description: Tests POSIX join functionality. +// +//####DESCRIPTIONEND#### +//========================================================================== + +#include +#include + +#include + +//-------------------------------------------------------------------------- +// Thread stack. + +char thread_stack[PTHREAD_STACK_MIN*2]; + +//-------------------------------------------------------------------------- + +void *pthread_entry1( void *arg) +{ + CYG_TEST_INFO( "Thread 1 running" ); + + pthread_exit( (void *)((int)arg+1) ); +} + +//-------------------------------------------------------------------------- + +int main(int argc, char **argv) +{ + pthread_t thread; + pthread_attr_t attr; + void *retval; + + CYG_TEST_INIT(); + + // Create test thread + pthread_attr_init( &attr ); + + pthread_attr_setstackaddr( &attr, (void *)&thread_stack[sizeof(thread_stack)] ); + pthread_attr_setstacksize( &attr, sizeof(thread_stack) ); + + pthread_create( &thread, + &attr, + pthread_entry1, + (void *)0x12345678); + + // Now join with it + pthread_join( thread, &retval ); + + // check retval + + if( (long)retval == 0x12345679 ) + CYG_TEST_PASS_FINISH( "pthread1" ); + else + CYG_TEST_FAIL_FINISH( "pthread1" ); +} + +//-------------------------------------------------------------------------- +// end of pthread1.c diff --git a/packages/compat/posix/current/tests/pthread2.c b/packages/compat/posix/current/tests/pthread2.c new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/tests/pthread2.c @@ -0,0 +1,151 @@ +//========================================================================== +// +// pthread2.cxx +// +// POSIX pthread test 2 - per-thread data +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-04-10 +// Description: Tests POSIX per-thread data. +// +//####DESCRIPTIONEND#### +//========================================================================== + +#include +#include + +#include + +//-------------------------------------------------------------------------- +// Thread stack. + +char thread_stack[2][PTHREAD_STACK_MIN*2]; + +pthread_t thread[2]; + +pthread_key_t key; + +//-------------------------------------------------------------------------- + +void key_destructor( void *val ) +{ + int ret; + + CYG_TEST_INFO( "key destructor called" ); + + if( (long)val == 0xAAAAAAAA ) + { + ret = pthread_setspecific( key, NULL ); + CYG_TEST_CHECK( ret == 0, "pthread_setspecific() returned error"); + } + else + { + ret = pthread_setspecific( key, (void *)0xAAAAAAAA ); + CYG_TEST_CHECK( ret == 0, "pthread_setspecific() returned error"); + } +} + +//-------------------------------------------------------------------------- + +void *pthread_entry( void *arg) +{ + int ret; + int retval = 1; + void *val; + + CYG_TEST_INFO( "Thread running" ); + + ret = pthread_setspecific( key, arg ); + CYG_TEST_CHECK( ret == 0, "pthread_setspecific() returned error"); + + val = pthread_getspecific( key ); + CYG_TEST_CHECK( val == arg, "pthread_getspecific() did not return expected value"); + if( val != arg ) retval = 0; + + sched_yield(); + + val = pthread_getspecific( key ); + CYG_TEST_CHECK( val == arg, "pthread_getspecific() did not return expected value"); + if( val != arg ) retval = 0; + + pthread_exit( (void *)retval ); +} + +//-------------------------------------------------------------------------- + +int main(int argc, char **argv) +{ + int i; + int ret; + void *retval[2]; + + CYG_TEST_INIT(); + + // allocate data key + ret = pthread_key_create( &key, key_destructor ); + CYG_TEST_CHECK( ret == 0, "pthread_key_create() returned error"); + + // Create test threads + for( i = 0; i < 2; i++ ) + { + pthread_attr_t attr; + pthread_attr_init( &attr ); + + pthread_attr_setstackaddr( &attr, (void *)&thread_stack[i][sizeof(thread_stack)] ); + pthread_attr_setstacksize( &attr, sizeof(thread_stack[i]) ); + + ret = pthread_create( &thread[i], + &attr, + pthread_entry, + (void *)(0x12340000+i)); + CYG_TEST_CHECK( ret == 0, "pthread_create() returned error"); + } + + // Now join with threads + for( i = 0; i < 2; i++ ) + pthread_join( thread[i], &retval[i] ); + + + ret = pthread_key_delete( key ); + CYG_TEST_CHECK( ret == 0, "pthread_key_delete() returned error"); + + // check retvals + + for( i = 0; i < 2; i++ ) + if( !(long)retval[0] ) + CYG_TEST_FAIL_FINISH( "pthread2" ); + + CYG_TEST_PASS_FINISH( "pthread2" ); + +} + +//-------------------------------------------------------------------------- +// end of pthread2.c diff --git a/packages/compat/posix/current/tests/pthread3.c b/packages/compat/posix/current/tests/pthread3.c new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/tests/pthread3.c @@ -0,0 +1,213 @@ +//========================================================================== +// +// pthread3.cxx +// +// POSIX pthread test 2 - cancellation +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-04-10 +// Description: Tests POSIX cancellation. +// +//####DESCRIPTIONEND#### +//========================================================================== + +#include +#include + +#include + +//-------------------------------------------------------------------------- +// Thread info + +#define NTHREADS 2 + +char thread_stack[NTHREADS][PTHREAD_STACK_MIN*2]; + +pthread_t thread[NTHREADS]; + +void *pthread_entry1( void *arg); +void *pthread_entry2( void *arg); + +void *(*pthread_entry[NTHREADS])(void *) = +{ + pthread_entry1, + pthread_entry2 +}; + +//-------------------------------------------------------------------------- + +volatile cyg_bool cancel_handler1_called = false; +volatile cyg_bool cancel_handler2_called = false; +volatile cyg_bool cancel_handler3_called = false; + +//-------------------------------------------------------------------------- + +void cancel_handler1( void * arg ) +{ + CYG_TEST_INFO( "cancel_handler1 called" ); + + CYG_TEST_CHECK( (long)arg == 0x12340000, "cancel_handler1: bad arg value"); + + cancel_handler1_called = true; +} + +//-------------------------------------------------------------------------- + +void cancel_handler2( void * arg ) +{ + CYG_TEST_INFO( "cancel_handler2 called" ); + + CYG_TEST_CHECK( (long)arg == 0xFFFF1111, "cancel_handler2: bad arg value"); + + cancel_handler2_called = true; +} + +//-------------------------------------------------------------------------- + +void cancel_handler3( void * arg ) +{ + CYG_TEST_INFO( "cancel_handler3 called" ); + + CYG_TEST_CHECK( (long)arg == 0x12340001, "cancel_handler3: bad arg value"); + + cancel_handler3_called = true; +} + +//-------------------------------------------------------------------------- + +void function1(void) +{ + + pthread_cleanup_push( cancel_handler2, (void *)0xFFFF1111 ); + + for(;;) + { + sched_yield(); + pthread_testcancel(); + } + + pthread_cleanup_pop( 0 ); +} + +//-------------------------------------------------------------------------- + +void *pthread_entry1( void *arg) +{ + int retval = 1; + + CYG_TEST_INFO( "pthread_entry1 entered"); + + pthread_setcanceltype( PTHREAD_CANCEL_DEFERRED, NULL ); + + pthread_cleanup_push( cancel_handler1, arg ); + + function1(); + + pthread_cleanup_pop( 0 ); + + pthread_exit( (void *)retval ); +} + +//-------------------------------------------------------------------------- + +void *pthread_entry2( void *arg) +{ + int retval = 1; + + CYG_TEST_INFO( "pthread_entry2 entered"); + + pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS, NULL ); + + pthread_cleanup_push( cancel_handler3, arg ); + + for(;;) sched_yield(); + + pthread_cleanup_pop( 0 ); + + pthread_exit( (void *)retval ); +} + +//-------------------------------------------------------------------------- + +int main(int argc, char **argv) +{ + int i; + int ret; + void *retval[NTHREADS]; + + CYG_TEST_INIT(); + + // Create test threads + for( i = 0; i < NTHREADS; i++ ) + { + pthread_attr_t attr; + pthread_attr_init( &attr ); + + pthread_attr_setstackaddr( &attr, (void *)&thread_stack[i][sizeof(thread_stack)] ); + pthread_attr_setstacksize( &attr, sizeof(thread_stack[i]) ); + + ret = pthread_create( &thread[i], + &attr, + pthread_entry[i], + (void *)(0x12340000+i)); + CYG_TEST_CHECK( ret == 0, "pthread_create() returned error"); + } + + // Let the threads get going + sched_yield(); + sched_yield(); + sched_yield(); + + // Now cancel them + for( i = 0; i < NTHREADS; i++ ) + pthread_cancel( thread[i] ); + + // Now join with threads + for( i = 0; i < NTHREADS; i++ ) + pthread_join( thread[i], &retval[i] ); + + + // check retvals + for( i = 0; i < NTHREADS; i++ ) + if( retval[0] != PTHREAD_CANCELED ) + CYG_TEST_FAIL_FINISH( "pthread3" ); + + if( !cancel_handler1_called ) CYG_TEST_FAIL_FINISH( "pthread3" ); + if( !cancel_handler2_called ) CYG_TEST_FAIL_FINISH( "pthread3" ); + if( !cancel_handler3_called ) CYG_TEST_FAIL_FINISH( "pthread3" ); + + + CYG_TEST_PASS_FINISH( "pthread3" ); + +} + +//-------------------------------------------------------------------------- +// end of pthread3.c diff --git a/packages/compat/posix/current/tests/signal1.c b/packages/compat/posix/current/tests/signal1.c new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/tests/signal1.c @@ -0,0 +1,243 @@ +//========================================================================== +// +// signal1.cxx +// +// POSIX signal test 1 +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-04-10 +// Description: Tests POSIX signal functionality. +// +//####DESCRIPTIONEND#### +//========================================================================== + +#include +#include +#include +#include + +#include + +//-------------------------------------------------------------------------- +// Thread stack. + +char thread_stack[PTHREAD_STACK_MIN*2]; + +//-------------------------------------------------------------------------- +// Local variables + +// Sync semaphore +sem_t sem; + +// Thread ID +pthread_t thread1; + +volatile int sigusr2_called = 0; +volatile int sigalrm_called = 0; + +//-------------------------------------------------------------------------- +// Signal handler functions + +static void sigusr2( int signo ) +{ + CYG_TEST_INFO( "sigusr2() handler called" ); + CYG_TEST_CHECK( signo == SIGUSR2, "Signal not SIGUSR2"); + CYG_TEST_CHECK( pthread_equal(pthread_self(), thread1), "Not called in thread1"); + + sigusr2_called++; +} + +static void sigalrm( int signo ) +{ + CYG_TEST_INFO( "sigalrm() handler called" ); + CYG_TEST_CHECK( signo == SIGALRM, "Signal not SIGALRM"); + CYG_TEST_CHECK( pthread_equal(pthread_self(), thread1), "Not called in thread1"); + + sigalrm_called++; +} + +//-------------------------------------------------------------------------- + +void *pthread_entry1( void *arg) +{ + sigset_t mask; + siginfo_t info; + struct timespec timeout; + int sig; + + CYG_TEST_INFO( "Thread 1 running" ); + + // Make a full set + sigfillset( &mask ); + + // remove USR2 and ALRM signals + sigdelset( &mask, SIGUSR2 ); + sigdelset( &mask, SIGALRM ); + + // Set signal mask + pthread_sigmask( SIG_SETMASK, &mask, NULL ); + + // Get main thread going again + sem_post( &sem ); + + // set up timeout + timeout.tv_sec = 10; + timeout.tv_nsec = 0; + + CYG_TEST_INFO( "Thread1: calling sigtimedwait()"); + + // Wait for a signal to be delivered + sigtimedwait( &mask, &info, &timeout ); + + sig = info.si_signo; + + CYG_TEST_CHECK( sig == SIGUSR1, "Signal not delivered"); + + while( sigusr2_called != 2 ) + { + CYG_TEST_INFO( "Thread1: calling pause()"); + pause(); + } + + // now wait for SIGALRM to be delivered + CYG_TEST_INFO( "Thread1: calling pause()"); + pause(); + + CYG_TEST_INFO( "Thread1: calling pthread_exit()"); + pthread_exit( (void *)((int)arg+sig) ); +} + +//-------------------------------------------------------------------------- + +int main(int argc, char **argv) +{ + int ret; + sigset_t mask; + pthread_attr_t attr; + void *retval; + union sigval value; + + CYG_TEST_INIT(); + + // Make a full signal set + sigfillset( &mask ); + + + // Install signal handlers + { + struct sigaction sa; + + sa.sa_handler = sigusr2; + sa.sa_mask = mask; + sa.sa_flags = 0; + + ret = sigaction( SIGUSR2, &sa, NULL ); + + CYG_TEST_CHECK( ret == 0 , "sigaction returned error"); + } + + { + struct sigaction sa; + + sa.sa_handler = sigalrm; + sa.sa_mask = mask; + sa.sa_flags = 0; + + ret = sigaction( SIGALRM, &sa, NULL ); + + CYG_TEST_CHECK( ret == 0 , "sigaction returned error"); + } + + + // Mask all signals + pthread_sigmask( SIG_SETMASK, &mask, NULL ); + + sem_init( &sem, 0, 0 ); + + // Create test thread + pthread_attr_init( &attr ); + + pthread_attr_setstackaddr( &attr, (void *)&thread_stack[sizeof(thread_stack)] ); + pthread_attr_setstacksize( &attr, sizeof(thread_stack) ); + + pthread_create( &thread1, + &attr, + pthread_entry1, + (void *)0x12345678); + + // Wait for other thread to get started + CYG_TEST_INFO( "Main: calling sem_wait()"); + sem_wait( &sem ); + + value.sival_int = 0; + + // send a signal to the other thread + CYG_TEST_INFO( "Main: calling sigqueue(SIGUSR1)"); + sigqueue( 0, SIGUSR1, value ); + + // Send the signal via kill + CYG_TEST_INFO( "Main: calling kill(0, SIGUSR2)"); + kill( 0, SIGUSR2 ); + + // Wait for thread1 to call pause() + CYG_TEST_INFO( "Main: calling sleep(1)"); + sleep(1); + + // And again + CYG_TEST_INFO( "Main: calling kill(0, SIGUSR2)"); + kill( 0, SIGUSR2 ); + + // Set up an alarm for 1 second hence + CYG_TEST_INFO( "Main: calling alarm(1)"); + alarm(1); + + // Wait for alarm signal to be delivered to thread1 + CYG_TEST_INFO( "Main: calling sleep(2)"); + sleep(2); + + // Now join with thread1 + CYG_TEST_INFO( "Main: calling pthread_join()"); + pthread_join( thread1, &retval ); + + CYG_TEST_CHECK( sigusr2_called == 2, "SIGUSR2 signal handler not called twice" ); + + CYG_TEST_CHECK( sigalrm_called == 1, "SIGALRM signal handler not called" ); + + // check retval + + if( (long)retval == 0x12345678+SIGUSR1 ) + CYG_TEST_PASS_FINISH( "signal1" ); + else + CYG_TEST_FAIL_FINISH( "signal1" ); +} + +//-------------------------------------------------------------------------- +// end of signal1.c diff --git a/packages/compat/posix/current/tests/signal2.c b/packages/compat/posix/current/tests/signal2.c new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/tests/signal2.c @@ -0,0 +1,261 @@ +//========================================================================== +// +// signal2.cxx +// +// POSIX signal test 2 +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: jlarmour +// Date: 2000-04-10 +// Description: Tests POSIX signal functionality. +// +//####DESCRIPTIONEND#### +//========================================================================== + +#include +#include // For exception codes + +#include +#include +#include +#include + +#include + +#include + +#if CYGINT_ISO_SETJMP == 0 +# define NA_MSG "Requires setjmp/longjmp implementation" +#endif + +#ifdef NA_MSG +void +cyg_start(void) +{ + CYG_TEST_INIT(); + CYG_TEST_NA( NA_MSG ); +} +#else + +//-------------------------------------------------------------------------- +// Local variables + +static jmp_buf jbuf; + +//-------------------------------------------------------------------------- + +static void +cause_unaligned_access(void) +{ + volatile int x; + volatile CYG_ADDRESS p=(CYG_ADDRESS) &jbuf; + + x = *(volatile int *)(p+1); + +} // cause_unaligned_access() + +//-------------------------------------------------------------------------- + +static void +cause_illegal_access(void) +{ + volatile int x; + volatile CYG_ADDRESS p=(CYG_ADDRESS) &jbuf; + + do + { + x = *(volatile int *)(p); + p += (CYG_ADDRESS)0x100000; + } while( p != 0 ); + +} // cause_unaligned_access() + +//-------------------------------------------------------------------------- + +// num must always be 0 - do it this way in case the optimizer tries to +// get smart + +static int +cause_fpe(int num) +{ + double a; + + a = 1.0/num; // Depending on FPU emulation and/or + // the FPU architecture, this may + // cause an exception. + // (float division by zero) + + return ((int)a)/num; // This may cause an exception if + // the architecture supports it. + // (integer division by zero). +} // cause_fpe() + +//-------------------------------------------------------------------------- +// Signal handler functions + +static void sigsegv( int signo ) +{ + CYG_TEST_INFO( "sigsegv() handler called" ); + CYG_TEST_CHECK( signo == SIGSEGV, "Signal not SIGSEGV"); + + longjmp( jbuf, 1 ); +} + +static void sigbus( int signo ) +{ + CYG_TEST_INFO( "sigbus() handler called" ); + CYG_TEST_CHECK( signo == SIGBUS, "Signal not SIGBUS"); + + longjmp( jbuf, 1 ); +} + +static void sigfpe( int signo ) +{ + CYG_TEST_INFO( "sigfpe() handler called" ); + CYG_TEST_CHECK( signo == SIGFPE, "Signal not SIGFPE"); + + longjmp( jbuf, 1 ); +} + + +//-------------------------------------------------------------------------- + +int main(int argc, char **argv) +{ + int ret; + sigset_t mask; + struct sigaction sa; + + CYG_TEST_INIT(); + + // Make a full signal set + sigfillset( &mask ); + + + // Install signal handlers + + sa.sa_mask = mask; + sa.sa_flags = 0; + + sa.sa_handler = sigsegv; + ret = sigaction( SIGSEGV, &sa, NULL ); + CYG_TEST_CHECK( ret == 0 , "sigaction returned error"); + + sa.sa_handler = sigbus; + ret = sigaction( SIGBUS, &sa, NULL ); + CYG_TEST_CHECK( ret == 0 , "sigaction returned error"); + + sa.sa_handler = sigfpe; + ret = sigaction( SIGFPE, &sa, NULL ); + CYG_TEST_CHECK( ret == 0 , "sigaction returned error"); + + // now make an empty signal set + sigemptyset( &mask ); + +// Now reset the various exception handlers to eCos handlers so that we +// have control; this is the target side equivalent of the CYG_TEST_GDBCMD +// lines above: +#ifdef HAL_VSR_SET_TO_ECOS_HANDLER + // Reclaim the VSR off CygMon possibly +#ifdef CYGNUM_HAL_EXCEPTION_DATA_ACCESS + HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DATA_ACCESS, NULL ); +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_ACCESS + HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_ACCESS, NULL ); +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS + HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS, NULL ); +#endif +#ifdef CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION + HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION, NULL ); +#endif +#ifdef CYGNUM_HAL_EXCEPTION_FPU_DIV_BY_ZERO + HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_FPU_DIV_BY_ZERO, NULL ); +#endif +#endif + +#ifdef CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS + + CYG_TEST_INFO("Test 1 - provoke unaligned access"); + + if( setjmp( jbuf ) == 0 ) + { + pthread_sigmask( SIG_SETMASK, &mask, NULL ); + cause_unaligned_access(); + CYG_TEST_FAIL("Didn't cause exception"); + } + +#else + + CYG_TEST_NA("Test 1 - provoke unaligned access - not supported"); + +#endif + +#ifdef CYGNUM_HAL_EXCEPTION_DATA_ACCESS + + CYG_TEST_INFO("Test 2 - provoke illegal access"); + + if( setjmp( jbuf ) == 0 ) + { + pthread_sigmask( SIG_SETMASK, &mask, NULL ); + cause_illegal_access(); + CYG_TEST_FAIL("Didn't cause exception"); + } + +#else + + CYG_TEST_NA("Test 1 - provoke illegal access - not supported"); + +#endif + +#ifdef CYGNUM_HAL_EXCEPTION_FPU_DIV_BY_ZERO + + CYG_TEST_INFO("Test 3 - provoke FP error"); + + if( setjmp( jbuf ) == 0 ) + { + pthread_sigmask( SIG_SETMASK, &mask, NULL ); + cause_fpe(0); + CYG_TEST_FAIL("Didn't cause exception"); + } + +#else + + CYG_TEST_NA("Test 3 - provoke FP error - not supported"); + +#endif + + CYG_TEST_FINISH( "signal2" ); +} + +#endif // ifndef NA_MSG + +//-------------------------------------------------------------------------- +// end of signal1.c diff --git a/packages/compat/posix/current/tests/timer1.c b/packages/compat/posix/current/tests/timer1.c new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/tests/timer1.c @@ -0,0 +1,321 @@ +//========================================================================== +// +// timer1.cxx +// +// POSIX signal test 1 +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-04-10 +// Description: Tests POSIX signal functionality. +// +//####DESCRIPTIONEND#### +//========================================================================== + +#include +#include +#include +#include +#include + +#include + +//-------------------------------------------------------------------------- +// Thread stack. + +char thread1_stack[PTHREAD_STACK_MIN*2]; +char thread2_stack[PTHREAD_STACK_MIN*2]; + +//-------------------------------------------------------------------------- +// Local variables + +// Sync semaphore +sem_t sem; + +// Thread IDs +pthread_t thread1; +pthread_t thread2; + +timer_t timer1; +timer_t timer2; + +volatile int sigusr1_called = 0; +volatile int sigusr2_called = 0; + +//-------------------------------------------------------------------------- +// Signal handler functions + +static void sigusr1( int signo, siginfo_t *info, void *context ) +{ + CYG_TEST_INFO( "sigusr1() handler called" ); + CYG_TEST_CHECK( signo == SIGUSR1, "Signal not SIGUSR1"); + CYG_TEST_CHECK( signo == info->si_signo, "Bad signal number in siginfo" ); + CYG_TEST_CHECK( info->si_code == SI_TIMER, "Siginfo code not SI_TIMER" ); + CYG_TEST_CHECK( info->si_value.sival_int == 0xABCDEF01, "Siginfo value wrong"); + CYG_TEST_CHECK( pthread_equal(pthread_self(), thread1), "Not called in thread1"); + + sigusr1_called++; +} + +static void sigusr2( int signo, siginfo_t *info, void *context ) +{ + CYG_TEST_INFO( "sigusr2() handler called" ); + CYG_TEST_CHECK( signo == SIGUSR2, "Signal not SIGUSR2"); + CYG_TEST_CHECK( signo == info->si_signo, "Bad signal number in siginfo" ); + CYG_TEST_CHECK( info->si_code == SI_TIMER, "Siginfo code not SI_TIMER" ); + CYG_TEST_CHECK( info->si_value.sival_int == 0xABCDEF02, "Siginfo value wrong"); + CYG_TEST_CHECK( pthread_equal(pthread_self(), thread2), "Not called in thread2"); + + sigusr2_called++; +} + +//-------------------------------------------------------------------------- + +void *pthread_entry1( void *arg) +{ + sigset_t mask; + + + CYG_TEST_INFO( "Thread 1 running" ); + + // Make a full set + sigfillset( &mask ); + + // remove USR1 signal + sigdelset( &mask, SIGUSR1 ); + + // Set signal mask + pthread_sigmask( SIG_SETMASK, &mask, NULL ); + + // Get main thread going again + sem_post( &sem ); + + while( sigusr1_called < 1 ) + { + CYG_TEST_INFO( "Thread1: calling pause()"); + pause(); + } + + CYG_TEST_INFO( "Thread1: calling pthread_exit()"); + pthread_exit( arg ); +} + +//-------------------------------------------------------------------------- + +void *pthread_entry2( void *arg) +{ + sigset_t mask; + + CYG_TEST_INFO( "Thread 2 running" ); + + // Make a full set + sigfillset( &mask ); + + // remove USR2 signal + sigdelset( &mask, SIGUSR2 ); + + // Set signal mask + pthread_sigmask( SIG_SETMASK, &mask, NULL ); + + // Get main thread going again + sem_post( &sem ); + + while( sigusr2_called < 6 ) + { + CYG_TEST_INFO( "Thread2: calling pause()"); + pause(); + } + + CYG_TEST_INFO( "Thread2: calling pthread_exit()"); + pthread_exit( arg ); +} + +//-------------------------------------------------------------------------- + +int main(int argc, char **argv) +{ + int ret; + sigset_t mask; + pthread_attr_t attr; + void *retval; + + CYG_TEST_INIT(); + + // Make a full signal set + sigfillset( &mask ); + + + // Install signal handlers + { + struct sigaction sa; + + sa.sa_sigaction = sigusr1; + sa.sa_mask = mask; + sa.sa_flags = SA_SIGINFO; + + ret = sigaction( SIGUSR1, &sa, NULL ); + + CYG_TEST_CHECK( ret == 0 , "sigaction returned error"); + } + { + struct sigaction sa; + + sa.sa_sigaction = sigusr2; + sa.sa_mask = mask; + sa.sa_flags = SA_SIGINFO; + + ret = sigaction( SIGUSR2, &sa, NULL ); + + CYG_TEST_CHECK( ret == 0 , "sigaction returned error"); + } + + + // Create the timers + + { + struct sigevent sev; + struct itimerspec value; + + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = SIGUSR1; + sev.sigev_value.sival_int = 0xABCDEF01; + + value.it_value.tv_sec = 1; + value.it_value.tv_nsec = 0; + value.it_interval.tv_sec = 0; + value.it_interval.tv_nsec = 0; + + ret = timer_create( CLOCK_REALTIME, &sev, &timer1 ); + + CYG_TEST_CHECK( ret == 0 , "timer_create returned error"); + + ret = timer_settime( timer1, 0, &value, NULL ); + + CYG_TEST_CHECK( ret == 0 , "timer_settime returned error"); + } + +#if 1 + { + struct sigevent sev; + struct itimerspec value; + + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = SIGUSR2; + sev.sigev_value.sival_int = 0xABCDEF02; + + value.it_value.tv_sec = 0; + value.it_value.tv_nsec = 500000000; + value.it_interval.tv_sec = 0; + value.it_interval.tv_nsec = 250000000; + + ret = timer_create( CLOCK_REALTIME, &sev, &timer1 ); + + CYG_TEST_CHECK( ret == 0 , "timer_create returned error"); + + ret = timer_settime( timer1, 0, &value, NULL ); + + CYG_TEST_CHECK( ret == 0 , "timer_settime returned error"); + } +#endif + + // Mask all signals + pthread_sigmask( SIG_SETMASK, &mask, NULL ); + + sem_init( &sem, 0, 0 ); + + // Create test threads + + { + pthread_attr_init( &attr ); + + pthread_attr_setstackaddr( &attr, (void *)&thread1_stack[sizeof(thread1_stack)] ); + pthread_attr_setstacksize( &attr, sizeof(thread1_stack) ); + + pthread_create( &thread1, + &attr, + pthread_entry1, + (void *)0x12345671); + } + + { + pthread_attr_init( &attr ); + + pthread_attr_setstackaddr( &attr, (void *)&thread2_stack[sizeof(thread2_stack)] ); + pthread_attr_setstacksize( &attr, sizeof(thread2_stack) ); + + pthread_create( &thread2, + &attr, + pthread_entry2, + (void *)0x12345672); + } + + // Wait for other thread to get started + CYG_TEST_INFO( "Main: calling sem_wait()"); + sem_wait( &sem ); + CYG_TEST_INFO( "Main: calling sem_wait() again"); + sem_wait( &sem ); + + // Now join with thread1 + CYG_TEST_INFO( "Main: calling pthread_join(thread1)"); + pthread_join( thread1, &retval ); + + CYG_TEST_CHECK( retval == (void *)0x12345671, "Thread 1 retval wrong"); + + // And thread 2 + CYG_TEST_INFO( "Main: calling pthread_join(thread2)"); + pthread_join( thread2, &retval ); + + // now delete the timers + CYG_TEST_INFO( "Main: calling timer_delete(timer1)"); + ret = timer_delete( timer1 ); + + CYG_TEST_CHECK( ret == 0 , "timer_delete(timer1) returned error"); + + CYG_TEST_INFO( "Main: calling timer_delete(timer2)"); + ret = timer_delete( timer2 ); + + CYG_TEST_CHECK( ret == 0 , "timer_delete(timer2) returned error"); + + + CYG_TEST_CHECK( retval == (void *)0x12345672, "Thread 2 retval wrong"); + + CYG_TEST_CHECK( sigusr1_called == 1, "SIGUSR1 signal handler not called once" ); + CYG_TEST_CHECK( sigusr2_called == 6, "SIGUSR2 signal handler not called six times" ); + + // check retval + + if( (long)retval == 0 ) + CYG_TEST_PASS_FINISH( "timer1" ); + else + CYG_TEST_FAIL_FINISH( "timer1" ); +} + +//-------------------------------------------------------------------------- +// end of timer1.c diff --git a/packages/compat/posix/current/tests/tm_basic.cxx b/packages/compat/posix/current/tests/tm_basic.cxx new file mode 100644 --- /dev/null +++ b/packages/compat/posix/current/tests/tm_basic.cxx @@ -0,0 +1,1675 @@ +//========================================================================== +// +// tm_basic.cxx +// +// Basic timing test / scaffolding +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 1998-10-19 +// Description: Very simple kernel timing test +//####DESCRIPTIONEND#### +//========================================================================== + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include CYGHWR_MEMORY_LAYOUT_H + + +// POSIX headers + +#include +#include +#include +#include +#include +#include + +//========================================================================== +// Define this to see the statistics with the first sample datum removed. +// This can expose the effects of caches on the speed of operations. + +#undef STATS_WITHOUT_FIRST_SAMPLE + +//========================================================================== + +#if defined(CYGPKG_POSIX) && \ + defined(CYGFUN_KERNEL_API_C) && \ + defined(CYGSEM_KERNEL_SCHED_MLQUEUE) && \ + defined(CYGVAR_KERNEL_COUNTERS_CLOCK) && \ + !defined(CYGPKG_HAL_I386_LINUX) && \ + !defined(CYGDBG_INFRA_DIAG_USE_DEVICE) && \ + (CYGNUM_KERNEL_SCHED_PRIORITIES > 12) + +//========================================================================== + +// Structure used to keep track of times +typedef struct fun_times { + cyg_uint32 start; + cyg_uint32 end; +} fun_times; + +//========================================================================== + +#define STACK_SIZE (PTHREAD_STACK_MIN*2) + +// Defaults +#define NTEST_THREADS 16 +#define NMUTEXES 32 +#define NMBOXES 32 +#define NSEMAPHORES 32 +#define NTIMERS 32 + + +#define NSAMPLES 32 +#define NTHREAD_SWITCHES 128 +#define NSCHEDS 128 + +#define NSAMPLES_SIM 2 +#define NTEST_THREADS_SIM 2 +#define NTHREAD_SWITCHES_SIM 4 +#define NMUTEXES_SIM 2 +#define NMBOXES_SIM 2 +#define NSEMAPHORES_SIM 2 +#define NSCHEDS_SIM 4 +#define NTIMERS_SIM 2 + +//========================================================================== + +static int nsamples; +static int ntest_threads; +static int nthread_switches; +static int nmutexes; +static int nmboxes; +static int nsemaphores; +static int nscheds; +static int ntimers; + +static char stacks[NTEST_THREADS][STACK_SIZE]; +static pthread_t threads[NTEST_THREADS]; +static int overhead; +static sem_t synchro; +static fun_times thread_ft[NTEST_THREADS]; + +static fun_times test2_ft[NTHREAD_SWITCHES]; + +static pthread_mutex_t test_mutexes[NMUTEXES]; +static fun_times mutex_ft[NMUTEXES]; +static pthread_t mutex_test_thread_handle; + +#if 0 +static cyg_mbox test_mboxes[NMBOXES]; +static cyg_handle_t test_mbox_handles[NMBOXES]; +static fun_times mbox_ft[NMBOXES]; +static cyg_thread mbox_test_thread; +static cyg_handle_t mbox_test_thread_handle; +#endif + +static sem_t test_semaphores[NSEMAPHORES]; +static fun_times semaphore_ft[NSEMAPHORES]; +static pthread_t semaphore_test_thread_handle; + +static fun_times sched_ft[NSCHEDS]; + +static timer_t timers[NTIMERS]; +static fun_times timer_ft[NTIMERS]; + +static long rtc_resolution[] = CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION; +static long ns_per_system_clock; + +#if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY) +// Data kept by kernel real time clock measuring clock interrupt latency +extern cyg_tick_count total_clock_latency, total_clock_interrupts; +extern cyg_int32 min_clock_latency, max_clock_latency; +extern bool measure_clock_latency; +#endif + +#if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_DSR_LATENCY) +extern cyg_tick_count total_clock_dsr_latency, total_clock_dsr_calls; +extern cyg_int32 min_clock_dsr_latency, max_clock_dsr_latency; +extern bool measure_clock_latency; +#endif + +//========================================================================== + +externC void diag_printf(const char *, ...); + +void run_sched_tests(void); +void run_thread_tests(void); +void run_thread_switch_test(void); +void run_mutex_tests(void); +void run_mutex_circuit_test(void); +void run_mbox_tests(void); +void run_mbox_circuit_test(void); +void run_semaphore_tests(void); +void run_semaphore_circuit_test(void); +void run_timer_tests(void); + +//========================================================================== + +#ifndef max +#define max(n,m) (m > n ? n : m) +#endif + +//========================================================================== +// Wait until a clock tick [real time clock] has passed. This should keep it +// from happening again during a measurement, thus minimizing any fluctuations +void +wait_for_tick(void) +{ + cyg_tick_count_t tv0, tv1; + tv0 = cyg_current_time(); + while (true) { + tv1 = cyg_current_time(); + if (tv1 != tv0) break; + } +} + +//-------------------------------------------------------------------------- +// Display a number of ticks as microseconds +// Note: for improved calculation significance, values are kept in ticks*1000 +void +show_ticks_in_us(cyg_uint32 ticks) +{ + long long ns; + ns = (ns_per_system_clock * (long long)ticks) / CYGNUM_KERNEL_COUNTERS_RTC_PERIOD; + ns += 5; // for rounding to .01us + diag_printf("%5d.%02d", (int)(ns/1000), (int)((ns%1000)/10)); +} + +//-------------------------------------------------------------------------- +// +// If the kernel is instrumented to measure clock interrupt latency, these +// measurements can be drastically perturbed by printing via "diag_printf()" +// since that code may run with interrupts disabled for long periods. +// +// In order to get accurate/reasonable latency figures _for the kernel +// primitive functions beint tested_, the kernel's latency measurements +// are suspended while the printing actually takes place. +// +// The measurements are reenabled after the printing, thus allowing for +// fair measurements of the kernel primitives, which are not distorted +// by the printing mechanisms. + +#if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY) && defined(HAL_CLOCK_LATENCY) +void +disable_clock_latency_measurement(void) +{ + wait_for_tick(); + measure_clock_latency = false; +} + +void +enable_clock_latency_measurement(void) +{ + wait_for_tick(); + measure_clock_latency = true; +} + +// Ensure that the measurements are reasonable (no startup anomalies) +void +reset_clock_latency_measurement(void) +{ + disable_clock_latency_measurement(); + total_clock_latency = 0; + total_clock_interrupts = 0; + min_clock_latency = 0x7FFFFFFF; + max_clock_latency = 0; +#if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_DSR_LATENCY) + total_clock_dsr_latency = 0; + total_clock_dsr_calls = 0; + min_clock_dsr_latency = 0x7FFFFFFF; + max_clock_dsr_latency = 0; +#endif + enable_clock_latency_measurement(); + +} +#else +#define disable_clock_latency_measurement() +#define enable_clock_latency_measurement() +#define reset_clock_latency_measurement() +#endif + +//-------------------------------------------------------------------------- + +void +show_times_hdr(void) +{ + disable_clock_latency_measurement(); + diag_printf("\n"); + diag_printf(" Confidence\n"); + diag_printf(" Ave Min Max Var Ave Min Function\n"); + diag_printf(" ====== ====== ====== ====== ========== ========\n"); + enable_clock_latency_measurement(); +} + +void +show_times_detail(fun_times ft[], int nsamples, char *title, bool ignore_first) +{ + int i, delta, min, max, con_ave, con_min, ave_dev; + int start_sample, total_samples; + cyg_int32 total, ave; + + if (ignore_first) { + start_sample = 1; + total_samples = nsamples-1; + } else { + start_sample = 0; + total_samples = nsamples; + } + total = 0; + min = 0x7FFFFFFF; + max = 0; + for (i = start_sample; i < nsamples; i++) { + if (ft[i].end < ft[i].start) { + // Clock wrapped around (timer tick) + delta = (ft[i].end+CYGNUM_KERNEL_COUNTERS_RTC_PERIOD) - ft[i].start; + } else { + delta = ft[i].end - ft[i].start; + } + delta -= overhead; + if (delta < 0) delta = 0; + delta *= 1000; + total += delta; + if (delta < min) min = delta; + if (delta > max) max = delta; + } + ave = total / total_samples; + total = 0; + ave_dev = 0; + for (i = start_sample; i < nsamples; i++) { + if (ft[i].end < ft[i].start) { + // Clock wrapped around (timer tick) + delta = (ft[i].end+CYGNUM_KERNEL_COUNTERS_RTC_PERIOD) - ft[i].start; + } else { + delta = ft[i].end - ft[i].start; + } + delta -= overhead; + if (delta < 0) delta = 0; + delta *= 1000; + delta = delta - ave; + if (delta < 0) delta = -delta; + ave_dev += delta; + } + ave_dev /= total_samples; + con_ave = 0; + con_min = 0; + for (i = start_sample; i < nsamples; i++) { + if (ft[i].end < ft[i].start) { + // Clock wrapped around (timer tick) + delta = (ft[i].end+CYGNUM_KERNEL_COUNTERS_RTC_PERIOD) - ft[i].start; + } else { + delta = ft[i].end - ft[i].start; + } + delta -= overhead; + if (delta < 0) delta = 0; + delta *= 1000; + if ((delta <= (ave+ave_dev)) && (delta >= (ave-ave_dev))) con_ave++; + if ((delta <= (min+ave_dev)) && (delta >= (min-ave_dev))) con_min++; + } + con_ave = (con_ave * 100) / total_samples; + con_min = (con_min * 100) / total_samples; + show_ticks_in_us(ave); + show_ticks_in_us(min); + show_ticks_in_us(max); + show_ticks_in_us(ave_dev); + disable_clock_latency_measurement(); + diag_printf(" %3d%% %3d%%", con_ave, con_min); + diag_printf(" %s\n", title); + enable_clock_latency_measurement(); +} + +void +show_times(fun_times ft[], int nsamples, char *title) +{ + show_times_detail(ft, nsamples, title, false); +#ifdef STATS_WITHOUT_FIRST_SAMPLE + show_times_detail(ft, nsamples, "", true); +#endif +} + +//-------------------------------------------------------------------------- + +void +show_test_parameters(void) +{ + disable_clock_latency_measurement(); + diag_printf("\nTesting parameters:\n"); + diag_printf(" Clock samples: %5d\n", nsamples); + diag_printf(" Threads: %5d\n", ntest_threads); + diag_printf(" Thread switches: %5d\n", nthread_switches); + diag_printf(" Mutexes: %5d\n", nmutexes); + diag_printf(" Mailboxes: %5d\n", nmboxes); + diag_printf(" Semaphores: %5d\n", nsemaphores); + diag_printf(" Scheduler operations: %5d\n", nscheds); + diag_printf(" Timers: %5d\n", ntimers); + diag_printf("\n"); + enable_clock_latency_measurement(); +} + +void +end_of_test_group(void) +{ + disable_clock_latency_measurement(); + diag_printf("\n"); + enable_clock_latency_measurement(); +} + +//-------------------------------------------------------------------------- +// Compute a name for a thread + +char * +thread_name(char *basename, int indx) { + return "<>"; // Not currently used +} + +//-------------------------------------------------------------------------- +// test0 - null test, just return + +void * +test0(void *indx) +{ + return indx; +} + +//-------------------------------------------------------------------------- +// test3 - loop, yeilding repeatedly and checking for cancellation + +void * +test3(void *indx) +{ + for(;;) + { + sched_yield(); + pthread_testcancel(); + } + + return indx; +} + +//-------------------------------------------------------------------------- +// test1 - empty test, simply exit. Last thread signals parent. + +void * +test1( void *indx) +{ + if ((cyg_uint32)indx == (cyg_uint32)(ntest_threads-1)) { + sem_post(&synchro); // Signal that last thread is dying + } + return indx; +} + +//-------------------------------------------------------------------------- +// test2 - measure thread switch times + +void * +test2(void *indx) +{ + int i; + for (i = 0; i < nthread_switches; i++) { + if ((int)indx == 0) { + HAL_CLOCK_READ(&test2_ft[i].start); + } else { + HAL_CLOCK_READ(&test2_ft[i].end); + } + sched_yield(); + } + if ((int)indx == 1) { + sem_post(&synchro); + } + + return indx; +} + +//-------------------------------------------------------------------------- +// Full-circuit mutex unlock/lock test + +void * +mutex_test(void * indx) +{ + int i; + pthread_mutex_lock(&test_mutexes[0]); + for (i = 0; i < nmutexes; i++) { + sem_wait(&synchro); + wait_for_tick(); // Wait until the next clock tick to minimize aberations + HAL_CLOCK_READ(&mutex_ft[i].start); + pthread_mutex_unlock(&test_mutexes[0]); + pthread_mutex_lock(&test_mutexes[0]); + sem_post(&synchro); + } + return indx; +} + +//-------------------------------------------------------------------------- +// Full-circuit mbox put/get test + +#if 0 +void +mbox_test(cyg_uint32 indx) +{ + void *item; + do { + item = cyg_mbox_get(test_mbox_handles[0]); + HAL_CLOCK_READ(&mbox_ft[(int)item].end); + cyg_semaphore_post(&synchro); + } while ((int)item != (nmboxes-1)); + cyg_thread_exit(0); +} +#endif + +//-------------------------------------------------------------------------- +// Full-circuit semaphore post/wait test + +void * +semaphore_test(void * indx) +{ + int i; + for (i = 0; i < nsemaphores; i++) { + sem_wait(&test_semaphores[0]); + HAL_CLOCK_READ(&semaphore_ft[i].end); + sem_post(&synchro); + } + return indx; +} + +//-------------------------------------------------------------------------- +// +// This set of tests is used to measure kernel primitives that deal with threads +// + +void +run_thread_tests(void) +{ + + + int i; + struct sched_param schedparam; + pthread_attr_t attr; + int policy; + void *retval; + + // Set my priority higher than any I plan to create + schedparam.sched_priority = 30; + pthread_setschedparam( pthread_self(), SCHED_RR, &schedparam ); + + // Initiaize thread creation attributes + + pthread_attr_init( &attr ); + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + schedparam.sched_priority = 10; + pthread_attr_setschedparam( &attr, &schedparam ); + + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < ntest_threads; i++) { + HAL_CLOCK_READ(&thread_ft[i].start); + + pthread_attr_setstackaddr( &attr, &stacks[i][STACK_SIZE] ); + pthread_attr_setstacksize( &attr, STACK_SIZE ); + pthread_create( &threads[i], + &attr, + test0, + (void *)i + ); + + HAL_CLOCK_READ(&thread_ft[i].end); + } + show_times(thread_ft, ntest_threads, "Create thread"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < ntest_threads; i++) { + HAL_CLOCK_READ(&thread_ft[i].start); + sched_yield(); + HAL_CLOCK_READ(&thread_ft[i].end); + } + show_times(thread_ft, ntest_threads, "Yield thread [all lower priority]"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < ntest_threads; i++) { + HAL_CLOCK_READ(&thread_ft[i].start); + + schedparam.sched_priority = 11; + pthread_attr_setschedparam( &attr, &schedparam ); + pthread_setschedparam(threads[i], SCHED_RR, &schedparam); + + HAL_CLOCK_READ(&thread_ft[i].end); + } + show_times(thread_ft, ntest_threads, "Set priority"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < ntest_threads; i++) { + HAL_CLOCK_READ(&thread_ft[i].start); + pthread_getschedparam( threads[i], &policy, &schedparam ); + HAL_CLOCK_READ(&thread_ft[i].end); + } + show_times(thread_ft, ntest_threads, "Get priority"); + + cyg_thread_delay(1); // Let the test threads run + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < ntest_threads; i++) { + HAL_CLOCK_READ(&thread_ft[i].start); + pthread_join(threads[i], &retval); + HAL_CLOCK_READ(&thread_ft[i].end); + } + show_times(thread_ft, ntest_threads, "Join exited thread"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < ntest_threads; i++) { + HAL_CLOCK_READ(&thread_ft[i].start); + sched_yield(); + HAL_CLOCK_READ(&thread_ft[i].end); + } + show_times(thread_ft, ntest_threads, "Yield [no other] thread"); + + + // Recreate the test set + + schedparam.sched_priority = 10; + pthread_attr_setschedparam( &attr, &schedparam ); + + for (i = 0; i < ntest_threads; i++) { + pthread_attr_setstackaddr( &attr, &stacks[i][STACK_SIZE] ); + pthread_attr_setstacksize( &attr, STACK_SIZE ); + pthread_create( &threads[i], + &attr, + test3, + (void *)i + ); + } + + cyg_thread_delay(1); // Let the test threads run + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < ntest_threads; i++) { + HAL_CLOCK_READ(&thread_ft[i].start); + pthread_cancel(threads[i]); + HAL_CLOCK_READ(&thread_ft[i].end); + } + show_times(thread_ft, ntest_threads, "Cancel [running] thread"); + + cyg_thread_delay(1); // Let the test threads do their cancellations + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < ntest_threads; i++) { + HAL_CLOCK_READ(&thread_ft[i].start); + pthread_join(threads[i], &retval); + HAL_CLOCK_READ(&thread_ft[i].end); + } + show_times(thread_ft, ntest_threads, "Join [cancelled] thread"); + + + // Set my priority lower than any I plan to create + schedparam.sched_priority = 5; + pthread_setschedparam( pthread_self(), SCHED_RR, &schedparam ); + + // Set up the end-of-threads synchronizer + sem_init(&synchro, 0, 0); + + schedparam.sched_priority = 10; + pthread_attr_setschedparam( &attr, &schedparam ); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < ntest_threads; i++) { + HAL_CLOCK_READ(&thread_ft[i].start); + + pthread_attr_setstackaddr( &attr, &stacks[i][STACK_SIZE] ); + pthread_attr_setstacksize( &attr, STACK_SIZE ); + pthread_create( &threads[i], + &attr, + test2, + (void *)i + ); + + HAL_CLOCK_READ(&thread_ft[i].end); + } + show_times(thread_ft, ntest_threads, "Create [high priority] thread"); + + sem_wait(&synchro); // Wait for all threads to finish + + // Make sure they are all dead + for (i = 0; i < ntest_threads; i++) { + pthread_join(threads[i], &retval); + } + + run_thread_switch_test(); + end_of_test_group(); + +} + +//-------------------------------------------------------------------------- + +void +run_thread_switch_test(void) +{ + + int i; + struct sched_param schedparam; + pthread_attr_t attr; + void *retval; + + // Set my priority higher than any I plan to create + schedparam.sched_priority = 30; + pthread_setschedparam( pthread_self(), SCHED_RR, &schedparam ); + + // Initiaize thread creation attributes + + pthread_attr_init( &attr ); + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + schedparam.sched_priority = 10; + pthread_attr_setschedparam( &attr, &schedparam ); + + // Set up the end-of-threads synchronizer + + sem_init(&synchro, 0, 0); + + // Set up for thread context switch + + for (i = 0; i < 2; i++) { + pthread_attr_setstackaddr( &attr, &stacks[i][STACK_SIZE] ); + pthread_attr_setstacksize( &attr, STACK_SIZE ); + pthread_create( &threads[i], + &attr, + test2, + (void *)i + ); + } + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + + sem_wait(&synchro); + + show_times(test2_ft, nthread_switches, "Thread switch"); + + // Clean up + for (i = 0; i < 2; i++) { + pthread_join(threads[i], &retval); + } + +} + + +//-------------------------------------------------------------------------- + +void +run_mutex_tests(void) +{ + + int i; + pthread_mutexattr_t attr; + + pthread_mutexattr_init( &attr ); + + // Mutex primitives + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmutexes; i++) { + HAL_CLOCK_READ(&mutex_ft[i].start); + pthread_mutex_init(&test_mutexes[i], &attr); + HAL_CLOCK_READ(&mutex_ft[i].end); + } + show_times(mutex_ft, nmutexes, "Init mutex"); + + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmutexes; i++) { + HAL_CLOCK_READ(&mutex_ft[i].start); + pthread_mutex_lock(&test_mutexes[i]); + HAL_CLOCK_READ(&mutex_ft[i].end); + } + show_times(mutex_ft, nmutexes, "Lock [unlocked] mutex"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmutexes; i++) { + HAL_CLOCK_READ(&mutex_ft[i].start); + pthread_mutex_unlock(&test_mutexes[i]); + HAL_CLOCK_READ(&mutex_ft[i].end); + } + show_times(mutex_ft, nmutexes, "Unlock [locked] mutex"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmutexes; i++) { + HAL_CLOCK_READ(&mutex_ft[i].start); + pthread_mutex_trylock(&test_mutexes[i]); + HAL_CLOCK_READ(&mutex_ft[i].end); + } + show_times(mutex_ft, nmutexes, "Trylock [unlocked] mutex"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmutexes; i++) { + HAL_CLOCK_READ(&mutex_ft[i].start); + pthread_mutex_trylock(&test_mutexes[i]); + HAL_CLOCK_READ(&mutex_ft[i].end); + } + show_times(mutex_ft, nmutexes, "Trylock [locked] mutex"); + + // Must unlock mutices before destroying them. + for (i = 0; i < nmutexes; i++) { + pthread_mutex_unlock(&test_mutexes[i]); + } + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmutexes; i++) { + HAL_CLOCK_READ(&mutex_ft[i].start); + pthread_mutex_destroy(&test_mutexes[i]); + HAL_CLOCK_READ(&mutex_ft[i].end); + } + show_times(mutex_ft, nmutexes, "Destroy mutex"); + + + run_mutex_circuit_test(); + end_of_test_group(); +} + +//-------------------------------------------------------------------------- + +void +run_mutex_circuit_test(void) +{ + int i; + pthread_mutexattr_t mattr; + struct sched_param schedparam; + pthread_attr_t attr; + void *retval; + + // Set my priority lower than any I plan to create + schedparam.sched_priority = 5; + pthread_setschedparam( pthread_self(), SCHED_RR, &schedparam ); + + // Initiaize thread creation attributes + + pthread_attr_init( &attr ); + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + schedparam.sched_priority = 10; + pthread_attr_setschedparam( &attr, &schedparam ); + + // Set up for full mutex unlock/lock test + pthread_mutexattr_init( &mattr ); + pthread_mutex_init(&test_mutexes[0], &mattr); + sem_init(&synchro, 0, 0); + + pthread_attr_setstackaddr( &attr, &stacks[0][STACK_SIZE] ); + pthread_attr_setstacksize( &attr, STACK_SIZE ); + pthread_create( &mutex_test_thread_handle, + &attr, + mutex_test, + (void *)0 + ); + + // Need to raise priority so that this thread will block on the "lock" + schedparam.sched_priority = 20; + pthread_setschedparam( pthread_self(), SCHED_RR, &schedparam ); + + for (i = 0; i < nmutexes; i++) { + sem_post(&synchro); + pthread_mutex_lock(&test_mutexes[0]); + HAL_CLOCK_READ(&mutex_ft[i].end); + pthread_mutex_unlock(&test_mutexes[0]); + sem_wait(&synchro); + } + pthread_join(mutex_test_thread_handle, &retval); + show_times(mutex_ft, nmutexes, "Unlock/Lock mutex"); + +} + + +//-------------------------------------------------------------------------- +// Message queue tests + +// Currently disabled, pending implementation of POSIX message queues + +#if 0 +void +run_mbox_tests(void) +{ + int i, cnt; + void *item; + // Mailbox primitives + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + cyg_mbox_create(&test_mbox_handles[i], &test_mboxes[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Create mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + cnt = cyg_mbox_peek(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Peek [empty] mbox"); + +#ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + cyg_mbox_put(test_mbox_handles[i], (void *)i); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Put [first] mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + cnt = cyg_mbox_peek(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Peek [1 msg] mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + cyg_mbox_put(test_mbox_handles[i], (void *)i); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Put [second] mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + cnt = cyg_mbox_peek(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Peek [2 msgs] mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + item = cyg_mbox_get(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Get [first] mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + item = cyg_mbox_get(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Get [second] mbox"); +#endif // ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + cyg_mbox_tryput(test_mbox_handles[i], (void *)i); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Tryput [first] mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + item = cyg_mbox_peek_item(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Peek item [non-empty] mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + item = cyg_mbox_tryget(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Tryget [non-empty] mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + item = cyg_mbox_peek_item(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Peek item [empty] mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + item = cyg_mbox_tryget(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Tryget [empty] mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + cyg_mbox_waiting_to_get(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Waiting to get mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + cyg_mbox_waiting_to_put(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Waiting to put mbox"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nmboxes; i++) { + HAL_CLOCK_READ(&mbox_ft[i].start); + cyg_mbox_delete(test_mbox_handles[i]); + HAL_CLOCK_READ(&mbox_ft[i].end); + } + show_times(mbox_ft, nmboxes, "Delete mbox"); + + run_mbox_circuit_test(); + end_of_test_group(); +} + +//-------------------------------------------------------------------------- + +void +run_mbox_circuit_test(void) +{ +#ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT + int i; + // Set my priority lower than any I plan to create + cyg_thread_set_priority(cyg_thread_self(), 3); + // Set up for full mbox put/get test + cyg_mbox_create(&test_mbox_handles[0], &test_mboxes[0]); + cyg_semaphore_init(&synchro, 0); + cyg_thread_create(2, // Priority - just a number + mbox_test, // entry + 0, // index + thread_name("thread", 0), // Name + &stacks[0][0], // Stack + STACK_SIZE, // Size + &mbox_test_thread_handle, // Handle + &mbox_test_thread // Thread data structure + ); + cyg_thread_resume(mbox_test_thread_handle); + for (i = 0; i < nmboxes; i++) { + wait_for_tick(); // Wait until the next clock tick to minimize aberations + HAL_CLOCK_READ(&mbox_ft[i].start); + cyg_mbox_put(test_mbox_handles[0], (void *)i); + cyg_semaphore_wait(&synchro); + } + cyg_thread_delete(mbox_test_thread_handle); + show_times(mbox_ft, nmboxes, "Put/Get mbox"); +#endif +} + +#endif + +//-------------------------------------------------------------------------- + +void +run_semaphore_tests(void) +{ + + int i; + int sem_val; + + // Semaphore primitives + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nsemaphores; i++) { + HAL_CLOCK_READ(&semaphore_ft[i].start); + sem_init(&test_semaphores[i], 0, 0); + HAL_CLOCK_READ(&semaphore_ft[i].end); + } + show_times(semaphore_ft, nsemaphores, "Init semaphore"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nsemaphores; i++) { + HAL_CLOCK_READ(&semaphore_ft[i].start); + sem_post(&test_semaphores[i]); + HAL_CLOCK_READ(&semaphore_ft[i].end); + } + show_times(semaphore_ft, nsemaphores, "Post [0] semaphore"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nsemaphores; i++) { + HAL_CLOCK_READ(&semaphore_ft[i].start); + sem_wait(&test_semaphores[i]); + HAL_CLOCK_READ(&semaphore_ft[i].end); + } + show_times(semaphore_ft, nsemaphores, "Wait [1] semaphore"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nsemaphores; i++) { + HAL_CLOCK_READ(&semaphore_ft[i].start); + sem_trywait(&test_semaphores[i]); + HAL_CLOCK_READ(&semaphore_ft[i].end); + } + show_times(semaphore_ft, nsemaphores, "Trywait [0] semaphore"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nsemaphores; i++) { + sem_post(&test_semaphores[i]); + HAL_CLOCK_READ(&semaphore_ft[i].start); + sem_trywait(&test_semaphores[i]); + HAL_CLOCK_READ(&semaphore_ft[i].end); + } + show_times(semaphore_ft, nsemaphores, "Trywait [1] semaphore"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nsemaphores; i++) { + HAL_CLOCK_READ(&semaphore_ft[i].start); + sem_getvalue(&test_semaphores[i], &sem_val); + HAL_CLOCK_READ(&semaphore_ft[i].end); + } + show_times(semaphore_ft, nsemaphores, "Get value of semaphore"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < nsemaphores; i++) { + HAL_CLOCK_READ(&semaphore_ft[i].start); + sem_destroy(&test_semaphores[i]); + HAL_CLOCK_READ(&semaphore_ft[i].end); + } + show_times(semaphore_ft, nsemaphores, "Destroy semaphore"); + + run_semaphore_circuit_test(); + end_of_test_group(); +} + +//-------------------------------------------------------------------------- + +void +run_semaphore_circuit_test(void) +{ + + int i; + struct sched_param schedparam; + pthread_attr_t attr; + void *retval; + + // Set my priority lower than any I plan to create + schedparam.sched_priority = 5; + pthread_setschedparam( pthread_self(), SCHED_RR, &schedparam ); + + // Initiaize thread creation attributes + + pthread_attr_init( &attr ); + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + schedparam.sched_priority = 10; + pthread_attr_setschedparam( &attr, &schedparam ); + + // Set up for full semaphore post/wait test + sem_init(&test_semaphores[0], 0, 0); + sem_init(&synchro, 0, 0); + + pthread_attr_setstackaddr( &attr, &stacks[0][STACK_SIZE] ); + pthread_attr_setstacksize( &attr, STACK_SIZE ); + pthread_create( &semaphore_test_thread_handle, + &attr, + semaphore_test, + (void *)0 + ); + + + for (i = 0; i < nsemaphores; i++) { + wait_for_tick(); // Wait until the next clock tick to minimize aberations + HAL_CLOCK_READ(&semaphore_ft[i].start); + sem_post(&test_semaphores[0]); + sem_wait(&synchro); + } + pthread_join(semaphore_test_thread_handle, &retval); + + show_times(semaphore_ft, nsemaphores, "Post/Wait semaphore"); + + +} + +//-------------------------------------------------------------------------- + +// Timer callback function +void +sigrt0(int signo, siginfo_t *info, void *context) +{ + diag_printf("sigrt0 called\n"); + // empty call back +} + +// Callback used to test determinancy +static volatile int timer_cnt; +void +sigrt1(int signo, siginfo_t *info, void *context) +{ + if (timer_cnt == nscheds) return; + sched_ft[timer_cnt].start = 0; + HAL_CLOCK_READ(&sched_ft[timer_cnt++].end); + if (timer_cnt == nscheds) { + sem_post(&synchro); + } +} + +static sem_t timer_sem; + +static void +sigrt2(int signo, siginfo_t *info, void *context) +{ + if (timer_cnt == nscheds) { + sem_post(&synchro); + sem_post(&timer_sem); + } else { + sched_ft[timer_cnt].start = 0; + sem_post(&timer_sem); + } +} + +// Null thread, used to keep scheduler busy +void * +timer_test(void * id) +{ + while (true) { + cyg_thread_yield(); + pthread_testcancel(); + } + + return id; +} + +// Thread that suspends itself at the first opportunity +void * +timer_test2(void *id) +{ + while (timer_cnt != nscheds) { + HAL_CLOCK_READ(&sched_ft[timer_cnt++].end); + sem_wait(&timer_sem); + } + return id; +} + +void +run_timer_tests(void) +{ + int res; + int i; + struct sigaction sa; + struct sigevent sigev; + struct itimerspec tp; + + // Install signal handlers + sigemptyset( &sa.sa_mask ); + sa.sa_flags = SA_SIGINFO; + + sa.sa_sigaction = sigrt0; + sigaction( SIGRTMIN, &sa, NULL ); + + sa.sa_sigaction = sigrt1; + sigaction( SIGRTMIN+1, &sa, NULL ); + + sa.sa_sigaction = sigrt2; + sigaction( SIGRTMIN+2, &sa, NULL ); + + // Set up common bits of sigevent + + sigev.sigev_notify = SIGEV_SIGNAL; + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < ntimers; i++) { + HAL_CLOCK_READ(&timer_ft[i].start); + sigev.sigev_signo = SIGRTMIN; + sigev.sigev_value.sival_ptr = (void*)(&timers[i]); + res = timer_create( CLOCK_REALTIME, &sigev, &timers[i]); + HAL_CLOCK_READ(&timer_ft[i].end); + CYG_ASSERT( res == 0 , "timer_create() returned error"); + } + show_times(timer_ft, ntimers, "Create timer"); + + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + tp.it_value.tv_sec = 0; + tp.it_value.tv_nsec = 0; + tp.it_interval.tv_sec = 0; + tp.it_interval.tv_nsec = 0; + for (i = 0; i < ntimers; i++) { + HAL_CLOCK_READ(&timer_ft[i].start); + res = timer_settime( timers[i], 0, &tp, NULL ); + HAL_CLOCK_READ(&timer_ft[i].end); + CYG_ASSERT( res == 0 , "timer_settime() returned error"); + } + show_times(timer_ft, ntimers, "Initialize timer to zero"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + tp.it_value.tv_sec = 1; + tp.it_value.tv_nsec = 250000000; + tp.it_interval.tv_sec = 0; + tp.it_interval.tv_nsec = 0; + for (i = 0; i < ntimers; i++) { + HAL_CLOCK_READ(&timer_ft[i].start); + res = timer_settime( timers[i], 0, &tp, NULL ); + HAL_CLOCK_READ(&timer_ft[i].end); + CYG_ASSERT( res == 0 , "timer_settime() returned error"); + } + show_times(timer_ft, ntimers, "Initialize timer to 1.25 sec"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + tp.it_value.tv_sec = 0; + tp.it_value.tv_nsec = 0; + tp.it_interval.tv_sec = 0; + tp.it_interval.tv_nsec = 0; + for (i = 0; i < ntimers; i++) { + HAL_CLOCK_READ(&timer_ft[i].start); + res = timer_settime( timers[i], 0, &tp, NULL ); + HAL_CLOCK_READ(&timer_ft[i].end); + CYG_ASSERT( res == 0 , "timer_settime() returned error"); + } + show_times(timer_ft, ntimers, "Disable timer"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + for (i = 0; i < ntimers; i++) { + HAL_CLOCK_READ(&timer_ft[i].start); + res = timer_delete( timers[i] ); + HAL_CLOCK_READ(&timer_ft[i].end); + CYG_ASSERT( res == 0 , "timer_settime() returned error"); + } + show_times(timer_ft, ntimers, "Delete timer"); + + + + sigev.sigev_signo = SIGRTMIN+1; + sigev.sigev_value.sival_ptr = (void*)(&timers[i]); + res = timer_create( CLOCK_REALTIME, &sigev, &timers[0]); + CYG_ASSERT( res == 0 , "timer_create() returned error"); + tp.it_value.tv_sec = 0; + tp.it_value.tv_nsec = 50000000; + tp.it_interval.tv_sec = 0; + tp.it_interval.tv_nsec = 50000000;; + timer_cnt = 0; + res = timer_settime( timers[0], 0, &tp, NULL ); + CYG_ASSERT( res == 0 , "timer_settime() returned error"); + sem_init(&synchro, 0, 0); + wait_for_tick(); // Wait until the next clock tick to minimize aberations + do + { res = sem_wait(&synchro); + } while( res == -1 && errno == EINTR ); + CYG_ASSERT( res == 0 , "sem_wait() returned error"); + tp.it_value.tv_sec = 0; + tp.it_value.tv_nsec = 0; + tp.it_interval.tv_sec = 0; + tp.it_interval.tv_nsec = 0; + res = timer_settime( timers[0], 0, &tp, NULL ); + CYG_ASSERT( res == 0 , "timer_settime() returned error"); + res = timer_delete( timers[0] ); + CYG_ASSERT( res == 0 , "timer_delete() returned error"); + show_times(sched_ft, nscheds, "Timer latency [0 threads]"); + + + + + struct sched_param schedparam; + pthread_attr_t attr; + void *retval; + + // Set my priority higher than any I plan to create + schedparam.sched_priority = 20; + pthread_setschedparam( pthread_self(), SCHED_RR, &schedparam ); + + + // Initiaize thread creation attributes + + pthread_attr_init( &attr ); + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + schedparam.sched_priority = 10; + pthread_attr_setschedparam( &attr, &schedparam ); + + for (i = 0; i < 2; i++) { + pthread_attr_setstackaddr( &attr, &stacks[i][STACK_SIZE] ); + pthread_attr_setstacksize( &attr, STACK_SIZE ); + res = pthread_create( &threads[i], + &attr, + timer_test, + (void *)i + ); + CYG_ASSERT( res == 0 , "pthread_create() returned error"); + } + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + + sigev.sigev_signo = SIGRTMIN+1; + sigev.sigev_value.sival_ptr = (void*)(&timers[i]); + res = timer_create( CLOCK_REALTIME, &sigev, &timers[0]); + CYG_ASSERT( res == 0 , "timer_create() returned error"); + tp.it_value.tv_sec = 0; + tp.it_value.tv_nsec = 50000000; + tp.it_interval.tv_sec = 0; + tp.it_interval.tv_nsec = 50000000;; + timer_cnt = 0; + res = timer_settime( timers[0], 0, &tp, NULL ); + CYG_ASSERT( res == 0 , "timer_settime() returned error"); + + sem_init(&synchro, 0, 0); + do + { res = sem_wait(&synchro); + } while( res == -1 && errno == EINTR ); + CYG_ASSERT( res == 0 , "sem_wait() returned error"); + res = timer_delete(timers[0]); + CYG_ASSERT( res == 0 , "timerdelete() returned error"); + show_times(sched_ft, nscheds, "Timer latency [2 threads]"); + for (i = 0; i < 2; i++) { + pthread_cancel(threads[i]); + pthread_join(threads[i], &retval); + } + + + + for (i = 0; i < ntest_threads; i++) { + pthread_attr_setstackaddr( &attr, &stacks[i][STACK_SIZE] ); + pthread_attr_setstacksize( &attr, STACK_SIZE ); + res = pthread_create( &threads[i], + &attr, + timer_test, + (void *)i + ); + CYG_ASSERT( res == 0 , "pthread_create() returned error"); + } + wait_for_tick(); // Wait until the next clock tick to minimize aberations + sigev.sigev_signo = SIGRTMIN+1; + sigev.sigev_value.sival_ptr = (void*)(&timers[i]); + res = timer_create( CLOCK_REALTIME, &sigev, &timers[0]); + CYG_ASSERT( res == 0 , "timer_create() returned error"); + tp.it_value.tv_sec = 0; + tp.it_value.tv_nsec = 50000000; + tp.it_interval.tv_sec = 0; + tp.it_interval.tv_nsec = 50000000;; + timer_cnt = 0; + res = timer_settime( timers[0], 0, &tp, NULL ); + CYG_ASSERT( res == 0 , "timer_settime() returned error"); + + sem_init(&synchro, 0, 0); + do + { res = sem_wait(&synchro); + } while( res == -1 && errno == EINTR ); + CYG_ASSERT( res == 0 , "sem_wait() returned error"); + res = timer_delete(timers[0]); + CYG_ASSERT( res == 0 , "timerdelete() returned error"); + show_times(sched_ft, nscheds, "Timer latency [many threads]"); + for (i = 0; i < ntest_threads; i++) { + pthread_cancel(threads[i]); + pthread_join(threads[i], &retval); + } + + sem_init(&synchro, 0, 0); + sem_init(&timer_sem, 0, 0); + pthread_attr_setstackaddr( &attr, &stacks[0][STACK_SIZE] ); + pthread_attr_setstacksize( &attr, STACK_SIZE ); + res = pthread_create( &threads[0], + &attr, + timer_test2, + (void *)0 + ); + CYG_ASSERT( res == 0 , "pthread_create() returned error"); + + wait_for_tick(); // Wait until the next clock tick to minimize aberations + sigev.sigev_signo = SIGRTMIN+2; + sigev.sigev_value.sival_ptr = (void*)(threads[0]); + res = timer_create( CLOCK_REALTIME, &sigev, &timers[0]); + CYG_ASSERT( res == 0 , "timer_create() returned error"); + tp.it_value.tv_sec = 0; + tp.it_value.tv_nsec = 50000000; + tp.it_interval.tv_sec = 0; + tp.it_interval.tv_nsec = 50000000;; + timer_cnt = 0; + res = timer_settime( timers[0], 0, &tp, NULL ); + CYG_ASSERT( res == 0 , "timer_settime() returned error"); + + do + { res = sem_wait(&synchro); + } while( res == -1 && errno == EINTR ); + CYG_ASSERT( res == 0 , "sem_wait() returned error"); + res = timer_delete(timers[0]); + CYG_ASSERT( res == 0 , "timerdelete() returned error"); + show_times(sched_ft, nscheds, "Timer -> thread post latency"); + sem_post(&timer_sem); +// pthread_cancel(threads[0]); + pthread_join(threads[0], &retval); + + + end_of_test_group(); +} + + +//-------------------------------------------------------------------------- + +void +run_all_tests() +{ + int i; + cyg_uint32 tv[nsamples], tv0, tv1; +// cyg_uint32 min_stack, max_stack, total_stack, actual_stack, j; + cyg_tick_count_t ticks, tick0, tick1; +#ifdef CYG_SCHEDULER_LOCK_TIMINGS + cyg_uint32 lock_ave, lock_max; +#endif +#if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY) && defined(HAL_CLOCK_LATENCY) + cyg_int32 clock_ave; +#endif + + disable_clock_latency_measurement(); + +// cyg_test_dump_thread_stack_stats( "Startup, main stack", thread[0] ); + cyg_test_dump_interrupt_stack_stats( "Startup" ); + cyg_test_dump_idlethread_stack_stats( "Startup" ); + cyg_test_clear_interrupt_stack(); + + diag_printf("\neCos Kernel Timings\n"); + diag_printf("Notes: all times are in microseconds (.000001) unless otherwise stated\n"); +#ifdef STATS_WITHOUT_FIRST_SAMPLE + diag_printf(" second line of results have first sample removed\n"); +#endif + + cyg_thread_delay(2); // Make sure the clock is actually running + + ns_per_system_clock = 1000000/rtc_resolution[1]; + + for (i = 0; i < nsamples; i++) { + HAL_CLOCK_READ(&tv[i]); + } + tv0 = 0; + for (i = 1; i < nsamples; i++) { + tv0 += tv[i] - tv[i-1]; + } + end_of_test_group(); + + overhead = tv0 / (nsamples-1); + diag_printf("Reading the hardware clock takes %d 'ticks' overhead\n", overhead); + diag_printf("... this value will be factored out of all other measurements\n"); + + // Try and measure how long the clock interrupt handling takes + for (i = 0; i < nsamples; i++) { + tick0 = cyg_current_time(); + while (true) { + tick1 = cyg_current_time(); + if (tick0 != tick1) break; + } + HAL_CLOCK_READ(&tv[i]); + } + tv1 = 0; + for (i = 0; i < nsamples; i++) { + tv1 += tv[i] * 1000; + } + tv1 = tv1 / nsamples; + tv1 -= overhead; // Adjust out the cost of getting the timer value + diag_printf("Clock interrupt took"); + show_ticks_in_us(tv1); + diag_printf(" microseconds (%d raw clock ticks)\n", tv1/1000); + enable_clock_latency_measurement(); + + ticks = cyg_current_time(); + + show_test_parameters(); + show_times_hdr(); + + reset_clock_latency_measurement(); + + run_thread_tests(); + run_mutex_tests(); +// run_mbox_tests(); + run_semaphore_tests(); + run_timer_tests(); + +#ifdef CYG_SCHEDULER_LOCK_TIMINGS + Cyg_Scheduler::get_lock_times(&lock_ave, &lock_max); + diag_printf("\nMax lock:"); + show_ticks_in_us(lock_max); + diag_printf(", Ave lock:"); + show_ticks_in_us(lock_ave); + diag_printf("\n"); +#endif + +#if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_LATENCY) && defined(HAL_CLOCK_LATENCY) + // Display latency figures in same format as all other numbers + disable_clock_latency_measurement(); + clock_ave = (total_clock_latency*1000) / total_clock_interrupts; + show_ticks_in_us(clock_ave); + show_ticks_in_us(min_clock_latency*1000); + show_ticks_in_us(max_clock_latency*1000); + show_ticks_in_us(0); + diag_printf(" Clock/interrupt latency\n\n"); + enable_clock_latency_measurement(); +#endif + +#if defined(CYGVAR_KERNEL_COUNTERS_CLOCK_DSR_LATENCY) + disable_clock_latency_measurement(); + clock_ave = (total_clock_dsr_latency*1000) / total_clock_dsr_calls; + show_ticks_in_us(clock_ave); + show_ticks_in_us(min_clock_dsr_latency*1000); + show_ticks_in_us(max_clock_dsr_latency*1000); + show_ticks_in_us(0); + diag_printf(" Clock DSR latency\n\n"); + enable_clock_latency_measurement(); +#endif + +#if 0 + disable_clock_latency_measurement(); + min_stack = STACK_SIZE; + max_stack = 0; + total_stack = 0; + for (i = 0; i < (int)NTEST_THREADS; i++) { + for (j = 0; j < STACK_SIZE; j++) { + if (stacks[i][j]) break; + } + actual_stack = STACK_SIZE-j; + if (actual_stack < min_stack) min_stack = actual_stack; + if (actual_stack > max_stack) max_stack = actual_stack; + total_stack += actual_stack; + } + for (j = 0; j < STACKSIZE; j++) { + if (((char *)stack[0])[j]) break; + } + diag_printf("%5d %5d %5d (main stack: %5d) Thread stack used (%d total)\n", + total_stack/NTEST_THREADS, min_stack, max_stack, + STACKSIZE - j, STACK_SIZE); +#endif + +// cyg_test_dump_thread_stack_stats( "All done, main stack", thread[0] ); + cyg_test_dump_interrupt_stack_stats( "All done" ); + cyg_test_dump_idlethread_stack_stats( "All done" ); + + enable_clock_latency_measurement(); + + ticks = cyg_current_time(); + diag_printf("\nTiming complete - %d ms total\n\n", (int)((ticks*ns_per_system_clock)/1000)); + + CYG_TEST_PASS_FINISH("Basic timing OK"); +} + +int main( int argc, char **argv ) +{ + CYG_TEST_INIT(); + + if (cyg_test_is_simulator) { + nsamples = NSAMPLES_SIM; + ntest_threads = NTEST_THREADS_SIM; + nthread_switches = NTHREAD_SWITCHES_SIM; + nmutexes = NMUTEXES_SIM; + nmboxes = NMBOXES_SIM; + nsemaphores = NSEMAPHORES_SIM; + nscheds = NSCHEDS_SIM; + ntimers = NTIMERS_SIM; + } else { + nsamples = NSAMPLES; + ntest_threads = NTEST_THREADS; + nthread_switches = NTHREAD_SWITCHES; + nmutexes = NMUTEXES; + nmboxes = NMBOXES; + nsemaphores = NSEMAPHORES; + nscheds = NSCHEDS; + ntimers = NTIMERS; + } + + // Sanity +#ifdef WORKHORSE_TEST + ntest_threads = max(512, ntest_threads); + nmutexes = max(1024, nmutexes); + nsemaphores = max(1024, nsemaphores); + nmboxes = max(1024, nmboxes); + ncounters = max(1024, ncounters); + ntimers = max(1024, ntimers); +#else + ntest_threads = max(64, ntest_threads); + nmutexes = max(32, nmutexes); + nsemaphores = max(32, nsemaphores); + nmboxes = max(32, nmboxes); + ntimers = max(32, ntimers); +#endif + + run_all_tests(); + +} + +#else // CYGFUN_KERNEL_API_C + +int main( int argc, char **argv ) +{ + CYG_TEST_INIT(); + CYG_TEST_NA("Timing tests require:\n" + "CYGFUN_KERNEL_API_C && \n" + "CYGSEM_KERNEL_SCHED_MLQUEUE &&\n" + "CYGVAR_KERNEL_COUNTERS_CLOCK &&\n" + "!CYGPKG_HAL_I386_LINUX &&\n" + "!CYGDBG_INFRA_DIAG_USE_DEVICE &&\n" + "(CYGNUM_KERNEL_SCHED_PRIORITIES > 12)\n"); +} +#endif // CYGFUN_KERNEL_API_C, etc. + +// EOF tm_basic.cxx diff --git a/packages/compat/uitron/current/ChangeLog b/packages/compat/uitron/current/ChangeLog --- a/packages/compat/uitron/current/ChangeLog +++ b/packages/compat/uitron/current/ChangeLog @@ -1,3 +1,20 @@ +2000-08-03 Jonathan Larmour + + * include/uit_func.inl (ref_mpf): Compute used blocks from + bytes used / blocks size rather than now obsolete blockcount member + +2000-07-04 Jonathan Larmour + + * include/uit_func.inl: Update all memory pool related functions to + reflect the new interface to memory pools, and that they come from + the new CYGPKG_MEMALLOC package + + * cdl/uitron.cdl: CYGPKG_UITRON_MEMPOOLFIXED and + CYGPKG_UITRON_MEMPOOLVAR require the CYGPKG_MEMALLOC package + + * include/uit_objs.hxx: Update includes - memory pool implementations + are now in CYGPKG_MEMALLOC + 2000-06-15 Gary Thomas * include/uit_ifnc.h (CYGPRI_UITRON_SET_RETCODE): Always return diff --git a/packages/compat/uitron/current/cdl/uitron.cdl b/packages/compat/uitron/current/cdl/uitron.cdl --- a/packages/compat/uitron/current/cdl/uitron.cdl +++ b/packages/compat/uitron/current/cdl/uitron.cdl @@ -215,6 +215,7 @@ cdl_package CYGPKG_UITRON { display "Fixed-size memorypools" flavor bool default_value 1 + requires CYGPKG_MEMALLOC description " uITRON supports memory pools for dynamic, task-safe memory allocation. @@ -233,6 +234,7 @@ cdl_package CYGPKG_UITRON { display "Variable-size memorypools" flavor bool default_value 1 + requires CYGPKG_MEMALLOC description " uITRON supports memory pools for dynamic, task-safe memory allocation. diff --git a/packages/compat/uitron/current/include/uit_func.inl b/packages/compat/uitron/current/include/uit_func.inl --- a/packages/compat/uitron/current/include/uit_func.inl +++ b/packages/compat/uitron/current/include/uit_func.inl @@ -1409,19 +1409,19 @@ cre_mpl ( ID mplid, T_CMPL *pk_cmpl ) CYG_UIT_PARAMCHECK_PTR( pk_cmpl ); CYG_UITRON_CHECK_NO_OBJ_LOCK_SCHED( MEMPOOLVAR, mplid ); Cyg_Mempool_Variable *p = &(CYG_UITRON_OBJS( MEMPOOLVAR )[ mplid - 1 ]); - cyg_uint8 *base; - cyg_int32 size; - CYG_ADDRWORD scratch; + Cyg_Mempool_Status stat; + // preserve the original memory area to use - p->get_arena( base, size, scratch ); + p->get_status( CYG_MEMPOOL_STAT_ORIGBASE|CYG_MEMPOOL_STAT_ORIGSIZE, stat ); - if ( size < pk_cmpl->mplsz ) + if ( stat.origsize < pk_cmpl->mplsz ) ret = E_NOMEM; else if ( TA_TFIFO != pk_cmpl->mplatr ) ret = E_RSATR; else CYG_UITRON_PTRS( MEMPOOLVAR )[ mplid - 1 ] = - new( p ) Cyg_Mempool_Variable( base, size ); + new( p ) Cyg_Mempool_Variable( + const_cast(stat.origbase), stat.origsize ); Cyg_Scheduler::unlock(); return ret; } @@ -1513,7 +1513,7 @@ rel_blk ( ID mplid, VP blk ) Cyg_Mempool_Variable *p; CYG_UITRON_CHECK_AND_GETP_MEMPOOLVAR( mplid, p ); CYG_UIT_PARAMCHECK_PTR( blk ); - cyg_bool result = p->free( (cyg_uint8 *)blk, 0 ); + cyg_bool result = p->free( (cyg_uint8 *)blk ); if ( ! result ) return E_PAR; return E_OK; @@ -1524,17 +1524,17 @@ ER ref_mpl ( T_RMPL *pk_rmpl, ID mplid ) { Cyg_Mempool_Variable *p; + Cyg_Mempool_Status stat; CYG_UITRON_CHECK_AND_GETP_MEMPOOLVAR( mplid, p ); CYG_UIT_PARAMCHECK_PTR( pk_rmpl ); + p->get_status( CYG_MEMPOOL_STAT_WAITING| + CYG_MEMPOOL_STAT_TOTALFREE| + CYG_MEMPOOL_STAT_MAXFREE, stat ); + pk_rmpl->exinf = NADR; - pk_rmpl->wtsk = p->waiting(); - pk_rmpl->frsz = p->get_freemem(); - - cyg_uint8 *base; - cyg_int32 size; - CYG_ADDRWORD maxfree; - p->get_arena(base, size, maxfree); - pk_rmpl->maxsz = maxfree; + pk_rmpl->wtsk = stat.waiting; + pk_rmpl->frsz = stat.totalfree; + pk_rmpl->maxsz = stat.maxfree; return E_OK; } @@ -1557,21 +1557,20 @@ cre_mpf ( ID mpfid, T_CMPF *pk_cmpf ) CYG_UIT_PARAMCHECK_PTR( pk_cmpf ); CYG_UITRON_CHECK_NO_OBJ_LOCK_SCHED( MEMPOOLFIXED, mpfid ); Cyg_Mempool_Fixed *p = &(CYG_UITRON_OBJS( MEMPOOLFIXED )[ mpfid - 1 ]); - cyg_uint8 *base; - cyg_int32 size; - CYG_ADDRWORD scratch; + Cyg_Mempool_Status stat; + // preserve the original memory area to use - p->get_arena( base, size, scratch ); + p->get_status( CYG_MEMPOOL_STAT_ORIGBASE|CYG_MEMPOOL_STAT_ORIGSIZE, stat ); - if ( size < (pk_cmpf->blfsz * (pk_cmpf->mpfcnt + 1)) ) + if ( stat.origsize < (pk_cmpf->blfsz * (pk_cmpf->mpfcnt + 1)) ) ret = E_NOMEM; else if ( TA_TFIFO != pk_cmpf->mpfatr ) ret = E_RSATR; else CYG_UITRON_PTRS( MEMPOOLFIXED )[ mpfid - 1 ] = new( p ) - Cyg_Mempool_Fixed( base, size, - (CYG_ADDRWORD)pk_cmpf->blfsz ); + Cyg_Mempool_Fixed( const_cast(stat.origbase), + stat.origsize, (CYG_ADDRWORD)pk_cmpf->blfsz ); Cyg_Scheduler::unlock(); return ret; } @@ -1670,16 +1669,22 @@ ER ref_mpf ( T_RMPF *pk_rmpf, ID mpfid ) { Cyg_Mempool_Fixed *p; + Cyg_Mempool_Status stat; CYG_UITRON_CHECK_AND_GETP_MEMPOOLFIXED( mpfid, p ); CYG_UIT_PARAMCHECK_PTR( pk_rmpf ); - pk_rmpf->exinf = NADR; - pk_rmpf->wtsk = p->waiting(); + + p->get_status( CYG_MEMPOOL_STAT_WAITING| + CYG_MEMPOOL_STAT_TOTALFREE| + CYG_MEMPOOL_STAT_TOTALALLOCATED| + CYG_MEMPOOL_STAT_BLOCKSIZE, stat ); - cyg_int32 blocksize = p->get_blocksize(); - pk_rmpf->frbcnt = p->get_freemem() / blocksize; + pk_rmpf->exinf = NADR; + pk_rmpf->wtsk = stat.waiting; + + pk_rmpf->frbcnt = stat.totalfree / stat.blocksize; // these two are "implementation dependent" ie. eCos only - pk_rmpf->numbcnt = p->get_totalmem() / blocksize; - pk_rmpf->bsize = blocksize; + pk_rmpf->numbcnt = stat.totalallocated / stat.blocksize; + pk_rmpf->bsize = stat.blocksize; return E_OK; } diff --git a/packages/compat/uitron/current/include/uit_objs.hxx b/packages/compat/uitron/current/include/uit_objs.hxx --- a/packages/compat/uitron/current/include/uit_objs.hxx +++ b/packages/compat/uitron/current/include/uit_objs.hxx @@ -58,8 +58,8 @@ #include // Cyg_Mbox #include // Cyg_Flag #include // Cyg_Counting_Semaphore2 -#include // Cyg_Mempool_Fixed -#include // Cyg_Mempool_Variable +#include // Cyg_Mempool_Fixed +#include // Cyg_Mempool_Variable #include // Cyg_Timer // ------------------------------------------------------------------------ diff --git a/packages/cygmon/current/ChangeLog b/packages/cygmon/current/ChangeLog --- a/packages/cygmon/current/ChangeLog +++ b/packages/cygmon/current/ChangeLog @@ -1,14 +1,59 @@ -2000-07-14 Drew Moseley +2000-08-14 Drew Moseley + + * misc/ecos_bsp.c: Added some include files to fix some build + failures on partially unsupported systems. (ie non-cygmon, etc). + +2000-08-12 Drew Moseley + + * misc/bsp/common/debug-io.c (bsp_debug_write): Use + output_gdb_string when stub_is_active. + +2000-08-10 Drew Moseley + + * misc/utils.c: Removed some unused functions. Also handle + printing invalid registers. + + * misc/monitor_cmd.c: Handle some unprintable characters better. + Also handle displaying of invalid memory locations better. + Add handling for register validity checking. + + * misc/monitor.h: Add a conditional field "reg_valid" to struct + regstruct. + + * misc/monitor.c: Added a call to a conditionally defined routine + INITIALIZE_MON_EACH_TIME(). This is called everytime the monitor + is invoked. For instance, this is used to determine which + registers have actually been read. - * misc/bsp/mips/gdb-cpu.c: New files. Mips based Cygmon now running on top of eCos HAL. - * misc/bsp/mips/gdb-cpu.h: Ditto. - * misc/bsp/mips/gdb.h: Ditto. - * misc/bsp/mips/insn.h: Ditto. - * misc/bsp/mips/singlestep.c: Ditto. - * misc/mips/board.h: Ditto. - * misc/mips/cpu.h: Ditto. - * misc/mips/cpu_info.h: Ditto. - * misc/mips/mips-mon.c: Ditto. + * misc/generic_mem.c: Allow Cygmon to use the Safe memory routines + in the HAL. + + * misc/board.h: Added MN10300 basic support. + * misc/cpu-mon.c: Ditto. + * misc/cpu_info.h: Ditto. + * misc/bsp/cpu.h: Ditto. + * misc/bsp/mn10300/gdb-cpu.c: Ditto. New file. + * misc/bsp/mn10300/gdb-cpu.h: Ditto. New file. + * misc/bsp/mn10300/gdb.h: Ditto. New file. + * misc/bsp/mn10300/insn.h: Ditto. New file. + * misc/bsp/mn10300/singlestep.c: Ditto. New file. + * misc/mn10300/board.h: Ditto. New file. + * misc/mn10300/cpu.h: Ditto. New file. + * misc/mn10300/cpu_info.h: Ditto. New file. + * misc/mn10300/mn10300-mon.c: Ditto. New file. + + * cdl/cygmon.cdl: Removed dependency on the kernel and Serial I/O. + * misc/ecos_bsp.c: Ditto. + * misc/ecos_dummy.c: Ditto. + +2000-07-21 Drew Moseley + + * misc/ecos_bsp.c: Rearrange the linkage between Cygmon and HAL so + that Cygmon needs HAL but not vice-versa. ie HAL no longer calls + any Cygmon functions. + * misc/monitor.c: Ditto. + +2000-07-14 Drew Moseley * misc/bsp/common/syscall.c: Added SYS_meminfo call to find out how much RAM we have. diff --git a/packages/cygmon/current/cdl/cygmon.cdl b/packages/cygmon/current/cdl/cygmon.cdl --- a/packages/cygmon/current/cdl/cygmon.cdl +++ b/packages/cygmon/current/cdl/cygmon.cdl @@ -33,7 +33,7 @@ # # Author(s): jskov # Original data: gthomas -# Contributors: +# Contributors: dmoseley # Date: 1999-11-03 # #####DESCRIPTIONEND#### @@ -41,9 +41,7 @@ # ==================================================================== cdl_package CYGPKG_CYGMON { display "CygMon ROM monitor" - requires CYGPKG_KERNEL - requires CYGPKG_LIBC - requires CYGPKG_IO_SERIAL + requires CYGPKG_LIBC_STRING include_dir cyg/cygmon define_header cygmon.h description " @@ -75,7 +73,7 @@ cdl_package CYGPKG_CYGMON { requires ! CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT requires ! CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT requires ! CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT - requires CYGPKG_LIBC + requires CYGPKG_LIBC_STRING requires ! CYGFUN_LIBC_strtod requires ! CYGPKG_LIBC_STDIO requires ! CYGSEM_LIBC_SIGNALS_THREAD_SAFE @@ -89,7 +87,7 @@ cdl_package CYGPKG_CYGMON { requires ! CYGSEM_LIBC_PER_THREAD_ERRNO requires ! CYGSEM_LIBC_TIME_TIME_WORKING requires ! CYGSEM_LIBC_TIME_SETTIME_WORKING - requires CYGPKG_HAL_ARM + requires { CYGPKG_HAL_ARM || CYGPKG_HAL_MIPS || CYGPKG_HAL_MN10300 } no_define description "This option enables the building of the CygMon ELF image. diff --git a/packages/cygmon/current/misc/board.h b/packages/cygmon/current/misc/board.h --- a/packages/cygmon/current/misc/board.h +++ b/packages/cygmon/current/misc/board.h @@ -34,7 +34,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 1999-10-20 // Purpose: // Description: @@ -56,4 +56,8 @@ #include "mips/board.h" #endif +#ifdef CYGPKG_HAL_MN10300 +#include "mn10300/board.h" +#endif + #endif // __CYGMON_BOARD_H__ diff --git a/packages/cygmon/current/misc/bsp/common/debug-io.c b/packages/cygmon/current/misc/bsp/common/debug-io.c --- a/packages/cygmon/current/misc/bsp/common/debug-io.c +++ b/packages/cygmon/current/misc/bsp/common/debug-io.c @@ -49,12 +49,18 @@ static unsigned char __debug_ungetc; +extern int stub_is_active; +extern int __output_gdb_string (const char *str, int string_len); void bsp_debug_write(const char *p, int len) { struct bsp_comm_procs *com = bsp_shared_data->__debug_procs; - - com->__write(com->ch_data, p, len); + if (stub_is_active) { + // We are running in 'GDB' mode + __output_gdb_string(p, len); + } else { + com->__write(com->ch_data, p, len); + } } diff --git a/packages/cygmon/current/misc/bsp/cpu.h b/packages/cygmon/current/misc/bsp/cpu.h --- a/packages/cygmon/current/misc/bsp/cpu.h +++ b/packages/cygmon/current/misc/bsp/cpu.h @@ -34,7 +34,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 1999-10-20 // Purpose: // Description: @@ -55,4 +55,8 @@ #include "mips/cpu.h" #endif +#ifdef CYGPKG_HAL_MN10300 +#include "mn10300/cpu.h" +#endif + #endif // __BSP_CPU_H__ diff --git a/packages/cygmon/current/misc/bsp/mips/gdb-cpu.c b/packages/cygmon/current/misc/bsp/mips/gdb-cpu.c new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/bsp/mips/gdb-cpu.c @@ -0,0 +1,44 @@ +//========================================================================== +// +// gdb-cpu.c +// +// CPU specific support for GDB stub. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-06-07 +// Purpose: CPU specific support for GDB stub. +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// Nothing now. diff --git a/packages/cygmon/current/misc/bsp/mips/gdb-cpu.h b/packages/cygmon/current/misc/bsp/mips/gdb-cpu.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/bsp/mips/gdb-cpu.h @@ -0,0 +1,49 @@ +#ifndef __BSP_MIPS_GDB_CPU_H__ +#define __BSP_MIPS_GDB_CPU_H__ +//========================================================================== +// +// gdb-cpu.h +// +// CPU specific definitions for GDB stub. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: dmoseley +// Date: 2000-07-10 +// Purpose: CPU specific definitions for GDB stub. +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// Nothing now. + +#endif // __BSP_MIPS_GDB_CPU_H__ diff --git a/packages/cygmon/current/misc/bsp/mips/gdb.h b/packages/cygmon/current/misc/bsp/mips/gdb.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/bsp/mips/gdb.h @@ -0,0 +1,49 @@ +#ifndef __BSP_MIPS_GDB_H__ +#define __BSP_MIPS_GDB_H__ +//========================================================================== +// +// gdb.h +// +// +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 1999-10-20 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// Nothing now. + +#endif // __BSP_ARM_GDB_H__ diff --git a/packages/cygmon/current/misc/bsp/mips/insn.h b/packages/cygmon/current/misc/bsp/mips/insn.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/bsp/mips/insn.h @@ -0,0 +1,50 @@ +#ifndef __BSP_MIPS_INSN_H__ +#define __BSP_MIPS_INSN_H__ +//========================================================================== +// +// insn.h +// +// MIPS instruction descriptions. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-07-10 +// Purpose: MIPS instruction descriptions. +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// Nothing now. +// We are using the eCos hal for single-stepping. +// FIXME: this file can be removed + +#endif // __BSP_ARM_INSN_H__ diff --git a/packages/cygmon/current/misc/bsp/mips/singlestep.c b/packages/cygmon/current/misc/bsp/mips/singlestep.c new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/bsp/mips/singlestep.c @@ -0,0 +1,46 @@ +//========================================================================== +// +// singlestep.c +// +// MIPS specific single-step support. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-07-10 +// Purpose: MIPS specific single-step support. +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// Nothing now. +// We are using the eCos hal for single-stepping. +// FIXME: this file can be removed diff --git a/packages/cygmon/current/misc/bsp/mn10300/gdb-cpu.c b/packages/cygmon/current/misc/bsp/mn10300/gdb-cpu.c new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/bsp/mn10300/gdb-cpu.c @@ -0,0 +1,44 @@ +//========================================================================== +// +// gdb-cpu.c +// +// CPU specific support for GDB stub. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-08-11 +// Purpose: CPU specific support for GDB stub. +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// Nothing now. diff --git a/packages/cygmon/current/misc/bsp/mn10300/gdb-cpu.h b/packages/cygmon/current/misc/bsp/mn10300/gdb-cpu.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/bsp/mn10300/gdb-cpu.h @@ -0,0 +1,49 @@ +#ifndef __BSP_MN10300_GDB_CPU_H__ +#define __BSP_MN10300_GDB_CPU_H__ +//========================================================================== +// +// gdb-cpu.h +// +// CPU specific definitions for GDB stub. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-08-11 +// Purpose: CPU specific definitions for GDB stub. +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// Nothing now. + +#endif // __BSP_MN10300_GDB_CPU_H__ diff --git a/packages/cygmon/current/misc/bsp/mn10300/gdb.h b/packages/cygmon/current/misc/bsp/mn10300/gdb.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/bsp/mn10300/gdb.h @@ -0,0 +1,49 @@ +#ifndef __BSP_MN10300_GDB_H__ +#define __BSP_MN10300_GDB_H__ +//========================================================================== +// +// gdb.h +// +// +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-08-11 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// Nothing now. + +#endif // __BSP_ARM_GDB_H__ diff --git a/packages/cygmon/current/misc/bsp/mn10300/insn.h b/packages/cygmon/current/misc/bsp/mn10300/insn.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/bsp/mn10300/insn.h @@ -0,0 +1,50 @@ +#ifndef __BSP_MN10300_INSN_H__ +#define __BSP_MN10300_INSN_H__ +//========================================================================== +// +// insn.h +// +// MN10300 instruction descriptions. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-08-11 +// Purpose: MN10300 instruction descriptions. +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// Nothing now. +// We are using the eCos hal for single-stepping. +// FIXME: this file can be removed + +#endif // __BSP_ARM_INSN_H__ diff --git a/packages/cygmon/current/misc/bsp/mn10300/singlestep.c b/packages/cygmon/current/misc/bsp/mn10300/singlestep.c new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/bsp/mn10300/singlestep.c @@ -0,0 +1,46 @@ +//========================================================================== +// +// singlestep.c +// +// MN10300 specific single-step support. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-08-11 +// Purpose: MN10300 specific single-step support. +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// Nothing now. +// We are using the eCos hal for single-stepping. +// FIXME: this file can be removed diff --git a/packages/cygmon/current/misc/cpu-mon.c b/packages/cygmon/current/misc/cpu-mon.c --- a/packages/cygmon/current/misc/cpu-mon.c +++ b/packages/cygmon/current/misc/cpu-mon.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 1999-10-11 // Description: Architecture support for Cygmon //####DESCRIPTIONEND#### @@ -46,3 +46,7 @@ #ifdef CYGPKG_HAL_MIPS #include "mips/mips-mon.c" #endif + +#ifdef CYGPKG_HAL_MN10300 +#include "mn10300/mn10300-mon.c" +#endif diff --git a/packages/cygmon/current/misc/cpu_info.h b/packages/cygmon/current/misc/cpu_info.h --- a/packages/cygmon/current/misc/cpu_info.h +++ b/packages/cygmon/current/misc/cpu_info.h @@ -34,7 +34,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 1999-10-20 // Purpose: // Description: @@ -53,4 +53,8 @@ #ifdef CYGPKG_HAL_MIPS #include "mips/cpu_info.h" #endif + +#ifdef CYGPKG_HAL_MN10300 +#include "mn10300/cpu_info.h" +#endif #endif // __CYGMON_CPU_INFO_H__ diff --git a/packages/cygmon/current/misc/ecos_bsp.c b/packages/cygmon/current/misc/ecos_bsp.c --- a/packages/cygmon/current/misc/ecos_bsp.c +++ b/packages/cygmon/current/misc/ecos_bsp.c @@ -32,38 +32,51 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 1999-10-11 // Description: Wrapper functions which provide BSP environment for Cygmon //####DESCRIPTIONEND#### +#ifdef CYGPKG_KERNEL #include // Configuration headers +#endif #include #include #include #include +#ifdef CYGPKG_KERNEL #include +#else +#include +#include +#endif #include #include "bsp/common/bsp_if.h" #include #include #include CYGHWR_MEMORY_LAYOUT_H +#include #ifdef CYGPKG_IO #include +#include #endif #define STACK_SIZE CYGNUM_HAL_STACK_SIZE_MINIMUM static char stack[STACK_SIZE]; +#ifdef CYGPKG_KERNEL static cyg_thread thread_data; static cyg_handle_t thread_handle; +#endif char *build_date = __DATE__; extern void monitor_main(int, char *); extern int stub_is_active; +void ecos_bsp_set_memsize(unsigned long size); + void cygmon_main(void) { @@ -71,9 +84,16 @@ cygmon_main(void) monitor_main(0, 0); // Null argument list } +extern unsigned long cygmon_memsize; + externC void cyg_start( void ) { + // Fill in the BSP memory info + if (cygmon_memsize != 0) + ecos_bsp_set_memsize(cygmon_memsize); + +#ifdef CYGPKG_KERNEL // Create a main thread, so we can run the scheduler and have time 'pass' cyg_thread_create(10, // Priority - just a number (cyg_thread_entry_t*)cygmon_main, // entry @@ -86,6 +106,13 @@ cyg_start( void ) ); cyg_thread_resume(thread_handle); // Start it cyg_scheduler_start(); +#else +#ifdef HAL_ARCH_FUNCALL_NEW_STACK + HAL_ARCH_FUNCALL_NEW_STACK(cygmon_main, &stack[0], STACK_SIZE); +#else + #error Need to define HAL_ARCH_FUNCALL_NEW_STACK +#endif +#endif } // cyg_package_start() #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS @@ -130,13 +157,14 @@ unhandled_exception(int num, void *args) void _bsp_cpu_init(void) { - cyg_exception_handler_t _bsp_breakpoint_handler; +#ifdef CYGPKG_KERNEL int d0; cyg_exception_set_handler(CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION, _bsp_handle_exception, (cyg_addrword_t)&d0, 0, 0); +#endif #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS bsp_install_dbg_handler((bsp_handler_t)__handle_exception); __install_traps(); diff --git a/packages/cygmon/current/misc/ecos_dummy.c b/packages/cygmon/current/misc/ecos_dummy.c --- a/packages/cygmon/current/misc/ecos_dummy.c +++ b/packages/cygmon/current/misc/ecos_dummy.c @@ -32,13 +32,15 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 1999-10-11 // Description: Wrapper functions which provide BSP environment for Cygmon //####DESCRIPTIONEND#### +#ifdef CYGPKG_KERNEL #include // Configuration header #include +#endif #include #include diff --git a/packages/cygmon/current/misc/generic_mem.c b/packages/cygmon/current/misc/generic_mem.c --- a/packages/cygmon/current/misc/generic_mem.c +++ b/packages/cygmon/current/misc/generic_mem.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 1999-10-20 // Purpose: // Description: It may be appropriate to relay directly into the stubs @@ -65,24 +65,24 @@ int read_memory (mem_addr_t *src, int size, int amt, char *dst) { -#ifdef HAVE_BSP +#if defined(HAVE_BSP) && !defined(USE_ECOS_HAL_SAFE_MEMORY) return (bsp_memory_read((unsigned char *)src->addr, MEM_ADDR_ASI(src), size << 3, amt, dst) != amt); #else int totamt = size * amt; - return (totamt != __read_mem_safe (dst, src->addr, totamt)); + return (totamt != __read_mem_safe (dst, (void*)src->addr, totamt)); #endif } int write_memory (mem_addr_t *dst, int size, int amt, char *src) { -#ifdef HAVE_BSP +#if defined(HAVE_BSP) && !defined(USE_ECOS_HAL_SAFE_MEMORY) return (bsp_memory_write((unsigned char *)dst->addr, MEM_ADDR_ASI(dst), size << 3, amt, src) != amt); #else int totamt = size * amt; - return (totamt != __write_mem_safe (src, dst->addr, totamt)); + return (totamt != __write_mem_safe (src, (void*)dst->addr, totamt)); #endif } diff --git a/packages/cygmon/current/misc/mips/board.h b/packages/cygmon/current/misc/mips/board.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/mips/board.h @@ -0,0 +1,101 @@ +#ifndef __CYGMON_MIPS_BOARD_H__ +#define __CYGMON_MIPS_BOARD_H__ +//========================================================================== +// +// board.h +// +// Cygmon board/platform configuration file +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-07-11 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================= +// Hardware/platform/configuration specifics + +// These defines are only necessary for using target_reg union in monitor.h +// It should be possible to remove that once the HAL integration is complete. +#define HAVE_FLOAT_REGS 0 +#define HAVE_DOUBLE_REGS 0 + +#define HAVE_CACHE 0 +#define HAVE_USAGE 0 +#define USE_CYGMON_PROTOTYPES 1 +#define NOMAIN 1 +#define CYGMON_SYSTEM_SERVICES 0 // Not used, fall back to BSP/HAL support + +#ifdef CYGDAT_CYGMON_USE_HELP +#define USE_HELP 1 +#endif + +#define USE_ECOS_HAL_EXCEPTIONS +#define USE_ECOS_HAL_BREAKPOINTS +#define USE_ECOS_HAL_SINGLESTEP + +#include "cpu_info.h" +extern void bp_print (target_register_t bp_val); +extern int __set_breakpoint (target_register_t addr); +extern int __remove_breakpoint (target_register_t addr); +extern void __install_breakpoint_list (void); +extern void __clear_breakpoint_list (void); +extern int __display_breakpoint_list (void (*print_func)(target_register_t)); + +#define bsp_skip_instruction(regs) __skipinst() +#define install_breakpoints() __install_breakpoints() +#define add_mon_breakpoint(bpt) __set_breakpoint((bpt).addr) +#define clear_mon_breakpoint(bpt) __remove_breakpoint((bpt).addr) +#define show_breakpoints() __display_breakpoint_list(bp_print) +#define clear_breakpoints() __clear_breakpoint_list() + +#define bsp_get_signal(exc_nr, regs) __computeSignal(exc_nr) +#define bsp_get_pc(regs) get_register(PC) + +#define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS +#include +#include "monitor.h" + +#ifdef __mips64 +#define bsp_set_pc(pc, regs) \ + put_register(PC, pc); \ + if (regs->_sr & SR_ERL) \ + put_register(EPC, pc); \ + else \ + put_register(EEPC, pc); +#else +#define bsp_set_pc(pc, regs) \ + put_register(PC, pc); +#endif + +#endif // __CYGMON_MIPS_BOARD_H__ diff --git a/packages/cygmon/current/misc/mips/cpu.h b/packages/cygmon/current/misc/mips/cpu.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/mips/cpu.h @@ -0,0 +1,50 @@ +#ifndef __MIPS_CPU_H__ +#define __MIPS_CPU_H__ +//========================================================================== +// +// cpu.h +// +// MIPS specific processor defines +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-06-07 +// Purpose: MIPS specific processor defines +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +#include + +#define BSP_MAX_EXCEPTIONS CYGNUM_HAL_VSR_COUNT + +#endif // __MIPS_CPU_H__ diff --git a/packages/cygmon/current/misc/mips/cpu_info.h b/packages/cygmon/current/misc/mips/cpu_info.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/mips/cpu_info.h @@ -0,0 +1,81 @@ +#ifndef __MIPS_CPU_INFO_H__ +#define __MIPS_CPU_INFO_H__ +//========================================================================== +// +// cpu_info.h +// +// Architecture information for MIPS processors +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-06-07 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +#define IS_MIPS 1 + +/* Temporary as long a multiple protypes are copied in multiple files */ +/* This variation does NOT clone the prototypes */ +#define NO_MALLOC 1 + +#ifndef USE_ECOS_HAL_BREAKPOINTS + +/* big enuf to store a trap in the BP structure */ + +#define BP_INST_T_DEFINED 1 +typedef unsigned int bp_inst_t ; + +#else /* USE_ECOS_HAL_BREAKPOINTS */ + +#define MEM_ADDR_DEFINED 1 +typedef struct mem_addr { + unsigned long addr; +} mem_addr_t ; + +#endif /* USE_ECOS_HAL_BREAKPOINTS */ + +typedef unsigned long target_register_t; + +#include +#include +#if CYG_BYTEORDER == CYG_MSBFIRST +#define PRINT_INSN print_insn_big_mips +#else +#define PRINT_INSN print_insn_little_mips +#endif + +#undef BFD_MACH +#define BFD_MACH 0 + +#endif // __MIPS_CPU_INFO_H__ diff --git a/packages/cygmon/current/misc/mips/mips-mon.c b/packages/cygmon/current/misc/mips/mips-mon.c new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/mips/mips-mon.c @@ -0,0 +1,174 @@ +//========================================================================== +// +// mips-mon.c +// +// Support code to extend the generic monitor code to support +// MIPS processors. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-06-07 +// Purpose: Support code to extend the generic monitor code to support +// MIPS(R) processors. +// Description: Further board specific support is in other files. +// This file contains: +// register names lookup table +// +// Empty Stubs: +// Interval timer - This should really belong to the application +// operating system. +// +// Should not contain: +// low level uart getchar and putchar functions +// delay function to support uart +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +#include "monitor.h" + +struct regstruct regtab[] = +{ + { "zero", REG_ZERO }, + { "at", REG_AT }, + { "v0", REG_V0 }, + { "v1", REG_V1 }, + { "a0", REG_A0 }, + { "a1", REG_A1 }, + { "a2", REG_A2 }, + { "a3", REG_A3 }, + { "t0", REG_T0 }, + { "t1", REG_T1 }, + { "t2", REG_T2 }, + { "t3", REG_T3 }, + { "t4", REG_T4 }, + { "t5", REG_T5 }, + { "t6", REG_T6 }, + { "t7", REG_T7 }, + { "s0", REG_S0 }, + { "s1", REG_S1 }, + { "s2", REG_S2 }, + { "s3", REG_S3 }, + { "s4", REG_S4 }, + { "s5", REG_S5 }, + { "s6", REG_S6 }, + { "s7", REG_S7 }, + { "t8", REG_T8 }, + { "t9", REG_T9 }, + { "k0", REG_K0 }, + { "k1", REG_K1 }, + { "gp", REG_GP }, + { "sp", REG_SP }, + { "s8", REG_S8 }, + { "ra", REG_RA }, + + { "sr", REG_SR }, + { "lo", REG_LO }, + { "hi", REG_HI }, + { "badvr", REG_BAD }, + { "cause", REG_CAUSE }, + { "pc", REG_PC }, +#ifdef CYGHWR_HAL_MIPS_FPU + { "f0", REG_F0 }, + { "f1", REG_F1 }, + { "f2", REG_F2 }, + { "f3", REG_F3 }, + { "f4", REG_F4 }, + { "f5", REG_F5 }, + { "f6", REG_F6 }, + { "f7", REG_F7 }, + { "f8", REG_F8 }, + { "f9", REG_F9 }, + { "f10", REG_F10 }, + { "f11", REG_F11 }, + { "f12", REG_F12 }, + { "f13", REG_F13 }, + { "f14", REG_F14 }, + { "f15", REG_F15 }, + { "f16", REG_F16 }, + { "f17", REG_F17 }, + { "f18", REG_F18 }, + { "f19", REG_F19 }, + { "f20", REG_F20 }, + { "f21", REG_F21 }, + { "f22", REG_F22 }, + { "f23", REG_F23 }, + { "f24", REG_F24 }, + { "f25", REG_F25 }, + { "f26", REG_F26 }, + { "f27", REG_F27 }, + { "f28", REG_F28 }, + { "f29", REG_F29 }, + { "f30", REG_F30 }, + { "f31", REG_F31 }, + { "fcr31", REG_FCR31 }, +#endif /* CYGHWR_HAL_MIPS_FPU */ + { 0, 0 }, /* Terminating element must be last */ +} ; + +void +initialize_mon(void) +{ +} /* initialize_mon */ + + +#include +#include +int +machine_syscall(HAL_SavedRegisters *regs) +{ + int res, err; + target_register_t a0, a1, a2, a3; + + a0 = get_register(REG_A0); + a1 = get_register(REG_A1); + a2 = get_register(REG_A2); + a3 = get_register(REG_A3); + + err = _bsp_do_syscall(a0, // Function + a1, a2, a3, 0, // arguments, + &res); + if (err) + { + // This was a syscall. It has now been handled, so update the registers appropriately + put_register(REG_V0, res); + bsp_skip_instruction(regs); + } + + return err; +} + + +// Utility function for printing breakpoints +void bp_print(target_register_t bp_val) +{ + bsp_printf("0x%08lx\n", (unsigned long)bp_val); +} diff --git a/packages/cygmon/current/misc/mn10300/board.h b/packages/cygmon/current/misc/mn10300/board.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/mn10300/board.h @@ -0,0 +1,90 @@ +#ifndef __CYGMON_MN10300_BOARD_H__ +#define __CYGMON_MN10300_BOARD_H__ +//========================================================================== +// +// board.h +// +// Cygmon board/platform configuration file +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-08-11 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================= +// Hardware/platform/configuration specifics + +// These defines are only necessary for using target_reg union in monitor.h +// It should be possible to remove that once the HAL integration is complete. +#define HAVE_FLOAT_REGS 0 +#define HAVE_DOUBLE_REGS 0 + +#define HAVE_CACHE 0 +#define HAVE_USAGE 0 +#define USE_CYGMON_PROTOTYPES 1 +#define NOMAIN 1 +#define CYGMON_SYSTEM_SERVICES 0 // Not used, fall back to BSP/HAL support + +#ifdef CYGDAT_CYGMON_USE_HELP +#define USE_HELP 1 +#endif + +#define USE_ECOS_HAL_EXCEPTIONS +#define USE_ECOS_HAL_BREAKPOINTS +#define USE_ECOS_HAL_SINGLESTEP +#define USE_ECOS_HAL_SAFE_MEMORY +extern int __read_mem_safe (void *dst, void *src, int count); +extern int __write_mem_safe (void *src, void *dst, int count); + + +#include "cpu_info.h" +extern void bp_print (target_register_t bp_val); +extern int __set_breakpoint (target_register_t addr); +extern int __remove_breakpoint (target_register_t addr); +extern void __install_breakpoint_list (void); +extern void __clear_breakpoint_list (void); +extern int __display_breakpoint_list (void (*print_func)(target_register_t)); + +#define bsp_skip_instruction(regs) __skipinst() +#define install_breakpoints() __install_breakpoints() +#define add_mon_breakpoint(bpt) __set_breakpoint((bpt).addr) +#define clear_mon_breakpoint(bpt) __remove_breakpoint((bpt).addr) +#define show_breakpoints() __display_breakpoint_list(bp_print) +#define clear_breakpoints() __clear_breakpoint_list() + +#define bsp_get_signal(exc_nr, regs) __computeSignal(exc_nr) +#define bsp_get_pc(regs) get_register(PC) +#define bsp_set_pc(pc, regs) put_register(PC, pc); + +#endif // __CYGMON_MN10300_BOARD_H__ diff --git a/packages/cygmon/current/misc/mn10300/cpu.h b/packages/cygmon/current/misc/mn10300/cpu.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/mn10300/cpu.h @@ -0,0 +1,52 @@ +#ifndef __MN10300_CPU_H__ +#define __MN10300_CPU_H__ +//========================================================================== +// +// cpu.h +// +// MN10300 specific processor defines +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-08-11 +// Purpose: MN10300 specific processor defines +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +#include + +#define BSP_MAX_EXCEPTIONS CYGNUM_HAL_VSR_COUNT + +#define REG_PC PC + +#endif // __MN10300_CPU_H__ diff --git a/packages/cygmon/current/misc/mn10300/cpu_info.h b/packages/cygmon/current/misc/mn10300/cpu_info.h new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/mn10300/cpu_info.h @@ -0,0 +1,82 @@ +#ifndef __MN10300_CPU_INFO_H__ +#define __MN10300_CPU_INFO_H__ +//========================================================================== +// +// cpu_info.h +// +// Architecture information for MN10300 processors +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-08-11 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +#define IS_MN10300 1 + +/* Temporary as long a multiple protypes are copied in multiple files */ +/* This variation does NOT clone the prototypes */ +#define NO_MALLOC 1 + +#ifndef USE_ECOS_HAL_BREAKPOINTS + +/* big enuf to store a trap in the BP structure */ + +#define BP_INST_T_DEFINED 1 +typedef unsigned char bp_inst_t ; + +#else /* USE_ECOS_HAL_BREAKPOINTS */ + +#define MEM_ADDR_DEFINED 1 +typedef struct mem_addr { + unsigned long addr; +} mem_addr_t ; + +#endif /* USE_ECOS_HAL_BREAKPOINTS */ + +typedef unsigned long target_register_t; + +#include +#include +#define PRINT_INSN print_insn_mn10300 + +#undef BFD_MACH +#define BFD_MACH 0 + +// Ensure that the reg_valid field in regstruct is used. +#define REG_VALID_FIELD_IN_REGSTRUCT +#define INITIALIZE_MON_EACH_TIME() initialize_mon_each_time() +extern void initialize_mon_each_time(void); + +#endif // __MN10300_CPU_INFO_H__ diff --git a/packages/cygmon/current/misc/mn10300/mn10300-mon.c b/packages/cygmon/current/misc/mn10300/mn10300-mon.c new file mode 100644 --- /dev/null +++ b/packages/cygmon/current/misc/mn10300/mn10300-mon.c @@ -0,0 +1,151 @@ +//========================================================================== +// +// mn10300-mon.c +// +// Support code to extend the generic monitor code to support +// MN10300 processors. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dmoseley +// Contributors: dmoseley +// Date: 2000-08-11 +// Purpose: Support code to extend the generic monitor code to support +// MN10300 processors. +// Description: Further board specific support is in other files. +// This file contains: +// register names lookup table +// +// Empty Stubs: +// Interval timer - This should really belong to the application +// operating system. +// +// Should not contain: +// low level uart getchar and putchar functions +// delay function to support uart +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +#include "monitor.h" + +struct regstruct regtab[] = +{ + {"d0", D0, 1}, + {"d1", D1, 1}, + {"d2", D2, 1}, + {"d3", D3, 1}, + {"a0", A0, 1}, + {"a1", A1, 1}, + {"a2", A2, 1}, + {"a3", A3, 1}, + {"sp", SP, 1}, + {"pc", PC, 1}, + {"mdr", MDR, 1}, + {"psw", PSW, 1}, + {"lir", LIR, 1}, + {"lar", LAR, 1}, +#ifdef CYGPKG_HAL_MN10300_AM33 + {"r0", R0, 1}, + {"r1", R1, 1}, + {"r2", R2, 1}, + {"r3", R3, 1}, + {"r4", R4, 1}, + {"r5", R5, 1}, + {"r6", R6, 1}, + {"r7", R7, 1}, + {"ssp", SSP, 1}, + {"msp", MSP, 1}, + {"usp", USP, 1}, + {"mcrh", MCRH, 1}, + {"mcrl", MCRL, 1}, + {"mcvf", MCVF, 1}, + {"mdrq", MDRQ, 1}, +#endif + { 0, 0, 1}, /* Terminating element must be last */ +} ; + +void +initialize_mon(void) +{ +} /* initialize_mon */ + + +#ifdef CYGPKG_HAL_MN10300_AM33 +extern int msp_read; +#endif + +void +initialize_mon_each_time(void) +{ + int i; + +#ifdef CYGPKG_HAL_MN10300_AM33 + // Make sure the regtab[] indicates the valid status of the MSP + for (i = 0; regtab[i].registername != NULL; i++) + { + if (regtab[i].registernumber == MSP) + regtab[i].registervalid = msp_read; + } +#endif +} /* initialize_mon_each_time */ + + +#include +#include +int +machine_syscall(HAL_SavedRegisters *regs) +{ + int res, err; + target_register_t d0, d1, d2, d3; + + d0 = get_register(D0); + d1 = get_register(D1); + d2 = get_register(D2); + d3 = get_register(D3); + + err = _bsp_do_syscall(d0, // Function + d1, d2, d3, 0, // arguments, + &res); + if (err) + { + // This was a syscall. It has now been handled, so update the registers appropriately + put_register(D0, res); + bsp_skip_instruction(regs); + } + + return err; +} + + +// Utility function for printing breakpoints +void bp_print(target_register_t bp_val) +{ + bsp_printf("0x%08lx\n", (unsigned long)bp_val); +} diff --git a/packages/cygmon/current/misc/monitor.c b/packages/cygmon/current/misc/monitor.c --- a/packages/cygmon/current/misc/monitor.c +++ b/packages/cygmon/current/misc/monitor.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 1999-10-20 // Purpose: Monitor shell and main routines for CygMON the Wonder Monitor // Description: @@ -98,7 +98,7 @@ static int mon_kill_handler(int exc_nr, * This global flag is used by generic-stub.c to communicate to us that we * are processing the breakpoint function within Cygmon itself. */ -int processing_breakpoint_function = 0; +extern int processing_breakpoint_function; #endif /* Global pointer to current set of saved registers. */ @@ -258,6 +258,11 @@ monitor_take_control (void) // stuff separately. bsp_debug_ungetc('\0'); +#ifdef INITIALIZE_MON_EACH_TIME + // Call the per-stop initialization routine if it is defined. + INITIALIZE_MON_EACH_TIME(); +#endif + #if defined(HAVE_BSP) && !defined(USE_ECOS_HAL_EXCEPTIONS) /* replace original BSP debug trap handler with ours */ (void)bsp_install_dbg_handler(mon_dbg_handler); diff --git a/packages/cygmon/current/misc/monitor.h b/packages/cygmon/current/misc/monitor.h --- a/packages/cygmon/current/misc/monitor.h +++ b/packages/cygmon/current/misc/monitor.h @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 1999-10-20 // Purpose: Main definitions for the CygMON ROM monitor // Description: @@ -122,6 +122,9 @@ struct regstruct int registertype; #endif // defined(CYGPKG_HAL_ARM) || !defined(__ECOS__) #endif +#ifdef REG_VALID_FIELD_IN_REGSTRUCT + int registervalid; +#endif }; @@ -250,7 +253,7 @@ extern char *int2str (target_register_t extern char *strdup(const char *str); #endif extern target_register_t get_pc(void); -extern char *get_register_str (regnames_t which, int detail); +extern char *get_register_str (regnames_t which, int detail, int valid); extern void store_register (regnames_t which, char *string); #ifndef USE_ECOS_HAL_BREAKPOINTS diff --git a/packages/cygmon/current/misc/monitor_cmd.c b/packages/cygmon/current/misc/monitor_cmd.c --- a/packages/cygmon/current/misc/monitor_cmd.c +++ b/packages/cygmon/current/misc/monitor_cmd.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 1999-10-20 // Purpose: Monitor commands for the CygMON ROM monitor // Description: @@ -721,8 +721,16 @@ display_memory (char *value, int size, i int end = littleEndian ? -1 : size; int incr = littleEndian ? -1 : 1; - for (x = start; x != end; x += incr) - xprintf ("%02x", value[x] & 0xff); + if (value) + { + for (x = start; x != end; x += incr) + xprintf ("%02x", value[x] & 0xff); + } + else + { + for (x = start; x != end; x += incr) + xprintf (".."); + } } @@ -929,15 +937,23 @@ Displays 16 bytes starting with 44f0 and addr2str (&addr, buf); xprintf("%s: ", buf); } - read_memory (&addr, size, 1, value); - display_memory (value, size, get_memory_display_mode ()); - xprintf (" "); - for (i = 0; i < size; i++) - { - chardumps[offset + i] = value[i] & 0x7f; - if (chardumps[offset + i] < 32) - chardumps[offset + i] = '.'; - } + if (read_memory (&addr, size, 1, value)) + { + display_memory (0, size, get_memory_display_mode ()); + for (i = 0; i < size; i++) + { + value[i] = 0; + } + } else { + display_memory (value, size, get_memory_display_mode ()); + } + xprintf (" "); + for (i = 0; i < size; i++) + { + chardumps[offset + i] = value[i] & 0x7f; + if (chardumps[offset + i] < 32) + chardumps[offset + i] = '.'; + } } xprintf (" "); for(i = 0; i < offset; i++) @@ -1259,9 +1275,15 @@ display_group (int which_group) else if (!skipping_group) { +#ifdef REG_VALID_FIELD_IN_REGSTRUCT +#define REGVALID_VAL regtab[i].registervalid +#else +#define REGVALID_VAL 1 +#endif xsprintf(buf, "%4s: %s", regtab[i].registername, - get_register_str (regtab[i].registernumber, 0)); + get_register_str (regtab[i].registernumber, 0 , REGVALID_VAL)); +#undef REGVALID_VAL buflen = strlen (buf); if ((buflen + len + 3) >= 80) { @@ -1314,8 +1336,14 @@ getregister (void) } else { +#ifdef REG_VALID_FIELD_IN_REGSTRUCT +#define REGVALID_VAL regtab[i].registervalid +#else +#define REGVALID_VAL 1 +#endif xprintf("%s: %s\n", argvect[1], - get_register_str (regtab[i].registernumber, 1)); + get_register_str (regtab[i].registernumber, 1, REGVALID_VAL)); +#undef REGVALID_VAL } } } @@ -2057,8 +2085,16 @@ Copies 0x300 bytes of memory from 0x1000 char buf[128]; int msize = (size > 128) ? 128 : size; - read_memory (&src, 1, msize, buf); - write_memory (&dst, 1, msize, buf); + if (read_memory (&src, 1, msize, buf)) + { + xprintf ("Memory read failed\n"); + break; + } + if (write_memory (&dst, 1, msize, buf)) + { + xprintf ("Memory write failed\n"); + break; + } ADD_OFFSET (&src, &src, msize); ADD_OFFSET (&dst, &dst, msize); size -= msize; diff --git a/packages/cygmon/current/misc/utils.c b/packages/cygmon/current/misc/utils.c --- a/packages/cygmon/current/misc/utils.c +++ b/packages/cygmon/current/misc/utils.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): -// Contributors: gthomas +// Contributors: gthomas, dmoseley // Date: 1999-10-20 // Purpose: Monitor utilities. // Description: @@ -138,41 +138,6 @@ str2int (char *str, int base) return str2ull(str, base); } - -/* Converts a string to a float, input is a raw integer string - * of the given assumed base. */ -#if HAVE_FLOAT_REGS -static float -str2float (char *str, int base) -{ - float f; - unsigned long long ull = str2ull(str, base); - - switch (sizeof(float)) - { - case sizeof(unsigned int): - *((unsigned int *)&f) = ull; - break; -#if __LONG_MAX__ != __INT_MAX__ - case sizeof(unsigned long): - *((unsigned long *)&f) = ull; - break; -#endif -#if __LONG_LONG_MAX__ != __LONG_MAX__ - case sizeof(unsigned long long): - *((unsigned long long *)&f) = ull; - break; -#endif - default: - f = 0.0; - break; - } - - return f; -} -#endif - - /* Converts a string to a double, input is a raw integer string * of the given assumed base. */ #if HAVE_DOUBLE_REGS @@ -297,30 +262,6 @@ int2str (target_register_t number, int b return ull2str((unsigned long long)number, base, numdigs); } -#if HAVE_FLOAT_REGS -static char * -float2str(float f) -{ - switch(sizeof(float)) - { - case sizeof(unsigned int): - return ull2str(*((unsigned int *)&f), 16, sizeof(float) * 2); - break; -#if __LONG_MAX__ != __INT_MAX__ - case sizeof(unsigned long): - return ull2str(*((unsigned long *)&f), 16, sizeof(float) * 2); - break; -#endif -#if __LONG_LONG_MAX__ != __LONG_MAX__ - case sizeof(unsigned long long): - return ull2str(*((unsigned long long *)&f), 16, sizeof(float) * 2); - break; -#endif - } - return "....fixme..."; -} -#endif - #if HAVE_DOUBLE_REGS static char * doudble2str(double d) @@ -377,9 +318,7 @@ get_register_type(regnames_t which) } #endif - -char * -get_register_str (regnames_t which, int detail) +char *get_register_str (regnames_t which, int detail, int valid) { #ifdef SPECIAL_REG_OUTPUT char *res; @@ -389,7 +328,21 @@ get_register_str (regnames_t which, int return res; } #endif - return int2str (get_register (which), 16, sizeof (target_register_t) * 2); + if (valid == 0) + { + switch (sizeof (target_register_t)) + { + case 1: return "..."; + case 2: return "....."; + case 4: return "........."; + case 8: return "................."; + default: return "........."; + } + } + else + { + return int2str (get_register (which), 16, sizeof (target_register_t) * 2); + } } diff --git a/packages/devs/eth/arm/ebsa285/current/ChangeLog b/packages/devs/eth/arm/ebsa285/current/ChangeLog --- a/packages/devs/eth/arm/ebsa285/current/ChangeLog +++ b/packages/devs/eth/arm/ebsa285/current/ChangeLog @@ -1,3 +1,43 @@ +2000-08-15 Hugo Tyson + + * src/if_ebsa285.c (PacketRxReady): Put back the check for very + small packets into the driver; the layer above checks for that + (defensive programming) but only *after* asserting that the size + is large enough, to help detect that scenario from other drivers. + I believe we only have struct ether_header available if CYGPKG_NET + but I could be wrong. + [CASE 104353] + +2000-08-08 Hugo Tyson + + * src/if_ebsa285.c (eth_set_promiscuous_mode): + - ccs->config_bytes[18]=0x70; + + ccs->config_bytes[18]=0x72; // Keep the Padding Enable bit + ...otherwise short frame sends don't work in promisc mode. + [CASE 104289] + +2000-08-07 Gary Thomas + + * src/if_ebsa285.c (pciwindow_mem_alloc): Take out very noisy debug. + +2000-08-03 Gary Thomas + + * src/if_ebsa285.c: Changes for stand-alone mode. + + * cdl/ebsa285_eth_drivers.cdl: Ethernet driver package hierarchy changed. + Add option to control number of interfaces. + +2000-07-28 Hugo Tyson + + * src/if_ebsa285.c (PacketRxReady): Do not attempt to forward + short packets; eth_drv.c assumes there is at least a header there. + (i82559_recv): Also be more careful and ASSERTive about -ve buffer + sizes; be more defensive about sglists. [CASE 104206] + +2000-07-26 Gary Thomas + + * src/if_ebsa285.c: Update for new eth_drv interfaces. + 2000-07-18 Hugo Tyson * src/if_ebsa285.c (i82559_poll): Fill in the flesh of this, it diff --git a/packages/devs/eth/arm/ebsa285/current/cdl/ebsa285_eth_drivers.cdl b/packages/devs/eth/arm/ebsa285/current/cdl/ebsa285_eth_drivers.cdl --- a/packages/devs/eth/arm/ebsa285/current/cdl/ebsa285_eth_drivers.cdl +++ b/packages/devs/eth/arm/ebsa285/current/cdl/ebsa285_eth_drivers.cdl @@ -44,8 +44,8 @@ cdl_package CYGPKG_DEVS_ETH_ARM_EBSA285 { display "Intel EBSA285 with PRO/100+ ethernet driver" - parent CYGPKG_NET_ETH_DRIVERS - active_if CYGPKG_NET_ETH_DRIVERS + parent CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_IO_ETH_DRIVERS active_if CYGPKG_HAL_ARM_EBSA285 implements CYGHWR_NET_DRIVER_ETH0 @@ -83,6 +83,16 @@ cdl_package CYGPKG_DEVS_ETH_ARM_EBSA285 connection." } + cdl_option CYGNUM_DEVS_ETH_ARM_EBSA285_DEV_COUNT { + display "Number of supported interfaces." + legal_values 1 2 + default_value 2 + flavor data + description " + This option selects the number of PCI ethernet interfaces to + be supported by the driver." + } + cdl_component CYGDBG_DEVS_ETH_ARM_EBSA285_KEEP_STATISTICS { display "Keep Ethernet statistics" default_value 1 diff --git a/packages/devs/eth/arm/ebsa285/current/src/if_ebsa285.c b/packages/devs/eth/arm/ebsa285/current/src/if_ebsa285.c --- a/packages/devs/eth/arm/ebsa285/current/src/if_ebsa285.c +++ b/packages/devs/eth/arm/ebsa285/current/src/if_ebsa285.c @@ -63,7 +63,14 @@ #include #include #include + +#ifdef CYGPKG_NET +#include #include /* Needed for struct ifnet */ +#else +#include +#define diag_printf printf +#endif #ifdef CYGPKG_IO_PCI #include @@ -81,8 +88,6 @@ #define DEBUG_EE // Some EEPROM specific retries &c #endif - - #define os_printf diag_printf #define db_printf diag_printf @@ -385,7 +390,8 @@ I82559_COUNTERS i82559_counters[2]; // ------------------------------------------------------------------------ // Instantiate the interfaces that we have: -#define MAX_82559 2 // number of interfaces +// number of interfaces +#define MAX_82559 CYGNUM_DEVS_ETH_ARM_EBSA285_DEV_COUNT I82559 i82559[MAX_82559]; // i82559 device info. structure @@ -407,7 +413,7 @@ NETDEVTAB_ENTRY(ebsa285_netdev0, ebsa285_i82559_init, &ebsa285_sc0); -#if 1 +#if (MAX_82559 > 1) // eth1 @@ -472,7 +478,9 @@ static void ResetTxRing(struct i82559* p #ifdef CYGPKG_DEVS_ETH_ARM_EBSA285_WRITE_EEPROM static void program_eeprom(cyg_uint32 , cyg_uint32 , cyg_uint8 * ); #endif +#ifdef CYGPKG_NET static int eth_set_promiscuous_mode(struct i82559* p_i82559); +#endif // debugging/logging only: void dump_txcb(TxCB *p_txcb); @@ -562,6 +570,7 @@ static void udelay(int delay) static void *pciwindow_mem_alloc(int size) { void *p_memory; + int _size = size; CYG_ASSERT( (CYGHWR_HAL_ARM_EBSA285_PCI_MEM_MAP_BASE <= (int)i82559_heap_free) @@ -582,7 +591,7 @@ static void *pciwindow_mem_alloc(int siz cyg_uint32 *p; p_memory = (void *)i82559_heap_free; i82559_heap_free += size; - for ( p = (cyg_uint32 *)p_memory; size > 0; size -= 4 ) + for ( p = (cyg_uint32 *)p_memory; _size > 0; _size -= 4 ) *p++ = 0; } @@ -910,9 +919,9 @@ ebsa285_i82559_init(struct cyg_netdevtab // Initialize upper level driver if ( p_i82559->mac_addr_ok ) - eth_drv_init(sc, &(p_i82559->mac_address[0]) ); + (sc->funs->eth_drv->init)(sc, &(p_i82559->mac_address[0]) ); else - eth_drv_init(sc, 0 ); + (sc->funs->eth_drv->init)(sc, 0 ); return (1); } @@ -930,7 +939,9 @@ static void i82559_start( struct eth_drv #ifdef KEEP_STATISTICS void *p_statistics; #endif +#ifdef CYGPKG_NET struct ifnet *ifp = &sc->sc_arpcom.ac_if; +#endif p_i82559 = (struct i82559 *)sc->driver_private; @@ -980,6 +991,7 @@ static void i82559_start( struct eth_drv p_i82559->active = 1; +#ifdef CYGPKG_NET if (( 0 #ifdef ETH_DRV_FLAGS_PROMISC_MODE != (flags & ETH_DRV_FLAGS_PROMISC_MODE) @@ -988,6 +1000,7 @@ static void i82559_start( struct eth_drv ) { eth_set_promiscuous_mode(p_i82559); } +#endif #ifdef DEBUG { int status = i82559_status( sc ); @@ -1153,9 +1166,14 @@ static void PacketRxReady(struct i82559* // dump_rfd( p_rfd, 1 ); #endif - // Offer the data to the network stack p_i82559->next_rx_descriptor = next_descriptor; - eth_drv_recv( sc, length ); + // Check for bogusly short packets; can happen in promisc mode: + // Asserted against and checked by upper layer driver. +#ifdef CYGPKG_NET + if ( length > sizeof( struct ether_header ) ) + // then it is acceptable; offer the data to the network stack +#endif + (sc->funs->eth_drv->recv)( sc, length ); p_rfd->count = 0; p_rfd->f = 0; @@ -1273,7 +1291,9 @@ static void i82559_recv( struct eth_drv_ to_p = (cyg_uint8 *)(sg_list->buf); l = sg_list->len; - if ( 0 == l || 0 == to_p ) + CYG_ASSERT( 0 <= l, "sg length -ve" ); + + if ( 0 >= l || 0 == to_p ) return; // caller was out of mbufs if ( l > total_len ) @@ -1438,7 +1458,7 @@ static void TxDone(struct i82559* p_i825 os_printf("TxDone %d %x: KEY %x\n", p_i82559->index, (int)p_i82559, key ); #endif - eth_drv_tx_done( sc, key, 1 /* status */ ); + (sc->funs->eth_drv->tx_done)( sc, key, 1 /* status */ ); if ( ++tx_descriptor_remove >= MAX_TX_DESCRIPTORS ) tx_descriptor_remove = 0; @@ -1753,7 +1773,7 @@ void i82559_poll(struct eth_drv_sc *sc) // As it happens, this driver always requests the DSR to be called: (void)eth_mux_isr( CYGNUM_HAL_INTERRUPT_PCI_IRQ, (cyg_addrword_t)p_i82559 ); - eth_dsr( CYGNUM_HAL_INTERRUPT_PCI_IRQ, 1, (cyg_addrword_t)p_i82559 ); + eth_mux_dsr( CYGNUM_HAL_INTERRUPT_PCI_IRQ, 1, (cyg_addrword_t)p_i82559 ); } // ------------------------------------------------------------------------ @@ -1915,7 +1935,7 @@ pci_init_find_82559s( void ) i82559_reset(p_i82559); if (p_i82559->vector != 0) { - cyg_interrupt_acknowledge(p_i82559->vector); + cyg_drv_interrupt_acknowledge(p_i82559->vector); cyg_drv_interrupt_unmask(p_i82559->vector); } #ifdef DEBUG @@ -1941,7 +1961,7 @@ pci_init_find_82559s( void ) // Now enable the mux shared interrupt if it is in use if (mux_interrupt_handle) { - cyg_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_PCI_IRQ); + cyg_drv_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_PCI_IRQ); cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_PCI_IRQ); } @@ -1953,6 +1973,7 @@ pci_init_find_82559s( void ) return 1; } +#ifdef CYGPKG_NET // ------------------------------------------------------------------------ // // Function : eth_set_promiscuous_mode @@ -2020,7 +2041,7 @@ static int eth_set_promiscuous_mode(stru // \ or 0x80 for normal mode. ccs->config_bytes[16]=0x0; ccs->config_bytes[17]=0x40; - ccs->config_bytes[18]=0x70; + ccs->config_bytes[18]=0x72; // Keep the Padding Enable bit // wait for SCB command complete wait_for_cmd_done(ioaddr); @@ -2045,6 +2066,7 @@ static int eth_set_promiscuous_mode(stru return 0; // OK } +#endif // ------------------------------------------------------------------------ // We use this as a templete when writing a new MAC address into the diff --git a/packages/devs/eth/arm/edb7xxx/current/ChangeLog b/packages/devs/eth/arm/edb7xxx/current/ChangeLog --- a/packages/devs/eth/arm/edb7xxx/current/ChangeLog +++ b/packages/devs/eth/arm/edb7xxx/current/ChangeLog @@ -1,3 +1,27 @@ +2000-08-21 Gary Thomas + + * cdl/edb7xxx_eth_drivers.cdl: Add configury to set ESA. + + * src/if_edb7xxx.c: Hardware address can come from various + sources, not just hardwired. + +2000-08-16 Gary Thomas + + * src/if_edb7xxx.c (cs8900_can_send): Can only send if the link + is OK. If the link is bad, the chip just stops... + +2000-08-14 Gary Thomas + + * src/if_edb7xxx.c: Changes to support stand-alone usage. + +2000-08-03 Gary Thomas + + * cdl/edb7xxx_eth_drivers.cdl: Ethernet driver package hierarchy changed. + +2000-07-26 Gary Thomas + + * src/if_edb7xxx.c: Update for new eth_drv interfaces. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/eth/arm/edb7xxx/current/cdl/edb7xxx_eth_drivers.cdl b/packages/devs/eth/arm/edb7xxx/current/cdl/edb7xxx_eth_drivers.cdl --- a/packages/devs/eth/arm/edb7xxx/current/cdl/edb7xxx_eth_drivers.cdl +++ b/packages/devs/eth/arm/edb7xxx/current/cdl/edb7xxx_eth_drivers.cdl @@ -44,8 +44,8 @@ cdl_package CYGPKG_DEVS_ETH_ARM_EDB7XXX { display "Cirrus Logic ethernet driver" - parent CYGPKG_NET_ETH_DRIVERS - active_if CYGPKG_NET_ETH_DRIVERS + parent CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_IO_ETH_DRIVERS active_if CYGPKG_HAL_ARM_EDB7XXX implements CYGHWR_NET_DRIVERS @@ -55,6 +55,23 @@ cdl_package CYGPKG_DEVS_ETH_ARM_EDB7XXX description "Ethernet driver for Cirrus Logic EDB7xxx boards." compile -library=libextras.a if_edb7xxx.c + cdl_component CYGSEM_ARM_EDB7XXX_SET_ESA { + display "Set the ethernet station address" + flavor bool + default_value 0 + description "Enabling this option will allow the ethernet + station address to be forced to the value set by the + configuration. This may be required if the hardware does + not include a serial EEPROM for the ESA." + + cdl_option CYGDAT_ARM_EDB7XXX_ESA { + display "The ethernet station address" + flavor data + default_value {"{0x08, 0x88, 0x12, 0x34, 0x56, 0x78}"} + description "The ethernet station address" + } + } + cdl_component CYGPKG_DEVS_ETH_ARM_EDB7XXX_OPTIONS { display "Cirrus Logic ethernet driver build options" flavor none diff --git a/packages/devs/eth/arm/edb7xxx/current/src/if_edb7xxx.c b/packages/devs/eth/arm/edb7xxx/current/src/if_edb7xxx.c --- a/packages/devs/eth/arm/edb7xxx/current/src/if_edb7xxx.c +++ b/packages/devs/eth/arm/edb7xxx/current/src/if_edb7xxx.c @@ -55,14 +55,34 @@ // Ethernet device driver for Cirrus Logic EDB7xxx // Based on CS8900A +#include +#include +#ifdef CYGPKG_NET #include +#endif #include #include +#include #include #include #include #include +#ifndef CYGSEM_ARM_EDB7XXX_SET_ESA +#ifdef CYGPKG_REDBOOT +#include +#ifdef CYGSEM_REDBOOT_FLASH_CONFIG +#include +#include +RedBoot_config_option("Network hardware address [MAC]", + edb7xxx_esa, + ALWAYS_ENABLED, true, + CONFIG_ESA + ); +#endif +#endif +#endif + #define INTS_DONT_WORK #undef INTS_DONT_WORK @@ -93,15 +113,19 @@ ETH_DRV_SC(edb7xxx_sc, cs8900_control, cs8900_can_send, cs8900_send, - cs8900_recv); + cs8900_recv, + cs8900_int); NETDEVTAB_ENTRY(edb7xxx_netdev, "edb7xxx", edb7xxx_cs8900_init, &edb7xxx_sc); -// FIXME -static unsigned char enaddr[] = { 0x08, 0x88, 0x12, 0x34, 0x56, 0x78}; +#ifdef CYGSEM_ARM_EDB7XXX_SET_ESA +static unsigned char enaddr[] = CYGDAT_ARM_EDB7XXX_ESA; +#else +static unsigned char enaddr[ETHER_ADDR_LEN]; +#endif static void cs8900_int(struct eth_drv_sc *sc); static cyg_interrupt cs8900_interrupt; @@ -132,8 +156,6 @@ edb7xxx_cs8900_init(struct cyg_netdevtab unsigned short chip_type, chip_rev, chip_status; int i; - diag_printf("cs8900 init\n"); - // Initialize environment, setup interrupt handler cyg_drv_interrupt_create(CYGNUM_HAL_INTERRUPT_EINT3, 99, // Priority - what goes here? @@ -162,23 +184,40 @@ edb7xxx_cs8900_init(struct cyg_netdevtab chip_type = get_reg(PP_ChipID); chip_rev = get_reg(PP_ChipRev); +#if 0 diag_printf("CS8900 - type: %x, rev: %x\n", chip_type, chip_rev); +#endif + + // Fetch hardware address +#if defined(CYGPKG_REDBOOT) && \ + defined(CYGSEM_REDBOOT_FLASH_CONFIG) && \ + !defined(CYGSEM_ARM_EDB7XXX_SET_ESA) + flash_get_config("edb7xxx_esa", enaddr, CONFIG_ESA); +#else + for (i = 0; i < ETHER_ADDR_LEN; i += 2) { + unsigned short esa_reg = get_reg(PP_IA+i); + enaddr[i] = esa_reg & 0xFF; + enaddr[i+1] = esa_reg >> 8; + } +#endif put_reg(PP_SelfCtl, PP_SelfCtl_Reset); // Reset chip while ((get_reg(PP_SelfStat) & PP_SelfStat_InitD) == 0) ; chip_status = get_reg(PP_SelfStat); +#if 0 diag_printf("CS8900 - status: %x (%sEEPROM present)\n", chip_status, chip_status&PP_SelfStat_EEPROM ? "" : "no "); +#endif - // Set up hardware address - FIXME + // Set up hardware address for (i = 0; i < ETHER_ADDR_LEN; i += 2) { put_reg(PP_LAF+i, 0xFFFF); put_reg(PP_IA+i, enaddr[i] | (enaddr[i+1] << 8)); } // Initialize upper level driver - eth_drv_init(sc, enaddr); + (sc->funs->eth_drv->init)(sc, enaddr); return true; } @@ -243,6 +282,11 @@ static int cs8900_can_send(struct eth_drv_sc *sc) { struct cs8900_priv_data *cpd = (struct cs8900_priv_data *)sc->driver_private; + unsigned short stat; + stat = get_reg(PP_LineStat); + if ((stat & PP_LineStat_LinkOK) == 0) { + return false; // Link not connected + } return (cpd->txbusy == 0); } @@ -318,7 +362,7 @@ cs8900_RxEvent(struct eth_drv_sc *sc) if (net_debug) { diag_printf("RxEvent - stat: %x, len: %d\n", stat, len); } - eth_drv_recv(sc, len); + (sc->funs->eth_drv->recv)(sc, len); } // @@ -348,7 +392,7 @@ cs8900_recv(struct eth_drv_sc *sc, struc if (mlen) { // Fetch last odd byte cval = CS8900_RTDATA & 0xFF; - if (cp = (unsigned char *)data) { + if ((cp = (unsigned char *)data) != 0) { *cp = cval; } } @@ -364,7 +408,7 @@ cs8900_TxEvent(struct eth_drv_sc *sc, in diag_printf("Tx event: %x\n", stat); } cpd->txbusy = 0; - eth_drv_tx_done(sc, cpd->txkey, 0); + (sc->funs->eth_drv->tx_done)(sc, cpd->txkey, 0); } static void diff --git a/packages/devs/eth/cf/current/ChangeLog b/packages/devs/eth/cf/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/devs/eth/cf/current/ChangeLog @@ -0,0 +1,58 @@ +2000-08-03 Gary Thomas + + * src/if_sc_lpe.c: Ensure DSR locked while initializing hardware. + + * cdl/cf_eth_drivers.cdl: Ethernet driver package hierarchy changed. + +2000-07-26 Gary Thomas + + * src/if_sc_lpe.c: Update for new eth_drv interfaces (via *sc). + +2000-07-18 Gary Thomas + + * src/if_sc_lpe.c (sc_lpe_RxEvent): Handle case where chip gets lost + and keeps returning the same input packet (hardware bug?). + +2000-07-16 Gary Thomas + + * src/if_sc_lpe.c (sc_lpe_card_handler): Add initialization message and + timeout when running stand-alone. + +2000-07-15 Gary Thomas + + * src/if_sc_lpe.c: CF interrupts are now handled by the slot handler, + not directly in this code. + +2000-07-14 Gary Thomas + + * cdl/cf_eth_drivers.cdl: + * src/if_sc_lpe.c: Support building in eCos and stand-alone modes. + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== + + + diff --git a/packages/devs/eth/cf/current/cdl/cf_eth_drivers.cdl b/packages/devs/eth/cf/current/cdl/cf_eth_drivers.cdl new file mode 100644 --- /dev/null +++ b/packages/devs/eth/cf/current/cdl/cf_eth_drivers.cdl @@ -0,0 +1,76 @@ +# ==================================================================== +# +# cf_eth_drivers.cdl +# +# Ethernet drivers - device support for PCMCIA (Compact Flash) +# Socket Communications: Low Power Compact Flash Ethernet board +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): gthomas +# Original data: gthomas +# Contributors: +# Date: 2000-07-07 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVS_ETH_CF { + display "PCMCIA (Compact Flash) ethernet drivers" + + parent CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_IO_PCMCIA + + implements CYGHWR_NET_DRIVERS + implements CYGHWR_NET_DRIVER_ETH0 + include_dir . + include_files ; # none _exported_ whatsoever + description "Ethernet driver for various PCMCIA (Compact Flash) boards." + compile -library=libextras.a if_sc_lpe.c + + cdl_component CYGPKG_DEVS_ETH_CF_OPTIONS { + display "Cirrus Logic ethernet driver build options" + flavor none + no_define + + cdl_option CYGPKG_DEVS_ETH_CF_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "-D_KERNEL -D__ECOS" } + description " + This option modifies the set of compiler flags for + building the Cirrus Logic ethernet driver package. + These flags are used in addition + to the set of global flags." + } + } +} + diff --git a/packages/devs/eth/cf/current/src/dp8390.h b/packages/devs/eth/cf/current/src/dp8390.h new file mode 100644 --- /dev/null +++ b/packages/devs/eth/cf/current/src/dp8390.h @@ -0,0 +1,260 @@ +//========================================================================== +// +// dev/dp8390.h +// +// National Semiconductor ethernet chip +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//####BSDCOPYRIGHTBEGIN#### +// +// ------------------------------------------- +// +// Portions of this software may have been derived from OpenBSD or other sources, +// and are covered by the appropriate copyright disclaimers included herein. +// +// ------------------------------------------- +// +//####BSDCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-07 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +typedef volatile union { + union { + struct { + unsigned char cr; + unsigned char clda0; + unsigned char clda1; + unsigned char bndry; + unsigned char tsr; + unsigned char ncr; + unsigned char fifo; + unsigned char isr; + unsigned char crda0; + unsigned char crda1; + unsigned char _reserved[2]; + unsigned char rsr; + unsigned char fer; + unsigned char cer; + unsigned char missed; + unsigned char data; + unsigned char _reserved2[14]; + unsigned char reset; + } page0; + struct { + unsigned char cr; + unsigned char par[6]; + unsigned char curp; + unsigned char mar[8]; + } page1; + struct { + unsigned char cr; + unsigned char pstart; + unsigned char pstop; + unsigned char rnpp; + unsigned char tpsr; + unsigned char lnpp; + unsigned char ach; + unsigned char acl; + unsigned char _reserved[4]; + unsigned char rcr; + unsigned char tcr; + unsigned char dcr; + unsigned char imr; + } page2; + unsigned char data; + } r; // Read registers + union { + struct { + unsigned char cr; + unsigned char pstart; + unsigned char pstop; + unsigned char bndry; + unsigned char tpsr; + unsigned char tbcl; + unsigned char tbch; + unsigned char isr; + unsigned char rsal; + unsigned char rsah; + unsigned char rbcl; + unsigned char rbch; + unsigned char rcr; + unsigned char tcr; + unsigned char dcr; + unsigned char imr; + unsigned char data; + unsigned char _reserved[14]; + unsigned char reset; + } page0; + struct { + unsigned char cr; + unsigned char par[6]; + unsigned char curp; + unsigned char mar[8]; + } page1; + struct { + unsigned char cr; + unsigned char clda0; + unsigned char clda1; + unsigned char rnpp; + unsigned char tpsr; + unsigned char lnpp; + unsigned char ach; + unsigned char acl; + unsigned char _reserved[8]; + } page2; + } w; // Write registers +} dp8390_regs; // __attribute__ ((aligned(1), packed)); + +// Command register - common to all pages + +#define DP8390_CR_STOP 0x01 // Stop: software reset +#define DP8390_CR_START 0x02 // Start: initialize device +#define DP8390_CR_TXPKT 0x04 // Transmit packet +#define DP8390_CR_RDMA 0x08 // Read DMA (recv data from device) +#define DP8390_CR_WDMA 0x10 // Write DMA (send data to device) +#define DP8390_CR_SEND 0x18 // Send packet +#define DP8390_CR_NODMA 0x20 // Remote (or no) DMA +#define DP8390_CR_PAGE0 0x00 // Page select +#define DP8390_CR_PAGE1 0x40 +#define DP8390_CR_PAGE2 0x80 +#define DP8390_CR_PAGEMSK 0x3F // Used to mask out page bits + +// Data configuration register + +#define DP8390_DCR_WTS 0x01 // 1=16 bit word transfers +#define DP8390_DCR_BOS 0x02 // 1=Little Endian +#define DP8390_DCR_LAS 0x04 // 1=Single 32 bit DMA mode +#define DP8390_DCR_LS 0x08 // 1=normal mode, 0=loopback +#define DP8390_DCR_ARM 0x10 // 0=no send command (program I/O) +#define DP8390_DCR_FIFO_1 0x00 // FIFO threshold +#define DP8390_DCR_FIFO_2 0x20 +#define DP8390_DCR_FIFO_4 0x40 +#define DP8390_DCR_FIFO_6 0x60 + +#define DP8390_DCR_INIT (DP8390_DCR_LS|DP8390_DCR_FIFO_4) + +// Interrupt status register + +#define DP8390_ISR_RxP 0x01 // Packet received +#define DP8390_ISR_TxP 0x02 // Packet transmitted +#define DP8390_ISR_RxE 0x04 // Receive error +#define DP8390_ISR_TxE 0x08 // Transmit error +#define DP8390_ISR_OFLW 0x10 // Receive overflow +#define DP8390_ISR_CNT 0x20 // Tally counters need emptying +#define DP8390_ISR_RDC 0x40 // Remote DMA complete +#define DP8390_ISR_RESET 0x80 // Device has reset (shutdown, error) + +// Interrupt mask register + +#define DP8390_IMR_RxP 0x01 // Packet received +#define DP8390_IMR_TxP 0x02 // Packet transmitted +#define DP8390_IMR_RxE 0x04 // Receive error +#define DP8390_IMR_TxE 0x08 // Transmit error +#define DP8390_IMR_OFLW 0x10 // Receive overflow +#define DP8390_IMR_CNT 0x20 // Tall counters need emptying +#define DP8390_IMR_RDC 0x40 // Remote DMA complete + +#define DP8390_IMR_All 0x3F // Everything but remote DMA + +// Receiver control register + +#define DP8390_RCR_SEP 0x01 // Save bad(error) packets +#define DP8390_RCR_AR 0x02 // Accept runt packets +#define DP8390_RCR_AB 0x04 // Accept broadcast packets +#define DP8390_RCR_AM 0x08 // Accept multicast packets +#define DP8390_RCR_PROM 0x10 // Promiscuous mode +#define DP8390_RCR_MON 0x20 // Monitor mode - 1=accept no packets + +// Receiver status register + +#define DP8390_RSR_RxP 0x01 // Packet received +#define DP8390_RSR_CRC 0x02 // CRC error +#define DP8390_RSR_FRAME 0x04 // Framing error +#define DP8390_RSR_FO 0x08 // FIFO overrun +#define DP8390_RSR_MISS 0x10 // Missed packet +#define DP8390_RSR_PHY 0x20 // 0=pad match, 1=mad match +#define DP8390_RSR_DIS 0x40 // Receiver disabled +#define DP8390_RSR_DFR 0x80 // Receiver processing deferred + +// Transmitter control register + +#define DP8390_TCR_NOCRC 0x01 // 1=inhibit CRC +#define DP8390_TCR_NORMAL 0x00 // Normal transmitter operation +#define DP8390_TCR_LOCAL 0x02 // Internal NIC loopback +#define DP8390_TCR_INLOOP 0x04 // Full internal loopback +#define DP8390_TCR_OUTLOOP 0x08 // External loopback +#define DP8390_TCR_ATD 0x10 // Auto transmit disable +#define DP8390_TCR_OFFSET 0x20 // Collision offset adjust + +// Transmit status register + +#define DP8390_TSR_TxP 0x01 // Packet transmitted +#define DP8390_TSR_COL 0x04 // Collision (at least one) +#define DP8390_TSR_ABT 0x08 // Aborted because of too many collisions +#define DP8390_TSR_CRS 0x10 // Lost carrier +#define DP8390_TSR_FU 0x20 // FIFO underrun +#define DP8390_TSR_CDH 0x40 // Collision Detect Heartbeat +#define DP8390_TSR_OWC 0x80 // Collision outside normal window + +// Page (buffer) allocation +#if 0 +#define DP8390_RX_START 1 +#define DP8390_RX_STOP 255-12 +#define DP8390_TX_BUF1 (DP8390_RX_STOP+1) +#define DP8390_TX_BUF2 (DP8390_TX_BUF1+6) +#define DP8390_TX_STOP 255 +#else +#if 0 +#define DP8390_RX_START 1 +#define DP8390_RX_STOP 127-12 +#define DP8390_TX_BUF1 (DP8390_RX_STOP+1) +#define DP8390_TX_BUF2 (DP8390_TX_BUF1+6) +#define DP8390_TX_STOP 127 +#else +#define DP8390_RX_START 0x60 +#define DP8390_RX_STOP 0x80 +#define DP8390_TX_BUF1 0x40 +#define DP8390_TX_BUF2 0x50 +#define DP8390_TX_STOP 127 +#endif +#endif + +#define IEEE_8023_MAX_FRAME 1518 // Largest possible ethernet frame +#define IEEE_8023_MIN_FRAME 64 // Smallest possible ethernet frame + +#define SC_LPE_MANUF 0x0104 + diff --git a/packages/devs/eth/cf/current/src/if_sc_lpe.c b/packages/devs/eth/cf/current/src/if_sc_lpe.c new file mode 100644 --- /dev/null +++ b/packages/devs/eth/cf/current/src/if_sc_lpe.c @@ -0,0 +1,587 @@ +//========================================================================== +// +// dev/if_sc_lpe.c +// +// Ethernet device driver for Socket Communications Compact Flash card +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//####BSDCOPYRIGHTBEGIN#### +// +// ------------------------------------------- +// +// Portions of this software may have been derived from OpenBSD or other sources, +// and are covered by the appropriate copyright disclaimers included herein. +// +// ------------------------------------------- +// +//####BSDCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-07 +// Purpose: +// Description: hardware driver for LPCF+ ethernet +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CYGPKG_NET +#include +#else +#include +#define diag_printf printf +#endif + +#include "dp8390.h" + +struct sc_lpe_priv_data { + struct cf_slot *slot; + dp8390_regs *regs; + int tx_next; // First free Tx page + int tx_int; // Expecting interrupt from this buffer + int rx_next; // First free Rx page + int tx1, tx2; // Page numbers for Tx buffers + unsigned long tx1_key, tx2_key; // Used to ack when packet sent + int tx1_len, tx2_len; + bool tx_started, running; + struct cyg_netdevtab_entry *tab; +} _sc_lpe_priv_data; + +ETH_DRV_SC(sc_lpe_sc, + &_sc_lpe_priv_data, // Driver specific data + "eth0", // Name for this interface + sc_lpe_start, + sc_lpe_stop, + sc_lpe_control, + sc_lpe_can_send, + sc_lpe_send, + sc_lpe_recv, + sc_lpe_int + ); + +NETDEVTAB_ENTRY(sc_lpe_netdev, + "sc_lpe", + sc_lpe_init, + &sc_lpe_sc); + +// Updated to actual address when card is inserted +static unsigned char enaddr[] = { 0x08, 0x88, 0x12, 0x34, 0x56, 0x78}; + +static void sc_lpe_int(struct eth_drv_sc *sc); + +#ifdef CYGPKG_NET +#define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL +static char sc_lpe_card_handler_stack[STACK_SIZE]; +static cyg_thread sc_lpe_card_handler_thread_data; +static cyg_handle_t sc_lpe_card_handler_thread_handle; +#endif // CYGPKG_NET + +static void +do_delay(int ticks) +{ +#ifdef CYGPKG_KERNEL + cyg_thread_delay(ticks); +#else + CYGACC_CALL_IF_DELAY_US(10000*ticks); +#endif +} + +// +// This runs as a separate thread to handle the card. In particular, insertions +// and deletions need to be handled and they take time/coordination, thus the +// separate thread. +// +#ifdef CYGPKG_NET +static void +#else +static int +#endif +sc_lpe_card_handler(cyg_addrword_t param) +{ + struct eth_drv_sc *sc = (struct eth_drv_sc *)param; + struct sc_lpe_priv_data *dp = (struct sc_lpe_priv_data *)sc->driver_private; + struct cf_slot *slot; + struct cf_cftable cftable; + struct cf_config config; + int i, len, ptr, cor = 0; + unsigned char buf[256], *cp; + dp8390_regs *regs; + unsigned char *vers_product, *vers_manuf, *vers_revision, *vers_date; +#ifndef CYGPKG_NET + int tries = 0; +#endif + + slot = dp->slot; + cyg_drv_dsr_lock(); + while (true) { + cyg_drv_dsr_unlock(); // Give DSRs a chance to run (card insertion) + cyg_drv_dsr_lock(); + if (slot->state == CF_SLOT_STATE_Inserted) { + cf_change_state(slot, CF_SLOT_STATE_Ready); + if (slot->state != CF_SLOT_STATE_Ready) { + diag_printf("CF card won't go ready!\n"); + continue; + } + len = sizeof(buf); + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_MANFID, buf, &len, &ptr)) { + if (*(short *)&buf[2] != SC_LPE_MANUF) { + diag_printf("Not a SC LPE, sorry\n"); + continue; + } + } + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_VERS_1, buf, &len, &ptr)) { + // Find individual strings + cp = &buf[4]; + vers_product = cp; + while (*cp++) ; // Skip to nul + vers_manuf = cp; + while (*cp++) ; // Skip to nul + vers_revision = cp; + while (*cp++) ; // Skip to nul + vers_date = cp; +#ifndef CYGPKG_NET + if (tries != 0) printf("\n"); + diag_printf("%s: %s %s %s\n", vers_manuf, vers_product, vers_revision, vers_date); +#endif + } + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_CONFIG, buf, &len, &ptr)) { + if (cf_parse_config(buf, len, &config)) { + cor = config.base; + } + } + if (!cor) { + diag_printf("Couldn't find COR pointer!\n"); + continue; + } + // Fetch hardware address from card - terrible, but not well defined + for (i = 0; i < ETHER_ADDR_LEN; i++) { + enaddr[i] = slot->attr[0x1C0+(i*2)]; + } + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_CFTABLE_ENTRY, buf, &len, &ptr)) { + if (cf_parse_cftable(buf, len, &cftable)) { + dp->regs = regs = (dp8390_regs *)&dp->slot->io[cftable.io_space.base[0]]; + cf_set_COR(slot, cor, cftable.cor); + // Reset card (read issues RESET, write clears it) + regs->w.page0.reset = regs->r.page0.reset; + while ((regs->r.page0.isr & DP8390_ISR_RESET) == 0) ; // Wait for card + // Initialize upper level driver + (sc->funs->eth_drv->init)(sc, enaddr); + // Tell system card is ready to talk + dp->tab->status = CYG_NETDEVTAB_STATUS_AVAIL; +#ifndef CYGPKG_NET + cyg_drv_dsr_unlock(); + return true; +#endif + } else { + diag_printf("Can't parse CIS\n"); + continue; + } + } else { + diag_printf("Can't fetch config info\n"); + continue; + } + } else if (slot->state == CF_SLOT_STATE_Removed) { + diag_printf("Compact Flash card removed!\n"); + } else { + cyg_drv_dsr_unlock(); + do_delay(50); // FIXME! +#ifndef CYGPKG_NET + if (tries == 0) printf("... Waiting for network card: "); + printf("."); + if (++tries == 10) { + // 5 seconds have elapsed - give up + return false; + } + cf_hwr_poll(slot); // Check to see if card has been inserted +#endif + cyg_drv_dsr_lock(); + } + } +} + +static bool +sc_lpe_init(struct cyg_netdevtab_entry *tab) +{ + struct eth_drv_sc *sc = (struct eth_drv_sc *)tab->device_instance; + struct sc_lpe_priv_data *dp = (struct sc_lpe_priv_data *)sc->driver_private; + + cf_init(); // Make sure Compact Flash subsystem is initialized + dp->slot = cf_get_slot(0); + dp->tab = tab; + +#ifdef CYGPKG_NET + // Create card handling [background] thread + cyg_thread_create(CYGPKG_NET_THREAD_PRIORITY-1, // Priority + sc_lpe_card_handler, // entry + (cyg_addrword_t)sc, // entry parameter + "SC LP-E card support", // Name + &sc_lpe_card_handler_stack[0], // Stack + STACK_SIZE, // Size + &sc_lpe_card_handler_thread_handle, // Handle + &sc_lpe_card_handler_thread_data // Thread data structure + ); + cyg_thread_resume(sc_lpe_card_handler_thread_handle); // Start it + + // Initialize environment, setup interrupt handler + cf_register_handler(dp->slot, sc_lpe_int, sc); + + return false; // Device is not ready until inserted, powered up, etc. +#else + // Initialize card + return sc_lpe_card_handler(sc); +#endif +} + +static void +sc_lpe_stop(struct eth_drv_sc *sc) +{ + struct sc_lpe_priv_data *dp = (struct sc_lpe_priv_data *)sc->driver_private; + dp8390_regs *regs = dp->regs; + + regs->w.page0.cr = DP8390_CR_PAGE0 | DP8390_CR_NODMA | DP8390_CR_STOP; // Brutal + regs->w.page0.isr = 0xFF; // Clear any pending interrupts + regs->w.page0.imr = 0x00; // Disable all interrupts + dp->running = false; +} + +// +// This function is called to "start up" the interface. It may be called +// multiple times, even when the hardware is already running. It will be +// called whenever something "hardware oriented" changes and should leave +// the hardware ready to send/receive packets. +// +static void +sc_lpe_start(struct eth_drv_sc *sc, unsigned char *enaddr, int flags) +{ + struct sc_lpe_priv_data *dp = (struct sc_lpe_priv_data *)sc->driver_private; + dp8390_regs *regs = dp->regs; + int i; + + regs->w.page0.cr = DP8390_CR_PAGE0 | DP8390_CR_NODMA | DP8390_CR_STOP; // Brutal + regs->w.page0.dcr = DP8390_DCR_INIT; + regs->w.page0.rbch = 0; // Remote byte count + regs->w.page0.rbcl = 0; + regs->w.page0.rcr = DP8390_RCR_MON; // Accept no packets + regs->w.page0.tcr = DP8390_TCR_LOCAL; // Transmitter [virtually] off + regs->w.page0.tpsr = DP8390_TX_BUF1; // Transmitter start page + dp->tx1 = dp->tx2 = 0; + dp->tx_next = DP8390_TX_BUF1; + dp->tx_started = false; + regs->w.page0.pstart = DP8390_RX_START; // Receive ring start page + regs->w.page0.bndry = DP8390_RX_STOP-1; // Receive ring boundary + regs->w.page0.pstop = DP8390_RX_STOP; // Receive ring end page + dp->rx_next = DP8390_RX_START-1; + regs->w.page0.isr = 0xFF; // Clear any pending interrupts + regs->w.page0.imr = DP8390_IMR_All; // Enable all interrupts + regs->w.page0.cr = DP8390_CR_NODMA | DP8390_CR_PAGE1; // Select page 1 + regs->w.page1.curp = DP8390_RX_START; // Current page - next free page for Rx + for (i = 0; i < ETHER_ADDR_LEN; i++) { + regs->w.page1.par[i] = enaddr[i]; + } + // Enable and start device + regs->w.page0.cr = DP8390_CR_NODMA | DP8390_CR_START; + regs->w.page0.tcr = DP8390_TCR_NORMAL; // Normal transmit operations + regs->w.page0.rcr = DP8390_RCR_AB; // Accept broadcast, no errors, no multicast + dp->running = true; +} + +// +// This routine is called to perform special "control" opertions +// +static int +sc_lpe_control(struct eth_drv_sc *sc, unsigned long key, + void *data, int data_len) +{ + switch (key) { + case ETH_DRV_SET_MAC_ADDRESS: + return 0; + break; + default: + return 1; + break; + } +} + +// +// This routine is called to see if it is possible to send another packet. +// It will return non-zero if a transmit is possible, zero otherwise. +// +static int +sc_lpe_can_send(struct eth_drv_sc *sc) +{ + struct sc_lpe_priv_data *dp = (struct sc_lpe_priv_data *)sc->driver_private; + return ((dp->tx1 == 0) || (dp->tx2 == 0)); +} + +// +// This routine is called to start the transmitter. It is split out from the +// data handling routine so it may be called either when data becomes first +// available or when an Tx interrupt occurs +// + +static void +sc_lpe_start_xmit(struct eth_drv_sc *sc, int start_page, int len) +{ + struct sc_lpe_priv_data *dp = (struct sc_lpe_priv_data *)sc->driver_private; + dp8390_regs *regs = dp->regs; + + regs->w.page0.cr = DP8390_CR_PAGE0 | DP8390_CR_NODMA | DP8390_CR_START; + regs->w.page0.tbcl = len & 0xFF; + regs->w.page0.tbch = len >> 8; + regs->w.page0.tpsr = start_page; + regs->w.page0.cr = DP8390_CR_NODMA | DP8390_CR_TXPKT | DP8390_CR_START; + dp->tx_started = true; +} + +// +// This routine is called to send data to the hardware. It is known a-priori +// that there is free buffer space (dp->tx_next). +// +static void +sc_lpe_send(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len, + int total_len, unsigned long key) +{ + struct sc_lpe_priv_data *dp = (struct sc_lpe_priv_data *)sc->driver_private; + dp8390_regs *regs = dp->regs; + int i, len, start_page, pkt_len; + unsigned char *data; + + pkt_len = total_len; + if (pkt_len < IEEE_8023_MIN_FRAME) pkt_len = IEEE_8023_MIN_FRAME; + start_page = dp->tx_next; + if (dp->tx_next == DP8390_TX_BUF1) { + dp->tx1 = start_page; + dp->tx1_len = pkt_len; + dp->tx1_key = key; + dp->tx_next = DP8390_TX_BUF2; + } else { + dp->tx2 = start_page; + dp->tx2_len = pkt_len; + dp->tx2_key = key; + dp->tx_next = DP8390_TX_BUF1; + } + // Send data to device buffer(s) + regs->w.page0.cr = DP8390_CR_PAGE0 | DP8390_CR_NODMA | DP8390_CR_START; + regs->w.page0.rbcl = pkt_len & 0xFF; + regs->w.page0.rbch = pkt_len >> 8; + regs->w.page0.rsal = 0; + regs->w.page0.rsah = start_page; + regs->w.page0.isr = DP8390_ISR_RDC; // Clear end of DMA + regs->w.page0.cr = DP8390_CR_WDMA | DP8390_CR_START; + // Put data into buffer + for (i = 0; i < sg_len; i++) { + data = (unsigned char *)sg_list[i].buf; + len = sg_list[i].len; + while (len-- > 0) { + regs->w.page0.data = *data++; + } + } + if (total_len < pkt_len) { + // Padding to 802.3 length was required + for (i = total_len; i < pkt_len; i++) { + regs->w.page0.data = 0; + } + } + // Wait for DMA to complete + while ((regs->r.page0.isr & DP8390_ISR_RDC) == 0) ; + // Start transmit if not already going + if (!dp->tx_started) { + if (start_page == dp->tx1) { + dp->tx_int = 1; // Expecting interrupt from BUF1 + } else { + dp->tx_int = 2; // Expecting interrupt from BUF2 + } + sc_lpe_start_xmit(sc, start_page, pkt_len); + } +} + +// +// This function is called when a packet has been received. It's job is +// to prepare to unload the packet from the hardware. Once the length of +// the packet is known, the upper layer of the driver can be told. When +// the upper layer is ready to unload the packet, the internal function +// 'sc_lpe_recv' will be called to actually fetch it from the hardware. +// +static void +sc_lpe_RxEvent(struct eth_drv_sc *sc, int stat) +{ + struct sc_lpe_priv_data *dp = (struct sc_lpe_priv_data *)sc->driver_private; + dp8390_regs *regs = dp->regs; + unsigned char rsr; + unsigned char rcv_hdr[4]; + int i, len, pkt, cur; + + rsr = regs->r.page0.rsr; + while (true) { + // Read incoming packet header + regs->w.page0.cr = DP8390_CR_PAGE1 | DP8390_CR_NODMA | DP8390_CR_START; + cur = regs->r.page1.curp; + regs->w.page0.cr = DP8390_CR_PAGE0 | DP8390_CR_NODMA | DP8390_CR_START; + pkt = regs->r.page0.bndry + 1; + if (pkt == cur) break; + if (pkt == DP8390_RX_STOP) pkt = DP8390_RX_START; + regs->w.page0.rbcl = sizeof(rcv_hdr); + regs->w.page0.rbch = 0; + regs->w.page0.rsal = 0; + regs->w.page0.rsah = pkt; + if (dp->rx_next == pkt) { +// printf("sc_lpe - receiver confused, stat: %x, , rsr: %x\n", stat, rsr); + regs->w.page0.bndry = cur-1; // Update pointer + return; + } + dp->rx_next = pkt; + regs->w.page0.isr = DP8390_ISR_RDC; // Clear end of DMA + regs->w.page0.cr = DP8390_CR_RDMA | DP8390_CR_START; + for (i = 0; i < sizeof(rcv_hdr); i++) { + rcv_hdr[i] = regs->r.page0.data; + } + len = ((rcv_hdr[3] << 8) | rcv_hdr[2]) - sizeof(rcv_hdr); + (sc->funs->eth_drv->recv)(sc, len); + regs->w.page0.bndry = rcv_hdr[1]-1; // Update pointer + } +} + +// +// This function is called as a result of the "eth_drv_recv()" call above. +// It's job is to actually fetch data for a packet from the hardware once +// memory buffers have been allocated for the packet. Note that the buffers +// may come in pieces, using a scatter-gather list. This allows for more +// efficient processing in the upper layers of the stack. +// +static void +sc_lpe_recv(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len) +{ + struct sc_lpe_priv_data *dp = (struct sc_lpe_priv_data *)sc->driver_private; + dp8390_regs *regs = dp->regs; + int i, mlen, len; + unsigned char *data; + + // Compute total packet length + len = 0; + for (i = 0; i < sg_len; i++) { + len += sg_list[i].len; + } + // Read incoming packet data + regs->w.page0.cr = DP8390_CR_PAGE0 | DP8390_CR_NODMA | DP8390_CR_START; + regs->w.page0.rbcl = len & 0xFF; + regs->w.page0.rbch = len >> 8; + regs->w.page0.rsal = 4; // Past header + regs->w.page0.rsah = dp->rx_next; + regs->w.page0.isr = DP8390_ISR_RDC; // Clear end of DMA + regs->w.page0.cr = DP8390_CR_RDMA | DP8390_CR_START; + for (i = 0; i < sg_len; i++) { + data = (unsigned char *)sg_list[i].buf; + mlen = sg_list[i].len; + while (mlen >= sizeof(*data)) { + *data++ = regs->r.page0.data; + mlen -= sizeof(*data); + } + } +} + +static void +sc_lpe_TxEvent(struct eth_drv_sc *sc, int stat) +{ + struct sc_lpe_priv_data *dp = (struct sc_lpe_priv_data *)sc->driver_private; + dp8390_regs *regs = dp->regs; + unsigned char tsr; + unsigned long key; + + tsr = regs->r.page0.tsr; + if (dp->tx_int == 1) { + key = dp->tx1_key; + dp->tx1 = 0; + } else { + key = dp->tx2_key; + dp->tx2 = 0; + } + // Start next packet if one is ready + dp->tx_started = false; + if (dp->tx1) { + sc_lpe_start_xmit(sc, dp->tx1, dp->tx1_len); + dp->tx_int = 1; + } else if (dp->tx2) { + sc_lpe_start_xmit(sc, dp->tx2, dp->tx2_len); + dp->tx_int = 2; + } else { + dp->tx_int = 0; + } + // Tell higher level we sent this packet + (sc->funs->eth_drv->tx_done)(sc, key, 0); +} + +static void +sc_lpe_BufEvent(struct eth_drv_sc *sc, int stat) +{ + diag_printf("%s\n", __FUNCTION__); +#if 0 + if (stat & PP_BufCFG_RxMiss) { + } + if (stat & PP_BufCFG_TxUE) { + } +#endif +} + +static void +sc_lpe_int(struct eth_drv_sc *sc) +{ + struct sc_lpe_priv_data *dp = (struct sc_lpe_priv_data *)sc->driver_private; + dp8390_regs *regs = dp->regs; + unsigned char isr; + + regs->w.page0.cr = DP8390_CR_NODMA | DP8390_CR_PAGE0 | DP8390_CR_START; + while ((isr = regs->r.page0.isr) != 0) { + regs->w.page0.isr = isr; // Clear set bits + if (!dp->running) return; // Is this necessary? + if (isr & (DP8390_ISR_TxP|DP8390_ISR_TxE)) { + sc_lpe_TxEvent(sc, isr); + } + if (isr & (DP8390_ISR_RxP|DP8390_ISR_RxE)) { + sc_lpe_RxEvent(sc, isr); + } + if (isr & (DP8390_ISR_OFLW|DP8390_ISR_CNT)) { + sc_lpe_BufEvent(sc, isr); + } + } +} + diff --git a/packages/devs/eth/powerpc/quicc/current/ChangeLog b/packages/devs/eth/powerpc/quicc/current/ChangeLog --- a/packages/devs/eth/powerpc/quicc/current/ChangeLog +++ b/packages/devs/eth/powerpc/quicc/current/ChangeLog @@ -1,3 +1,11 @@ +2000-08-03 Gary Thomas + + * cdl/quicc_eth_drivers.cdl: Ethernet driver package hierarchy changed. + +2000-07-26 Gary Thomas + + * src/if_quicc.c: Update for new eth_drv interfaces. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/eth/powerpc/quicc/current/cdl/quicc_eth_drivers.cdl b/packages/devs/eth/powerpc/quicc/current/cdl/quicc_eth_drivers.cdl --- a/packages/devs/eth/powerpc/quicc/current/cdl/quicc_eth_drivers.cdl +++ b/packages/devs/eth/powerpc/quicc/current/cdl/quicc_eth_drivers.cdl @@ -43,8 +43,8 @@ cdl_package CYGPKG_DEVS_ETH_POWERPC_QUICC { display "MPC8xx QUICC ethernet driver" - parent CYGPKG_NET_ETH_DRIVERS - active_if CYGPKG_NET_ETH_DRIVERS + parent CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_IO_ETH_DRIVERS active_if CYGPKG_HAL_POWERPC active_if CYGPKG_HAL_POWERPC_MPC8xx diff --git a/packages/devs/eth/powerpc/quicc/current/src/if_quicc.c b/packages/devs/eth/powerpc/quicc/current/src/if_quicc.c --- a/packages/devs/eth/powerpc/quicc/current/src/if_quicc.c +++ b/packages/devs/eth/powerpc/quicc/current/src/if_quicc.c @@ -84,7 +84,8 @@ ETH_DRV_SC(quicc_eth0_sc, quicc_eth_control, quicc_eth_can_send, quicc_eth_send, - quicc_eth_recv); + quicc_eth_recv, + quicc_eth_int); NETDEVTAB_ENTRY(quicc_netdev, "quicc_eth", @@ -310,7 +311,7 @@ quicc_eth_init(struct cyg_netdevtab_entr HAL_DCACHE_ENABLE(); // Initialize upper level driver - eth_drv_init(sc, (unsigned char *)&enaddr); + (sc->funs->eth_drv->init)(sc, (unsigned char *)&enaddr); return true; } @@ -435,7 +436,7 @@ quicc_eth_RxEvent(struct eth_drv_sc *sc) rxbd = qi->rnext; while ((rxbd->ctrl & (QUICC_BD_CTL_Ready | QUICC_BD_CTL_Int)) == QUICC_BD_CTL_Int) { qi->rxbd = rxbd; // Save for callback - eth_drv_recv(sc, rxbd->length); + (sc->funs->eth_drv->recv)(sc, rxbd->length); rxbd->ctrl |= QUICC_BD_CTL_Ready; if (rxbd->ctrl & QUICC_BD_CTL_Wrap) { rxbd = qi->rbase; @@ -484,7 +485,7 @@ quicc_eth_TxEvent(struct eth_drv_sc *sc, while ((txbd->ctrl & (QUICC_BD_CTL_Ready | QUICC_BD_CTL_Int)) == QUICC_BD_CTL_Int) { txindex = ((unsigned long)txbd - (unsigned long)qi->tbase) / sizeof(*txbd); txbd->ctrl &= ~QUICC_BD_CTL_Int; // Reset int pending bit - eth_drv_tx_done(sc, qi->txkey[txindex], 0); + (sc->funs->eth_drv->tx_done)(sc, qi->txkey[txindex], 0); if (txbd->ctrl & QUICC_BD_CTL_Wrap) { txbd = qi->tbase; } else { diff --git a/packages/devs/flash/arm/ebsa285/current/ChangeLog b/packages/devs/flash/arm/ebsa285/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/ebsa285/current/ChangeLog @@ -0,0 +1,34 @@ +2000-08-15 Gary Thomas + + * src/ebsa285_flash.c (flash_code_overlaps): + stext,etext now are _stext,_etext + +2000-08-14 Gary Thomas + + * src/ebsa285_flash.c: New file(s). + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/devs/flash/arm/ebsa285/current/cdl/flash_ebsa285.cdl b/packages/devs/flash/arm/ebsa285/current/cdl/flash_ebsa285.cdl new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/ebsa285/current/cdl/flash_ebsa285.cdl @@ -0,0 +1,82 @@ +# ==================================================================== +# +# flash_ebsa285.cdl +# +# FLASH memory - Hardware support on StrongARM EBSA-285 +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): gthomas +# Original data: gthomas +# Contributors: +# Date: 2000-07-26 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVS_FLASH_EBSA285 { + display "StrongARM EBSA-285 FLASH memory support" + + parent CYGPKG_IO_FLASH + active_if CYGPKG_IO_FLASH + requires CYGPKG_HAL_ARM_EBSA285 + + implements CYGHWR_IO_FLASH_DEVICE + + include_dir . + include_files ; # none _exported_ whatsoever + description "FLASH memory device support for StrongARM EBSA-285" + compile ebsa285_flash.c + + make -priority 1 { + flash_erase_block.o: $(REPOSITORY)/$(PACKAGE)/src/flash_erase_block.c + $(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_erase_block.c + echo " .globl flash_erase_block_end" >>flash_erase_block.s + echo "flash_erase_block_end:" >>flash_erase_block.s + $(CC) -c -o flash_erase_block.o flash_erase_block.s + $(AR) rcs $(PREFIX)/lib/libtarget.a flash_erase_block.o + } + make -priority 1 { + flash_program_buf.o: $(REPOSITORY)/$(PACKAGE)/src/flash_program_buf.c + $(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_program_buf.c + echo " .globl flash_program_buf_end" >>flash_program_buf.s + echo "flash_program_buf_end:" >>flash_program_buf.s + $(CC) -c -o flash_program_buf.o flash_program_buf.s + $(AR) rcs $(PREFIX)/lib/libtarget.a flash_program_buf.o + } + make -priority 1 { + flash_query.o: $(REPOSITORY)/$(PACKAGE)/src/flash_query.c + $(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_query.c + echo " .globl flash_query_end" >>flash_query.s + echo "flash_query_end:" >>flash_query.s + $(CC) -c -o flash_query.o flash_query.s + $(AR) rcs $(PREFIX)/lib/libtarget.a flash_query.o + } +} + diff --git a/packages/devs/flash/arm/ebsa285/current/src/ebsa285_flash.c b/packages/devs/flash/arm/ebsa285/current/src/ebsa285_flash.c new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/ebsa285/current/src/ebsa285_flash.c @@ -0,0 +1,105 @@ +//========================================================================== +// +// ebsa285_flash.c +// +// Flash programming +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-26 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#define _FLASH_PRIVATE_ +#include + +#include "flash.h" + +int +flash_hwr_init(void) +{ + unsigned char data[96]; + extern char flash_query, flash_query_end; + typedef int code_fun(unsigned char *); + code_fun *_flash_query; + int code_len, stat, num_regions, region_size; + + // Copy 'program' code to RAM for execution + code_len = (unsigned long)&flash_query_end - (unsigned long)&flash_query; + _flash_query = (code_fun *)flash_info.work_space; + memcpy(_flash_query, &flash_query, code_len); + HAL_DCACHE_SYNC(); // Should guarantee this code will run + + stat = (*_flash_query)(data); + if ((data[0] == FLASH_Intel_code) && (data[4] == FLASH_28F008SA)) { + num_regions = 16; + region_size = 0x40000; + flash_info.block_size = region_size; + flash_info.blocks = num_regions; + flash_info.start = (void *)0x41000000; + flash_info.end = (void *)(0x41000000+(num_regions*region_size)); + return FLASH_ERR_OK; + } else { + printf("Can't identify FLASH, sorry\n"); + diag_dump_buf(data, sizeof(data)); + return FLASH_ERR_HWR; + } +} + +// Map a hardware status to a package error +int +flash_hwr_map_error(int err) +{ + if (err & 0x7E) { + return FLASH_ERR_ERASE; // FIXME + } else { + return FLASH_ERR_OK; + } +} + +// See if a range of FLASH addresses overlaps currently running code +bool +flash_code_overlaps(void *start, void *end) +{ + extern char _stext, _etext; + + return ((((unsigned long)&_stext >= (unsigned long)start) && + ((unsigned long)&_stext < (unsigned long)end)) || + (((unsigned long)&_etext >= (unsigned long)start) && + ((unsigned long)&_etext < (unsigned long)end))); +} diff --git a/packages/devs/flash/arm/ebsa285/current/src/flash.h b/packages/devs/flash/arm/ebsa285/current/src/flash.h new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/ebsa285/current/src/flash.h @@ -0,0 +1,65 @@ +//========================================================================== +// +// flash.h +// +// Flash programming - device constants, etc. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-26 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#ifndef _FLASH_HWR_H_ +#define _FLASH_HWR_H_ + +// EBSA-285 FLASH layout +// 4x 28F008SA, one device per byte-lane +// each device is 16x64k blocks + +#define FLASH_Read_ID 0x90909090 +#define FLASH_Read_Status 0x70707070 +#define FLASH_Clear_Status 0x50505050 +#define FLASH_Status_Ready 0x80808080 +#define FLASH_Program 0x10101010 +#define FLASH_Block_Erase 0x20202020 +#define FLASH_Confirm 0xD0D0D0D0 +#define FLASH_Reset 0xFFFFFFFF + +#define FLASH_BLOCK_SIZE 0x40000 + +#define FLASH_Intel_code 0x89 +#define FLASH_28F008SA 0xA2 + +#endif // _FLASH_HWR_H_ diff --git a/packages/devs/flash/arm/ebsa285/current/src/flash_erase_block.c b/packages/devs/flash/arm/ebsa285/current/src/flash_erase_block.c new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/ebsa285/current/src/flash_erase_block.c @@ -0,0 +1,86 @@ +//========================================================================== +// +// flash_erase_block.c +// +// Flash programming +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-14 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include "flash.h" + +#include +#include +#include + +// +// CAUTION! This code must be copied to RAM before execution. Therefore, +// it must not contain any code which might be position dependent! +// + +int +flash_erase_block(volatile unsigned long *block) +{ + unsigned long stat; + int timeout = 5000000; + int cache_on; + + HAL_DCACHE_IS_ENABLED(cache_on); + if (cache_on) { + HAL_DCACHE_SYNC(); + HAL_DCACHE_DISABLE(); + } + + // Clear any error conditions + *block = FLASH_Clear_Status; + + // Set to erase + *block = FLASH_Block_Erase; + *block = FLASH_Confirm; + while(((stat = *block) & FLASH_Status_Ready) != FLASH_Status_Ready) { + if (--timeout == 0) break; + } + + // Restore ROM to "normal" mode + *block = FLASH_Reset; + + if (cache_on) { + HAL_DCACHE_ENABLE(); + } + + return stat; +} diff --git a/packages/devs/flash/arm/ebsa285/current/src/flash_program_buf.c b/packages/devs/flash/arm/ebsa285/current/src/flash_program_buf.c new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/ebsa285/current/src/flash_program_buf.c @@ -0,0 +1,94 @@ +//========================================================================== +// +// flash_program_buf.c +// +// Flash programming +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-14 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include "flash.h" + +#include +#include +#include + +// +// CAUTION! This code must be copied to RAM before execution. Therefore, +// it must not contain any code which might be position dependent! +// + +int +flash_program_buf(volatile unsigned long *addr, unsigned long *data, int len) +{ + unsigned long stat; + int timeout = 5000000; + int cache_on; + volatile unsigned long *orig_addr = addr; + + HAL_DCACHE_IS_ENABLED(cache_on); + if (cache_on) { + HAL_DCACHE_SYNC(); + HAL_DCACHE_DISABLE(); + } + + // Clear any error conditions + *addr = FLASH_Clear_Status; + + while (len > 0) { + *addr = FLASH_Program; + *addr = *data++; + timeout = 5000000; + while(((stat = *addr) & FLASH_Status_Ready) != FLASH_Status_Ready) { + if (--timeout == 0) { + goto bad; + } + } + addr++; + len -= sizeof(unsigned long); + } + + // Restore ROM to "normal" mode + bad: + *orig_addr = FLASH_Reset; + + if (cache_on) { + HAL_DCACHE_ENABLE(); + } + + return stat; +} diff --git a/packages/devs/flash/arm/ebsa285/current/src/flash_query.c b/packages/devs/flash/arm/ebsa285/current/src/flash_query.c new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/ebsa285/current/src/flash_query.c @@ -0,0 +1,86 @@ +//========================================================================== +// +// flash_query.c +// +// Flash programming - query device +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-26 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include "flash.h" + +#include +#include +#include + +// +// CAUTION! This code must be copied to RAM before execution. Therefore, +// it must not contain any code which might be position dependent! +// + +#define CNT 20*1000*10 // Approx 200ms + +int +flash_query(unsigned char *data) +{ + volatile unsigned long *lROM; + volatile unsigned char *cROM; + int i, cnt; + int cache_on; + + HAL_DCACHE_IS_ENABLED(cache_on); + if (cache_on) { + HAL_DCACHE_SYNC(); + HAL_DCACHE_DISABLE(); + } + + lROM = 0x41000000; + cROM = 0x41000000; + + lROM[0] = FLASH_Read_ID; + for (cnt = CNT; cnt > 0; cnt--) ; + for (i = 0; i < 8; i++) { + *data++ = cROM[i]; + } + lROM[0] = FLASH_Reset; + + if (cache_on) { + HAL_DCACHE_ENABLE(); + } + + return 0; +} diff --git a/packages/devs/flash/arm/edb7xxx/current/ChangeLog b/packages/devs/flash/arm/edb7xxx/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/edb7xxx/current/ChangeLog @@ -0,0 +1,30 @@ +2000-08-15 Gary Thomas + + * src/edb7xxx_flash.c (flash_code_overlaps): + stext,etext now are _stext,_etext + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/devs/flash/arm/edb7xxx/current/cdl/flash_edb7xxx.cdl b/packages/devs/flash/arm/edb7xxx/current/cdl/flash_edb7xxx.cdl new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/edb7xxx/current/cdl/flash_edb7xxx.cdl @@ -0,0 +1,82 @@ +# ==================================================================== +# +# flash_edb7xxx.cdl +# +# FLASH memory - Hardware support on Cirrus Logic EDB7xxx +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): gthomas +# Original data: gthomas +# Contributors: +# Date: 2000-07-26 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVS_FLASH_EDB7XXX { + display "Cirrus Logic EDB7xxx FLASH memory support" + + parent CYGPKG_IO_FLASH + active_if CYGPKG_IO_FLASH + requires CYGPKG_HAL_ARM_EDB7XXX + + implements CYGHWR_IO_FLASH_DEVICE + + include_dir . + include_files ; # none _exported_ whatsoever + description "FLASH memory device support for Cirrus Logic EDB7xxx boards" + compile edb7xxx_flash.c + + make -priority 1 { + flash_erase_block.o: $(REPOSITORY)/$(PACKAGE)/src/flash_erase_block.c + $(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -mcpu=strongarm -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_erase_block.c + echo " .globl flash_erase_block_end" >>flash_erase_block.s + echo "flash_erase_block_end:" >>flash_erase_block.s + $(CC) -c -o flash_erase_block.o flash_erase_block.s + $(AR) rcs $(PREFIX)/lib/libtarget.a flash_erase_block.o + } + make -priority 1 { + flash_program_buf.o: $(REPOSITORY)/$(PACKAGE)/src/flash_program_buf.c + $(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -mcpu=strongarm -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_program_buf.c + echo " .globl flash_program_buf_end" >>flash_program_buf.s + echo "flash_program_buf_end:" >>flash_program_buf.s + $(CC) -c -o flash_program_buf.o flash_program_buf.s + $(AR) rcs $(PREFIX)/lib/libtarget.a flash_program_buf.o + } + make -priority 1 { + flash_query.o: $(REPOSITORY)/$(PACKAGE)/src/flash_query.c + $(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -mcpu=strongarm -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_query.c + echo " .globl flash_query_end" >>flash_query.s + echo "flash_query_end:" >>flash_query.s + $(CC) -c -o flash_query.o flash_query.s + $(AR) rcs $(PREFIX)/lib/libtarget.a flash_query.o + } +} + diff --git a/packages/devs/flash/arm/edb7xxx/current/src/edb7xxx_flash.c b/packages/devs/flash/arm/edb7xxx/current/src/edb7xxx_flash.c new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/edb7xxx/current/src/edb7xxx_flash.c @@ -0,0 +1,140 @@ +//========================================================================== +// +// edb7xxx_flash.c +// +// Flash programming +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-26 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#define _FLASH_PRIVATE_ +#include + +#include "flash.h" + +#define _si(p) ((p[0]<<8)|p[1]) + +int +flash_hwr_init(void) +{ + unsigned short data[4]; + extern char flash_query, flash_query_end; + typedef int code_fun(unsigned char *); + code_fun *_flash_query; + int code_len, stat, num_regions, region_size; + + // Copy 'program' code to RAM for execution + code_len = (unsigned long)&flash_query_end - (unsigned long)&flash_query; + _flash_query = (code_fun *)flash_info.work_space; + memcpy(_flash_query, &flash_query, code_len); + HAL_DCACHE_SYNC(); // Should guarantee this code will run + +#if 0 + { + volatile int cache_test; + volatile int *cp = 0xE0000000; + // See if the data cache is working + *cp = 0x12345678; + printf("cache test = %x\n", *cp); + HAL_DCACHE_DISABLE(); + *cp = 0xDEADDEAD; + printf("cache test = %x\n", *cp); + HAL_DCACHE_ENABLE(); + printf("cache test = %x\n", *cp); + } +#endif + + stat = (*_flash_query)(data); +#if 0 + printf("stat = %x\n", stat); + dump_buf(data, sizeof(data)); +#endif + + if (data[0] != FLASH_Intel_code) { + printf("Not Intel = %x\n", data[0]); + return FLASH_ERR_HWR; + } + + if (data[1] == (unsigned short)0x8897) { + num_regions = 64*2; + region_size = 0x20000; + } else { + printf("Unknown device type: %x\n", data[1]); + return FLASH_ERR_HWR; + } + + // Hard wired for now + flash_info.block_size = region_size; + flash_info.blocks = num_regions; + flash_info.start = (void *)0xE0000000; + flash_info.end = (void *)(0xE0000000+(num_regions*region_size)); + return FLASH_ERR_OK; +} + +// Map a hardware status to a package error +int +flash_hwr_map_error(int err) +{ + if (err & 0x007E007E) { + printf("Err = %x\n", err); + if (err & 0x00100010) { + return FLASH_ERR_PROGRAM; + } else + if (err & 0x00200020) { + return FLASH_ERR_ERASE; + } else + return FLASH_ERR_ERASE; // FIXME + } else { + return FLASH_ERR_OK; + } +} + +// See if a range of FLASH addresses overlaps currently running code +bool +flash_code_overlaps(void *start, void *end) +{ + extern char _stext, _etext; + + return ((((unsigned long)&_stext >= (unsigned long)start) && + ((unsigned long)&_stext < (unsigned long)end)) || + (((unsigned long)&_etext >= (unsigned long)start) && + ((unsigned long)&_etext < (unsigned long)end))); +} diff --git a/packages/devs/flash/arm/edb7xxx/current/src/flash.h b/packages/devs/flash/arm/edb7xxx/current/src/flash.h new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/edb7xxx/current/src/flash.h @@ -0,0 +1,61 @@ +//========================================================================== +// +// flash.h +// +// Flash programming - device constants, etc. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-26 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#ifndef _FLASH_HWR_H_ +#define _FLASH_HWR_H_ + +#define FLASH_Read_ID 0x90909090 +#define FLASH_Read_Status 0x00700070 +#define FLASH_Clear_Status 0x50505050 +#define FLASH_Status_Ready 0x00800080 // Only low 8 bits +#define FLASH_Program 0x40404040 +#define FLASH_Block_Erase 0x20202020 +#define FLASH_Confirm 0xD0D0D0D0 +#define FLASH_Reset 0xFFFFFFFF + +#define FLASH_BLOCK_SIZE 0x20000 +#define FLASH_BOOT_BLOCK_SIZE 0x4000 + +#define FLASH_Intel_code 0x89 + +#endif // _FLASH_HWR_H_ diff --git a/packages/devs/flash/arm/edb7xxx/current/src/flash_erase_block.c b/packages/devs/flash/arm/edb7xxx/current/src/flash_erase_block.c new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/edb7xxx/current/src/flash_erase_block.c @@ -0,0 +1,113 @@ +//========================================================================== +// +// flash_erase_block.c +// +// Flash programming +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-14 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include "flash.h" + +#include +#include +#include + +// +// CAUTION! This code must be copied to RAM before execution. Therefore, +// it must not contain any code which might be position dependent! +// + +int flash_erase_block(volatile unsigned long *block) +{ + volatile unsigned long *ROM, *sb; + unsigned long stat; + int timeout = 50000; + int cache_on; + int len, block_size; + + HAL_DCACHE_IS_ENABLED(cache_on); + if (cache_on) { + HAL_DCACHE_SYNC(); + HAL_DCACHE_DISABLE(); + } + + ROM = (volatile unsigned long *)((unsigned long)block & 0xFF800000); + + // Clear any error conditions + ROM[0] = FLASH_Clear_Status; + + len = FLASH_BLOCK_SIZE; + if (((unsigned long)block - (unsigned long)ROM) < FLASH_BLOCK_SIZE) { + block_size = FLASH_BOOT_BLOCK_SIZE; // First 8 blocks are only 8Kx2 each + } else { + block_size = FLASH_BLOCK_SIZE; + } + sb = block; + while (len > 0) { + // Erase block + ROM[0] = FLASH_Block_Erase; + *block = FLASH_Confirm; + timeout = 5000000; + while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) { + if (--timeout == 0) break; + } + + len -= block_size; + block += block_size / sizeof(*block); + } + + // Restore ROM to "normal" mode + ROM[0] = FLASH_Reset; + + // If an error was reported, see if the block erased anyway + if (stat & 0x007E007E) { + len = FLASH_BLOCK_SIZE; + block = sb; + while (len > 0) { + if (*block++ != 0xFFFFFFFF) break; + len -= sizeof(*block); + } + if (len == 0) stat = 0; + } + + if (cache_on) { + HAL_DCACHE_ENABLE(); + } + + return stat; +} diff --git a/packages/devs/flash/arm/edb7xxx/current/src/flash_program_buf.c b/packages/devs/flash/arm/edb7xxx/current/src/flash_program_buf.c new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/edb7xxx/current/src/flash_program_buf.c @@ -0,0 +1,103 @@ +//========================================================================== +// +// flash_program_buf.c +// +// Flash programming +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-14 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include "flash.h" + +#include +#include +#include + +// +// CAUTION! This code must be copied to RAM before execution. Therefore, +// it must not contain any code which might be position dependent! +// + +int +flash_program_buf(volatile unsigned long *addr, unsigned long *data, int len) +{ + volatile unsigned long *ROM; + unsigned long stat = 0; + int timeout = 50000; + int cache_on; + + HAL_DCACHE_IS_ENABLED(cache_on); + if (cache_on) { + HAL_DCACHE_SYNC(); + HAL_DCACHE_DISABLE(); + } + + ROM = (volatile unsigned long *)((unsigned long)addr & 0xFF800000); + + // Clear any error conditions + ROM[0] = FLASH_Clear_Status; + + while (len > 0) { + ROM[0] = FLASH_Program; + *addr = *data; + timeout = 5000000; + while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) { + if (--timeout == 0) { + goto bad; + } + } + if (stat & 0x007E007E) { + break; + } + ROM[0] = FLASH_Reset; + if (*addr++ != *data++) { + stat = 0x99109910; + break; + } + len -= 4; + } + + // Restore ROM to "normal" mode + bad: + ROM[0] = FLASH_Reset; + + if (cache_on) { + HAL_DCACHE_ENABLE(); + } + + return stat; +} diff --git a/packages/devs/flash/arm/edb7xxx/current/src/flash_query.c b/packages/devs/flash/arm/edb7xxx/current/src/flash_query.c new file mode 100644 --- /dev/null +++ b/packages/devs/flash/arm/edb7xxx/current/src/flash_query.c @@ -0,0 +1,85 @@ +//========================================================================== +// +// flash_query.c +// +// Flash programming - query device +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-26 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include "flash.h" + +#include +#include +#include +#include CYGHWR_MEMORY_LAYOUT_H + +// +// CAUTION! This code must be copied to RAM before execution. Therefore, +// it must not contain any code which might be position dependent! +// + +#define CNT 200*1000*10 // Approx 20ms + +int +flash_query(unsigned short *data) +{ + volatile unsigned long *ROM; + int cnt; + int cache_on; + + HAL_DCACHE_IS_ENABLED(cache_on); + if (cache_on) { + HAL_DCACHE_SYNC(); + HAL_DCACHE_DISABLE(); + } + + ROM = (volatile unsigned long *)0xE0000000; + + ROM[0] = FLASH_Read_ID; + for (cnt = CNT; cnt > 0; cnt--) ; + *data++ = *ROM++; // Manufacturer code + *data++ = *ROM++; // Device identifier + + ROM[0] = FLASH_Reset; + + if (cache_on) { + HAL_DCACHE_ENABLE(); + } + + return 0; +} diff --git a/packages/devs/pcmcia/arm/assabet/current/ChangeLog b/packages/devs/pcmcia/arm/assabet/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/devs/pcmcia/arm/assabet/current/ChangeLog @@ -0,0 +1,38 @@ +2000-07-16 Gary Thomas + + * src/assabet_pcmcia.c: Remove dependency in generic I/O package. + +2000-07-15 Gary Thomas + + * src/assabet_pcmcia.c: Support new slot-oriented interrupts. + +2000-07-14 Gary Thomas + + * src/assabet_pcmcia.c: Support running in non-kernel (stand-alone) + environments. + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/devs/pcmcia/arm/assabet/current/cdl/pcmcia_assabet.cdl b/packages/devs/pcmcia/arm/assabet/current/cdl/pcmcia_assabet.cdl new file mode 100644 --- /dev/null +++ b/packages/devs/pcmcia/arm/assabet/current/cdl/pcmcia_assabet.cdl @@ -0,0 +1,57 @@ +# ==================================================================== +# +# pcmcia_assabet.cdl +# +# PCMCIA (Compact Flash) - Hardware support on Assabet +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): gthomas +# Original data: gthomas +# Contributors: +# Date: 2000-07-06 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVS_PCMCIA_ASSABET { + display "SA11x0/Assabet PCMCIA support" + + parent CYGPKG_IO_PCMCIA + active_if CYGPKG_IO_PCMCIA + active_if CYGPKG_HAL_ARM_SA11X0_ASSABET + + implements CYGHWR_IO_PCMCIA_DEVICE + + include_dir . + include_files ; # none _exported_ whatsoever + description "PCMCIA (Compact Flash) device support for SA11x0/Assabet" + compile assabet_pcmcia.c +} + diff --git a/packages/devs/pcmcia/arm/assabet/current/src/assabet_pcmcia.c b/packages/devs/pcmcia/arm/assabet/current/src/assabet_pcmcia.c new file mode 100644 --- /dev/null +++ b/packages/devs/pcmcia/arm/assabet/current/src/assabet_pcmcia.c @@ -0,0 +1,238 @@ +//========================================================================== +// +// devs/pcmcia/assabet/assabet_pcmcia.c +// +// PCMCIA support (Card Services) +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-06 +// Purpose: PCMCIA support +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include + +#include // IO macros +#include // Register state info +#include // HAL interrupt macros + +#ifdef CYGPKG_KERNEL +#include // Configuration header +#include +#else +#include +#endif + +#include +#include + +#include // Board definitions +#include + +#ifdef CYGPKG_KERNEL +static cyg_interrupt cf_detect_interrupt; +static cyg_handle_t cf_detect_interrupt_handle; +static cyg_interrupt cf_irq_interrupt; +static cyg_handle_t cf_irq_interrupt_handle; + +// This ISR is called when a CompactFlash board is inserted +static int +cf_detect_isr(cyg_vector_t vector, cyg_addrword_t data, HAL_SavedRegisters *regs) +{ + cyg_interrupt_mask(SA1110_CF_DETECT); + return (CYG_ISR_HANDLED|CYG_ISR_CALL_DSR); // Run the DSR +} + +// This DSR handles the board insertion +static void +cf_detect_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data) +{ + unsigned long new_state = *SA11X0_GPIO_PIN_LEVEL; + struct cf_slot *slot = (struct cf_slot *)data; + if ((new_state & SA1110_GPIO_CF_DETECT) == SA1110_GPIO_CF_PRESENT) { + slot->state = CF_SLOT_STATE_Inserted; + } else { + slot->state = CF_SLOT_STATE_Removed; // Implies powered up, etc. + } + cyg_interrupt_acknowledge(SA1110_CF_DETECT); + cyg_interrupt_unmask(SA1110_CF_DETECT); +} + +// This ISR is called when the card interrupt occurs +static int +cf_irq_isr(cyg_vector_t vector, cyg_addrword_t data, HAL_SavedRegisters *regs) +{ + cyg_drv_interrupt_mask(SA1110_CF_IRQ); + return (CYG_ISR_HANDLED|CYG_ISR_CALL_DSR); // Run the DSR +} + +// This DSR handles the card interrupt +static void +cf_irq_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data) +{ + struct cf_slot *slot = (struct cf_slot *)data; + // Clear interrupt [edge indication] + cyg_drv_interrupt_acknowledge(SA1110_CF_IRQ); + // Process interrupt + (slot->irq_handler.handler)(slot->irq_handler.param); + // Allow interrupts to happen again + cyg_drv_interrupt_unmask(SA1110_CF_IRQ); +} +#endif + +// +// Fill in the details of a PCMCIA slot and initialize the device +// +void +cf_hwr_init(struct cf_slot *slot) +{ + static int int_init = 0; + unsigned long new_state = *SA11X0_GPIO_PIN_LEVEL; + if (!int_init) { + int_init = 1; +#ifdef CYGPKG_KERNEL + // Set up interrupts + cyg_interrupt_create(SA1110_CF_DETECT, + 99, // Priority - what goes here? + (cyg_addrword_t) slot, // Data item passed to interrupt handler + (cyg_ISR_t *)cf_detect_isr, + (cyg_DSR_t *)cf_detect_dsr, + &cf_detect_interrupt_handle, + &cf_detect_interrupt); + cyg_interrupt_attach(cf_detect_interrupt_handle); + cyg_interrupt_configure(SA1110_CF_DETECT, true, true); // Detect either edge + cyg_interrupt_acknowledge(SA1110_CF_DETECT); + cyg_interrupt_unmask(SA1110_CF_DETECT); + cyg_interrupt_create(SA1110_CF_IRQ, + 99, // Priority - what goes here? + (cyg_addrword_t) slot, // Data item passed to interrupt handler + (cyg_ISR_t *)cf_irq_isr, + (cyg_DSR_t *)cf_irq_dsr, + &cf_irq_interrupt_handle, + &cf_irq_interrupt); + cyg_interrupt_attach(cf_irq_interrupt_handle); + cyg_interrupt_configure(SA1110_CF_IRQ, false, false); // Falling edge + cyg_interrupt_acknowledge(SA1110_CF_IRQ); + cyg_interrupt_unmask(SA1110_CF_IRQ); +#endif + } + slot->attr = (unsigned char *)0x38000000; + slot->attr_length = 0x200; + slot->io = (unsigned char *)0x30000000; + slot->io_length = 0x04000000; + slot->mem = (unsigned char *)0x3C000000; + slot->mem_length = 0x04000000; + slot->int_num = SA1110_CF_IRQ; + // Disable CF bus & power (idle/off) + assabet_BCR(SA1110_BCR_CF_POWER | + SA1110_BCR_CF_RESET | + SA1110_BCR_CF_BUS, + SA1110_BCR_CF_POWER_OFF | + SA1110_BCR_CF_RESET_DISABLE | + SA1110_BCR_CF_BUS_OFF); + if ((new_state & SA1110_GPIO_CF_DETECT) == SA1110_GPIO_CF_PRESENT) { + slot->state = CF_SLOT_STATE_Inserted; + } else { + slot->state = CF_SLOT_STATE_Empty; + } +} + +void +cf_hwr_poll(struct cf_slot *slot) +{ + unsigned long new_state = *SA11X0_GPIO_PIN_LEVEL; + if ((new_state & SA1110_GPIO_CF_DETECT) == SA1110_GPIO_CF_PRESENT) { + slot->state = CF_SLOT_STATE_Inserted; + } else { + slot->state = CF_SLOT_STATE_Empty; + } +} + +static void +do_delay(int ticks) +{ +#ifdef CYGPKG_KERNEL + cyg_thread_delay(ticks); +#else + CYGACC_CALL_IF_DELAY_US(10000*ticks); +#endif +} + +// +// Transition the card/slot to a new state +// note: currently only supports transitions to Ready, Empty +// +bool +cf_hwr_change_state(struct cf_slot *slot, int new_state) +{ + int i, ptr, len; + unsigned char buf[64]; + + if (new_state == CF_SLOT_STATE_Ready) { + if (slot->state == CF_SLOT_STATE_Inserted) { + assabet_BCR(SA1110_BCR_CF_POWER | + SA1110_BCR_CF_RESET | + SA1110_BCR_CF_BUS, + SA1110_BCR_CF_POWER_ON | + SA1110_BCR_CF_RESET_DISABLE | + SA1110_BCR_CF_BUS_OFF); + do_delay(30); // At least 300 ms + slot->state = CF_SLOT_STATE_Powered; + assabet_BCR(SA1110_BCR_CF_POWER | + SA1110_BCR_CF_RESET | + SA1110_BCR_CF_BUS, + SA1110_BCR_CF_POWER_ON | + SA1110_BCR_CF_RESET_ENABLE | + SA1110_BCR_CF_BUS_ON); + do_delay(1); // At least 10 us + slot->state = CF_SLOT_STATE_Reset; + assabet_BCR(SA1110_BCR_CF_POWER | + SA1110_BCR_CF_RESET | + SA1110_BCR_CF_BUS, + SA1110_BCR_CF_POWER_ON | + SA1110_BCR_CF_RESET_DISABLE | + SA1110_BCR_CF_BUS_ON); + do_delay(5); // At least 20 ms + // Wait until the card is ready to talk + for (i = 0; i < 10; i++) { + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_MANFID, buf, &len, &ptr)) { + slot->state = CF_SLOT_STATE_Ready; + break; + } + do_delay(10); + } + } + } +} diff --git a/packages/devs/serial/arm/aeb/current/ChangeLog b/packages/devs/serial/arm/aeb/current/ChangeLog --- a/packages/devs/serial/arm/aeb/current/ChangeLog +++ b/packages/devs/serial/arm/aeb/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/aeb_serial.c (aeb_serial_set_config): Now use keys to make + more flexible. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/arm/aeb/current/src/aeb_serial.c b/packages/devs/serial/arm/aeb/current/src/aeb_serial.c --- a/packages/devs/serial/arm/aeb/current/src/aeb_serial.c +++ b/packages/devs/serial/arm/aeb/current/src/aeb_serial.c @@ -67,7 +67,9 @@ static Cyg_ErrNo aeb_serial_lookup(struc struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char aeb_serial_getc(serial_channel *chan); -static bool aeb_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo aeb_serial_set_config(serial_channel *chan, + cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void aeb_serial_start_xmit(serial_channel *chan); static void aeb_serial_stop_xmit(serial_channel *chan); @@ -264,10 +266,26 @@ aeb_serial_getc(serial_channel *chan) } // Set up the device characteristics; baud rate, etc. -static bool -aeb_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +aeb_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return aeb_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != aeb_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter on the device diff --git a/packages/devs/serial/arm/cma230/current/ChangeLog b/packages/devs/serial/arm/cma230/current/ChangeLog --- a/packages/devs/serial/arm/cma230/current/ChangeLog +++ b/packages/devs/serial/arm/cma230/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/cma230_serial.c (cma230_serial_set_config): Now use keys to make + more flexible. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/arm/cma230/current/src/cma230_serial.c b/packages/devs/serial/arm/cma230/current/src/cma230_serial.c --- a/packages/devs/serial/arm/cma230/current/src/cma230_serial.c +++ b/packages/devs/serial/arm/cma230/current/src/cma230_serial.c @@ -68,7 +68,8 @@ static Cyg_ErrNo cma230_serial_lookup(st struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char cma230_serial_getc(serial_channel *chan); -static bool cma230_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo cma230_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf; cyg_uint32 *len); static void cma230_serial_start_xmit(serial_channel *chan); static void cma230_serial_stop_xmit(serial_channel *chan); @@ -265,10 +266,26 @@ cma230_serial_getc(serial_channel *chan) } // Set up the device characteristics; baud rate, etc. -static bool -cma230_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +cma230_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return cma230_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != cma230_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter on the device diff --git a/packages/devs/serial/arm/ebsa285/current/ChangeLog b/packages/devs/serial/arm/ebsa285/current/ChangeLog --- a/packages/devs/serial/arm/ebsa285/current/ChangeLog +++ b/packages/devs/serial/arm/ebsa285/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/ebsa285_serial.c (ebsa285_serial_set_config): Now use keys to make + more flexible. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/arm/ebsa285/current/src/ebsa285_serial.c b/packages/devs/serial/arm/ebsa285/current/src/ebsa285_serial.c --- a/packages/devs/serial/arm/ebsa285/current/src/ebsa285_serial.c +++ b/packages/devs/serial/arm/ebsa285/current/src/ebsa285_serial.c @@ -147,7 +147,9 @@ static Cyg_ErrNo ebsa285_serial_lookup(s struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char ebsa285_serial_getc(serial_channel *chan); -static bool ebsa285_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo ebsa285_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); + static void ebsa285_serial_start_xmit(serial_channel *chan); static void ebsa285_serial_stop_xmit(serial_channel *chan); @@ -346,10 +348,26 @@ ebsa285_serial_getc(serial_channel *chan } // Set up the device characteristics; baud rate, etc. -static bool -ebsa285_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +ebsa285_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return ebsa285_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != ebsa285_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter on the device (nope, already in use by hal_diag) diff --git a/packages/devs/serial/arm/edb7xxx/current/ChangeLog b/packages/devs/serial/arm/edb7xxx/current/ChangeLog --- a/packages/devs/serial/arm/edb7xxx/current/ChangeLog +++ b/packages/devs/serial/arm/edb7xxx/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/edb7xxx_serial.c (edb7xxx_serial_set_config): Now use keys to make + more flexible. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/arm/edb7xxx/current/src/edb7xxx_serial.c b/packages/devs/serial/arm/edb7xxx/current/src/edb7xxx_serial.c --- a/packages/devs/serial/arm/edb7xxx/current/src/edb7xxx_serial.c +++ b/packages/devs/serial/arm/edb7xxx/current/src/edb7xxx_serial.c @@ -77,7 +77,8 @@ static Cyg_ErrNo edb7xxx_serial_lookup(s struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char edb7xxx_serial_getc(serial_channel *chan); -static bool edb7xxx_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo edb7xxx_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void edb7xxx_serial_start_xmit(serial_channel *chan); static void edb7xxx_serial_stop_xmit(serial_channel *chan); @@ -292,10 +293,26 @@ edb7xxx_serial_getc(serial_channel *chan } // Set up the device characteristics; baud rate, etc. -static bool -edb7xxx_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +edb7xxx_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return edb7xxx_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != edb7xxx_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter (interrupt) on the device diff --git a/packages/devs/serial/arm/pid/current/ChangeLog b/packages/devs/serial/arm/pid/current/ChangeLog --- a/packages/devs/serial/arm/pid/current/ChangeLog +++ b/packages/devs/serial/arm/pid/current/ChangeLog @@ -1,3 +1,16 @@ +2000-08-01 Jonathan Larmour + + * src/pid_serial_with_ints.c: Throughout, add support for line status + and modem status callbacks, hardware RTS/CTS and DSR/DTR flow control + (pid_serial_set_config): Now use keys to make + more flexible. + + * src/pid_serial.h: Add more line status, interrupt status and modem + status register definitions + + * cdl/ser_arm_pid.cdl: Implements flow control and line status + interfaces + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/arm/pid/current/cdl/ser_arm_pid.cdl b/packages/devs/serial/arm/pid/current/cdl/ser_arm_pid.cdl --- a/packages/devs/serial/arm/pid/current/cdl/ser_arm_pid.cdl +++ b/packages/devs/serial/arm/pid/current/cdl/ser_arm_pid.cdl @@ -68,6 +68,8 @@ cdl_component CYGPKG_IO_SERIAL_ARM_PID_S display "ARM PID serial port 0 driver" flavor bool default_value 1 + implements CYGINT_IO_SERIAL_FLOW_CONTROL_HW + implements CYGINT_IO_SERIAL_LINE_STATUS_HW description " This option includes the serial device driver for the ARM PID port 0." @@ -108,6 +110,8 @@ cdl_component CYGPKG_IO_SERIAL_ARM_PID_S display "ARM PID serial port 1 driver" flavor bool default_value 1 + implements CYGINT_IO_SERIAL_FLOW_CONTROL_HW + implements CYGINT_IO_SERIAL_LINE_STATUS_HW description " This option includes the serial device driver for the ARM PID port 1." diff --git a/packages/devs/serial/arm/pid/current/src/pid_serial.h b/packages/devs/serial/arm/pid/current/src/pid_serial.h --- a/packages/devs/serial/arm/pid/current/src/pid_serial.h +++ b/packages/devs/serial/arm/pid/current/src/pid_serial.h @@ -100,7 +100,13 @@ struct serial_port { // Line Status Register #define LSR_RSR 0x01 +#define LSR_OE 0x02 +#define LSR_PE 0x04 +#define LSR_FE 0x08 +#define LSR_BI 0x10 #define LSR_THE 0x20 +#define LSR_TEMT 0x40 +#define LSR_FIE 0x80 // Modem Control Register #define MCR_DTR 0x01 @@ -108,10 +114,23 @@ struct serial_port { #define MCR_INT 0x08 // Enable interrupts // Interrupt status Register +#define ISR_MS 0x00 +#define ISR_nIP 0x01 #define ISR_Tx 0x02 +#define ISR_LS 0x03 #define ISR_Rx 0x04 #define ISR_RxTO 0x0C +// Modem Status Register +#define MSR_DCTS 0x01 +#define MSR_DDSR 0x02 +#define MSR_TERI 0x04 +#define MSR_DDCD 0x08 +#define MSR_CTS 0x10 +#define MSR_DSR 0x20 +#define MSR_RI 0x40 +#define MSR_CD 0x80 + static unsigned char select_word_length[] = { LCR_WL5, // 5 bits / word (char) LCR_WL6, diff --git a/packages/devs/serial/arm/pid/current/src/pid_serial_with_ints.c b/packages/devs/serial/arm/pid/current/src/pid_serial_with_ints.c --- a/packages/devs/serial/arm/pid/current/src/pid_serial_with_ints.c +++ b/packages/devs/serial/arm/pid/current/src/pid_serial_with_ints.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, jlarmour // Date: 1999-02-04 // Purpose: PID Serial I/O module (interrupt driven version) // Description: @@ -66,7 +66,8 @@ static Cyg_ErrNo pid_serial_lookup(struc struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char pid_serial_getc(serial_channel *chan); -static bool pid_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo pid_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void pid_serial_start_xmit(serial_channel *chan); static void pid_serial_stop_xmit(serial_channel *chan); @@ -181,14 +182,16 @@ pid_serial_config_port(serial_channel *c if (init) { port->REG_fcr = 0x07; // Enable and clear FIFO if (chan->out_cbuf.len != 0) { - port->REG_ier = IER_RCV; + _ier = IER_RCV; } else { - port->REG_ier = 0; + _ier = 0; } port->REG_mcr = MCR_INT|MCR_DTR|MCR_RTS; // Master interrupt enable - } else { - port->REG_ier = _ier; } +#ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS + _ier |= (IER_LS|IER_MS); +#endif + port->REG_ier = _ier; if (new_config != &chan->config) { chan->config = *new_config; } @@ -261,10 +264,54 @@ pid_serial_getc(serial_channel *chan) } // Set up the device characteristics; baud rate, etc. -static bool -pid_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +pid_serial_set_config(serial_channel *chan, cyg_uint32 key, const void *xbuf, + cyg_uint32 *len) { - return pid_serial_config_port(chan, config, false); + pid_serial_info *pid_chan = (pid_serial_info *)chan->dev_priv; + + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != pid_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_HW + case CYG_IO_SET_CONFIG_SERIAL_HW_RX_FLOW_THROTTLE: + { + volatile struct serial_port *port = (volatile struct serial_port *)pid_chan->base; + cyg_uint8 *f = (cyg_uint8 *)xbuf; + unsigned char mask=0; + if ( *len < *f ) + return -EINVAL; + + if ( chan->config.flags & CYGNUM_SERIAL_FLOW_RTSCTS_RX ) + mask = MCR_RTS; + if ( chan->config.flags & CYGNUM_SERIAL_FLOW_DSRDTR_RX ) + mask |= MCR_DTR; + if (*f) // we should throttle + port->REG_mcr &= ~mask; + else // we should no longer throttle + port->REG_mcr |= mask; + } + break; + case CYG_IO_SET_CONFIG_SERIAL_HW_FLOW_CONFIG: + // Nothing to do because we do support both RTSCTS and DSRDTR flow + // control. + // Other targets would clear any unsupported flags here. + // We just return ENOERR. + break; +#endif + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter on the device @@ -304,14 +351,90 @@ pid_serial_DSR(cyg_vector_t vector, cyg_ pid_serial_info *pid_chan = (pid_serial_info *)chan->dev_priv; volatile struct serial_port *port = (volatile struct serial_port *)pid_chan->base; unsigned char isr; - while ((isr = port->REG_isr & 0x0E) != 0) { - if (isr == ISR_Tx) { - (chan->callbacks->xmt_char)(chan); - } else if (isr == ISR_RxTO || isr == ISR_Rx) { + + // Check if we have an interrupt pending - note that the interrupt + // is pending of the low bit of the isr is *0*, not 1. + while (((isr = port->REG_isr) & ISR_nIP) == 0) { + switch (isr&0x6) { + case ISR_Rx: while(port->REG_lsr & LSR_RSR) (chan->callbacks->rcv_char)(chan, port->REG_rhr); + break; + case ISR_Tx: + (chan->callbacks->xmt_char)(chan); + break; + +#ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS + case ISR_LS: + { + cyg_serial_line_status_t stat; + unsigned char lsr=port->REG_lsr; + // this might look expensive, but it is rarely the case that + // more than one of these is set + stat.value = 1; + if ( lsr & LSR_OE ) { + stat.which = CYGNUM_SERIAL_STATUS_OVERRUNERR; + (chan->callbacks->indicate_status)(chan, &stat ); + } + if ( lsr & LSR_PE ) { + stat.which = CYGNUM_SERIAL_STATUS_PARITYERR; + (chan->callbacks->indicate_status)(chan, &stat ); + } + if ( lsr & LSR_FE ) { + stat.which = CYGNUM_SERIAL_STATUS_FRAMEERR; + (chan->callbacks->indicate_status)(chan, &stat ); + } + if ( lsr & LSR_BI ) { + stat.which = CYGNUM_SERIAL_STATUS_BREAK; + (chan->callbacks->indicate_status)(chan, &stat ); + } + if ( lsr & LSR_OE ) { + stat.which = CYGNUM_SERIAL_STATUS_OVERRUNERR; + (chan->callbacks->indicate_status)(chan, &stat ); + } + } + break; + + case ISR_MS: + { + cyg_serial_line_status_t stat; + unsigned char msr=port->REG_msr; +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_HW + if ( msr & MSR_DDSR ) + if ( chan->config.flags & CYGNUM_SERIAL_FLOW_DSRDTR_TX ) { + stat.which = CYGNUM_SERIAL_STATUS_FLOW; + stat.value = (0 != (msr & MSR_DSR)); + (chan->callbacks->indicate_status)(chan, &stat ); + } + if ( msr & MSR_DCTS ) + if ( chan->config.flags & CYGNUM_SERIAL_FLOW_RTSCTS_TX ) { + stat.which = CYGNUM_SERIAL_STATUS_FLOW; + stat.value = (0 != (msr & MSR_CTS)); + (chan->callbacks->indicate_status)(chan, &stat ); + } +#endif + if ( msr & MSR_DDCD ) { + stat.which = CYGNUM_SERIAL_STATUS_CARRIERDETECT; + stat.value = (0 != (msr & MSR_CD)); + (chan->callbacks->indicate_status)(chan, &stat ); + } + if ( msr & MSR_RI ) { + stat.which = CYGNUM_SERIAL_STATUS_RINGINDICATOR; + stat.value = 1; + (chan->callbacks->indicate_status)(chan, &stat ); + } + if ( msr & MSR_TERI ) { + stat.which = CYGNUM_SERIAL_STATUS_RINGINDICATOR; + stat.value = 0; + (chan->callbacks->indicate_status)(chan, &stat ); + } + } + break; +#endif } } cyg_drv_interrupt_unmask(pid_chan->int_num); } #endif + +// EOF pid_serial_with_ints.c diff --git a/packages/devs/serial/arm/sa11x0/current/ChangeLog b/packages/devs/serial/arm/sa11x0/current/ChangeLog --- a/packages/devs/serial/arm/sa11x0/current/ChangeLog +++ b/packages/devs/serial/arm/sa11x0/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/sa11x0_serial.c (sa11x0_serial_set_config): Now use keys to make + more flexible. + 2000-06-29 Jesper Skov * src/sa11x0_serial.h: diff --git a/packages/devs/serial/arm/sa11x0/current/src/sa11x0_serial.c b/packages/devs/serial/arm/sa11x0/current/src/sa11x0_serial.c --- a/packages/devs/serial/arm/sa11x0/current/src/sa11x0_serial.c +++ b/packages/devs/serial/arm/sa11x0/current/src/sa11x0_serial.c @@ -69,7 +69,8 @@ static Cyg_ErrNo sa11x0_serial_lookup(st struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char sa11x0_serial_getc(serial_channel *chan); -static bool sa11x0_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo sa11x0_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void sa11x0_serial_start_xmit(serial_channel *chan); static void sa11x0_serial_stop_xmit(serial_channel *chan); @@ -266,10 +267,26 @@ sa11x0_serial_getc(serial_channel *chan) } // Set up the device characteristics; baud rate, etc. -static bool -sa11x0_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +sa11x0_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return sa11x0_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != sa11x0_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter on the device diff --git a/packages/devs/serial/i386/pc/current/ChangeLog b/packages/devs/serial/i386/pc/current/ChangeLog --- a/packages/devs/serial/i386/pc/current/ChangeLog +++ b/packages/devs/serial/i386/pc/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/pc_serial.c (pc_serial_set_config): Now use keys to make + more flexible. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/i386/pc/current/src/pc_serial.c b/packages/devs/serial/i386/pc/current/src/pc_serial.c --- a/packages/devs/serial/i386/pc/current/src/pc_serial.c +++ b/packages/devs/serial/i386/pc/current/src/pc_serial.c @@ -76,7 +76,8 @@ static Cyg_ErrNo pc_serial_lookup(struct struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char pc_serial_getc(serial_channel *chan); -static bool pc_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo pc_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void pc_serial_start_xmit(serial_channel *chan); static void pc_serial_stop_xmit(serial_channel *chan); @@ -339,13 +340,29 @@ static unsigned char pc_serial_getc(seri // Set up the device characteristics; baud rate, etc. -static bool pc_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +pc_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return pc_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != pc_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } - // Enable the transmitter on the device static void pc_serial_start_xmit(serial_channel *chan) { diff --git a/packages/devs/serial/loop/current/ChangeLog b/packages/devs/serial/loop/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/devs/serial/loop/current/ChangeLog @@ -0,0 +1,36 @@ +2000-08-01 Jonathan Larmour + + * src/loop_serial.c (loop_serial_set_config): Now use keys to make + more flexible. + +2000-06-15 Nick Garnett + + * cdl/ser_loop.cdl: + * src/loop/loop_serial.c: + Added loopback serial driver. + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/devs/serial/loop/current/cdl/ser_loop.cdl b/packages/devs/serial/loop/current/cdl/ser_loop.cdl new file mode 100644 --- /dev/null +++ b/packages/devs/serial/loop/current/cdl/ser_loop.cdl @@ -0,0 +1,181 @@ +# ==================================================================== +# +# ser_loop.cdl +# +# eCos serial LOOP configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jskov +# Original data: gthomas +# Contributors: +# Date: 1999-07-07 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_IO_SERIAL_LOOP { + display "Loop serial device drivers" + + parent CYGPKG_IO_SERIAL_DEVICES + active_if CYGPKG_IO_SERIAL + requires CYGPKG_ERROR + include_dir cyg/io + include_files ; # none _exported_ whatsoever + doc redirect/ecos-device-drivers.html + + description " + This package contains the loop serial device driver." + + compile -library=libextras.a loop_serial.c + + # FIXME: Bad name + cdl_option CYGPKG_IO_SERIAL_LOOP_POLLED_MODE { + display "LOOP polled mode serial drivers" + flavor bool + default_value 0 + description " + If asserted, this option specifies that the serial loop device + drivers for the should be polled-mode instead of + interrupt driven." + } + + cdl_component CYGPKG_IO_SERIAL_LOOP_SERIAL0 { + display "LOOP serial port 0 driver" + flavor bool + default_value 0 + description " + This option includes the serial loop device driver for port 0." + + cdl_option CYGDAT_IO_SERIAL_LOOP_SERIAL0_NAME { + display "Device name for LOOP serial port 0" + flavor data + default_value {"\"/dev/ser0\""} + description " + This option specifies the first loop device name." + } + + cdl_option CYGNUM_IO_SERIAL_LOOP_SERIAL0_BAUD { + display "Baud rate for the LOOP serial port 0 driver" + flavor data + legal_values { 50 75 110 "134_5" 150 200 300 600 1200 1800 + 2400 3600 4800 7200 9600 14400 19200 38400 + 57600 115200 234000 + } + default_value 38400 + description " + This option specifies the default baud rate (speed) for the + LOOP port 0." + } + + cdl_option CYGNUM_IO_SERIAL_LOOP_SERIAL0_BUFSIZE { + display "Buffer size for the LOOP serial port 0 driver" + flavor data + legal_values 0 to 8192 + default_value 128 + description " + This option specifies the size of the internal buffers used + for the LOOP port 0." + } + } + + cdl_component CYGPKG_IO_SERIAL_LOOP_SERIAL1 { + display "LOOP serial port 1 driver" + flavor bool + default_value 0 + description " + This option includes the serial device driver for port 1 on + the LOOP." + + cdl_option CYGDAT_IO_SERIAL_LOOP_SERIAL1_NAME { + display "Device name for LOOP serial port 1" + flavor data + default_value {"\"/dev/ser1\""} + description " + This option specifies the device name port 1 on the LOOP." + } + + cdl_option CYGNUM_IO_SERIAL_LOOP_SERIAL1_BAUD { + display "Baud rate for the LOOP serial port 1 driver" + flavor data + legal_values { 50 75 110 "134_5" 150 200 300 600 1200 1800 + 2400 3600 4800 7200 9600 14400 19200 38400 + 57600 115200 234000 + } + default_value 38400 + description " + This option specifies the default baud rate (speed) for the + LOOP port 1." + } + + cdl_option CYGNUM_IO_SERIAL_LOOP_SERIAL1_BUFSIZE { + display "Buffer size for the LOOP serial port 1 driver" + flavor data + legal_values 0 to 8192 + default_value 128 + description " + This option specifies the size of the internal buffers used + for the LOOP port 1." + } + } + + cdl_component CYGPKG_IO_SERIAL_LOOP_OPTIONS { + display "Serial device driver build options" + flavor none + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_IO_SERIAL_LOOP_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building these serial device drivers. These flags + are used in addition to the set of global flags." + } + + cdl_option CYGPKG_IO_SERIAL_LOOP_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building these serial device drivers. These flags are + removed from the set of global flags if present." + } + } +} + +# EOF ser_loop.cdl diff --git a/packages/devs/serial/loop/current/src/loop_serial.c b/packages/devs/serial/loop/current/src/loop_serial.c new file mode 100644 --- /dev/null +++ b/packages/devs/serial/loop/current/src/loop_serial.c @@ -0,0 +1,448 @@ +//========================================================================== +// +// loop_serial.c +// +// Loopback serial device driver +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 1999-02-25 +// Purpose: Loopback serial device driver +// Description: This device driver implements a pair of serial lines that are +// connected back-to-back. Data output to one will appear as +// input on the other. This process in in part driven by an alarm +// object which provides a degree of separation between the two +// channels. +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifdef CYGPKG_IO_SERIAL_LOOP + +//------------------------------------------------------------------------- + +extern void diag_printf(const char *fmt, ...); + +//------------------------------------------------------------------------- +// Forward definitions + +static bool loop_serial_init(struct cyg_devtab_entry *tab); +static bool loop_serial_putc(serial_channel *chan, unsigned char c); +static Cyg_ErrNo loop_serial_lookup(struct cyg_devtab_entry **tab, + struct cyg_devtab_entry *sub_tab, + const char *name); +static unsigned char loop_serial_getc(serial_channel *chan); +static Cyg_ErrNo loop_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); +static void loop_serial_start_xmit(serial_channel *chan); +static void loop_serial_stop_xmit(serial_channel *chan); + +#ifndef CYGPKG_IO_SERIAL_LOOP_POLLED_MODE +static void alarm_handler(cyg_handle_t alarm, cyg_addrword_t data); +#endif + +//------------------------------------------------------------------------- +// Alarm object for feeding data back into serial channels + +static cyg_alarm alarm_obj; + +static cyg_handle_t alarm_handle; + +//------------------------------------------------------------------------- +// Transfer FIFOs + +#define FIFO_SIZE 16 + +struct fifo +{ + cyg_bool tx_enable; + volatile int head; + volatile int tail; + volatile int num; + volatile char buf[FIFO_SIZE+1]; +}; + +static struct fifo fifo0 = { false, 0, 0, 0 }; // from serial0 to serial1 +static struct fifo fifo1 = { false, 0, 0, 0 }; // from serial1 to serial0 + +//------------------------------------------------------------------------- + +#define BUFSIZE 128 + +//------------------------------------------------------------------------- +// Info for each serial device controlled + +typedef struct loop_serial_info { + struct fifo *write_fifo; + struct fifo *read_fifo; +} loop_serial_info; + +//------------------------------------------------------------------------- +// Callback functions exported by this driver + +static SERIAL_FUNS(loop_serial_funs, + loop_serial_putc, + loop_serial_getc, + loop_serial_set_config, + loop_serial_start_xmit, + loop_serial_stop_xmit + ); + +//------------------------------------------------------------------------- +// Hardware info for each serial line + +#ifdef CYGPKG_IO_SERIAL_LOOP_SERIAL0 +static loop_serial_info loop_serial_info0 = { + &fifo0, + &fifo1 +}; +#if CYGNUM_IO_SERIAL_LOOP_SERIAL0_BUFSIZE > 0 +static unsigned char loop_serial_out_buf0[CYGNUM_IO_SERIAL_LOOP_SERIAL0_BUFSIZE]; +static unsigned char loop_serial_in_buf0[CYGNUM_IO_SERIAL_LOOP_SERIAL0_BUFSIZE]; +#endif +#endif // CYGPKG_IO_SERIAL_LOOP_SERIAL0 + +#ifdef CYGPKG_IO_SERIAL_LOOP_SERIAL1 +static loop_serial_info loop_serial_info1 = { + &fifo1, + &fifo0 +}; +#if CYGNUM_IO_SERIAL_LOOP_SERIAL1_BUFSIZE > 0 +static unsigned char loop_serial_out_buf1[CYGNUM_IO_SERIAL_LOOP_SERIAL1_BUFSIZE]; +static unsigned char loop_serial_in_buf1[CYGNUM_IO_SERIAL_LOOP_SERIAL1_BUFSIZE]; +#endif +#endif // CYGPKG_IO_SERIAL_LOOP_SERIAL1 + +//------------------------------------------------------------------------- +// Channel descriptions: + +#ifdef CYGPKG_IO_SERIAL_LOOP_POLLED_MODE +#define SIZEOF_BUF(_x_) 0 +#else +#define SIZEOF_BUF(_x_) sizeof(_x_) +#endif + +#ifdef CYGPKG_IO_SERIAL_LOOP_SERIAL0 +#if CYGNUM_IO_SERIAL_LOOP_SERIAL0_BUFSIZE > 0 +static SERIAL_CHANNEL_USING_INTERRUPTS(loop_serial_channel0, + loop_serial_funs, + loop_serial_info0, + CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_LOOP_SERIAL0_BAUD), + CYG_SERIAL_STOP_DEFAULT, + CYG_SERIAL_PARITY_DEFAULT, + CYG_SERIAL_WORD_LENGTH_DEFAULT, + CYG_SERIAL_FLAGS_DEFAULT, + &loop_serial_out_buf0[0], + SIZEOF_BUF(loop_serial_out_buf0), + &loop_serial_in_buf0[0], + SIZEOF_BUF(loop_serial_in_buf0) + ); +#else +static SERIAL_CHANNEL(loop_serial_channel0, + loop_serial_funs, + loop_serial_info0, + CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_LOOP_SERIAL0_BAUD), + CYG_SERIAL_STOP_DEFAULT, + CYG_SERIAL_PARITY_DEFAULT, + CYG_SERIAL_WORD_LENGTH_DEFAULT, + CYG_SERIAL_FLAGS_DEFAULT + ); +#endif +#endif // CYGPKG_IO_SERIAL_LOOP_SERIAL0 + +#ifdef CYGPKG_IO_SERIAL_LOOP_SERIAL1 +#if CYGNUM_IO_SERIAL_LOOP_SERIAL1_BUFSIZE > 0 +static SERIAL_CHANNEL_USING_INTERRUPTS(loop_serial_channel1, + loop_serial_funs, + loop_serial_info1, + CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_LOOP_SERIAL1_BAUD), + CYG_SERIAL_STOP_DEFAULT, + CYG_SERIAL_PARITY_DEFAULT, + CYG_SERIAL_WORD_LENGTH_DEFAULT, + CYG_SERIAL_FLAGS_DEFAULT, + &loop_serial_out_buf1[0], + SIZEOF_BUF(loop_serial_out_buf1), + &loop_serial_in_buf1[0], + SIZEOF_BUF(loop_serial_in_buf1) + ); +#else +static SERIAL_CHANNEL(loop_serial_channel1, + loop_serial_funs, + loop_serial_info1, + CYG_SERIAL_BAUD_RATE(CYGNUM_IO_SERIAL_LOOP_SERIAL1_BAUD), + CYG_SERIAL_STOP_DEFAULT, + CYG_SERIAL_PARITY_DEFAULT, + CYG_SERIAL_WORD_LENGTH_DEFAULT, + CYG_SERIAL_FLAGS_DEFAULT + ); +#endif +#endif // CYGPKG_IO_SERIAL_LOOP_SERIAL1 + +//------------------------------------------------------------------------- +// And finally, the device table entries: + +#ifdef CYGPKG_IO_SERIAL_LOOP_SERIAL0 +DEVTAB_ENTRY(loop_serial_io0, + CYGDAT_IO_SERIAL_LOOP_SERIAL0_NAME, + 0, // Does not depend on a lower level interface + &cyg_io_serial_devio, + loop_serial_init, + loop_serial_lookup, // Serial driver may need initializing + &loop_serial_channel0 + ); +#endif // CYGPKG_IO_SERIAL_LOOP_SERIAL0 + +#ifdef CYGPKG_IO_SERIAL_LOOP_SERIAL1 +DEVTAB_ENTRY(loop_serial_io1, + CYGDAT_IO_SERIAL_LOOP_SERIAL1_NAME, + 0, // Does not depend on a lower level interface + &cyg_io_serial_devio, + loop_serial_init, + loop_serial_lookup, // Serial driver may need initializing + &loop_serial_channel1 + ); +#endif // CYGPKG_IO_SERIAL_LOOP_SERIAL1 + +//------------------------------------------------------------------------- + +static bool +loop_serial_config_port(serial_channel *chan, cyg_serial_info_t *new_config, bool init) +{ +// loop_serial_info *loop_chan = (loop_serial_info *)chan->dev_priv; + + if (new_config != &chan->config) { + chan->config = *new_config; + } + return true; +} + +//------------------------------------------------------------------------- +// Function to initialize the device. Called at bootstrap time. + +bool loop_serial_init(struct cyg_devtab_entry *tab) +{ + serial_channel *chan = (serial_channel *)tab->priv; +// loop_serial_info *loop_chan = (loop_serial_info *)chan->dev_priv; + + (chan->callbacks->serial_init)(chan); // Really only required for interrupt driven devices + +#ifndef CYGPKG_IO_SERIAL_LOOP_POLLED_MODE + + // Set up alarm for feeding data back into channels + + cyg_alarm_create( cyg_real_time_clock(), + alarm_handler, + 0, + &alarm_handle, + &alarm_obj); + + cyg_alarm_initialize( alarm_handle, 1, 1 ); + +#endif + + loop_serial_config_port(chan, &chan->config, true); + + return true; +} + +//------------------------------------------------------------------------- +// This routine is called when the device is "looked" up (i.e. attached) + +static Cyg_ErrNo +loop_serial_lookup(struct cyg_devtab_entry **tab, + struct cyg_devtab_entry *sub_tab, + const char *name) +{ + serial_channel *chan = (serial_channel *)(*tab)->priv; + (chan->callbacks->serial_init)(chan); // Really only required for interrupt driven devices + return ENOERR; +} + +//------------------------------------------------------------------------- +// Return 'true' if character is sent to device + +bool +loop_serial_putc(serial_channel *chan, unsigned char c) +{ + loop_serial_info *loop_chan = (loop_serial_info *)chan->dev_priv; + + struct fifo *f = loop_chan->write_fifo; + + if( f->num == FIFO_SIZE ) + return false; + + f->buf[f->tail] = c; + f->num++; + f->tail++; + if( f->tail == sizeof(f->buf) ) + f->tail = 0; + + return true; +} + +//------------------------------------------------------------------------- + +unsigned char +loop_serial_getc(serial_channel *chan) +{ + unsigned char c; + loop_serial_info *loop_chan = (loop_serial_info *)chan->dev_priv; + + struct fifo *f = loop_chan->read_fifo; + + while( f->num == 0 ) + continue; + + c = f->buf[f->head]; + f->num--; + f->head++; + if( f->head == sizeof(f->buf) ) + f->head = 0; + + return c; +} + +//------------------------------------------------------------------------- + +static Cyg_ErrNo +loop_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) +{ + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != loop_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; +} + +//------------------------------------------------------------------------- +// Enable the transmitter on the device + +static void +loop_serial_start_xmit(serial_channel *chan) +{ +#ifndef CYGPKG_IO_SERIAL_LOOP_POLLED_MODE + loop_serial_info *loop_chan = (loop_serial_info *)chan->dev_priv; + + loop_chan->write_fifo->tx_enable = true; + + (chan->callbacks->xmt_char)(chan); +#endif +} + +//------------------------------------------------------------------------- +// Disable the transmitter on the device + +static void +loop_serial_stop_xmit(serial_channel *chan) +{ +#ifndef CYGPKG_IO_SERIAL_LOOP_POLLED_MODE + loop_serial_info *loop_chan = (loop_serial_info *)chan->dev_priv; + + loop_chan->write_fifo->tx_enable = false; + +#endif +} + +//------------------------------------------------------------------------- + +static void alarm_handler(cyg_handle_t alarm, cyg_addrword_t data) +{ + serial_channel *chan0 = &loop_serial_channel0; + serial_channel *chan1 = &loop_serial_channel1; + + while( fifo0.num ) + { + // Data ready for delivery to serial1 + + struct fifo *f = &fifo0; + char c; + + c = f->buf[f->head]; + f->num--; + f->head++; + if( f->head == sizeof(f->buf) ) + f->head = 0; + + (chan1->callbacks->rcv_char)(chan1, c); + if( f->tx_enable ) + (chan0->callbacks->xmt_char)(chan0); + } + + while( fifo1.num ) + { + // Data ready for delivery to serial0 + + struct fifo *f = &fifo1; + char c; + + c = f->buf[f->head]; + f->num--; + f->head++; + if( f->head == sizeof(f->buf) ) + f->head = 0; + + (chan0->callbacks->rcv_char)(chan0, c); + if( f->tx_enable ) + (chan1->callbacks->xmt_char)(chan1); + } + + + +} + + +#endif // CYGPKG_IO_SERIAL_LOOP + +//------------------------------------------------------------------------- +// EOF loop.c diff --git a/packages/devs/serial/mips/jmr3904/current/ChangeLog b/packages/devs/serial/mips/jmr3904/current/ChangeLog --- a/packages/devs/serial/mips/jmr3904/current/ChangeLog +++ b/packages/devs/serial/mips/jmr3904/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/tx3904_serial.c (tx3904_serial_set_config): Now use keys to make + more flexible. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/mips/jmr3904/current/src/tx3904_serial.c b/packages/devs/serial/mips/jmr3904/current/src/tx3904_serial.c --- a/packages/devs/serial/mips/jmr3904/current/src/tx3904_serial.c +++ b/packages/devs/serial/mips/jmr3904/current/src/tx3904_serial.c @@ -68,7 +68,8 @@ static Cyg_ErrNo tx3904_serial_lookup(st struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char tx3904_serial_getc(serial_channel *chan); -static bool tx3904_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo tx3904_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void tx3904_serial_start_xmit(serial_channel *chan); static void tx3904_serial_stop_xmit(serial_channel *chan); @@ -560,10 +561,26 @@ tx3904_serial_getc(serial_channel *chan) //------------------------------------------------------------------------- -bool -tx3904_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +tx3904_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return tx3904_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != tx3904_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } //------------------------------------------------------------------------- diff --git a/packages/devs/serial/mips/vrc4373/current/ChangeLog b/packages/devs/serial/mips/vrc4373/current/ChangeLog --- a/packages/devs/serial/mips/vrc4373/current/ChangeLog +++ b/packages/devs/serial/mips/vrc4373/current/ChangeLog @@ -1,3 +1,13 @@ +2000-08-01 Jonathan Larmour + + * src/vrc4373_serial.c (vrc4373_serial_set_config): Now use keys to make + more flexible. + +2000-07-22 Jonathan Larmour + + * src/vrc4373_serial.c (vrc4373_serial_init): Add comment about broken + interrupt handling + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/mips/vrc4373/current/src/vrc4373_serial.c b/packages/devs/serial/mips/vrc4373/current/src/vrc4373_serial.c --- a/packages/devs/serial/mips/vrc4373/current/src/vrc4373_serial.c +++ b/packages/devs/serial/mips/vrc4373/current/src/vrc4373_serial.c @@ -78,7 +78,8 @@ static Cyg_ErrNo vrc4373_serial_lookup(s struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char vrc4373_serial_getc(serial_channel *chan); -static bool vrc4373_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo vrc4373_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void vrc4373_serial_start_xmit(serial_channel *chan); static void vrc4373_serial_stop_xmit(serial_channel *chan); @@ -313,6 +314,8 @@ vrc4373_serial_init(struct cyg_devtab_en (chan->callbacks->serial_init)(chan); // Really only required for interrupt driven devices if (!init && chan->out_cbuf.len != 0) { init = true; +// Note that the hardware is rather broken. The interrupt status needs to +// be read using only channel A cyg_drv_interrupt_create(VRC4373_SCC_INT, 99, (cyg_addrword_t)VRC4373_SCC_BASE+SCC_CHANNEL_A, @@ -368,10 +371,26 @@ vrc4373_serial_getc(serial_channel *chan } // Set up the device characteristics; baud rate, etc. -static bool -vrc4373_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +vrc4373_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return vrc4373_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != vrc4373_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter on the device diff --git a/packages/devs/serial/mn10300/mn10300/current/ChangeLog b/packages/devs/serial/mn10300/mn10300/current/ChangeLog --- a/packages/devs/serial/mn10300/mn10300/current/ChangeLog +++ b/packages/devs/serial/mn10300/mn10300/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/mn10300_serial.c (mn10300_serial_set_config): Now use keys to make + more flexible. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/mn10300/mn10300/current/src/mn10300_serial.c b/packages/devs/serial/mn10300/mn10300/current/src/mn10300_serial.c --- a/packages/devs/serial/mn10300/mn10300/current/src/mn10300_serial.c +++ b/packages/devs/serial/mn10300/mn10300/current/src/mn10300_serial.c @@ -67,7 +67,8 @@ static Cyg_ErrNo mn10300_serial_lookup(s struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char mn10300_serial_getc(serial_channel *chan); -static bool mn10300_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo mn10300_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void mn10300_serial_start_xmit(serial_channel *chan); static void mn10300_serial_stop_xmit(serial_channel *chan); @@ -802,10 +803,26 @@ mn10300_serial_getc(serial_channel *chan //------------------------------------------------------------------------- -bool -mn10300_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +mn10300_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return mn10300_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != mn10300_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } //------------------------------------------------------------------------- diff --git a/packages/devs/serial/powerpc/cogent/current/ChangeLog b/packages/devs/serial/powerpc/cogent/current/ChangeLog --- a/packages/devs/serial/powerpc/cogent/current/ChangeLog +++ b/packages/devs/serial/powerpc/cogent/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/cogent_serial_with_ints.c (cogent_serial_set_config): Now use + keys to make more flexible. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/powerpc/cogent/current/src/cogent_serial_with_ints.c b/packages/devs/serial/powerpc/cogent/current/src/cogent_serial_with_ints.c --- a/packages/devs/serial/powerpc/cogent/current/src/cogent_serial_with_ints.c +++ b/packages/devs/serial/powerpc/cogent/current/src/cogent_serial_with_ints.c @@ -81,7 +81,8 @@ static Cyg_ErrNo cogent_serial_lookup(st struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char cogent_serial_getc(serial_channel *chan); -static bool cogent_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo cogent_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void cogent_serial_start_xmit(serial_channel *chan); static void cogent_serial_stop_xmit(serial_channel *chan); @@ -319,10 +320,26 @@ cogent_serial_getc(serial_channel *chan) } // Set up the device characteristics; baud rate, etc. -static bool -cogent_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +cogent_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return cogent_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != cogent_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter on the device diff --git a/packages/devs/serial/powerpc/quicc/current/ChangeLog b/packages/devs/serial/powerpc/quicc/current/ChangeLog --- a/packages/devs/serial/powerpc/quicc/current/ChangeLog +++ b/packages/devs/serial/powerpc/quicc/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/quicc_smc_serial.c (quicc_smc_serial_set_config): Now use keys + to make more flexible. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/powerpc/quicc/current/src/quicc_smc_serial.c b/packages/devs/serial/powerpc/quicc/current/src/quicc_smc_serial.c --- a/packages/devs/serial/powerpc/quicc/current/src/quicc_smc_serial.c +++ b/packages/devs/serial/powerpc/quicc/current/src/quicc_smc_serial.c @@ -106,7 +106,9 @@ static Cyg_ErrNo quicc_smc_serial_lookup struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char quicc_smc_serial_getc(serial_channel *chan); -static bool quicc_smc_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo quicc_smc_serial_set_config(serial_channel *chan, + cyg_uint32 key, const void *xbuf, + cyg_uint32 *len); static void quicc_smc_serial_start_xmit(serial_channel *chan); static void quicc_smc_serial_stop_xmit(serial_channel *chan); @@ -546,13 +548,28 @@ quicc_smc_serial_getc(serial_channel *ch } // Set up the device characteristics; baud rate, etc. -static bool -quicc_smc_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +quicc_smc_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - bool res = quicc_smc_serial_config_port(chan, config, false); - // FIXME - The documentation says that you can't change the baud rate - // again until at least two BRG input clocks have occurred. - return res; + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + // FIXME - The documentation says that you can't change the baud rate + // again until at least two BRG input clocks have occurred. + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != quicc_smc_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter (interrupt) on the device diff --git a/packages/devs/serial/sh/cq7708/current/ChangeLog b/packages/devs/serial/sh/cq7708/current/ChangeLog --- a/packages/devs/serial/sh/cq7708/current/ChangeLog +++ b/packages/devs/serial/sh/cq7708/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/sh_sci_serial.c (sh_serial_set_config): Now use keys to make + more flexible. + 2000-06-23 Jesper Skov diff --git a/packages/devs/serial/sh/cq7708/current/src/sh_sci_serial.c b/packages/devs/serial/sh/cq7708/current/src/sh_sci_serial.c --- a/packages/devs/serial/sh/cq7708/current/src/sh_sci_serial.c +++ b/packages/devs/serial/sh/cq7708/current/src/sh_sci_serial.c @@ -140,7 +140,8 @@ static Cyg_ErrNo sh_serial_lookup(struct struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char sh_serial_getc(serial_channel *chan); -static bool sh_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo sh_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void sh_serial_start_xmit(serial_channel *chan); static void sh_serial_stop_xmit(serial_channel *chan); @@ -329,10 +330,26 @@ sh_serial_getc(serial_channel *chan) } // Set up the device characteristics; baud rate, etc. -static bool -sh_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +sh_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return sh_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != sh_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter on the device diff --git a/packages/devs/serial/sh/edk7708/current/ChangeLog b/packages/devs/serial/sh/edk7708/current/ChangeLog --- a/packages/devs/serial/sh/edk7708/current/ChangeLog +++ b/packages/devs/serial/sh/edk7708/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/sh_sci_serial.c (sh_serial_set_config): Now use keys to make + more flexible. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/sh/edk7708/current/src/sh_sci_serial.c b/packages/devs/serial/sh/edk7708/current/src/sh_sci_serial.c --- a/packages/devs/serial/sh/edk7708/current/src/sh_sci_serial.c +++ b/packages/devs/serial/sh/edk7708/current/src/sh_sci_serial.c @@ -140,7 +140,8 @@ static Cyg_ErrNo sh_serial_lookup(struct struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char sh_serial_getc(serial_channel *chan); -static bool sh_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo sh_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void sh_serial_start_xmit(serial_channel *chan); static void sh_serial_stop_xmit(serial_channel *chan); @@ -329,10 +330,26 @@ sh_serial_getc(serial_channel *chan) } // Set up the device characteristics; baud rate, etc. -static bool -sh_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +sh_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return sh_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != sh_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter on the device diff --git a/packages/devs/serial/sparclite/sleb/current/ChangeLog b/packages/devs/serial/sparclite/sleb/current/ChangeLog --- a/packages/devs/serial/sparclite/sleb/current/ChangeLog +++ b/packages/devs/serial/sparclite/sleb/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/sleb_sdtr.c (sleb_sdtr_set_config): Now use keys to make + more flexible. + 2000-06-22 Hugo Tyson * cdl/.cdl: Remove the comment on the empty diff --git a/packages/devs/serial/sparclite/sleb/current/src/sleb_sdtr.c b/packages/devs/serial/sparclite/sleb/current/src/sleb_sdtr.c --- a/packages/devs/serial/sparclite/sleb/current/src/sleb_sdtr.c +++ b/packages/devs/serial/sparclite/sleb/current/src/sleb_sdtr.c @@ -74,7 +74,8 @@ static Cyg_ErrNo sleb_sdtr_lookup(struct struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char sleb_sdtr_getc(serial_channel *chan); -static bool sleb_sdtr_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo sleb_sdtr_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void sleb_sdtr_start_xmit(serial_channel *chan); static void sleb_sdtr_stop_xmit(serial_channel *chan); @@ -299,6 +300,27 @@ sleb_sdtr_getc(serial_channel *chan) } // Set up the device characteristics; baud rate, etc. +static Cyg_ErrNo +sleb_sdtr_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) +{ + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != sleb_sdtr_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; +} static bool sleb_sdtr_set_config(serial_channel *chan, cyg_serial_info_t *config) { diff --git a/packages/devs/serial/v85x/v850/current/ChangeLog b/packages/devs/serial/v85x/v850/current/ChangeLog --- a/packages/devs/serial/v85x/v850/current/ChangeLog +++ b/packages/devs/serial/v85x/v850/current/ChangeLog @@ -1,3 +1,8 @@ +2000-08-01 Jonathan Larmour + + * src/v85x_v850_serial.c (v850_serial_set_config): Now use keys to make + more flexible. + 2000-07-19 Gary Thomas * src/v85x_v850_serial.h: Base baud rate calculations on CPU frequency. diff --git a/packages/devs/serial/v85x/v850/current/src/v85x_v850_serial.c b/packages/devs/serial/v85x/v850/current/src/v85x_v850_serial.c --- a/packages/devs/serial/v85x/v850/current/src/v85x_v850_serial.c +++ b/packages/devs/serial/v85x/v850/current/src/v85x_v850_serial.c @@ -78,7 +78,8 @@ static Cyg_ErrNo v850_serial_lookup(stru struct cyg_devtab_entry *sub_tab, const char *name); static unsigned char v850_serial_getc(serial_channel *chan); -static bool v850_serial_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo v850_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static void v850_serial_start_xmit(serial_channel *chan); static void v850_serial_stop_xmit(serial_channel *chan); @@ -256,10 +257,26 @@ v850_serial_getc(serial_channel *chan) } // Set up the device characteristics; baud rate, etc. -static bool -v850_serial_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +v850_serial_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len) { - return v850_serial_config_port(chan, config, false); + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + { + cyg_serial_info_t *config = (cyg_serial_info_t *)xbuf; + if ( *len < sizeof(cyg_serial_info_t) ) { + return -EINVAL; + } + *len = sizeof(cyg_serial_info_t); + if ( true != v850_serial_config_port(chan, config, false) ) + return -EINVAL; + } + break; + default: + return -EINVAL; + } + return ENOERR; } // Enable the transmitter on the device diff --git a/packages/ecos.db b/packages/ecos.db --- a/packages/ecos.db +++ b/packages/ecos.db @@ -86,6 +86,54 @@ package CYGPKG_IO_SERIAL { This package contains drivers for basic I/O services on serial devices." } +package CYGPKG_IO_PCMCIA { + alias { "PCMCIA & Compact Flash support" pcmcia io_pcmcia cf } + directory io/pcmcia + script io_pcmcia.cdl + description " + This package contains basic card services support for PCMCIA + and Compact Flash devices." +} + +package CYGPKG_DEVS_PCMCIA_ASSABET { + alias { "SA11x0/Assabet PCMCIA & Compact Flash support" pcmcia_assabet assabet_pcmcia assabet_cf io_assabet_pcmcia} + directory devs/pcmcia/arm/assabet + script pcmcia_assabet.cdl + hardware + description " + This package contains hardware support for PCMCIA + and Compact Flash devices on the SA11x0/Assabet board." +} + +package CYGPKG_IO_FLASH { + alias { "Generic FLASH memory support" flash } + directory io/flash + script io_flash.cdl + description " + This package contains generic support for FLASH memory." +} + + +package CYGPKG_DEVS_FLASH_EBSA285 { + alias { "FLASH memory support for StrongARM EBSA-285" flash_ebsa285 } + directory devs/flash/arm/ebsa285 + script flash_ebsa285.cdl + hardware + description " + This package contains hardware support for FLASH memory + on the StrongARM EBSA-285 platform." +} + +package CYGPKG_DEVS_FLASH_EDB7XXX { + alias { "FLASH memory support for Cirrus Logic EDB7xxx" flash_edb7xxx } + directory devs/flash/arm/edb7xxx + script flash_edb7xxx.cdl + hardware + description " + This package contains hardware support for FLASH memory + on the Cirrus Logic EDB7xxx platform(s)." +} + package CYGPKG_IO_SERIAL_ARM_EBSA285 { alias { "Intel EBSA285 serial driver" devs_serial_arm_ebsa285 ebsa285_serial_driver } @@ -239,6 +287,38 @@ package CYGPKG_IO_SERIAL_V85X_V850 { SA1 (70F3017) or SB1 (70F3033) processors." } +package CYGPKG_IO_SERIAL_LOOP { + alias { "Loop serial device drivers" + devs_serial_loop loop_serial_driver } + directory devs/serial/loop + script ser_loop.cdl + description "Loopback serial device driver." +} + +package CYGPKG_IO_FILEIO { + alias { "File IO" fileio io_file } + directory io/fileio + script fileio.cdl + description " + This package contains the infrastructure for doing POSIX compliant + file IO." +} + +package CYGPKG_FS_RAM { + alias { "RAM Filesystem" ramfs ram_fs fs_ram } + directory fs/ram + script ramfs.cdl + description " + This package contains a RAM resident filesystem." +} + +package CYGPKG_IO_ETH_DRIVERS { + alias { "Common ethernet support" net_drivers } + directory io/eth + script eth_drivers.cdl + description "Platform independent ethernet support." +} + package CYGPKG_NET { alias { "Networking" net } directory net/tcpip @@ -246,13 +326,6 @@ package CYGPKG_NET { description "Generic networking support, including TCP/IP." } -package CYGPKG_NET_ETH_DRIVERS { - alias { "Common ethernet support" net_drivers } - directory net/drivers/eth/common - script eth_drivers.cdl - description "Platform independent ethernet support." -} - package CYGPKG_SNMPLIB { alias { "SNMP library" snmplib } directory net/snmp/lib @@ -290,6 +363,15 @@ package CYGPKG_DEVS_ETH_POWERPC_QUICC { script quicc_eth_drivers.cdl description "Ethernet driver for PowerPC QUICC (MPC8xx) based boards." } + +# Not sure whether this should be "hardware"; if so, it should be mentioned +# in all targets that can use it. +package CYGPKG_DEVS_ETH_CF { + alias { "PCMCIA (Compact Flash) ethernet drivers" cf_eth_drivers } + directory devs/eth/cf + script cf_eth_drivers.cdl + description "Ethernet drivers for PCMCIA (Compact Flash) cardss." +} package CYGPKG_IO_PCI { alias { "PCI configuration library" io_pci } directory io/pci @@ -390,6 +472,16 @@ other packages such as the device driver layer." } +package CYGPKG_MEMALLOC { + alias { "Dynamic memory allocation" memalloc malloc } + directory services/memalloc/common + script memalloc.cdl + description " +This package provides memory allocator infrastructure required for +dynamic memory allocators, including the ISO standard malloc +interface. It also contains some sample implementations." +} + package CYGPKG_UITRON { alias { "uITRON compatibility" uitron } directory compat/uitron @@ -400,15 +492,121 @@ eCos supports a uITRON Compatibility Lay many Level E (Extended) features. uITRON is the premier Japanese embedded RTOS standard." } + +package CYGPKG_ISOINFRA { + alias { "ISO C and POSIX infrastructure" isoinfra } + directory isoinfra + script isoinfra.cdl + description " +eCos supports implementations of ISO C libraries and POSIX implementations. +This package provides infrastructure used by all such implementations." +} + +package CYGPKG_POSIX { + alias { "POSIX compatibility" posix } + directory compat/posix + script posix.cdl + description " +This package enables compatibility with the ISO/IEEE 1003.1 POSIX +standard. This allows the user application to use a well known +standard API, and starts a thread to invoke the user function +main()" +} + package CYGPKG_LIBC { alias { "C library" libc clib clibrary } - directory language/c/libc + directory language/c/libc/common script libc.cdl description " -This package enables compatibility with the ISO C standard - ISO/IEC -9899:1990. This allows the user application to use well known standard -C library functions, and in eCos starts a thread to invoke the user -function main()" +The packages under this package enable compatibility with the ISO C +standard - ISO/IEC 9899:1990. This allows the user application to use +well known standard C library functions, and in eCos starts a thread +to invoke the user function main(). This package is a top-level placeholder +to contain the implementations." +} + +package CYGPKG_LIBC_I18N { + alias { "ISO C library internationalization" libc_i18n } + directory language/c/libc/i18n + script i18n.cdl + description " +This package provides internationalization functions specified by the +ISO C standard - ISO/IEC 9899:1990." +} + +package CYGPKG_LIBC_SETJMP { + alias { "ISO C library non-local jumps" libc_setjmp } + directory language/c/libc/setjmp + script setjmp.cdl + description " +This package provides non-local jump functionality specified by the +ISO C standard - ISO/IEC 9899:1990." +} + +package CYGPKG_LIBC_SIGNALS { + alias { "ISO C library signals" libc_signals } + directory language/c/libc/signals + script signals.cdl + description " +This component controls signal functionality, as implemented in +ISO/IEC 9899:1990 chapter 7.7 with the signal() and raise() functions. +As well as allowing a program to send itself signals, it is also +possible to cause hardware exceptions to be signalled to the program +in a similar way." +} + +package CYGPKG_LIBC_STARTUP { + alias { "ISO environment startup/termination" libc_startup } + directory language/c/libc/startup + script startup.cdl + description " + This package manages the control of the + environment (in the general sense) that an + application would require for full ISO C / POSIX + compatibility, including a main() entry point + supplied with arguments and an environment + (as retrievable by the getenv() function). + It also includes at the other end of things, + what happens when main() returns or exit() is + called." +} + +package CYGPKG_LIBC_STDIO { + alias { "ISO C library standard input/output functions" libc_stdio } + directory language/c/libc/stdio + script stdio.cdl + description " +This package provides standard input/output functions associated +with the header file as specified by the +ISO C standard - ISO/IEC 9899:1990." +} + +package CYGPKG_LIBC_STDLIB { + alias { "ISO C library general utility functions" libc_stdlib } + directory language/c/libc/stdlib + script stdlib.cdl + description " +This package provides general utility functions associated +with the header file as specified by the +ISO C standard - ISO/IEC 9899:1990." +} + +package CYGPKG_LIBC_STRING { + alias { "ISO C library string functions" libc_string } + directory language/c/libc/string + script string.cdl + description " +This package provides string functions specified by the ISO C standard +- ISO/IEC 9899:1990." +} + +package CYGPKG_LIBC_TIME { + alias { "ISO C library date/time functions" libc_time } + directory language/c/libc/time + script time.cdl + description " +This package provides date and time manipulation functionality specified +by the ISO C standard - ISO/IEC 9899:1990." } package CYGPKG_LIBM { @@ -431,7 +629,7 @@ codes in a common way, rather than each conventions for error/status reporting. The error codes are modelled on the POSIX style naming e.g. EINVAL etc. This package also provides the standard strerror() function to convert error codes to textual -representation." +representation, as well as an implementation of the errno idiom." } package CYGPKG_CYGMON { alias { "CygMon support via eCos" cygmon } @@ -442,6 +640,15 @@ package CYGPKG_CYGMON { using eCos as the underlying board support mechanism." } +package CYGPKG_REDBOOT { + alias { "RedBoot, the Red Hat bootstrap" cygmon } + directory redboot + script redboot.cdl + description " + This package creates the RedBoot \[stand-alone bootstrap & debug monitor\] + using eCos as the underlying board support mechanism." +} + # -------------------------------------------------------------------------- # ARM packages package CYGPKG_HAL_ARM { @@ -940,6 +1147,7 @@ target ebsa285 { CYGPKG_DEVS_ETH_ARM_EBSA285 CYGPKG_IO_SERIAL_ARM_EBSA285 CYGPKG_DEVICES_WATCHDOG_ARM_EBSA285 + CYGPKG_DEVS_FLASH_EBSA285 } description " The ebsa285 target provides the packages needed to run @@ -952,6 +1160,7 @@ target assabet { CYGPKG_HAL_ARM_SA11X0 CYGPKG_HAL_ARM_SA11X0_ASSABET CYGPKG_IO_SERIAL_ARM_SA11X0 + CYGPKG_DEVS_PCMCIA_ASSABET } description " The assabet target provides the packages needed to run @@ -975,6 +1184,7 @@ target edb7xxx { CYGPKG_HAL_ARM_EDB7XXX CYGPKG_DEVS_ETH_ARM_EDB7XXX CYGPKG_IO_SERIAL_ARM_EDB7XXX + CYGPKG_DEVS_FLASH_EDB7XXX } description " The edb7xxx target provides the packages needed to run eCos on Cirrus Logic development boards." diff --git a/packages/error/current/ChangeLog b/packages/error/current/ChangeLog --- a/packages/error/current/ChangeLog +++ b/packages/error/current/ChangeLog @@ -1,3 +1,38 @@ +2000-06-19 Nick Garnett + + * include/errno.h (errno): Added extern modifier to non-per-thread + instance of errno. + +2000-06-07 Nick Garnett + + * src/strerror.cxx: + * include/codes.h: Added ESPIPE. + +2000-06-02 Nick Garnett + + * include/codes.h: + * src/strerror.cxx: Added some more codes. + +2000-05-31 Nick Garnett + + * src/strerror.cxx: + * include/codes.h: Added EXDEV. + +2000-05-20 Jonathan Larmour + + * include/codes.h: Add EDEADLOCK synonym for EDEADLK + Add ENFILE + * src/strerror.cxx: Add blurb for ENFILE, ENOSPC, EDEADLK and ENOTSUP + +2000-05-02 Jonathan Larmour + + * include/codes.h: No need to conditionalize codes on CYGPKG_NET + Tidy a bit. + * src/errno.cxx: Move here from libc. Use kernel constant + per-thread data slot, not a dynamic one. Generally tidy. + * src/strerror.cxx: No need to conditionalize codes on CYGPKG_NET. + Tidy a bit. + 2000-03-31 Nick Garnett * include/codes.h: Added some further codes. diff --git a/packages/error/current/cdl/error.cdl b/packages/error/current/cdl/error.cdl --- a/packages/error/current/cdl/error.cdl +++ b/packages/error/current/cdl/error.cdl @@ -31,10 +31,10 @@ # ==================================================================== ######DESCRIPTIONBEGIN#### # -# Author(s): bartv +# Author(s): bartv,jlarmour # Original data: jlarmour -# Contributors: -# Date: 1999-06-13 +# Contributors: +# Date: 2000-04-14 # #####DESCRIPTIONEND#### # @@ -42,8 +42,10 @@ cdl_package CYGPKG_ERROR { display "Common error code support" - compile strerror.cxx + compile strerror.cxx errno.cxx include_dir cyg/error + implements CYGINT_ISO_ERRNO_CODES + requires { CYGBLD_ISO_ERRNO_CODES_HEADER == "" } description " This package contains the common list of error and status codes. It is held centrally to allow @@ -53,11 +55,94 @@ cdl_package CYGPKG_ERROR { reporting. The error codes are modelled on the POSIX style naming e.g. EINVAL etc. This package also provides the standard strerror() function to - convert error codes to textual representation." + convert error codes to textual representation, as + well as an implementation of the errno idiom." + +# ==================================================================== +# ERRNO OPTIONS + + cdl_component CYGPKG_ERROR_ERRNO { + display "errno variable" + flavor bool + implements CYGINT_ISO_ERRNO + requires { CYGBLD_ISO_ERRNO_HEADER == "" } + default_value 1 + description " + This package controls the behaviour of the + errno variable (or more strictly, expression) + from ." + + cdl_option CYGSEM_ERROR_PER_THREAD_ERRNO { + display "Per-thread errno" + requires CYGVAR_KERNEL_THREADS_DATA + default_value 1 + description " + This option controls whether the standard error + code reporting variable errno is a per-thread + variable, rather than global." + } + + cdl_option CYGNUM_ERROR_ERRNO_TRACE_LEVEL { + display "Tracing level" + flavor data + legal_values 0 to 1 + default_value 0 + description " + Trace verbosity level for debugging the errno + retrieval mechanism in errno.cxx. Increase this + value to get additional trace output." + } + } + +# ==================================================================== +# STRERROR OPTIONS - define_proc { - puts $::cdl_header "/***** proc output start *****/" - puts $::cdl_header "#include " - puts $::cdl_header "/***** proc output end *****/" + cdl_option CYGPKG_ERROR_STRERROR { + display "strerror function" + flavor bool + implements CYGINT_ISO_STRERROR + requires { CYGBLD_ISO_STRERROR_HEADER == "" } + default_value 1 + description " + This package controls the presence and behaviour of the + strerror() function from " + } + +# ==================================================================== +# BUILD OPTIONS + cdl_component CYGPKG_ERROR_OPTIONS { + display "Error package build options" + flavor none + no_define + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_ERROR_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the error package. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_ERROR_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the error package. These flags are removed from + the set of global flags if present." + } } } + +# ==================================================================== +# EOF error.cdl diff --git a/packages/error/current/include/codes.h b/packages/error/current/include/codes.h --- a/packages/error/current/include/codes.h +++ b/packages/error/current/include/codes.h @@ -1,6 +1,6 @@ #ifndef CYGONCE_ERROR_CODES_H #define CYGONCE_ERROR_CODES_H -//=========================================================================== +/*=========================================================================== // // codes.h // @@ -33,149 +33,143 @@ //=========================================================================== //#####DESCRIPTIONBEGIN#### // -// Author(s): jlarmour -// Contributors: jlarmour -// Date: 1998-06-11 -// Purpose: To provide a common set of error codes -// Description: This provides a common set of error codes that all packages can -// agree on. It doesn't preclude them defining their own error -// return system, but this is a preferable system to use to help -// error support be as general as possible. -// -// We try and conform to the ANSI/POSIX error code format, namely -// starting with the character 'E' +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 2000-04-14 +// Purpose: To provide a common set of error codes +// Description: This provides a common set of error codes that all +// packages can agree on. It doesn't preclude them defining +// their own error return system, but this is a preferable +// system to use to help error support be as general as +// possible. // -// Usage: #include +// We try and conform to the ANSI/POSIX error code format, +// namely starting with the character 'E' // -// Example: +// Usage: #include +// +// Example: // -// err=myfun(); -// if (err != ENOERR) -// { -// str=strerror(err); -// printf("myfun returned error: %s\n", str); -// } -// else .... +// err=myfun(); +// if (err != ENOERR) +// { +// str=strerror(err); +// printf("myfun returned error: %s\n", str); +// } +// else .... // //####DESCRIPTIONEND#### // -//=========================================================================== +//=========================================================================*/ -// CONFIGURATION +/* CONFIGURATION */ #include // Configuration header -#include // externC -// Include the error package? -#ifdef CYGPKG_ERROR - +#ifdef __cplusplus +extern "C" { +#endif -// TYPE DEFINITIONS +/* TYPE DEFINITIONS */ -// A type for error codes which may be useful to explain the purpose of -// a variable or return code. It shows that it contains an error code -// of the type defined below +/* A type for error codes which may be useful to explain the purpose of + * a variable or return code. It shows that it contains an error code + * of the type defined below */ typedef int Cyg_ErrNo; -// FUNCTION PROTOTYPES - -// ANSI standard strerror() function as described by ANSI chap. 7.11.6.2. -// This is normally provided by - -externC char * -strerror( Cyg_ErrNo ); - -// prototype for the actual implementation. Equivalent to the above, but -// used internally by this product in preference - -externC char * -_strerror( Cyg_ErrNo ); - - -// CONSTANT DEFINITIONS - -// If adding to this list, you must also update strerror() with its text -// If there is a common error of the same purpose on Unix, try and use its -// name and number. If not, use one above 200 to prevent future conflicts -// -// Do not use negative numbers, so that functions can return positive on -// success and -ESOMETHING on error, and it all works consistently. +/* CONSTANT DEFINITIONS */ -#define ENOERR 0 // No error -#define EPERM 1 // Not permitted -#define ENOENT 2 // No such entity -#define ESRCH 3 // No such process -#define EINTR 4 // Operation interrupted -#define EIO 5 // I/O error -#define EBADF 9 // Bad file handle -#define EAGAIN 11 // Try again later -#define EWOULDBLOCK EAGAIN -#define ENOMEM 12 // Out of memory -#define EBUSY 16 // Resource busy -#define ENODEV 19 // No such device -#define EINVAL 22 // Invalid argument -#define EMFILE 24 // Too many open files -#define EDOM 33 // Argument to math function outside valid - // domain -#define ERANGE 34 // Math result cannot be represented -#define ENOSYS 38 // Function not implemented - -#define ENOTSUP 95 // POSIX not supported error - -#define EEOF 200 // End of file reached -#define ENOSUPP 201 // Operation not supported -#define EDEVNOSUPP 202 // Device does not support this operation +/* If adding to this list, you must also update strerror() with its text + * If there is a common error of the same purpose on Unix, try and use its + * name and number. If not, use one above 200 to prevent future conflicts + * + * Do not use negative numbers, so that functions can return positive on + * success and -ESOMETHING on error, and it all works consistently. +*/ -#define EDEADLK 301 // POSIX deadlock error - -#ifdef CYGPKG_NET -// Additional errors used by networking -#define ENXIO 300 // Device not configured -#define EACCES 301 // Permission denied -#define EEXIST 302 // File exists -#define ENOTTY 303 // Inappropriate ioctl for device -#define EPIPE 304 // Broken pipe - -// non-blocking and interrupt i/o -#define EINPROGRESS 310 // Operation now in progress -#define EALREADY 311 // Operation already in progress +#define ENOERR 0 /* No error */ +#define EPERM 1 /* Not permitted */ +#define ENOENT 2 /* No such entity */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Operation interrupted */ +#define EIO 5 /* I/O error */ +#define EBADF 9 /* Bad file handle */ +#define EAGAIN 11 /* Try again later */ +#define EWOULDBLOCK EAGAIN +#define ENOMEM 12 /* Out of memory */ +#define EBUSY 16 /* Resource busy */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* Too many open files in system */ +#define EMFILE 24 /* Too many open files */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EDOM 33 /* Argument to math function outside valid */ + /* domain */ +#define ERANGE 34 /* Math result cannot be represented */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define EDEADLOCK EDEADLK +#define ENOSYS 38 /* Function not implemented */ +#define ENAMETOOLONG 60 /* File name too long */ +#define ENOTSUP 95 /* Not supported error */ +#define EEOF 200 /* End of file reached */ +#define ENOSUPP 201 /* Operation not supported */ +#define EDEVNOSUPP 202 /* Device does not support this operation */ + +/* Additional errors used by networking */ +#define ENXIO 300 /* Device not configured */ +#define EACCES 301 /* Permission denied */ +#define EEXIST 302 /* File exists */ +#define ENOTTY 303 /* Inappropriate ioctl for device */ +#define EPIPE 304 /* Broken pipe */ -// ipc/network software -- argument errors -#define ENOTSOCK 320 // Socket operation on non-socket -#define EDESTADDRREQ 321 // Destination address required -#define EMSGSIZE 322 // Message too long -#define EPROTOTYPE 323 // Protocol wrong type for socket -#define ENOPROTOOPT 324 // Protocol not available -#define EPROTONOSUPPORT 325 // Protocol not supported -#define ESOCKTNOSUPPORT 326 // Socket type not supported -#define EOPNOTSUPP 327 // Operation not supported -#define EPFNOSUPPORT 328 // Protocol family not supported -#define EAFNOSUPPORT 329 // Address family not supported by protocol family -#define EADDRINUSE 330 // Address already in use -#define EADDRNOTAVAIL 331 // Can't assign requested address +/* non-blocking and interrupt i/o */ +#define EINPROGRESS 310 /* Operation now in progress */ +#define EALREADY 311 /* Operation already in progress */ + +/* ipc/network software -- argument errors */ +#define ENOTSOCK 320 /* Socket operation on non-socket */ +#define EDESTADDRREQ 321 /* Destination address required */ +#define EMSGSIZE 322 /* Message too long */ +#define EPROTOTYPE 323 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 324 /* Protocol not available */ +#define EPROTONOSUPPORT 325 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 326 /* Socket type not supported */ +#define EOPNOTSUPP 327 /* Operation not supported */ +#define EPFNOSUPPORT 328 /* Protocol family not supported */ +#define EAFNOSUPPORT 329 /* Address family not supported by */ + /* protocol family */ +#define EADDRINUSE 330 /* Address already in use */ +#define EADDRNOTAVAIL 331 /* Can't assign requested address */ -// ipc/network software -- operational errors -#define ENETDOWN 350 // Network is down -#define ENETUNREACH 351 // Network is unreachable -#define ENETRESET 352 // Network dropped connection on reset -#define ECONNABORTED 353 // Software caused connection abort -#define ECONNRESET 354 // Connection reset by peer -#define ENOBUFS 355 // No buffer space available -#define EISCONN 356 // Socket is already connected -#define ENOTCONN 357 // Socket is not connected -#define ESHUTDOWN 358 // Can't send after socket shutdown -#define ETOOMANYREFS 359 // Too many references: can't splice -#define ETIMEDOUT 360 // Operation timed out -#define ECONNREFUSED 361 // Connection refused +/* ipc/network software -- operational errors */ +#define ENETDOWN 350 /* Network is down */ +#define ENETUNREACH 351 /* Network is unreachable */ +#define ENETRESET 352 /* Network dropped connection on reset */ +#define ECONNABORTED 353 /* Software caused connection abort */ +#define ECONNRESET 354 /* Connection reset by peer */ +#define ENOBUFS 355 /* No buffer space available */ +#define EISCONN 356 /* Socket is already connected */ +#define ENOTCONN 357 /* Socket is not connected */ +#define ESHUTDOWN 358 /* Can't send after socket shutdown */ +#define ETOOMANYREFS 359 /* Too many references: can't splice */ +#define ETIMEDOUT 360 /* Operation timed out */ +#define ECONNREFUSED 361 /* Connection refused */ -#define EHOSTDOWN 364 // Host is down -#define EHOSTUNREACH 365 // No route to host -#endif // CYGPKG_NET +#define EHOSTDOWN 364 /* Host is down */ +#define EHOSTUNREACH 365 /* No route to host */ -#endif // ifdef CYGPKG_ERROR +#ifdef __cplusplus +} /* extern "C" */ +#endif -#endif // CYGONCE_ERROR_CODES_H multiple inclusion protection +#endif /* CYGONCE_ERROR_CODES_H multiple inclusion protection */ -// EOF codes.h +/* EOF codes.h */ diff --git a/packages/error/current/include/errno.h b/packages/error/current/include/errno.h new file mode 100644 --- /dev/null +++ b/packages/error/current/include/errno.h @@ -0,0 +1,89 @@ +#ifndef CYGONCE_ERROR_ERRNO_H +#define CYGONCE_ERROR_ERRNO_H +/*======================================================================== +// +// errno.h +// +// ISO C errno variable and constants +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 2000-04-14 +// Purpose: This file provides the errno variable (or more strictly +// expression) required by ISO C and POSIX 1003.1 +// Description: +// Usage: Do not include this file directly - use #include +// +//####DESCRIPTIONEND#### +// +//======================================================================*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +#ifdef CYGPKG_ERROR_ERRNO + +/* INCLUDES */ + +#include /* for Cyg_ErrNo */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* FUNCTION PROTOTYPES */ + + +#ifdef CYGSEM_ERROR_PER_THREAD_ERRNO + +extern Cyg_ErrNo * const +cyg_error_get_errno_p( void ) __attribute__((const)); + +#endif /* ifdef CYGSEM_ERROR_PER_THREAD_ERRNO */ + + +/* VARIABLES */ + +#ifdef CYGSEM_ERROR_PER_THREAD_ERRNO +# define errno (*cyg_error_get_errno_p()) /* Per-thread error status */ +#else +extern Cyg_ErrNo errno; /* Global error status */ +#endif /* ifdef CYGSEM_ERROR_PER_THREAD_ERRNO */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* ifdef CYGPKG_ERROR_ERRNO */ + +#endif /* CYGONCE_ERROR_ERRNO_H multiple inclusion protection */ + +/* EOF errno.h */ diff --git a/packages/error/current/include/strerror.h b/packages/error/current/include/strerror.h new file mode 100644 --- /dev/null +++ b/packages/error/current/include/strerror.h @@ -0,0 +1,82 @@ +#ifndef CYGONCE_ERROR_STRERROR_H +#define CYGONCE_ERROR_STRERROR_H +/*======================================================================== +// +// strerror.h +// +// ISO C strerror function +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 2000-04-14 +// Purpose: This file provides the strerror() function +// required by ISO C and POSIX 1003.1 +// Description: +// Usage: Do not include this file directly - use #include +// +//####DESCRIPTIONEND#### +// +//======================================================================*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#include /* for Cyg_ErrNo */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* FUNCTION PROTOTYPES */ + +/* Standard strerror() function as described by ISO C 1990 chap. 7.11.6.2. + * This is normally provided by + */ + +extern char * +strerror( Cyg_ErrNo ); + +/* prototype for the actual implementation. Equivalent to the above, but + * used internally by this product in preference + */ + +extern char * +__strerror( Cyg_ErrNo ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* CYGONCE_ERROR_STRERROR_H multiple inclusion protection */ + +/* EOF strerror.h */ diff --git a/packages/error/current/src/errno.cxx b/packages/error/current/src/errno.cxx new file mode 100644 --- /dev/null +++ b/packages/error/current/src/errno.cxx @@ -0,0 +1,112 @@ +//=========================================================================== +// +// errno.cxx +// +// ISO C and POSIX error code +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 2000-04-14 +// Purpose: Provide the errno variable +// Description: This file either provides the errno variable directly, +// or if thread-safe, using a kernel per-thread data +// access function +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include +#include // Configuration header + +#ifdef CYGPKG_ERROR_ERRNO + +// INCLUDES + +#include // Common project-wide type definitions +#include // Common tracing functions +#include // Header for this file + +#ifdef CYGSEM_ERROR_PER_THREAD_ERRNO +# include // kernel configuration +# include // per-thread data +# include // per-thread data +# include // mutexes +#endif + +// GLOBAL VARIABLES + +#ifndef CYGSEM_ERROR_PER_THREAD_ERRNO + +// errno is initialised to 0 at program startup - ANSI 7.1.4 +Cyg_ErrNo errno = 0; + +#else // ifndef CYGSEM_ERROR_PER_THREAD_ERRNO + +# if defined(CYGDBG_USE_TRACING) && defined(CYGNUM_ERROR_ERRNO_TRACE_LEVEL) +static int errno_trace = CYGNUM_ERROR_ERRNO_TRACE_LEVEL; +# define TL1 (0 < errno_trace) +# else +# define TL1 (0) +# endif + +// FUNCTIONS + +Cyg_ErrNo * const +cyg_error_get_errno_p( void ) +{ + Cyg_ErrNo *errno_p; + + CYG_REPORT_FUNCNAMETYPE( "cyg_error_get_errno_p", "&errno is %d"); + + // set up the thread data, allocating if necessary (even though the + // user _shouldn't_ read errno before its set, we can't stop them - and + // ANSI prescribes it has a sensible value (0) before its set too anyway. + + Cyg_Thread *self = Cyg_Thread::self(); + + errno_p = (Cyg_ErrNo *)self->get_data_ptr(CYGNUM_KERNEL_THREADS_DATA_ERRNO); + + CYG_TRACE1( TL1, "errno is %d", *errno_p ); + + CYG_REPORT_RETVAL( errno_p ); + + // return the internal data's errno + return errno_p; +} // cyg_error_get_errno_p() + +#endif // ifdef CYGSEM_ERROR_PER_THREAD_ERRNO + +#endif // ifdef CYGPKG_ERROR_ERRNO + +// EOF errno.cxx diff --git a/packages/error/current/src/strerror.cxx b/packages/error/current/src/strerror.cxx --- a/packages/error/current/src/strerror.cxx +++ b/packages/error/current/src/strerror.cxx @@ -31,12 +31,12 @@ //=========================================================================== //#####DESCRIPTIONBEGIN#### // -// Author(s): jlarmour -// Contributors: jlarmour -// Date: 1998-06-11 -// Purpose: To provide the strerror() implementation -// Description: This implements strerror() as described in ANSI chap 7.11.6.2 -// Usage: See +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: To provide the strerror() implementation +// Description: This implements strerror() as described in ANSI chap 7.11.6.2 +// Usage: See // //####DESCRIPTIONEND#### // @@ -47,9 +47,6 @@ #include // Configuration header -// Include the C library? -#ifdef CYGPKG_ERROR - // INCLUDES #include // Common project-wide type definitions @@ -60,16 +57,16 @@ // EXPORTED SYMBOLS externC char * -strerror( int errnum ) __attribute__ ((weak, alias("_strerror") )); +strerror( int errnum ) __attribute__ ((weak, alias("__strerror") )); // FUNCTIONS externC char * -_strerror( int errnum ) +__strerror( int errnum ) { register char *s; - CYG_REPORT_FUNCNAMETYPE( "_strerror", "String form of error is \"%s\"" ); + CYG_REPORT_FUNCNAMETYPE( "__strerror", "String form of error is \"%s\"" ); switch (errnum) { @@ -140,18 +137,60 @@ externC char * break; #endif +#ifdef ENOTDIR + case ENOTDIR: + s = "Not a directory"; + break; +#endif + +#ifdef EISDIR + case EISDIR: + s = "Is a directory"; + break; +#endif + #ifdef EINVAL case EINVAL: s = "Invalid argument"; break; #endif +#ifdef ENFILE + case ENFILE: + s = "Too many open files in system"; + break; +#endif + #ifdef EMFILE case EMFILE: s = "Too many open files"; break; #endif +#ifdef EFBIG + case EFBIG: + s = "File too large"; + break; +#endif + +#ifdef ENOSPC + case ENOSPC: + s = "No space left on device"; + break; +#endif + +#ifdef ESPIPE + case ESPIPE: + s = "Illegal seek"; + break; +#endif + +#ifdef EROFS + case EROFS: + s = "Read-only file system"; + break; +#endif + #ifdef EDOM case EDOM: s = "Argument to math function outside valid domain"; @@ -164,12 +203,30 @@ externC char * break; #endif +#ifdef EDEADLK + case EDEADLK: + s = "Resource deadlock would occur"; + break; +#endif + #ifdef ENOSYS case ENOSYS: s = "Function not implemented"; break; #endif +#ifdef ENAMETOOLONG + case ENAMETOOLONG: + s = "File name too long"; + break; +#endif + +#ifdef ENOTSUP + case ENOTSUP: + s = "Not supported"; + break; +#endif + #ifdef EEOF case EEOF: s = "End of file reached"; @@ -188,6 +245,12 @@ externC char * break; #endif +#ifdef EXDEV + case EXDEV: + s = "Improper link"; + break; +#endif + // Additional errors used by networking #ifdef ENXIO case ENXIO: @@ -364,8 +427,6 @@ externC char * CYG_REPORT_RETVAL(s); return s; -} // _strerror() - -#endif // ifdef CYGPKG_ERROR +} // __strerror() // EOF strerror.cxx diff --git a/packages/fs/ram/current/ChangeLog b/packages/fs/ram/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/fs/ram/current/ChangeLog @@ -0,0 +1,38 @@ +2000-08-18 Nick Garnett + + * cdl/ramfs.cdl: + * src/ramfs.c: + * tests/fileio1.c: + Created this example RAM filesystem both as a usable filesystem + and as an example of how to build filesystems for the fileio + infrastructure. + + + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== + + diff --git a/packages/fs/ram/current/cdl/ramfs.cdl b/packages/fs/ram/current/cdl/ramfs.cdl new file mode 100644 --- /dev/null +++ b/packages/fs/ram/current/cdl/ramfs.cdl @@ -0,0 +1,181 @@ +# ==================================================================== +# +# ramfs.cdl +# +# RAM Filesystem configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): nickg +# Original data: nickg +# Contributors: +# Date: 2000-08-01 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_FS_RAM { + display "RAM filesystem" + doc doc/index.html + include_dir cyg/ramfs + + requires CYGPKG_IO_FILEIO + + requires CYGPKG_ISOINFRA + requires CYGPKG_ERROR + requires CYGINT_ISO_ERRNO + requires CYGINT_ISO_ERRNO_CODES + + compile -library=libextras.a ramfs.c + + # ---------------------------------------------------------------------- + # Simple allocation mechanism using malloc() + + cdl_component CYGPKG_FS_RAM_SIMPLE { + display "Simple, malloc() based, implementation" + requires { CYGINT_ISO_MALLOC != 0 } + default_value 1 + active_if !CYGPKG_FS_RAM_BLOCKS + + cdl_option CYGNUM_RAMFS_REALLOC_INCREMENT { + display "Size of file data storage increment" + flavor data + default_value 256 + legal_values 64 to 32768 + description "This option controls the size of the increment to a file data + storage block." + } + + } + + # ---------------------------------------------------------------------- + # Block based allocation, using either malloc() or a private block + # pool. + + cdl_component CYGPKG_FS_RAM_BLOCKS { + display "Block-based RAM filesystem allocation" + default_value 0 + active_if !CYGPKG_FS_RAM_SIMPLE + + + cdl_option CYGNUM_RAMFS_BLOCK_SIZE { + display "Size of file data storage block" + flavor data + default_value 256 + legal_values 64 to 32768 + description "This option controls the size of a data storage block." + } + + cdl_option CYGNUM_RAMFS_BLOCKS_DIRECT { + display "Directly referenced data storage blocks" + flavor data + default_value 8 + legal_values 0 to 32 + description "This option controls the number of data storage blocks that + are referenced directly from a file or directory node." + } + + cdl_option CYGNUM_RAMFS_BLOCKS_INDIRECT1 { + display "Single level indirect data storage blocks" + flavor data + default_value 1 + legal_values 0 to 32 + description "This option controls the number of single level indirect storage + blocks that are referenced from a file or directory node." + } + + cdl_option CYGNUM_RAMFS_BLOCKS_INDIRECT2 { + display "Two level indirect data storage blocks" + flavor data + default_value 1 + legal_values 0 to 32 + description "This option controls the number of two level indirect storage + blocks that are referenced from a file or directory node." + } + + cdl_component CYGPKG_FS_RAM_BLOCKS_ARRAY { + display "Use block array rather than malloc()" + default_value 0 + description "This option controls whether the blocks are allocated from + an array of blocks rather from the heap using malloc()." + + cdl_option CYGPKG_FS_RAM_BLOCKS_ARRAY_EXTERN { + display "Block array is external" + default_value 0 + description "This option controls whether the block array is + defined by the RAMFS package or whether it is provided + by an external component. The latter option may be + useful when the RAM file system is to be put into a + special memory area." + } + + cdl_option CYGPKG_FS_RAM_BLOCKS_ARRAY_NAME { + display "Name of external block array" + active_if CYGPKG_FS_RAM_BLOCKS_ARRAY_EXTERN + flavor data + default_value "cyg_ramfs_block_array" + description "This option controls what the symbol name of the external + block array will be." + } + + cdl_option CYGNUM_FS_RAM_BLOCKS_ARRAY_SIZE { + display "Size of blocks array" + flavor data + default_value 128 + legal_values 1 to 9999999999 + description "The number of blocks in the array. The total size of + the array will be this value times the block size." + } + } + } + + cdl_option CYGNUM_RAMFS_DIRENT_SIZE { + display "Directory entry size" + flavor data + default_value 32 + legal_values 16 to { CYGNUM_RAMFS_BLOCK_SIZE ? CYGNUM_RAMFS_BLOCK_SIZE : 128 } + description "This option controls the number of two level indirect storage + blocks that are referenced from a file or directory node." + } + + # ---------------------------------------------------------------- + # Tests + + cdl_option CYGPKG_FS_RAM_TESTS { + display "RAM FS tests" + flavor data + no_define + calculated { "tests/fileio1.c" } + description " + This option specifies the set of tests for the RAM FS package." + } + +} + +# End of ramfs.cdl \ No newline at end of file diff --git a/packages/fs/ram/current/src/ramfs.c b/packages/fs/ram/current/src/ramfs.c new file mode 100644 --- /dev/null +++ b/packages/fs/ram/current/src/ramfs.c @@ -0,0 +1,2386 @@ +//========================================================================== +// +// ramfs.c +// +// RAM file system +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-07-25 +// Purpose: RAM file system +// Description: This is a RAM filesystem for eCos. It attempts to +// provide full POSIX-compatible filesystem behaviour +// while at the same time being efficient in terms of +// time and space used. +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== +// +// General Description +// =================== +// +// This is an implementation of a RAM filesystem for eCos. Its goal is +// to provide a working example of a filesystem that provides most of +// the required POSIX functionality. And obviously it may also be +// useful in its own right. +// +// +// Nodes +// ----- +// +// All files and directories are represented by node objects. Each +// ramfs_node structure contains the following fields: +// +// mode - Node type, file or directory. +// refcnt - Number of references to this node. For files each open counts as +// a reference and for directories a node is referenced when it is made +// current directory, or is opened for reading. +// nlink - Number of links to this node. Each directory entry that references +// this node is a link. +// size - Size of the data in this node in bytes. +// atime - Last time this node was accessed. +// mtime - Last time the data in this node was modified. +// ctime - Last time the status information in this node was changed. +// +// The data storage in a node is controlled by the configuration and +// can take two forms. These will be described later. +// +// Directories +// ----------- +// +// A directory is a node whose data is a list of directory entries. To +// simplify management of these, long directory entries are split into +// a chain of fixed size ramfs_dirent structures. These contain the +// following fields: +// +// node - Pointer to node referenced by this entry. This is present in +// every directory entry fragment +// inuse - Set to 1 if this entry is in use, zero if it is free. +// first - Set to 1 if this is the first fragment of a directory entry. +// last - Set to 1 if this is the last fragment of a directory entry. +// namelen - The size of the whole file name. +// fraglen - The number of bytes of the file name that are stored in this +// fragment. +// next - The offset of the next fragment of this directory entry. +// name - The characters of the fragment of the file name stored in this +// entry. +// +// Small file names are stored in a single fragment. Longer names are +// stored in a chain of fragments. +// +// Data Storage +// ------------ +// +// Two data storage mechanisms may be configured, the SIMPLE and the +// BLOCKS mechanisms. +// +// SIMPLE Data Storage +// ~~~~~~~~~~~~~~~~~~~ +// +// This mechanism simply uses malloc() and free() to allocate the +// memory for both nodes and file data. File data is stored in a +// single malloced vector that is realloced as necessary to acquire +// more space. +// +// The advantage of this approach is that the RAM filesystem only uses +// as much memory as it needs, the rest is available for use by other +// components. It also requires much simpler data structures and code +// in the filesystem to manage. However, if any files get to be a +// significant proportion of the size of the heap, there is the danger +// that fragmentation will prevent any further extension of some +// files, even if there is enough memory in total. It also requires an +// implementation of malloc() to be present. If this needs to be +// present for other components,then this is not a significant +// overhead, but including it just for use by this filesystem +// represents a major addition of code and data structures. +// +// +// BLOCKS Data Storage +// ~~~~~~~~~~~~~~~~~~~ +// +// This mechanism divides the memory used for file storage into fixed +// sized blocks. These blocks may either be allocated using +// malloc()/free(), or may be obtained from a array of blocks reserved +// for the purpose. Configuration allows the block size to be +// selected, as well as the allocation mechanism, and in the case of a +// block array, whether it is defined here or by an external +// component. +// +// Data storage in nodes is arranges in three arrays of pointers to +// blocks. The first array points directly to data blocks, the second +// to blocks which themselves contain pointers to data blocks, and the +// third to blocks which contain pointers to blocks which contain +// pointers to data blocks. In the default configuration These last +// two arrays have only one element each. +// +// The following shows how the data is arranged in a fully populated +// file with a 256 byte block size using the default configuration. +// +// Node +// ~ ~ +// | | +// | | +// +------------+ +// | *------+--------> data block 0 +// +------------+ +// | *------+--------> data block 1 +// +------------+ +// | *------+--------> data block 2 +// +------------+ +// | *------+--------> data block 3 +// +------------+ +// | *------+--------> data block 4 +// +------------+ +// | *------+--------> data block 5 +// +------------+ +// | *------+--------> data block 6 +// +------------+ +// | *------+--------> data block 7 +// +------------+ +// | *------+--------> +------------+ +// +------------+ | *------+--------> data block 8 +// | *------+----+ +------------+ +// +------------+ | | | +// | ~ ~ +// | | | +// | +------------+ +// | | *------+--------> data block 71 +// | +------------+ +// | +// +---->+------------+ +------------+ +// | *------+-------->| *------+---->data block 72 +// +------------+ +------------+ +// | | | | +// ~ ~ ~ ~ +// | | | | +// +------------+ +------------+ +// | *------+---+ | *------+----> data block 135 +// +------------+ | +------------+ +// | +// | +------------+ +// +---->| *------+----> data block 4104 +// +------------+ +// | | +// ~ ~ +// | | +// +------------+ +// | *------+----> data block 4167 +// +------------+ +// +// +// +// The advantages of this approach are that, first, memory usage is +// divided into discreet fixed size blocks which are easier to +// manage. When using malloc() to allocate them, they will fit into +// any free memory of at least the right size. Using the block array +// option removes the need to have a malloc() implementation at all. +// +// The disadvantages of this mechanism are that, first, when using +// malloc() to allocate blocks, the per-block memory allocator +// overhead is paid for each block, rather than per file. This may +// result in less memory overall being available for data +// storage. When using the block array, it is permanently reserved for +// use by the ram filesystem, and is not available for use by other +// components. +// +//========================================================================== + +#include +#include +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include + +//========================================================================== +// Sizes derived from configuration + +// ------------------------------------------------------------------------- +// Simple malloc based allocator parameters + +#ifdef CYGPKG_FS_RAM_SIMPLE + +#define RAMFS_FILESIZE_MAX UINT_MAX + +#else + +// ------------------------------------------------------------------------- +// Block allocator parameters + +// The number of nodes per block +#define RAMFS_NODES_PER_BLOCK (CYGNUM_RAMFS_BLOCK_SIZE/sizeof(ramfs_node)) + +// The number of indirect pointers that can be stored in a single data block +#define RAMFS_INDIRECT_PER_BLOCK (CYGNUM_RAMFS_BLOCK_SIZE/sizeof(ramfs_block *)) + +// The number of directory entries that can be stored in a single data block +#define RAMFS_DIRENT_PER_BLOCK (CYGNUM_RAMFS_BLOCK_SIZE/sizeof(ramfs_dirent)) + +// Number of bytes contained in a one level indirect block +#define RAMFS_INDIRECT1_BLOCK_EXTENT (RAMFS_INDIRECT_PER_BLOCK* \ + CYGNUM_RAMFS_BLOCK_SIZE) + +// number of bytes contained in a two level indirect block +#define RAMFS_INDIRECT2_BLOCK_EXTENT (RAMFS_INDIRECT_PER_BLOCK* \ + RAMFS_INDIRECT_PER_BLOCK* \ + CYGNUM_RAMFS_BLOCK_SIZE) + +// The maximum data offset for data directly accessed from the node +#define RAMFS_DIRECT_MAX (CYGNUM_RAMFS_BLOCKS_DIRECT*CYGNUM_RAMFS_BLOCK_SIZE) + +// The maximum data offset for data accessed from the single level indirect blocks +#define RAMFS_INDIRECT1_MAX (RAMFS_DIRECT_MAX+ \ + (CYGNUM_RAMFS_BLOCKS_INDIRECT1* \ + RAMFS_INDIRECT1_BLOCK_EXTENT)) + +// The maximum data offset for data accessed from the two level indirect blocks +#define RAMFS_INDIRECT2_MAX (RAMFS_INDIRECT1_MAX+ \ + (CYGNUM_RAMFS_BLOCKS_INDIRECT2* \ + RAMFS_INDIRECT2_BLOCK_EXTENT)) + +// The maximum size of a file +#define RAMFS_FILESIZE_MAX RAMFS_INDIRECT2_MAX + +#endif + +//========================================================================== +// Forward definitions + +// Filesystem operations +static int ramfs_mount ( cyg_fstab_entry *fste, cyg_mtab_entry *mte ); +static int ramfs_umount ( cyg_mtab_entry *mte ); +static int ramfs_open ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int mode, cyg_file *fte ); +static int ramfs_unlink ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +static int ramfs_mkdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +static int ramfs_rmdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +static int ramfs_rename ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2 ); +static int ramfs_link ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2, int type ); +static int ramfs_opendir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_file *fte ); +static int ramfs_chdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_dir *dir_out ); +static int ramfs_stat ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + struct stat *buf); +static int ramfs_getinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ); +static int ramfs_setinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ); + +// File operations +static int ramfs_fo_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +static int ramfs_fo_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +static int ramfs_fo_lseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence ); +static int ramfs_fo_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com, + CYG_ADDRWORD data); +static int ramfs_fo_fsync (struct CYG_FILE_TAG *fp, int mode ); +static int ramfs_fo_close (struct CYG_FILE_TAG *fp); +static int ramfs_fo_fstat (struct CYG_FILE_TAG *fp, struct stat *buf ); +static int ramfs_fo_getinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ); +static int ramfs_fo_setinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ); + +// Directory operations +static int ramfs_fo_dirread (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +static int ramfs_fo_dirlseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence ); + + +//========================================================================== +// Filesystem table entries + +// ------------------------------------------------------------------------- +// Fstab entry. +// This defines the entry in the filesystem table. +// For simplicity we use _FILESYSTEM synchronization for all accesses since +// we should never block in any filesystem operations. + +FSTAB_ENTRY( ramfs_fste, "ramfs", 0, + CYG_SYNCMODE_FILE_FILESYSTEM|CYG_SYNCMODE_IO_FILESYSTEM, + ramfs_mount, + ramfs_umount, + ramfs_open, + ramfs_unlink, + ramfs_mkdir, + ramfs_rmdir, + ramfs_rename, + ramfs_link, + ramfs_opendir, + ramfs_chdir, + ramfs_stat, + ramfs_getinfo, + ramfs_setinfo); + +// ------------------------------------------------------------------------- +// File operations. +// This set of file operations are used for normal open files. + +static cyg_fileops ramfs_fileops = +{ + ramfs_fo_read, + ramfs_fo_write, + ramfs_fo_lseek, + ramfs_fo_ioctl, + cyg_fileio_seltrue, + ramfs_fo_fsync, + ramfs_fo_close, + ramfs_fo_fstat, + ramfs_fo_getinfo, + ramfs_fo_setinfo +}; + +// ------------------------------------------------------------------------- +// Directory file operations. +// This set of operations are used for open directories. Most entries +// point to error-returning stub functions. Only the read, lseek and +// close entries are functional. + +static cyg_fileops ramfs_dirops = +{ + ramfs_fo_dirread, + (cyg_fileop_write *)cyg_fileio_enosys, + ramfs_fo_dirlseek, + (cyg_fileop_ioctl *)cyg_fileio_enosys, + cyg_fileio_seltrue, + (cyg_fileop_fsync *)cyg_fileio_enosys, + ramfs_fo_close, + (cyg_fileop_fstat *)cyg_fileio_enosys, + (cyg_fileop_getinfo *)cyg_fileio_enosys, + (cyg_fileop_setinfo *)cyg_fileio_enosys +}; + +//========================================================================== +// Data typedefs +// Some forward typedefs for the main data structures. + +struct ramfs_node; +typedef struct ramfs_node ramfs_node; + +struct ramfs_dirent; +typedef struct ramfs_dirent ramfs_dirent; + +#ifndef CYGPKG_FS_RAM_SIMPLE + +typedef cyg_uint8 ramfs_block[CYGNUM_RAMFS_BLOCK_SIZE]; + +#endif + +//========================================================================== +// File and directory node +// This data structure represents a file or directory. + +struct ramfs_node +{ + mode_t mode; // node type + cyg_ucount32 refcnt; // open file/current dir references + nlink_t nlink; // number of links to this node + size_t size; // size of file in bytes + time_t atime; // last access time + time_t mtime; // last modified time + time_t ctime; // last changed status time + +#ifdef CYGPKG_FS_RAM_SIMPLE + + // The data storage in this case consists of a single + // malloced memory block, together with its size. + + size_t datasize; // size of data block + cyg_uint8 *data; // malloced data buffer + +#else + + // The data storage in this case consists of arrays of pointers + // to data blocks. + +#if CYGNUM_RAMFS_BLOCKS_DIRECT > 0 + // Directly accessible blocks from the inode. + ramfs_block *direct[CYGNUM_RAMFS_BLOCKS_DIRECT]; +#endif +#if CYGNUM_RAMFS_BLOCKS_INDIRECT1 > 0 + // Single level indirection + ramfs_block **indirect1[CYGNUM_RAMFS_BLOCKS_INDIRECT1]; +#endif +#if CYGNUM_RAMFS_BLOCKS_INDIRECT2 > 0 + // Two level indirection + ramfs_block ***indirect2[CYGNUM_RAMFS_BLOCKS_INDIRECT2]; +#endif + +#endif + +}; + +//========================================================================== +// Directory entry. +// Fixed sized entry containing a fragment of the name of a file/directory. + +struct ramfs_dirent +{ + ramfs_node *node; // pointer to node + unsigned int inuse:1, // entry in use? + first:1, // first directory entry fragment? + last:1, // last directory entry fragment? + namelen:8, // bytes in whole name + fraglen:8; // bytes in name fragment + off_t next; // offset of next dirent + + // Name fragment, fills rest of entry. + char name[CYGNUM_RAMFS_DIRENT_SIZE- + sizeof(ramfs_node *)- + sizeof( cyg_uint32)- + sizeof(off_t)]; +}; + +//========================================================================== +// Directory search data +// Parameters for a directory search. The fields of this structure are +// updated as we follow a pathname through the directory tree. + +struct ramfs_dirsearch +{ + ramfs_node *dir; // directory to search + const char *path; // path to follow + ramfs_node *node; // Node found + const char *name; // last name fragment used + int namelen; // name fragment length + cyg_bool last; // last name in path? +}; + +typedef struct ramfs_dirsearch ramfs_dirsearch; + +//========================================================================== +// Forward defs + +static int del_direntry( ramfs_node *dir, const char *name, int namelen ); + + +//========================================================================== +// Block array +// This is used for block allocation when malloc is not being used. + +#ifdef CYGPKG_FS_RAM_BLOCKS_ARRAY + +# ifdef CYGPKG_FS_RAM_BLOCKS_ARRAY_EXTERN + +// Array is defined externally with a user-supplied name + +__externC ramfs_block CYGPKG_FS_RAM_BLOCKS_ARRAY_NAME[CYGNUM_FS_RAM_BLOCKS_ARRAY_SIZE]; + +// Translate into a usable common name +#define ramfs_block_array CYGPKG_FS_RAM_BLOCKS_ARRAY_NAME + +# else + +// Array is defined here + +static ramfs_block cyg_ramfs_block_array[CYGNUM_FS_RAM_BLOCKS_ARRAY_SIZE]; + +#define ramfs_block_array cyg_ramfs_block_array + +# endif + +// Pointer to list of free blocks +static ramfs_block *block_free_list = NULL; + +#endif + +//========================================================================== +// Block allocation + +#ifndef CYGPKG_FS_RAM_SIMPLE + +// ------------------------------------------------------------------------- +// block_init() +// Initialize the block allocator by chaining them all together on +// block_free_list. + +#ifdef CYGPKG_FS_RAM_BLOCKS_ARRAY + +static void block_init() +{ + static cyg_bool initialized = false; + int i; + + if( !initialized ) + { + for( i = 0; i < CYGNUM_FS_RAM_BLOCKS_ARRAY_SIZE; i++ ) + { + ramfs_block *b = &ramfs_block_array[i]; + *(ramfs_block **)b = block_free_list; + block_free_list = b; + } + initialized = true; + } +} + +#endif + +// ------------------------------------------------------------------------- +// block_alloc() +// Allocate a block for data storage. +// If we have a block array, just pick the first off the free list. +// If we are mallocing, call malloc() to get it. + +static ramfs_block *block_alloc(void) +{ + ramfs_block *b; + +#ifdef CYGPKG_FS_RAM_BLOCKS_ARRAY + + block_init(); // Check blocks are initialized + + // pick first block off free list. + b = block_free_list; + + // and advance list + if( b != NULL ) + block_free_list = *(ramfs_block **)b; + +#else + + b = malloc(CYGNUM_RAMFS_BLOCK_SIZE); + +#endif + + // Clear the block to zero if it was allocated + if( b != NULL ) + memset( b, 0, CYGNUM_RAMFS_BLOCK_SIZE ); + + return b; + +} + +// ------------------------------------------------------------------------- +// block_free() +// Free a block. Depending on the configuration send it back to the +// heap or put it back on free list. + +static void block_free( ramfs_block *b ) +{ +#ifdef CYGPKG_FS_RAM_BLOCKS_ARRAY + + // Put the block back on the free list + + *(ramfs_block **)b = block_free_list; + block_free_list = b; + +#else + + // Call free() to return it to the memory pool + + free( b ); + +#endif +} + +#endif + +//========================================================================== +// Node buffer management +// There are two versions of this, one for the _SIMPLE variant and one for +// the _BLOCKS variant. In both cases the interface to this code is via the +// findbuffer_node() and freebuffer_node() functions. + +#ifdef CYGPKG_FS_RAM_SIMPLE + +//========================================================================== +// SIMPLE buffer management. +// Each node has a data buffer pointer and a size. This buffer is +// realloc()ed as needed. + +// ------------------------------------------------------------------------- +// findbuffer_node() +// return a pointer to the data at the indicated file position, extending +// the buffer if required. + +static int findbuffer_node( ramfs_node *node, // node pointer + off_t pos, // data position to get + cyg_uint8 **buffer, // returned buffer pointer + size_t *size, // returned buffer size + cyg_bool alloc) // extend allocation? +{ + if( alloc && (pos == node->datasize || node->datasize == 0) ) + { + // If we are allowed to alloc new data, and we are at the end of the + // current data allocation, or there is no data present, allocate or + // extend the data buffer. + + cyg_uint8 *newdata; + + if( node->data == NULL ) + newdata = malloc( CYGNUM_RAMFS_REALLOC_INCREMENT ); + else + newdata = realloc( node->data, pos+CYGNUM_RAMFS_REALLOC_INCREMENT ); + + if( newdata == NULL ) return ENOSPC; + else memset( newdata+pos, 0, CYGNUM_RAMFS_REALLOC_INCREMENT ); + + node->data = newdata; + node->datasize = pos+CYGNUM_RAMFS_REALLOC_INCREMENT; + } + else if( pos > node->datasize ) + { + // Indicate end of data. + *size = 0; + return ENOERR; + } + + *buffer = node->data+pos; + *size = node->datasize-pos; + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// freebuffer_node() +// Empty out the data storage from the node. + +static int freebuffer_node( ramfs_node *node ) +{ + if( node->data != NULL ) + { + free( node->data ); + } + + node->data = NULL; + node->datasize = 0; + + return ENOERR; +} + +//========================================================================== + +#else + +//========================================================================== +// _BLOCKS storage management. +// Data storage in the node is by means of a set of arrays of pointers to +// blocks. The first array points directly to the data blocks. Subsequent +// arrays point to single and double indirect blocks respectively. + +// ------------------------------------------------------------------------- +// findbuffer_direct() +// Indexes into an array of block pointers and extracts a pointer to the +// data at offset _pos_, allocating new blocks if required. + +static int findbuffer_direct( off_t pos, + ramfs_block **blocks, + int nblocks, + cyg_uint8 **buffer, + size_t *size, + cyg_bool alloc) +{ + int bi = pos / CYGNUM_RAMFS_BLOCK_SIZE; + int bpos = pos % CYGNUM_RAMFS_BLOCK_SIZE; + ramfs_block *b; + + *buffer = NULL; + *size = 0; + + if( bi > nblocks ) + return ENOERR; + + b = blocks[bi]; + + if( b == NULL ) + { + // There is no block there. If _alloc_ is true we can fill the + // slot in with a new block. If it is false, we indicate end of + // data with a zero size result. + if( alloc ) + { + b = block_alloc(); + if( b == NULL ) + return ENOSPC; + blocks[bi] = b; + } + else return ENOERR; + } + + *buffer = &((*b)[bpos]); + *size = CYGNUM_RAMFS_BLOCK_SIZE - bpos; + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// findbuffer_indirect1() +// Indexes into an array of pointers to blocks containing pointers to +// blocks and extracts a pointer to the data at offset _pos_, +// allocating new blocks if required. + +#if CYGNUM_RAMFS_BLOCKS_INDIRECT1 > 0 + +static int findbuffer_indirect1( off_t pos, + ramfs_block ***blocks, + int nblocks, + cyg_uint8 **buffer, + size_t *size, + cyg_bool alloc) +{ + + int bi = pos / RAMFS_INDIRECT1_BLOCK_EXTENT; + int bpos = pos % RAMFS_INDIRECT1_BLOCK_EXTENT; + int err; + cyg_uint8 *b; + size_t sz; + + // Use findbuffer_direct() to index and allocate + // the first level indirect block. + + err = findbuffer_direct( bi, + (ramfs_block **)blocks, + nblocks, + &b, + &sz, + alloc); + + if( err != ENOERR ) + return err; + + if( sz == 0 ) + { + *size = 0; + return ENOERR; + } + + // Use findbuffer_direct() on the first level indirect + // block to allocate and return the data pointer. + + return findbuffer_direct( bpos, + blocks[bi], + RAMFS_INDIRECT_PER_BLOCK, + buffer, + size, + alloc); +} + +#endif + +// ------------------------------------------------------------------------- +// findbuffer_indirect1() +// Indexes into an array of pointers to blocks containing pointers to +// blocks containing pointers to blocks (!) and extracts a pointer to +// the data at offset _pos_, allocating new blocks if required. + +#if CYGNUM_RAMFS_BLOCKS_INDIRECT2 > 0 + +static int findbuffer_indirect2( off_t pos, + ramfs_block ****blocks, + int nblocks, + cyg_uint8 **buffer, + size_t *size, + cyg_bool alloc) +{ + int bi = pos / RAMFS_INDIRECT2_BLOCK_EXTENT; + int bpos = pos % RAMFS_INDIRECT2_BLOCK_EXTENT; + int err; + cyg_uint8 *b; + size_t sz; + + // Use findbuffer_direct() to index and allocate + // the first level indirect block. + + err = findbuffer_direct( bi, + (ramfs_block **)blocks, + nblocks, + &b, + &sz, + alloc); + + if( err != ENOERR ) + return err; + + if( sz == 0 ) + { + *size = 0; + return ENOERR; + } + + // Use findbuffer_indirect1() on the first level indirect block to + // index and allocate the next level indirect block and the data + // block. + + return findbuffer_indirect1( bpos, + blocks[bi], + RAMFS_INDIRECT_PER_BLOCK, + buffer, + size, + alloc); +} + +#endif + +// ------------------------------------------------------------------------- +// findbuffer_node() +// Depending on the offset and configuration, call the appropriate +// function to get the buffer pointer. + +static int findbuffer_node( ramfs_node *node, + off_t pos, + cyg_uint8 **buffer, + size_t *size, + cyg_bool alloc) +{ +#if CYGNUM_RAMFS_BLOCKS_DIRECT > 0 + if( pos < RAMFS_DIRECT_MAX ) + return findbuffer_direct( pos, + node->direct, + CYGNUM_RAMFS_BLOCKS_DIRECT, + buffer, + size, + alloc); +#endif +#if CYGNUM_RAMFS_BLOCKS_INDIRECT1 > 0 + if( pos < RAMFS_INDIRECT1_MAX ) + return findbuffer_indirect1( pos - RAMFS_DIRECT_MAX, + node->indirect1, + CYGNUM_RAMFS_BLOCKS_INDIRECT1, + buffer, + size, + alloc); +#endif +#if CYGNUM_RAMFS_BLOCKS_INDIRECT2 > 0 + if( pos < RAMFS_INDIRECT2_MAX ) + return findbuffer_indirect2( pos - RAMFS_INDIRECT1_MAX, + node->indirect2, + CYGNUM_RAMFS_BLOCKS_INDIRECT2, + buffer, + size, + alloc); +#endif + + return EINVAL; +} + +// ------------------------------------------------------------------------- +// freeblock_list() +// Free a list of data blocks. + +static void freeblock_list( ramfs_block *blocks[],int nblocks ) +{ + int i; + for( i = 0; i < nblocks ; i++ ) + { + if( blocks[i] != NULL ) + { + block_free( blocks[i] ); + blocks[i] = NULL; + } + } +} + +// ------------------------------------------------------------------------- +// freebuffer_node() +// Free all the data blocks in the node and clear the pointers. + +static int freebuffer_node( ramfs_node *node ) +{ +#if CYGNUM_RAMFS_BLOCKS_DIRECT > 0 + freeblock_list( node->direct, CYGNUM_RAMFS_BLOCKS_DIRECT ); +#endif + +#if CYGNUM_RAMFS_BLOCKS_INDIRECT1 > 0 + { + int i; + for( i = 0; i < CYGNUM_RAMFS_BLOCKS_INDIRECT1 ; i++ ) + { + if( node->indirect1[i] != NULL ) + { + freeblock_list( (ramfs_block **)node->indirect1[i], RAMFS_INDIRECT_PER_BLOCK ); + block_free( (ramfs_block *)node->indirect1[i] ); + node->indirect1[i] = NULL; + } + } + } +#endif + +#if CYGNUM_RAMFS_BLOCKS_INDIRECT2 > 0 + { + int i; + for( i = 0; i < CYGNUM_RAMFS_BLOCKS_INDIRECT2 ; i++ ) + { + if( node->indirect2[i] != NULL ) + { + ramfs_block ***b = node->indirect2[i]; + int j; + for( j = 0; j < RAMFS_INDIRECT_PER_BLOCK ; j++ ) + { + if( b[j] != NULL ) + { + freeblock_list( (ramfs_block **)b[j], RAMFS_INDIRECT_PER_BLOCK ); + block_free( (ramfs_block *)b[j] ); + b[j] = NULL; + } + } + block_free( (ramfs_block *)node->indirect2[i] ); + node->indirect2[i] = NULL; + } + } + } +#endif + + return ENOERR; +} + +//========================================================================== + +#endif + +//========================================================================== +// Node allocation + +// ------------------------------------------------------------------------- +// alloc_node() +// Allocate a node and initialize it. +// For the _SIMPLE allocation option, we just malloc it. For the +// _BLOCKS option we allocate a block and use that. In theory we could +// pack several nodes into a single block, but we don't at present due +// to sheer lazyness. + +static ramfs_node *alloc_node( mode_t mode ) +{ +#ifdef CYGPKG_FS_RAM_SIMPLE + ramfs_node *node = malloc( sizeof( ramfs_node ) ); + + if( node == NULL ) + return NULL; + +#else + ramfs_block *b = block_alloc(); + ramfs_node *node; + + if( b == NULL ) + return NULL; + + node = (ramfs_node *)b; + +#endif + + memset( node, 0, sizeof(ramfs_node) ); + + node->mode = mode; + node->refcnt = 0; + node->nlink = 0; + node->size = 0; + node->atime = + node->mtime = + node->ctime = cyg_timestamp(); + +#ifdef CYGPKG_FS_RAM_SIMPLE + node->datasize = 0; + node->data = NULL; +#else + + // The node is already all zero + +#endif + return node; +} + +// ------------------------------------------------------------------------- +// free_node() +// Release a node either back to the free pool or back into the block +// pool. + +static void free_node( ramfs_node *node ) +{ +#ifdef CYGPKG_FS_RAM_SIMPLE + + free( node ); + +#else + + block_free( (ramfs_block *)node ); + +#endif + +} + + +//========================================================================== +// Ref count and nlink management + +// ------------------------------------------------------------------------- +// dec_refcnt() +// Decrment the reference count on a node. If this makes the ref count +// zero, and the number of links is either zero for a file or one for +// a node, then this node is detached from the directory tree and can +// be freed. + +static int dec_refcnt( ramfs_node *node ) +{ + int err = ENOERR; + node->refcnt--; + + if( node->refcnt == 0 && + ((S_ISREG(node->mode) && node->nlink == 0 ) || + (S_ISDIR(node->mode) && node->nlink == 1) ) + ) + { + // This node it now totally detached from the directory tree, + // so delete it. + + if( S_ISDIR(node->mode) ) + { + del_direntry( node, ".", 1 ); + del_direntry( node, "..", 2 ); + } + + err = freebuffer_node( node ); + + if( err == ENOERR ) + free_node( node ); + } + + return err; +} + +// ------------------------------------------------------------------------- +// dec_nlink() +// Decrement a node's link count. Since this has to do all the same +// work as dec_refcnt() we implement this using that function by +// essentially transferring the count to refcnt and then decrement +// that. + +static int dec_nlink( ramfs_node *node ) +{ + node->refcnt++; + + node->nlink--; + + return dec_refcnt( node ); +} + +//========================================================================== +// Directory operations + +// ------------------------------------------------------------------------- +// add_direntry() +// Add an entry to a directory. This is added as a chain of entry +// fragments until the name is exhausted. + +static int add_direntry( ramfs_node *dir, // dir to add to + const char *name, // name to add + int namelen, // length of name + ramfs_node *node // node to reference + ) +{ + off_t pos = 0; + ramfs_dirent *d = NULL, *dp = NULL; + cyg_bool isfirst = true; + + // Loop inserting fragments of the name into the directory until we + // have found a home for them all. + + while( namelen > 0 ) + { + int fraglen = namelen; + + if( fraglen > sizeof(d->name) ) + fraglen = sizeof(d->name); + + // Find a free fragment + for(;;) + { + cyg_uint8 *buf; + size_t size; + int err = findbuffer_node( dir, pos, &buf, &size, true ); + if( err != ENOERR ) return err; + + d = (ramfs_dirent *)buf; + + if( size < sizeof(ramfs_dirent) || d->inuse ) + { + pos += sizeof(ramfs_dirent); + continue; + } + + break; + } + + // d now points to a free dirent structure + + d->node = node; + d->inuse = 1; + d->first = isfirst; + d->namelen = namelen; + d->fraglen = fraglen; + if( dp ) dp->next = pos; + + memcpy( d->name, name, fraglen ); + + name += fraglen; + namelen -= fraglen; + pos += sizeof(ramfs_dirent); + dp = d; + isfirst = false; + + } + + + d->last = 1; // Mark last fragment + + // Update directory times + dir->mtime = + dir->ctime = cyg_timestamp(); + + // Extend dir size if necessary + if( pos > dir->size ) + dir->size = pos; + + // Count the new link + node->nlink++; + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// find_direntry() +// Find a directory entry for the name and return a pointer to the first +// entry fragment. + +static ramfs_dirent *find_direntry( ramfs_node *dir, const char *name, int namelen ) +{ + ramfs_dirent *first = NULL; + off_t pos = 0; + int err; + + // Loop over all the entries until a match is found or we run out + // of data. + while( pos < dir->size ) + { + const char *frag = name; + ramfs_dirent *d; + cyg_uint8 *buf; + size_t size; + + // look for a first name fragment + for(;;) + { + err = findbuffer_node( dir, pos, &buf, &size, false ); + if( err != ENOERR || size == 0) + return NULL; + + d = (ramfs_dirent *)buf; + + if( size < sizeof(ramfs_dirent) || !d->inuse || !d->first ) + { + pos += sizeof(ramfs_dirent); + continue; + } + + break; + } + + // Here we have got a first fragment of a name, check it + // against the name we are looking for. First check that they + // are the same length. + + if( d->namelen == namelen ) + { + // We have a potential candidate here... + + first = d; // Save it for later + + // Now check that all the name fragments match + for(;;) + { + int fraglen = namelen-(frag-name); + + if( fraglen > d->fraglen ) + fraglen = d->fraglen; + + // compare strings, if different, look for another + if( memcmp( frag, d->name, fraglen ) != 0 ) + break; + + frag += fraglen; + + // If we are at the last fragment, then the whole name string + // has matched and we have a successful search. + + if( d->last ) + return first; + + // Otherwise move on to next entry in chain + err = findbuffer_node( dir, d->next, &buf, &size, false ); + if( err != ENOERR ) + return NULL; + + d = (ramfs_dirent *)buf; + + } + } + + pos += sizeof(ramfs_dirent); + } + + return NULL; +} + +// ------------------------------------------------------------------------- +// del_direntry() +// Delete a named directory entry. Find it and then follow the chain +// deleting the fragments as we go. + +static int del_direntry( ramfs_node *dir, const char *name, int namelen ) +{ + ramfs_dirent *d = find_direntry( dir, name, namelen ); + + if( d == NULL ) + return ENOENT; + + for(;;) + { + int err; + cyg_uint8 *buf; + size_t size; + + d->inuse = 0; + if( d->last ) break; + + err = findbuffer_node( dir, d->next, &buf, &size, false ); + if( err != ENOERR ) + return ENOENT; + + d = (ramfs_dirent *)buf; + } + + dec_nlink( d->node ); + + return ENOERR; +} + +//========================================================================== +// Directory search + +// ------------------------------------------------------------------------- +// init_dirsearch() +// Initialize a dirsearch object to start a search + +static void init_dirsearch( ramfs_dirsearch *ds, + ramfs_node *dir, + const char *name) +{ + ds->dir = dir; + ds->path = name; + ds->node = dir; + ds->name = name; + ds->namelen = 0; + ds->last = false; +} + +// ------------------------------------------------------------------------- +// find_entry() +// Search a single directory for the next name in a path and update the +// dirsearch object appropriately. + +static int find_entry( ramfs_dirsearch *ds ) +{ + ramfs_node *dir = ds->dir; + const char *name = ds->path; + const char *n = name; + char namelen = 0; + ramfs_dirent *d; + + // check that we really have a directory + if( !S_ISDIR(dir->mode) ) + return ENOTDIR; + + // Isolate the next element of the path name. + while( *n != '\0' && *n != '/' ) + n++, namelen++; + + // If we terminated on a NUL, set last flag. + if( *n == '\0' ) + ds->last = true; + + // update name in dirsearch object + ds->name = name; + ds->namelen = namelen; + + // Here we have the name and its length set up. + // Search the directory for a matching entry + + d = find_direntry( dir, name, namelen ); + + if( d == NULL ) + return ENOENT; + + // pass back the node we have found + ds->node = d->node; + + return ENOERR; + +} + +// ------------------------------------------------------------------------- +// ramfs_find() +// Main interface to directory search code. This is used in all file +// level operations to locate the object named by the pathname. + +static int ramfs_find( ramfs_dirsearch *d ) +{ + int err; + + // Short circuit empty paths + if( *(d->path) == '\0' ) + return ENOERR; + + // iterate down directory tree until we find the object + // we want. + for(;;) + { + err = find_entry( d ); + + if( err != ENOERR ) + return err; + + if( d->last ) + return ENOERR; + + // Update dirsearch object to search next directory. + d->dir = d->node; + d->path += d->namelen; + if( *(d->path) == '/' ) d->path++; // skip dirname separators + } +} + +//========================================================================== +// Pathconf support +// This function provides support for pathconf() and fpathconf(). + +static int ramfs_pathconf( ramfs_node *node, struct cyg_pathconf_info *info ) +{ + int err = ENOERR; + + switch( info->name ) + { + case _PC_LINK_MAX: + info->value = LINK_MAX; + break; + + case _PC_MAX_CANON: + info->value = -1; // not supported + err = EINVAL; + break; + + case _PC_MAX_INPUT: + info->value = -1; // not supported + err = EINVAL; + break; + + case _PC_NAME_MAX: + info->value = NAME_MAX; + break; + + case _PC_PATH_MAX: + info->value = PATH_MAX; + break; + + case _PC_PIPE_BUF: + info->value = -1; // not supported + err = EINVAL; + break; + + + case _PC_ASYNC_IO: + info->value = -1; // not supported + err = EINVAL; + break; + + case _PC_CHOWN_RESTRICTED: + info->value = -1; // not supported + err = EINVAL; + break; + + case _PC_NO_TRUNC: + info->value = 0; + break; + + case _PC_PRIO_IO: + info->value = 0; + break; + + case _PC_SYNC_IO: + info->value = 0; + break; + + case _PC_VDISABLE: + info->value = -1; // not supported + err = EINVAL; + break; + + default: + err = EINVAL; + break; + } + + return err; +} + +//========================================================================== +// Filesystem operations + +// ------------------------------------------------------------------------- +// ramfs_mount() +// Process a mount request. This mainly creates a root for the +// filesystem. + +static int ramfs_mount ( cyg_fstab_entry *fste, cyg_mtab_entry *mte ) +{ + ramfs_node *root; + int err; + + // Allocate a node to be the root of this filesystem and initialize it. + + root = alloc_node(__stat_mode_DIR); + + if( root == NULL ) + return ENOSPC; + + // Add . and .. entries back to self. + + err = add_direntry( root, ".", 1, root ); + if( err == ENOERR ) + err = add_direntry( root, "..", 2, root ); + + if( err != ENOERR ) + { + free_node( root ); + return err; + } + + mte->root = (cyg_dir)root; + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// ramfs_umount() +// Unmount the filesystem. This will currently only succeed if the +// filesystem is empty. + +static int ramfs_umount ( cyg_mtab_entry *mte ) +{ + ramfs_node *root = (ramfs_node *)mte->root; + + // Check for open/inuse root + if( root->refcnt != 0 ) + return EBUSY; + + // Check that root directory is clear of extra links. + if( root->nlink != 2 ) + return EBUSY; + + // Just return it to free pool + free_node( root ); + + // Clear root pointer + mte->root = CYG_DIR_NULL; + + // That's all folks. + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// ramfs_open() +// Open a file for reading or writing. + +static int ramfs_open ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int mode, cyg_file *file ) +{ + + ramfs_dirsearch ds; + ramfs_node *node = NULL; + int err; + + init_dirsearch( &ds, (ramfs_node *)dir, name ); + + err = ramfs_find( &ds ); + + if( err == ENOENT ) + { + if( ds.last && (mode & O_CREAT) ) + { + // No node there, if the O_CREAT bit is set then we must + // create a new one. The dir and name fields of the dirsearch + // object will have been updated so we know where to put it. + + node = alloc_node( __stat_mode_REG ); + + if( node == NULL ) + return ENOSPC; + + err = add_direntry( ds.dir, ds.name, ds.namelen, node ); + + if( err != ENOERR ) + { + free_node( node ); + return err; + } + + err = ENOERR; + } + } + else if( err == ENOERR ) + { + // The node exists. If the O_CREAT and O_EXCL bits are set, we + // must fail the open. + + if( (mode & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL) ) + err = EEXIST; + else node = ds.node; + } + + if( err == ENOERR && (mode & O_TRUNC ) ) + { + // If the O_TRUNC bit is set we must clean out the file data. + + err = freebuffer_node( node ); + node->size = 0; + + // Update file times + node->ctime = + node->mtime = cyg_timestamp(); + } + + if( err != ENOERR ) return err; + + // Check that we actually have a file here + if( S_ISDIR(node->mode) ) return EISDIR; + + node->refcnt++; // Count successful open + + // Initialize the file object + + file->f_flag |= mode & CYG_FILE_MODE_MASK; + file->f_type = CYG_FILE_TYPE_FILE; + file->f_ops = &ramfs_fileops; + file->f_offset = (mode&O_APPEND) ? node->size : 0; + file->f_data = (CYG_ADDRWORD)node; + file->f_xops = 0; + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// ramfs_unlink() +// Remove a file link from its directory. + +static int ramfs_unlink ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ) +{ + ramfs_dirsearch ds; + int err; + + init_dirsearch( &ds, (ramfs_node *)dir, name ); + + err = ramfs_find( &ds ); + + if( err != ENOERR ) return err; + + // Cannot unlink directories, use rmdir() instead + if( S_ISDIR(ds.node->mode) ) + return EPERM; + + // Delete it from its directory + err = del_direntry( ds.dir, ds.name, ds.namelen ); + + return err; +} + +// ------------------------------------------------------------------------- +// ramfs_mkdir() +// Create a new directory. + +static int ramfs_mkdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ) +{ + ramfs_dirsearch ds; + ramfs_node *node = NULL; + int err; + + init_dirsearch( &ds, (ramfs_node *)dir, name ); + + err = ramfs_find( &ds ); + + if( err == ENOENT ) + { + if( ds.last ) + { + // The entry does not exist, and it is the last element in + // the pathname, so we can create it here. + int doterr, dotdoterr, direrr; + + node = alloc_node( __stat_mode_DIR ); + + if( node == NULL ) + return ENOSPC; + + // Add "." and ".." entries. + doterr = add_direntry( node, ".", 1, node ); + dotdoterr = add_direntry( node, "..", 2, ds.dir ); + + // And add to parent directory. + direrr = add_direntry( ds.dir, ds.name, ds.namelen, node ); + + // check for any errors in that... + if( doterr+dotdoterr+direrr != ENOERR ) + { + // For each of the add_direntry() calls that succeeded, + // we must now undo it. + + if( doterr == ENOERR ) + del_direntry( node, ".", 1 ); + else err = doterr; + + if( dotdoterr == ENOERR ) + del_direntry( node, "..", 2 ); + else err = dotdoterr; + + if( direrr == ENOERR ) + del_direntry( ds.dir, ds.name, ds.namelen ); + else err = direrr; + + // Free the data and the node itself. + freebuffer_node( node ); + free_node( node ); + } + else err = ENOERR; + } + // If this was not the last element, then and intermediate + // directory does not exist. + } + else + { + // If there we no error, something already exists with that + // name, so we cannot create another one. + + if( err == ENOERR ) + err = EEXIST; + } + + return err; +} + +// ------------------------------------------------------------------------- +// ramfs_rmdir() +// Remove a directory. + +static int ramfs_rmdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ) +{ + ramfs_dirsearch ds; + int err; + + init_dirsearch( &ds, (ramfs_node *)dir, name ); + + err = ramfs_find( &ds ); + + if( err != ENOERR ) return err; + + // Check that this is actually a directory. + if( !S_ISDIR(ds.node->mode) ) + return EPERM; + + // Delete the entry. This will adjust the link values + // accordingly and if the directory is now unreferenced, + // will cause it to be deleted. + + err = del_direntry( ds.dir, ds.name, ds.namelen ); + + return err; +} + +// ------------------------------------------------------------------------- +// ramfs_rename() +// Rename a file/dir. + +static int ramfs_rename ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2 ) +{ + ramfs_dirsearch ds1, ds2; + int err; + + init_dirsearch( &ds1, (ramfs_node *)dir1, name1 ); + + err = ramfs_find( &ds1 ); + + if( err != ENOERR ) return err; + + init_dirsearch( &ds2, (ramfs_node *)dir2, name2 ); + + err = ramfs_find( &ds2 ); + + // Allow through renames to non-existent objects. + if( ds2.last && err == ENOENT ) + ds2.node = NULL, err = ENOERR; + + if( err != ENOERR ) return err; + + // Null rename, just return + if( ds1.node == ds2.node ) + return ENOERR; + + // First deal with any entry that is at the destination + if( ds2.node ) + { + // Check that we are renaming like-for-like + + if( !S_ISDIR(ds1.node->mode) && S_ISDIR(ds2.node->mode) ) + return EISDIR; + + if( S_ISDIR(ds1.node->mode) && !S_ISDIR(ds2.node->mode) ) + return ENOTDIR; + + // Now delete the destination directory entry + + err = del_direntry( ds2.dir, ds2.name, ds2.namelen ); + + if( err != ENOERR ) return err; + + } + + // Now we know that there is no clashing node at the destination, + // make a new direntry at the destination and delete the old entry + // at the source. + + err = add_direntry( ds2.dir, ds2.name, ds2.namelen, ds1.node ); + + if( err == ENOERR ) + err = del_direntry( ds1.dir, ds1.name, ds1.namelen ); + + // Update directory times + if( err == ENOERR ) + ds1.dir->ctime = + ds1.dir->mtime = + ds2.dir->ctime = + ds2.dir->mtime = cyg_timestamp(); + + return err; +} + +// ------------------------------------------------------------------------- +// ramfs_link() +// Make a new directory entry for a file. + +static int ramfs_link ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2, int type ) +{ + ramfs_dirsearch ds1, ds2; + int err; + + // Only do hard links for now in this filesystem + if( type != CYG_FSLINK_HARD ) + return EINVAL; + + init_dirsearch( &ds1, (ramfs_node *)dir1, name1 ); + + err = ramfs_find( &ds1 ); + + if( err != ENOERR ) return err; + + init_dirsearch( &ds2, (ramfs_node *)dir2, name2 ); + + err = ramfs_find( &ds2 ); + + // Don't allow links to existing objects + if( err == ENOERR ) return EEXIST; + + // Allow through links to non-existing terminal objects + if( ds2.last && err == ENOENT ) + ds2.node = NULL, err = ENOERR; + + if( err != ENOERR ) return err; + + // Now we know that there is no existing node at the destination, + // make a new direntry at the destination. + + err = add_direntry( ds2.dir, ds2.name, ds2.namelen, ds1.node ); + + if( err == ENOERR ) + ds1.node->ctime = + ds2.dir->ctime = + ds2.dir->mtime = cyg_timestamp(); + + return err; +} + +// ------------------------------------------------------------------------- +// ramfs_opendir() +// Open a directory for reading. + +static int ramfs_opendir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_file *file ) +{ + ramfs_dirsearch ds; + int err; + + init_dirsearch( &ds, (ramfs_node *)dir, name ); + + err = ramfs_find( &ds ); + + if( err != ENOERR ) return err; + + // check it is really a directory. + if( !S_ISDIR(ds.node->mode) ) return ENOTDIR; + + ds.node->refcnt++; // Count successful open + + // Initialize the file object, setting the f_ops field to a + // special set of file ops. + + file->f_type = CYG_FILE_TYPE_FILE; + file->f_ops = &ramfs_dirops; + file->f_offset = 0; + file->f_data = (CYG_ADDRWORD)ds.node; + file->f_xops = 0; + + return ENOERR; + +} + +// ------------------------------------------------------------------------- +// ramfs_chdir() +// Change directory support. + +static int ramfs_chdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_dir *dir_out ) +{ + if( dir_out != NULL ) + { + // This is a request to get a new directory pointer in + // *dir_out. + + ramfs_dirsearch ds; + int err; + + init_dirsearch( &ds, (ramfs_node *)dir, name ); + + err = ramfs_find( &ds ); + + if( err != ENOERR ) return err; + + // check it is a directory + if( !S_ISDIR(ds.node->mode) ) + return ENOTDIR; + + // Increment ref count to keep this directory in existent + // while it is the current cdir. + ds.node->refcnt++; + + // Pass it out + *dir_out = (cyg_dir)ds.node; + } + else + { + // If no output dir is required, this means that the mte and + // dir arguments are the current cdir setting and we should + // forget this fact. + + ramfs_node *node = (ramfs_node *)dir; + + // Just decrement directory reference count. + dec_refcnt( node ); + } + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// ramfs_stat() +// Get struct stat info for named object. + +static int ramfs_stat ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + struct stat *buf) +{ + ramfs_dirsearch ds; + int err; + + init_dirsearch( &ds, (ramfs_node *)dir, name ); + + err = ramfs_find( &ds ); + + if( err != ENOERR ) return err; + + // Fill in the status + buf->st_mode = ds.node->mode; + buf->st_ino = (ino_t)ds.node; + buf->st_dev = 0; + buf->st_nlink = ds.node->nlink; + buf->st_uid = 0; + buf->st_gid = 0; + buf->st_size = ds.node->size; + buf->st_atime = ds.node->atime; + buf->st_mtime = ds.node->mtime; + buf->st_ctime = ds.node->ctime; + + return err; +} + +// ------------------------------------------------------------------------- +// ramfs_getinfo() +// Getinfo. Currently only support pathconf(). + +static int ramfs_getinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ) +{ + ramfs_dirsearch ds; + int err; + + init_dirsearch( &ds, (ramfs_node *)dir, name ); + + err = ramfs_find( &ds ); + + if( err != ENOERR ) return err; + + switch( key ) + { + case FS_INFO_CONF: + err = ramfs_pathconf( ds.node, (struct cyg_pathconf_info *)buf ); + break; + + default: + err = EINVAL; + } + return err; +} + +// ------------------------------------------------------------------------- +// ramfs_setinfo() +// Setinfo. Nothing to support here at present. + +static int ramfs_setinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ) +{ + // No setinfo keys supported at present + + return EINVAL; +} + + +//========================================================================== +// File operations + +// ------------------------------------------------------------------------- +// ramfs_fo_read() +// Read data from the file. + +static int ramfs_fo_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio) +{ + ramfs_node *node = (ramfs_node *)fp->f_data; + int i; + off_t pos = fp->f_offset; + ssize_t resid = uio->uio_resid; + + // Loop over the io vectors until there are none left + for( i = 0; i < uio->uio_iovcnt; i++ ) + { + cyg_iovec *iov = &uio->uio_iov[i]; + char *buf = (char *)iov->iov_base; + off_t len = iov->iov_len; + + // Loop over each vector filling it with data from the file. + while( len > 0 && pos < node->size ) + { + cyg_uint8 *fbuf; + size_t bsize; + off_t l = len; + int err; + + // Get a pointer to the data at offset _pos_. + err = findbuffer_node( node, pos, &fbuf, &bsize, false ); + + if( err != ENOERR ) + return err; + + // adjust size to end of file if necessary + if( l > node->size-pos ) + l = node->size-pos; + + // adjust size to the amount of contiguous data we can see + // at present. + if( l > bsize ) + l = bsize; + + // copy data out + memcpy( buf, fbuf, l ); + + // Update working vars + len -= l; + buf += l; + pos += l; + resid -= l; + } + } + + // We successfully read some data, update the node's access time + // and update the file offset and transfer residue. + + node->atime = cyg_timestamp(); + + uio->uio_resid = resid; + fp->f_offset = pos; + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// ramfs_fo_write() +// Write data to file. + +static int ramfs_fo_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio) +{ + ramfs_node *node = (ramfs_node *)fp->f_data; + off_t pos = fp->f_offset; + ssize_t resid = uio->uio_resid; + int i; + + // If the APPEND mode bit was supplied, force all writes to + // the end of the file. + if( fp->f_flag & CYG_FAPPEND ) + pos = fp->f_offset = node->size; + + // Check that pos is within current file size, or at the very end. + if( pos < 0 || pos > node->size ) + return EINVAL; + + // Now loop over the iovecs until they are all done, or + // we get an error. + for( i = 0; i < uio->uio_iovcnt; i++ ) + { + cyg_iovec *iov = &uio->uio_iov[i]; + char *buf = (char *)iov->iov_base; + off_t len = iov->iov_len; + + // loop over the vector writing it to the file until it has + // all been done. + while( len > 0 ) + { + cyg_uint8 *fbuf; + size_t bsize; + off_t l = len; + int err; + + err = findbuffer_node( node, pos, &fbuf, &bsize, true ); + + // Stop writing if there is no more space in the file and + // indicate end of data. + if( err == ENOSPC ) + break; + + if( err != ENOERR ) + return err; + + // adjust size to this block + if( l > bsize ) + l = bsize; + + // copy data in + memcpy( fbuf, buf, l ); + + // Update working vars + len -= l; + buf += l; + pos += l; + resid -= l; + } + } + + // We wrote some data successfully, update the modified and access + // times of the node, increase its size appropriately, and update + // the file offset and transfer residue. + node->mtime = + node->ctime = cyg_timestamp(); + if( pos > node->size ) + node->size = pos; + + uio->uio_resid = resid; + fp->f_offset = pos; + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// ramfs_fo_lseek() +// Seek to a new file position. + +static int ramfs_fo_lseek (struct CYG_FILE_TAG *fp, off_t *apos, int whence ) +{ + ramfs_node *node = (ramfs_node *)fp->f_data; + off_t pos = *apos; + + switch( whence ) + { + case SEEK_SET: + // Pos is already where we want to be. + break; + + case SEEK_CUR: + // Add pos to current offset. + pos += fp->f_offset; + break; + + case SEEK_END: + // Add pos to file size. + pos += node->size; + break; + + default: + return EINVAL; + } + + // Check that pos is still within current file size, or at the + // very end. + if( pos < 0 || pos > node->size ) + return EINVAL; + + // All OK, set fp offset and return new position. + *apos = fp->f_offset = pos; + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// ramfs_fo_ioctl() +// Handle ioctls. Currently none are defined. + +static int ramfs_fo_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com, + CYG_ADDRWORD data) +{ + // No Ioctls currenly defined. + + return EINVAL; +} + +// ------------------------------------------------------------------------- +// ramfs_fo_fsync(). +// Force the file out to data storage. + +static int ramfs_fo_fsync (struct CYG_FILE_TAG *fp, int mode ) +{ + // Data is always permanently where it belongs, nothing to do + // here. + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// ramfs_fo_close() +// Close a file. We just decrement the refcnt and let it go away if +// that is all that is keeping it here. + +static int ramfs_fo_close (struct CYG_FILE_TAG *fp) +{ + ramfs_node *node = (ramfs_node *)fp->f_data; + + dec_refcnt( node ); + + fp->f_data = 0; // zero data pointer + + return ENOERR; +} + +// ------------------------------------------------------------------------- +//ramfs_fo_fstat() +// Get file status. + +static int ramfs_fo_fstat (struct CYG_FILE_TAG *fp, struct stat *buf ) +{ + ramfs_node *node = (ramfs_node *)fp->f_data; + + // Fill in the status + buf->st_mode = node->mode; + buf->st_ino = (ino_t)node; + buf->st_dev = 0; + buf->st_nlink = node->nlink; + buf->st_uid = 0; + buf->st_gid = 0; + buf->st_size = node->size; + buf->st_atime = node->atime; + buf->st_mtime = node->mtime; + buf->st_ctime = node->ctime; + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// ramfs_fo_getinfo() +// Get info. Currently only supports fpathconf(). + +static int ramfs_fo_getinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ) +{ + ramfs_node *node = (ramfs_node *)fp->f_data; + int err; + + switch( key ) + { + case FS_INFO_CONF: + err = ramfs_pathconf( node, (struct cyg_pathconf_info *)buf ); + break; + + default: + err = EINVAL; + } + return err; +} + +// ------------------------------------------------------------------------- +// ramfs_fo_setinfo() +// Set info. Nothing supported here. + +static int ramfs_fo_setinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ) +{ + // No setinfo key supported at present + + return ENOERR; +} + + +//========================================================================== +// Directory operations + +// ------------------------------------------------------------------------- +// ramfs_fo_dirread() +// Read a single directory entry from a file. + +static int ramfs_fo_dirread (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio) +{ + ramfs_node *dir = (ramfs_node *)fp->f_data; + off_t pos = fp->f_offset; + int err = ENOERR; + struct dirent *ent = (struct dirent *)uio->uio_iov[0].iov_base; + char *nbuf = ent->d_name; + int nlen = sizeof(ent->d_name)-1; + off_t len = uio->uio_iov[0].iov_len; + ramfs_dirent *d = NULL; + cyg_uint8 *buf; + size_t size; + + if( len < sizeof(struct dirent) ) + return EINVAL; + + // look for a first name fragment + + while( pos < dir->size ) + { + err = findbuffer_node( dir, pos, &buf, &size, false ); + if( err != ENOERR || size == 0) + break; + + d = (ramfs_dirent *)buf; + + if( size < sizeof(ramfs_dirent) || !d->inuse || !d->first ) + { + pos += sizeof(ramfs_dirent); + continue; + } + + break; + } + + // Check we have not exceeded the size of the directory. + if( pos == dir->size ) + return err; + + // Here we have the first fragment of a directory entry. + + for(;;) + { + int fraglen = d->fraglen; + + // adjust to allow for remaining space in dirent struct + if( fraglen > nlen ) + fraglen = nlen; + + memcpy( nbuf, d->name, fraglen); + nbuf += fraglen; + nlen -= fraglen; + + // if we hit the last entry, we have a successful transfer + if( d->last || nlen == 0) + break; + + // Otherwise move on to next entry in chain + err = findbuffer_node( dir, d->next, &buf, &size, false ); + if( err != ENOERR ) + return err; + + d = (ramfs_dirent *)buf; + } + + // A successful read. Terminate the entry name with a NUL, set the + // residue and set the file offset to restart at the next + // directory entry. + + *nbuf = '\0'; + uio->uio_resid -= sizeof(struct dirent); + fp->f_offset = pos+sizeof(ramfs_dirent); + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// ramfs_fo_dirlseek() +// Seek directory to start. + +static int ramfs_fo_dirlseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence ) +{ + // Only allow SEEK_SET to zero + + if( whence != SEEK_SET || *pos != 0) + return EINVAL; + + *pos = fp->f_offset = 0; + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// EOF ramfs.c diff --git a/packages/fs/ram/current/tests/fileio1.c b/packages/fs/ram/current/tests/fileio1.c new file mode 100644 --- /dev/null +++ b/packages/fs/ram/current/tests/fileio1.c @@ -0,0 +1,547 @@ +//========================================================================== +// +// fileio1.c +// +// Test fileio system +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Test fileio system +// Description: This test uses the testfs to check out the initialization +// and basic operation of the fileio system +// +// +// +// +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include // HAL polled output + +//========================================================================== + +#if 0 +MTAB_ENTRY( ramfs_mte1, + "/", + "ramfs", + "", + 0); +#endif + +//========================================================================== + +#define SHOW_RESULT( _fn, _res ) \ +diag_printf(": " #_fn "() returned %d %s\n", _res, _res<0?strerror(errno):""); + +//========================================================================== + +#define IOSIZE 100 + +#define LONGNAME1 "long_file_name_that_should_take_up_more_than_one_directory_entry_1" +#define LONGNAME2 "long_file_name_that_should_take_up_more_than_one_directory_entry_2" + + +//========================================================================== + +#ifndef CYGPKG_LIBC_STRING + +char *strcat( char *s1, const char *s2 ) +{ + char *s = s1; + while( *s1 ) s1++; + while( (*s1++ = *s2++) != 0); + return s; +} + +#endif + +//========================================================================== + +static void listdir( char *name, int statp ) +{ + int err; + DIR *dirp; + + diag_printf(": reading directory %s\n",name); + + dirp = opendir( name ); + if( dirp == NULL ) SHOW_RESULT( opendir, -1 ); + + for(;;) + { + struct dirent *entry = readdir( dirp ); + + if( entry == NULL ) + break; + + diag_printf(": entry %14s",entry->d_name); + if( statp ) + { + char fullname[PATH_MAX]; + struct stat sbuf; + + if( name[0] ) + { + strcpy(fullname, name ); + if( !(name[0] == '/' && name[1] == 0 ) ) + strcat(fullname, "/" ); + } + else fullname[0] = 0; + + strcat(fullname, entry->d_name ); + + err = stat( fullname, &sbuf ); + if( err < 0 ) + { + if( errno == ENOSYS ) + diag_printf(" "); + else SHOW_RESULT( stat, err ); + } + else + { + diag_printf(" [mode %08x ino %08x nlink %d size %d]", + sbuf.st_mode,sbuf.st_ino,sbuf.st_nlink,sbuf.st_size); + } + } + + diag_printf("\n"); + } + + err = closedir( dirp ); + if( err < 0 ) SHOW_RESULT( stat, err ); +} + +//========================================================================== + +static void createfile( char *name, size_t size ) +{ + char buf[IOSIZE]; + int fd; + ssize_t wrote; + int i; + int err; + + diag_printf(": create file %s size %d\n",name,size); + + err = access( name, F_OK ); + if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err ); + + for( i = 0; i < IOSIZE; i++ ) buf[i] = i%256; + + fd = open( name, O_WRONLY|O_CREAT ); + if( fd < 0 ) SHOW_RESULT( open, fd ); + + while( size > 0 ) + { + ssize_t len = size; + if ( len > IOSIZE ) len = IOSIZE; + + wrote = write( fd, buf, len ); + if( wrote != len ) SHOW_RESULT( write, wrote ); + + size -= wrote; + } + + err = close( fd ); + if( err < 0 ) SHOW_RESULT( close, err ); +} + +//========================================================================== + +#if 0 +static void maxfile( char *name ) +{ + char buf[IOSIZE]; + int fd; + ssize_t wrote; + int i; + int err; + size_t size = 0; + + diag_printf(": create maximal file %s\n",name); + + err = access( name, F_OK ); + if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err ); + + for( i = 0; i < IOSIZE; i++ ) buf[i] = i%256; + + fd = open( name, O_WRONLY|O_CREAT ); + if( fd < 0 ) SHOW_RESULT( open, fd ); + + do + { + wrote = write( fd, buf, IOSIZE ); + if( wrote < 0 ) SHOW_RESULT( write, wrote ); + + size += wrote; + + } while( wrote == IOSIZE ); + + diag_printf(": file size == %d\n",size); + + err = close( fd ); + if( err < 0 ) SHOW_RESULT( close, err ); +} +#endif + +//========================================================================== + +static void checkfile( char *name ) +{ + char buf[IOSIZE]; + int fd; + ssize_t done; + int i; + int err; + off_t pos = 0; + + diag_printf(": check file %s\n",name); + + err = access( name, F_OK ); + if( err != 0 ) SHOW_RESULT( access, err ); + + fd = open( name, O_RDONLY ); + if( fd < 0 ) SHOW_RESULT( open, fd ); + + for(;;) + { + done = read( fd, buf, IOSIZE ); + if( done < 0 ) SHOW_RESULT( read, done ); + + if( done == 0 ) break; + + for( i = 0; i < done; i++ ) + if( buf[i] != i%256 ) + { + diag_printf("buf[%d+%d](%02x) != %02x\n",pos,i,buf[i],i%256); + CYG_TEST_FAIL("Data read not equal to data written\n"); + } + + pos += done; + } + + err = close( fd ); + if( err < 0 ) SHOW_RESULT( close, err ); +} + +//========================================================================== + +static void copyfile( char *name2, char *name1 ) +{ + + int err; + char buf[IOSIZE]; + int fd1, fd2; + ssize_t done, wrote; + + diag_printf(": copy file %s -> %s\n",name2,name1); + + err = access( name1, F_OK ); + if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err ); + + err = access( name2, F_OK ); + if( err != 0 ) SHOW_RESULT( access, err ); + + fd1 = open( name1, O_WRONLY|O_CREAT ); + if( fd1 < 0 ) SHOW_RESULT( open, fd1 ); + + fd2 = open( name2, O_RDONLY ); + if( fd2 < 0 ) SHOW_RESULT( open, fd2 ); + + for(;;) + { + done = read( fd2, buf, IOSIZE ); + if( done < 0 ) SHOW_RESULT( read, done ); + + if( done == 0 ) break; + + wrote = write( fd1, buf, done ); + if( wrote != done ) SHOW_RESULT( write, wrote ); + + if( wrote != done ) break; + } + + err = close( fd1 ); + if( err < 0 ) SHOW_RESULT( close, err ); + + err = close( fd2 ); + if( err < 0 ) SHOW_RESULT( close, err ); + +} + +//========================================================================== + +static void comparefiles( char *name2, char *name1 ) +{ + int err; + char buf1[IOSIZE]; + char buf2[IOSIZE]; + int fd1, fd2; + ssize_t done1, done2; + int i; + + diag_printf(": compare files %s == %s\n",name2,name1); + + err = access( name1, F_OK ); + if( err != 0 ) SHOW_RESULT( access, err ); + + err = access( name1, F_OK ); + if( err != 0 ) SHOW_RESULT( access, err ); + + fd1 = open( name1, O_RDONLY ); + if( fd1 < 0 ) SHOW_RESULT( open, fd1 ); + + fd2 = open( name2, O_RDONLY ); + if( fd2 < 0 ) SHOW_RESULT( open, fd2 ); + + for(;;) + { + done1 = read( fd1, buf1, IOSIZE ); + if( done1 < 0 ) SHOW_RESULT( read, done1 ); + + done2 = read( fd2, buf2, IOSIZE ); + if( done2 < 0 ) SHOW_RESULT( read, done2 ); + + if( done1 != done2 ) + diag_printf("Files different sizes\n"); + + if( done1 == 0 ) break; + + for( i = 0; i < done1; i++ ) + if( buf1[i] != buf2[i] ) + { + diag_printf("buf1[%d](%02x) != buf1[%d](%02x)\n",i,buf1[i],i,buf2[i]); + CYG_TEST_FAIL("Data in files not equal\n"); + } + } + + err = close( fd1 ); + if( err < 0 ) SHOW_RESULT( close, err ); + + err = close( fd2 ); + if( err < 0 ) SHOW_RESULT( close, err ); + +} + +//========================================================================== +// main + +int main( int argc, char **argv ) +{ + int err; + + CYG_TEST_INIT(); + + // -------------------------------------------------------------- + + err = mount( "", "/", "ramfs" ); + if( err < 0 ) SHOW_RESULT( mount, err ); + + err = chdir( "/" ); + if( err < 0 ) SHOW_RESULT( chdir, err ); + + // -------------------------------------------------------------- + + createfile( "/foo", 202 ); + checkfile( "foo" ); + copyfile( "foo", "fee"); + checkfile( "fee" ); + comparefiles( "foo", "/fee" ); + + err = mkdir( "/bar", 0 ); + if( err < 0 ) SHOW_RESULT( mkdir, err ); + + listdir( "/" , true); + + copyfile( "fee", "/bar/fum" ); + checkfile( "bar/fum" ); + comparefiles( "/fee", "bar/fum" ); + + diag_printf(": cd bar\n"); + err = chdir( "bar" ); + if( err < 0 ) SHOW_RESULT( chdir, err ); + + diag_printf(": rename /foo bundy\n"); + err = rename( "/foo", "bundy" ); + if( err < 0 ) SHOW_RESULT( rename, err ); + + listdir( "/", true ); + listdir( "" , true ); + + checkfile( "/bar/bundy" ); + comparefiles("/fee", "bundy" ); + + // -------------------------------------------------------------- + + createfile( LONGNAME1, 123 ); + checkfile( LONGNAME1 ); + copyfile( LONGNAME1, LONGNAME2 ); + + listdir( "", false ); + + diag_printf(": unlink " LONGNAME1 "\n"); + err = unlink( LONGNAME1 ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + diag_printf(": unlink " LONGNAME2 "\n"); + err = unlink( LONGNAME2 ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + + // -------------------------------------------------------------- + + diag_printf(": unlink fee\n"); + err = unlink( "/fee" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + diag_printf(": unlink fum\n"); + err = unlink( "fum" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + diag_printf(": unlink /bar/bundy\n"); + err = unlink( "/bar/bundy" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + diag_printf(": cd /\n"); + err = chdir( "/" ); + if( err < 0 ) SHOW_RESULT( chdir, err ); + + diag_printf(": rmdir /bar\n"); + err = rmdir( "/bar" ); + if( err < 0 ) SHOW_RESULT( rmdir, err ); + + listdir( "/", false ); + + // -------------------------------------------------------------- + + diag_printf(": mount /ram \n"); + err = mount( "", "/ram", "ramfs" ); + if( err < 0 ) SHOW_RESULT( mount, err ); + + createfile( "/ram/tinky", 456 ); + copyfile( "/ram/tinky", "/ram/laalaa" ); + checkfile( "/ram/tinky"); + checkfile( "/ram/laalaa"); + comparefiles( "/ram/tinky", "/ram/laalaa" ); + + diag_printf(": cd /ram\n"); + err = chdir( "/ram" ); + if( err < 0 ) SHOW_RESULT( chdir, err ); + + diag_printf(": mkdir noonoo\n"); + err = mkdir( "noonoo", 0 ); + if( err < 0 ) SHOW_RESULT( mkdir, err ); + + listdir( "." , true ); + + diag_printf(": cd noonoo\n"); + err = chdir( "noonoo" ); + if( err < 0 ) SHOW_RESULT( chdir, err ); + + + createfile( "tinky", 678 ); + checkfile( "tinky" ); + + createfile( "dipsy", 3456 ); + checkfile( "dipsy" ); + copyfile( "dipsy", "po" ); + checkfile( "po" ); + comparefiles( "dipsy", "po" ); + + listdir( ".", true ); + listdir( "", true ); + listdir( "..", true ); + + // -------------------------------------------------------------- + + diag_printf(": unlink tinky\n"); + err = unlink( "tinky" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + diag_printf(": unlink dipsy\n"); + err = unlink( "dipsy" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + diag_printf(": unlink po\n"); + err = unlink( "po" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + diag_printf(": cd ..\n"); + err = chdir( ".." ); + if( err < 0 ) SHOW_RESULT( chdir, err ); + + diag_printf(": rmdir noonoo\n"); + err = rmdir( "noonoo" ); + if( err < 0 ) SHOW_RESULT( rmdir, err ); + + diag_printf(": unlink tinky\n"); + err = unlink( "tinky" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + diag_printf(": unlink laalaa\n"); + err = unlink( "laalaa" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + diag_printf(": cd /\n"); + err = chdir( "/" ); + if( err < 0 ) SHOW_RESULT( chdir, err ); + + diag_printf(": umount /ram\n"); + err = umount( "/ram" ); + if( err < 0 ) SHOW_RESULT( umount, err ); + + CYG_TEST_PASS_FINISH("fileio1"); +} + +// ------------------------------------------------------------------------- +// EOF fileio1.c diff --git a/packages/hal/arm/arch/current/ChangeLog b/packages/hal/arm/arch/current/ChangeLog --- a/packages/hal/arm/arch/current/ChangeLog +++ b/packages/hal/arm/arch/current/ChangeLog @@ -1,3 +1,20 @@ +2000-08-15 Hugo Tyson + + * src/arm.ld (SECTION_text): Change it back so that + infra/... range checking can see them. _stext and _etext as seen + from C are the eventual destination, so this is a step in the + right direction. You must hack if building redboot, for now. + +2000-08-14 Hugo Tyson + + * src/arm.ld (SECTION_text): Change to stext and etext unadorned + with underlines so that RedBoot can see them. + +2000-08-14 Gary Thomas + + * include/hal_arch.h: + * src/arm.ld: Changes to support new [anonymous] tables. + 2000-07-17 Jesper Skov * src/vectors.S (start): Hack to allow thumb tests to run in farm @@ -16,12 +33,41 @@ 2000-07-05 Jesper Skov + + * cdl/hal_arm.cdl: Add CYGINT_HAL_ARM_MEM_REAL_REGION_TOP + interface + + * include/hal_intr.h: If the platform implements the + CYGINT_HAL_ARM_MEM_REAL_REGION_TOP interface, define a new + HAL_MEM_REAL_REGION_TOP macro appropriately + 2000-06-28 Jesper Skov * src/hal_mk_defs.c: * src/arm_stub.c: Fix compiler warnings. +2000-06-21 Nick Garnett + + * include/hal_arch.h: + Added local variants of CYG_HAL_TABLE_BEGIN() and + CYG_HAL_TABLE_END() since the ARM assembler implements some of + this code with a slightly different syntax to all the other + targets. + + * include/basetype.h: + Removed definition of CYG_LABEL_NAME(). Now dealt with by default + definition in cyg_type.h. + + * src/hal_misc.c: + * src/arm_stub.c: + Removed use of CYG_LABEL_NAME(), added underscore to _breakinst. + + * src/arm.ld: + Added extra underscores to _stext and _etext. + Switched over to new table creation mechanism. + 2000-06-19 Gary Thomas * src/vectors.S: Changes for virtual vector support. diff --git a/packages/hal/arm/arch/current/cdl/hal_arm.cdl b/packages/hal/arm/arch/current/cdl/hal_arm.cdl --- a/packages/hal/arm/arch/current/cdl/hal_arm.cdl +++ b/packages/hal/arm/arch/current/cdl/hal_arm.cdl @@ -142,4 +142,8 @@ cdl_package CYGPKG_HAL_ARM { no_define calculated { "src/arm.ld" } } + + cdl_interface CYGINT_HAL_ARM_MEM_REAL_REGION_TOP { + display "Implementations of hal_arm_mem_real_region_top()" + } } diff --git a/packages/hal/arm/arch/current/include/basetype.h b/packages/hal/arm/arch/current/include/basetype.h --- a/packages/hal/arm/arch/current/include/basetype.h +++ b/packages/hal/arm/arch/current/include/basetype.h @@ -55,11 +55,9 @@ #define CYG_DOUBLE_BYTEORDER CYG_MSBFIRST // Big? endian //----------------------------------------------------------------------------- -// ARM does not usually use labels with underscores. Some labels generated -// by the linker do, so add an underscore where required. +// ARM does not usually use labels with underscores. -//#define CYG_LABEL_NAME(_name_) _##_name_ -#define CYG_LABEL_NAME(_name_) _name_ +//#define CYG_LABEL_NAME(_name_) _name_ //----------------------------------------------------------------------------- // Define the standard variable sizes diff --git a/packages/hal/arm/arch/current/include/hal_arch.h b/packages/hal/arm/arch/current/include/hal_arch.h --- a/packages/hal/arm/arch/current/include/hal_arch.h +++ b/packages/hal/arm/arch/current/include/hal_arch.h @@ -279,6 +279,35 @@ externC void hal_idle_thread_action(cyg_ #define HAL_IDLE_THREAD_ACTION(_count_) hal_idle_thread_action(_count_) //--------------------------------------------------------------------------- +// Table definition macros. +// The ARM assembler has a slightly different syntax for some of this, so +// we have to define alternatives here. +// Note that the __string() and __xstring() macros used here are defined in +// hal_tables.h. + +#ifndef CYG_HAL_TABLE_BEGIN +#define CYG_HAL_TABLE_BEGIN( _label, _name ) \ +__asm__(".section \"" __string(.ecos.table.##_name##.begin) "\",\"aw\"\n" \ + ".globl " __xstring(CYG_LABEL_DEFN(_label)) "\n" \ + ".type " __xstring(CYG_LABEL_DEFN(_label)) ",object\n" \ + ".p2align 2\n" \ +__xstring(CYG_LABEL_DEFN(_label)) ":\n" \ + ".previous\n" \ + ) +#endif + +#ifndef CYG_HAL_TABLE_END +#define CYG_HAL_TABLE_END( _label, _name ) \ +__asm__(".section \"" __string(.ecos.table.##_name##.finish) "\",\"aw\"\n" \ + ".globl " __xstring(CYG_LABEL_DEFN(_label)) "\n" \ + ".type " __xstring(CYG_LABEL_DEFN(_label)) ",object\n" \ + ".p2align 2\n" \ +__xstring(CYG_LABEL_DEFN(_label)) ":\n" \ + ".previous\n" \ + ) +#endif + +//--------------------------------------------------------------------------- // Minimal and sensible stack sizes: the intention is that applications // will use these to provide a stack size in the first instance prior to diff --git a/packages/hal/arm/arch/current/include/hal_intr.h b/packages/hal/arm/arch/current/include/hal_intr.h --- a/packages/hal/arm/arch/current/include/hal_intr.h +++ b/packages/hal/arm/arch/current/include/hal_intr.h @@ -104,6 +104,14 @@ externC CYG_ADDRESS hal_vsr_table[CYG // Platform setup memory size (0 if unknown by hardware) externC CYG_ADDRWORD hal_dram_size; +#if CYGINT_HAL_ARM_MEM_REAL_REGION_TOP + +externC cyg_uint8 *hal_arm_mem_real_region_top( cyg_uint8 *_regionend_ ); + +# define HAL_MEM_REAL_REGION_TOP( _regionend_ ) \ + hal_arm_mem_real_region_top( _regionend_ ) +#endif + //-------------------------------------------------------------------------- // Default ISR // The #define is used to test whether this routine exists, and to allow diff --git a/packages/hal/arm/arch/current/src/arm.ld b/packages/hal/arm/arch/current/src/arm.ld --- a/packages/hal/arm/arch/current/src/arm.ld +++ b/packages/hal/arm/arch/current/src/arm.ld @@ -91,12 +91,12 @@ OUTPUT_FORMAT(elf32-bigarm) #define SECTION_text(_region_, _vma_, _lma_) \ .text _vma_ : _lma_ \ - { stext = ABSOLUTE(.); \ + { _stext = ABSOLUTE(.); \ PROVIDE (__stext = ABSOLUTE(.)); \ *(.text*) *(.gnu.warning) *(.gnu.linkonce*) *(.init) \ *(.glue_7) *(.glue_7t) \ } > _region_ \ - etext = .; PROVIDE (__etext = .); + _etext = .; PROVIDE (__etext = .); #define SECTION_fini(_region_, _vma_, _lma_) \ .fini _vma_ : _lma_ \ @@ -144,8 +144,8 @@ OUTPUT_FORMAT(elf32-bigarm) _GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.); \ _GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); \ . = ALIGN (4); \ - __DEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.devtab*))) __DEVTAB_END__ = ABSOLUTE (.); \ - __NETDEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.netdevtab*))) __NETDEVTAB_END__ = ABSOLUTE (.); \ + KEEP(*( SORT (.ecos.table.*))) ; \ + . = ALIGN (4); \ __CTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.ctors*))) __CTOR_END__ = ABSOLUTE (.); \ __DTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.dtors*))) __DTOR_END__ = ABSOLUTE (.); \ *(.dynamic) *(.sdata*) *(.sbss*) } \ diff --git a/packages/hal/arm/arch/current/src/arm_stub.c b/packages/hal/arm/arch/current/src/arm_stub.c --- a/packages/hal/arm/arch/current/src/arm_stub.c +++ b/packages/hal/arm/arch/current/src/arm_stub.c @@ -508,7 +508,7 @@ void __clear_breakpoints (void) int __is_breakpoint_function () { - return get_register (PC) == (target_register_t)&CYG_LABEL_NAME(breakinst); + return get_register (PC) == (target_register_t)&_breakinst; } diff --git a/packages/hal/arm/arch/current/src/hal_misc.c b/packages/hal/arm/arch/current/src/hal_misc.c --- a/packages/hal/arm/arch/current/src/hal_misc.c +++ b/packages/hal/arm/arch/current/src/hal_misc.c @@ -208,7 +208,7 @@ hal_idle_thread_action( cyg_uint32 count void breakpoint(void) { - HAL_BREAKPOINT(breakinst); + HAL_BREAKPOINT(_breakinst); } diff --git a/packages/hal/arm/cma230/current/include/hal_cma230.h b/packages/hal/arm/cma230/current/include/hal_cma230.h --- a/packages/hal/arm/cma230/current/include/hal_cma230.h +++ b/packages/hal/arm/cma230/current/include/hal_cma230.h @@ -46,7 +46,7 @@ //===========================================================================*/ // Note: these defintions match the documentation, thus no attempt is made -// to sanitize (mangle) the names. Also, care should be taken to keep this +// to sanitise (mangle) the names. Also, care should be taken to keep this // clean for use in assembly code (no "C" constructs). #define CMA230_ISR 0x0F600000 // Interrupt source register - Read only diff --git a/packages/hal/arm/ebsa285/current/ChangeLog b/packages/hal/arm/ebsa285/current/ChangeLog --- a/packages/hal/arm/ebsa285/current/ChangeLog +++ b/packages/hal/arm/ebsa285/current/ChangeLog @@ -1,3 +1,42 @@ +2000-08-16 Hugo Tyson + + * include/hal_platform_setup.h (CYGHWR_LED_MACRO): Use an address + that works for a customer's own not-quite-exactly-like an EBSA + board. It works fine on a real EBSA too of course. + [CASE 104355] + +2000-08-15 Hugo Tyson + + * include/pkgconf/mlt_arm_ebsa285_ram.h (CYGMEM_REGION_ram_SIZE): + * include/pkgconf/mlt_arm_ebsa285_rom.h (CYGMEM_REGION_ram_SIZE): + Do not "helpfully" consume all of memory for the heap, including + PCI space, unconditionally; leave the PCI window alone. + +2000-08-07 Gary Thomas + + * include/plf_io.h (HAL_PCI_INIT): Force PCI reset, just for + good measure. + +2000-08-03 Gary Thomas + + * src/ebsa285_misc.c (hal_delay_us): New routine, used for + hardware delays when no kernel timers are available. + + * include/hal_platform_setup.h (PLATFORM_SETUP1): Don't re-init + hardware for RAM startup. Doing so keeps network debugging from + working (PCI gets shutdown, etc). + +2000-07-25 Jonathan Larmour + + * include/pkgconf/mlt_arm_ebsa285_ram.mlt: Add heap1 section for malloc + * include/pkgconf/mlt_arm_ebsa285_ram.ldi: Regenerate + * include/pkgconf/mlt_arm_ebsa285_ram.h: Regenerate + * include/pkgconf/mlt_arm_ebsa285_rom.mlt: Add heap1 section for malloc + * include/pkgconf/mlt_arm_ebsa285_rom.ldi: Regenerate + * include/pkgconf/mlt_arm_ebsa285_rom.h: Regenerate + + * src/ebsa285_misc.c (hal_arm_mem_real_region_top): Remove warnings + 2000-07-17 Jesper Skov * src/hal_diag.c (cyg_hal_plf_serial_isr): Return value was not @@ -14,6 +53,15 @@ 2000-07-04 Jesper Skov + + * cdl/hal_arm_ebsa285.cdl: This platform implements + CYGINT_HAL_ARM_MEM_REAL_REGION_TOP + + * src/ebsa285_misc.c (hal_arm_mem_real_region_top): Add to allow + true memory sizes to be reported, for the benefit of dynamic memory + systems + 2000-06-19 Gary Thomas * include/hal_platform_setup.h: diff --git a/packages/hal/arm/ebsa285/current/cdl/hal_arm_ebsa285.cdl b/packages/hal/arm/ebsa285/current/cdl/hal_arm_ebsa285.cdl --- a/packages/hal/arm/ebsa285/current/cdl/hal_arm_ebsa285.cdl +++ b/packages/hal/arm/ebsa285/current/cdl/hal_arm_ebsa285.cdl @@ -54,6 +54,7 @@ cdl_package CYGPKG_HAL_ARM_EBSA285 { implements CYGINT_HAL_DEBUG_GDB_STUBS implements CYGINT_HAL_DEBUG_GDB_STUBS_BREAK implements CYGINT_HAL_VIRTUAL_VECTOR_SUPPORT + implements CYGINT_HAL_ARM_MEM_REAL_REGION_TOP define_proc { puts $::cdl_system_header "#define CYGBLD_HAL_TARGET_H " @@ -103,6 +104,12 @@ cdl_package CYGPKG_HAL_ARM_EBSA285 { increments." } + cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT { + display "Default console channel." + flavor data + calculated 0 + } + cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS { display "Number of communication channels on the board" flavor data @@ -320,4 +327,32 @@ cdl_package CYGPKG_HAL_ARM_EBSA285 { \"GDB_stubs\" provides support when GDB stubs are included in the ROM monitor or boot ROM." } + + cdl_component CYGPKG_REDBOOT_HAL_OPTIONS { + display "Redboot HAL options" + flavor none + no_define + parent CYGPKG_REDBOOT + active_if CYGPKG_REDBOOT + description " + This option lists the target's requirements for a valid Redboot + configuration." + + cdl_option CYGBLD_BUILD_REDBOOT_BIN { + display "Build Redboot ROM binary image" + active_if CYGBLD_BUILD_REDBOOT + default_value 1 + no_define + description "This option enables the conversion of the Redboot ELF + image to a binary image suitable for ROM programming." + + make -priority 325 { + /bin/redboot.bin : /bin/redboot.elf + $(OBJCOPY) --strip-debug $< $(@:.bin=.img) + $(OBJCOPY) -O srec $< $(@:.bin=.srec) + $(OBJCOPY) -O binary $< $@ + } + } + } + } diff --git a/packages/hal/arm/ebsa285/current/include/hal_diag.h b/packages/hal/arm/ebsa285/current/include/hal_diag.h --- a/packages/hal/arm/ebsa285/current/include/hal_diag.h +++ b/packages/hal/arm/ebsa285/current/include/hal_diag.h @@ -57,6 +57,11 @@ #define HAL_DIAG_WRITE_CHAR(_c_) hal_if_diag_write_char(_c_) #define HAL_DIAG_READ_CHAR(_c_) hal_if_diag_read_char(&_c_) +// Not the best place for this, but ... +extern void hal_delay_us(cyg_int32 usecs); + +#define HAL_DELAY_US(n) hal_delay_us(n); + #else // everything by steam /*---------------------------------------------------------------------------*/ diff --git a/packages/hal/arm/ebsa285/current/include/hal_ebsa285.h b/packages/hal/arm/ebsa285/current/include/hal_ebsa285.h --- a/packages/hal/arm/ebsa285/current/include/hal_ebsa285.h +++ b/packages/hal/arm/ebsa285/current/include/hal_ebsa285.h @@ -47,7 +47,7 @@ //===========================================================================*/ // Note: these defintions match the documentation, thus no attempt is made -// to mangle the names against namespace pollution. Also, care should be +// to santise (mangle) the names against namespace pollution. Also, care should be // taken to keep this clean for use in assembly code (no "C" constructs). diff --git a/packages/hal/arm/ebsa285/current/include/hal_platform_setup.h b/packages/hal/arm/ebsa285/current/include/hal_platform_setup.h --- a/packages/hal/arm/ebsa285/current/include/hal_platform_setup.h +++ b/packages/hal/arm/ebsa285/current/include/hal_platform_setup.h @@ -63,7 +63,7 @@ ldr r0,[r0] ;\ tsts r0,#0x00800000 /* SA110_XBUS_CYCLE_ARBITER_ENABLED */ ;\ bne 667f /* Don't touch if PCI arbiter enabled */;\ - ldr r0,=0x40012000 /* SA110_XBUS_XCS2 */ ;\ + ldr r0,=0x40012800 /* SA110_XBUS_XCS2 */ ;\ mov r1,#7&(~(\x)) ;\ str r1,[r0] ;\ 667: @@ -73,13 +73,17 @@ 667: // divided into further macros to make it easier to manage what's enabled // when. +#ifdef CYG_HAL_STARTUP_ROM // Dependence on ROM/RAM start removed when meminit code fixed up. #define PLATFORM_SETUP1 \ PLATFORM_FLUSH_DISABLE_CACHES \ INIT_XBUS_ACCESS \ ALLOW_CLOCK_SWITCHING \ CALL_MEMINIT_CODE \ - BASIC_PCI_SETUP \ + BASIC_PCI_SETUP +#else +#define PLATFORM_SETUP1 +#endif // Discard and disable all caches: we are about to be writing vectors... diff --git a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.h b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.h --- a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.h +++ b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.h @@ -1,13 +1,27 @@ -// eCos memory layout - Tue Feb 29 14:43:13 2000 +// eCos memory layout - Tue Jul 25 19:44:27 2000 -// This is a generated file - do not edit +// This is a generated file - do not edit - ho ho ho. #include #include +#include +#include CYGBLD_HAL_PLATFORM_H + #define CYGMEM_REGION_ram (0) + +#ifndef CYGHWR_HAL_ARM_EBSA285_PCI_MEM_MAP_BASE +// Then no PCI window is to be reserved. #define CYGMEM_REGION_ram_SIZE (0x1000000) +#else +// Do not trample the PCI window: +#define CYGMEM_REGION_ram_SIZE CYGHWR_HAL_ARM_EBSA285_PCI_MEM_MAP_BASE +#endif + #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) -extern char CYG_LABEL_NAME (_reserved) []; -#define CYGMEM_SECTION_reserved (CYG_LABEL_NAME (_reserved)) -#define CYGMEM_SECTION_reserved_SIZE (0x10000) + +extern char CYG_LABEL_NAME (__heap1) []; +#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1)) +#define CYGMEM_SECTION_heap1_SIZE \ + (CYGMEM_REGION_ram_SIZE - (size_t) CYG_LABEL_NAME (__heap1)) + diff --git a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.ldi b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.ldi --- a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.ldi +++ b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.ldi @@ -1,7 +1,9 @@ -// eCos memory layout - Tue Feb 29 14:43:13 2000 +// eCos memory layout - Tue Jul 25 19:44:27 2000 // This is a generated file - do not edit +#include + MEMORY { ram : ORIGIN = 0, LENGTH = 0x1000000 @@ -11,7 +13,7 @@ SECTIONS { SECTIONS_BEGIN SECTION_fixed_vectors (ram, 0x20, LMA_EQ_VMA) - SECTION_rom_vectors (ram, 0x10000, LMA_EQ_VMA) + SECTION_rom_vectors (ram, 0x20000, LMA_EQ_VMA) SECTION_text (ram, ALIGN (0x4), LMA_EQ_VMA) SECTION_fini (ram, ALIGN (0x4), LMA_EQ_VMA) SECTION_rodata (ram, ALIGN (0x4), LMA_EQ_VMA) @@ -20,5 +22,6 @@ SECTIONS SECTION_gcc_except_table (ram, ALIGN (0x4), LMA_EQ_VMA) SECTION_data (ram, ALIGN (0x4), LMA_EQ_VMA) SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA) + CYG_LABEL_DEFN(__heap1) = ALIGN (0x8); SECTIONS_END } diff --git a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.mlt b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.mlt --- a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.mlt +++ b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_ram.mlt @@ -1,7 +1,7 @@ version 0 region ram 0 1000000 0 ! section fixed_vectors 0 1 0 1 1 0 1 0 20 20 ! -section rom_vectors 0 1 0 1 1 1 1 1 10000 10000 text text ! +section rom_vectors 0 1 0 1 1 1 1 1 20000 20000 text text ! section text 0 4 0 1 0 1 0 1 fini fini ! section fini 0 4 0 1 0 1 0 1 rodata rodata ! section rodata 0 4 0 1 0 1 0 1 rodata1 rodata1 ! @@ -9,4 +9,5 @@ section rodata1 0 4 0 1 0 1 0 1 fixup fi section fixup 0 4 0 1 0 1 0 1 gcc_except_table gcc_except_table ! section gcc_except_table 0 4 0 1 0 1 0 1 data data ! section data 0 4 0 1 0 1 0 1 bss bss ! -section bss 0 4 0 1 0 0 0 0 ! +section bss 0 4 0 1 0 1 0 1 heap1 heap1 ! +section heap1 0 8 0 0 0 0 0 0 ! diff --git a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.h b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.h --- a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.h +++ b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.h @@ -1,16 +1,31 @@ -// eCos memory layout - Tue Feb 29 14:44:14 2000 +// eCos memory layout - Tue Jul 25 19:45:02 2000 -// This is a generated file - do not edit +// This is a generated file - do not edit - ho ho ho. #include #include +#include +#include CYGBLD_HAL_PLATFORM_H + #define CYGMEM_REGION_ram (0) + +#ifndef CYGHWR_HAL_ARM_EBSA285_PCI_MEM_MAP_BASE +// Then no PCI window is to be reserved. #define CYGMEM_REGION_ram_SIZE (0x1000000) +#else +// Do not trample the PCI window: +#define CYGMEM_REGION_ram_SIZE CYGHWR_HAL_ARM_EBSA285_PCI_MEM_MAP_BASE +#endif + #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) + #define CYGMEM_REGION_rom (0x41000000) #define CYGMEM_REGION_rom_SIZE (0x400000) #define CYGMEM_REGION_rom_ATTR (CYGMEM_REGION_ATTR_R) -extern char CYG_LABEL_NAME (_reserved) []; -#define CYGMEM_SECTION_reserved (CYG_LABEL_NAME (_reserved)) -#define CYGMEM_SECTION_reserved_SIZE (0x8000) + +extern char CYG_LABEL_NAME (__heap1) []; +#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1)) +#define CYGMEM_SECTION_heap1_SIZE \ + (CYGMEM_REGION_ram_SIZE - (size_t) CYG_LABEL_NAME (__heap1)) + diff --git a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.ldi b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.ldi --- a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.ldi +++ b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.ldi @@ -1,7 +1,9 @@ -// eCos memory layout - Tue Feb 29 14:44:14 2000 +// eCos memory layout - Tue Jul 25 19:45:02 2000 // This is a generated file - do not edit +#include + MEMORY { ram : ORIGIN = 0, LENGTH = 0x1000000 @@ -21,5 +23,6 @@ SECTIONS SECTION_fixed_vectors (ram, 0x20, LMA_EQ_VMA) SECTION_data (ram, 0x8000, FOLLOWING (.gcc_except_table)) SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA) + CYG_LABEL_DEFN(__heap1) = ALIGN (0x8); SECTIONS_END } diff --git a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.mlt b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.mlt --- a/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.mlt +++ b/packages/hal/arm/ebsa285/current/include/pkgconf/mlt_arm_ebsa285_rom.mlt @@ -3,7 +3,8 @@ region ram 0 1000000 0 ! region rom 41000000 400000 1 ! section fixed_vectors 0 1 0 1 1 0 1 0 20 20 ! section data 0 1 1 1 1 1 0 0 8000 bss ! -section bss 0 4 0 1 0 0 0 0 ! +section bss 0 4 0 1 0 1 0 1 heap1 heap1 ! +section heap1 0 8 0 0 0 0 0 0 ! section rom_vectors 0 1 0 1 1 1 1 1 41000000 41000000 text text ! section text 0 4 0 1 0 1 0 1 fini fini ! section fini 0 4 0 1 0 1 0 1 rodata rodata ! diff --git a/packages/hal/arm/ebsa285/current/include/plf_io.h b/packages/hal/arm/ebsa285/current/include/plf_io.h --- a/packages/hal/arm/ebsa285/current/include/plf_io.h +++ b/packages/hal/arm/ebsa285/current/include/plf_io.h @@ -70,6 +70,11 @@ CYG_MACRO_START \ cyg_uint32 __tmp, __tmp2; \ \ + /* Assert PCI_reset */ \ + HAL_READ_UINT32(SA110_CONTROL, __tmp); \ + __tmp &= ~SA110_CONTROL_RST_I; \ + HAL_WRITE_UINT32(SA110_CONTROL, __tmp); \ + \ /* Disable PCI Outbound interrupts */ \ /* (according to 7-14 SA110_OUT_INT_MASK is not accessible */ \ /* by SA-100) */ \ diff --git a/packages/hal/arm/ebsa285/current/src/ebsa285_misc.c b/packages/hal/arm/ebsa285/current/src/ebsa285_misc.c --- a/packages/hal/arm/ebsa285/current/src/ebsa285_misc.c +++ b/packages/hal/arm/ebsa285/current/src/ebsa285_misc.c @@ -44,6 +44,7 @@ #include #include #include CYGBLD_HAL_PLATFORM_H +#include CYGHWR_MEMORY_LAYOUT_H #include // base types #include // tracing macros @@ -106,6 +107,9 @@ void hal_hardware_init(void) *SA110_TIMER3_CLEAR = 0; *SA110_TIMER4_CLEAR = 0; + // Let the timer run at a default rate (for delays) + hal_clock_initialize(CYGNUM_HAL_RTC_PERIOD); + // Set up MMU so that we can use caches hal_bsp_mmu_init( hal_dram_size ); @@ -304,6 +308,30 @@ hal_bsp_mmu_init(int sdram_size) } +/*------------------------------------------------------------------------*/ + +// +// Memory layout +// + +externC cyg_uint8 * +hal_arm_mem_real_region_top( cyg_uint8 *regionend ) +{ + CYG_ASSERT( hal_dram_size > 0, "Didn't detect DRAM size!" ); + CYG_ASSERT( hal_dram_size <= 256<<20, + "More than 256MB reported - that can't be right" ); + + // is it the "normal" end of the DRAM region? If so, it should be + // replaced by the real size + if ( regionend == + ((cyg_uint8 *)CYGMEM_REGION_ram + CYGMEM_REGION_ram_SIZE) ) { + regionend = (cyg_uint8 *)CYGMEM_REGION_ram + hal_dram_size; + } + return regionend; +} // hal_arm_mem_real_region_top() + + + // ------------------------------------------------------------------------- static cyg_uint32 _period; @@ -342,6 +370,30 @@ void hal_clock_read(cyg_uint32 *pvalue) *pvalue = (cyg_uint32)(_period) - *SA110_TIMER3_VALUE; } +// +// Delay for some number of micro-seconds +// +void hal_delay_us(cyg_int32 usecs) +{ + int diff, diff2; + cyg_uint32 val1, val2; + while (usecs-- > 0) { + diff = 0; + while (diff < 3) { + val1 = *SA110_TIMER3_VALUE; + while ((val2 = *SA110_TIMER3_VALUE) == val1) ; + if (*SA110_TIMER3_LOAD) { + // A kernel is running, the counter may get reset as we watch + diff2 = val2 - val1; + if (diff2 < 0) diff2 += *SA110_TIMER3_LOAD; + diff += diff2; + } else { + diff += val2 - val1; + } + } + } +} + // ------------------------------------------------------------------------- // This routine is called to respond to a hardware interrupt (IRQ). It diff --git a/packages/hal/arm/edb7xxx/current/ChangeLog b/packages/hal/arm/edb7xxx/current/ChangeLog --- a/packages/hal/arm/edb7xxx/current/ChangeLog +++ b/packages/hal/arm/edb7xxx/current/ChangeLog @@ -1,3 +1,38 @@ +2000-08-18 Gary Thomas + + * src/hal_diag.c (cyg_hal_plf_serial_getc): Only call dram refresh + [workaround] every 10ms or so, not all the time. This fixes GDB + serial overrun problems. + +2000-08-16 Gary Thomas + + * include/hal_cache.h (HAL_UCACHE_INVALIDATE_ALL): Fix - wrong code. + + * include/hal_platform_setup.h: Map all of SRAM (was only mapping + 4K which is all that the CL7111 had). + +2000-08-15 Gary Thomas + + * include/hal_platform_setup.h: Make ROM segment not cached (since + the data cache seems to stick on). + + * include/pkgconf/mlt_arm_edb7211_ram.h: + * include/pkgconf/mlt_arm_edb7211_ram.ldi: + * include/pkgconf/mlt_arm_edb7211_ram.mlt: Expand reserved area. + +2000-08-14 Gary Thomas + + * cdl/hal_arm_edb7xxx.cdl: Add support for RedBoot. + + * include/hal_cache.h: Trying to get cache working properly. + + * include/pkgconf/mlt_arm_edb7212_ram.h: + * include/pkgconf/mlt_arm_edb7212_ram.ldi: + * include/pkgconf/mlt_arm_edb7212_ram.mlt: Expand reserved area. + + * include/hal_diag.h: + * src/edb7xxx_misc.c: Add support for HAL_DELAY_US(). + 2000-07-07 Jesper Skov * src/edb7xxx_misc.c (dram_delay_loop): diff --git a/packages/hal/arm/edb7xxx/current/cdl/hal_arm_edb7xxx.cdl b/packages/hal/arm/edb7xxx/current/cdl/hal_arm_edb7xxx.cdl --- a/packages/hal/arm/edb7xxx/current/cdl/hal_arm_edb7xxx.cdl +++ b/packages/hal/arm/edb7xxx/current/cdl/hal_arm_edb7xxx.cdl @@ -55,6 +55,7 @@ cdl_package CYGPKG_HAL_ARM_EDB7XXX { implements CYGINT_HAL_DEBUG_GDB_STUBS implements CYGINT_HAL_DEBUG_GDB_STUBS_BREAK implements CYGINT_HAL_VIRTUAL_VECTOR_SUPPORT + implements CYGINT_HAL_VIRTUAL_VECTOR_SUPPORT_GUARANTEED define_proc { puts $::cdl_system_header "#define CYGBLD_HAL_TARGET_H " @@ -141,6 +142,13 @@ cdl_package CYGPKG_HAL_ARM_EDB7XXX { flavor data calculated 2 } + + cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT { + display "Default console channel." + flavor data + legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1 + calculated 0 + } cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL { display "Debug serial port" @@ -559,4 +567,32 @@ cdl_package CYGPKG_HAL_ARM_EDB7XXX { \"GDB_stubs\" provides support when GDB stubs are included in the ROM monitor or boot ROM." } + + cdl_component CYGPKG_REDBOOT_HAL_OPTIONS { + display "Redboot HAL options" + flavor none + no_define + parent CYGPKG_REDBOOT + active_if CYGPKG_REDBOOT + description " + This option lists the target's requirements for a valid Redboot + configuration." + + cdl_option CYGBLD_BUILD_REDBOOT_BIN { + display "Build Redboot ROM binary image" + active_if CYGBLD_BUILD_REDBOOT + default_value 1 + no_define + description "This option enables the conversion of the Redboot ELF + image to a binary image suitable for ROM programming." + + make -priority 325 { + /bin/redboot.bin : /bin/redboot.elf + $(OBJCOPY) --strip-debug $< $(@:.bin=.img) + $(OBJCOPY) -O srec $< $(@:.bin=.srec) + $(OBJCOPY) -O binary $< $@ + } + } + } + } diff --git a/packages/hal/arm/edb7xxx/current/include/hal_cache.h b/packages/hal/arm/edb7xxx/current/include/hal_cache.h --- a/packages/hal/arm/edb7xxx/current/include/hal_cache.h +++ b/packages/hal/arm/edb7xxx/current/include/hal_cache.h @@ -100,7 +100,7 @@ #define HAL_UCACHE_ENABLE() \ { \ asm volatile ("mov r1,#0x7D;" \ - "mcr p15,0,r1,c1,c0;" \ + "mcr p15,0,r1,c1,c0,0;" \ : \ : \ : "r1" /* Clobber list */ \ @@ -112,7 +112,8 @@ #define HAL_UCACHE_DISABLE() \ { \ asm volatile ("mov r1,#0x71;" \ - "mcr p15,0,r1,c1,c0;" \ + "mcr p15,0,r1,c1,c0,0;" \ + "mcr p15,0,r1,c8,c7,0;" /* flush I+D TLBs */ \ : \ : \ : "r1" /* Clobber list */ \ @@ -128,7 +129,7 @@ // mcr MMU_CP,0,r1,MMU_InvalidateCache,c0 #define HAL_UCACHE_INVALIDATE_ALL() \ { \ - asm volatile ("mcr p15,0,r1,c7,c0,0;" ); \ + asm volatile ("mcr p15,0,r1,c7,c7,0;" ); \ \ } diff --git a/packages/hal/arm/edb7xxx/current/include/hal_diag.h b/packages/hal/arm/edb7xxx/current/include/hal_diag.h --- a/packages/hal/arm/edb7xxx/current/include/hal_diag.h +++ b/packages/hal/arm/edb7xxx/current/include/hal_diag.h @@ -57,6 +57,11 @@ #define HAL_DIAG_WRITE_CHAR(_c_) hal_if_diag_write_char(_c_) #define HAL_DIAG_READ_CHAR(_c_) hal_if_diag_read_char(&_c_) +// Not the best place for this, but ... +extern void hal_delay_us(cyg_int32 usecs); + +#define HAL_DELAY_US(n) hal_delay_us(n); + #else // everything by steam /*---------------------------------------------------------------------------*/ diff --git a/packages/hal/arm/edb7xxx/current/include/hal_edb7xxx.h b/packages/hal/arm/edb7xxx/current/include/hal_edb7xxx.h --- a/packages/hal/arm/edb7xxx/current/include/hal_edb7xxx.h +++ b/packages/hal/arm/edb7xxx/current/include/hal_edb7xxx.h @@ -46,7 +46,7 @@ //===========================================================================*/ // Note: these defintions match the documentation, thus no attempt is made -// to sanitize (mangle) the names. Also, care should be taken to keep this +// to sanitise (mangle) the names. Also, care should be taken to keep this // clean for use in assembly code (no "C" constructs). #define PADR 0x80000000 // Port A data register diff --git a/packages/hal/arm/edb7xxx/current/include/hal_platform_setup.h b/packages/hal/arm/edb7xxx/current/include/hal_platform_setup.h --- a/packages/hal/arm/edb7xxx/current/include/hal_platform_setup.h +++ b/packages/hal/arm/edb7xxx/current/include/hal_platform_setup.h @@ -104,7 +104,11 @@ #define PCMCIA1_LA_START 0x50000000 #define PCMCIA1_PA 0x50000000 #define SRAM_LA_START 0x60000000 +#ifdef CYGHWR_HAL_ARM_EDB7XXX_VARIANT_CL_PS7111 // 4K SRAM #define SRAM_LA_END 0x60001000 +#else // 72xx - 37.5K SRAM +#define SRAM_LA_END 0x6000A000 +#endif #define SRAM_PA 0x60000000 #define IO_LA_START 0x80000000 #define IO_LA_END 0x80003000 @@ -354,13 +358,16 @@ 10: orr r0,r5,r6 ldr r4,=MMU_L1_TYPE_Page|MMU_DOMAIN(0) ;\ orr r4,r4,r2 ;\ str r4,[r1],#4 ;\ - ldr r4,=MMU_L2_TYPE_Small|MMU_AP_Any|MMU_Bufferable|MMU_Cacheable;\ + ldr r7,=MMU_PAGE_SIZE ;\ + ldr r5,=SRAM_LA_END ;\ +05: ldr r4,=MMU_L2_TYPE_Small|MMU_AP_Any|MMU_Bufferable|MMU_Cacheable;\ orr r4,r3,r4 ;\ str r4,[r2],#4 ;\ - ldr r3,=SRAM_LA_START+MMU_PAGE_SIZE ;\ + add r3,r3,r7 ;\ + cmp r3,r5 ;\ + bne 05b ;\ ldr r4,=SRAM_LA_START+MMU_SECTION_SIZE ;\ ldr r5,=MMU_L2_TYPE_Fault ;\ - ldr r7,=MMU_PAGE_SIZE ;\ 10: str r5,[r2],#4 ;\ add r3,r3,r7 ;\ cmp r3,r4 ;\ @@ -407,7 +414,7 @@ 20: str r5,[r1],#4 ldr r3,=LCD_LA_START ;\ ldr r4,=ROM0_LA_START ;\ ldr r5,=LCD_PA ;\ - ldr r6,=MMU_L1_TYPE_Section|MMU_AP_Any \ + ldr r6,=MMU_L1_TYPE_Section|MMU_AP_Any \ |MMU_Bufferable|MMU_Cacheable ;\ ldr r7,=MMU_SECTION_SIZE ;\ 10: orr r0,r5,r6 ;\ @@ -420,7 +427,7 @@ 10: orr r0,r5,r6 ldr r3,=ROM0_LA_START ;\ ldr r4,=ROM0_LA_END ;\ ldr r5,=ROM0_PA ;\ - ldr r6,=MMU_L1_TYPE_Section|MMU_AP_Any|MMU_Cacheable ;\ + ldr r6,=MMU_L1_TYPE_Section|MMU_AP_Any/*|MMU_Cacheable*/ ;\ ldr r7,=MMU_SECTION_SIZE ;\ 10: orr r0,r5,r6 ;\ str r0,[r1],#4 ;\ diff --git a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.h b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.h --- a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.h +++ b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.h @@ -10,4 +10,4 @@ #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) extern char CYG_LABEL_NAME (_reserved) []; #define CYGMEM_SECTION_reserved (CYG_LABEL_NAME (_reserved)) -#define CYGMEM_SECTION_reserved_SIZE (0x8000 - (size_t) CYG_LABEL_NAME (_reserved)) +#define CYGMEM_SECTION_reserved_SIZE (0x10000 - (size_t) CYG_LABEL_NAME (_reserved)) diff --git a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.ldi b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.ldi --- a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.ldi +++ b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.ldi @@ -11,7 +11,7 @@ SECTIONS { SECTIONS_BEGIN SECTION_fixed_vectors (ram, 0x20, LMA_EQ_VMA) - SECTION_rom_vectors (ram, 0x8000, LMA_EQ_VMA) + SECTION_rom_vectors (ram, 0x10000, LMA_EQ_VMA) SECTION_text (ram, ALIGN (0x4), LMA_EQ_VMA) SECTION_fini (ram, ALIGN (0x4), LMA_EQ_VMA) SECTION_rodata (ram, ALIGN (0x4), LMA_EQ_VMA) diff --git a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.mlt b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.mlt --- a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.mlt +++ b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7211_ram.mlt @@ -1,7 +1,7 @@ version 0 region ram 0 fd9000 0 !DRAM section fixed_vectors 0 1 0 1 1 0 1 0 20 20 ! -section rom_vectors 0 1 0 1 1 1 1 1 8000 8000 text text ! +section rom_vectors 0 1 0 1 1 1 1 1 10000 10000 text text ! section text 0 4 0 1 0 1 0 1 fini fini ! section fini 0 4 0 1 0 1 0 1 rodata rodata ! section rodata 0 4 0 1 0 1 0 1 rodata1 rodata1 ! diff --git a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.h b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.h --- a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.h +++ b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.h @@ -13,4 +13,4 @@ #define CYGMEM_REGION_sram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) extern char CYG_LABEL_NAME (_reserved) []; #define CYGMEM_SECTION_reserved (CYG_LABEL_NAME (_reserved)) -#define CYGMEM_SECTION_reserved_SIZE (0x8000) +#define CYGMEM_SECTION_reserved_SIZE (0x10000) diff --git a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.ldi b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.ldi --- a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.ldi +++ b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.ldi @@ -12,7 +12,7 @@ SECTIONS { SECTIONS_BEGIN SECTION_fixed_vectors (ram, 0x20, LMA_EQ_VMA) - SECTION_rom_vectors (ram, 0x8000, LMA_EQ_VMA) + SECTION_rom_vectors (ram, 0x10000, LMA_EQ_VMA) SECTION_text (ram, ALIGN (0x4), LMA_EQ_VMA) SECTION_fini (ram, ALIGN (0x4), LMA_EQ_VMA) SECTION_rodata (ram, ALIGN (0x4), LMA_EQ_VMA) diff --git a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.mlt b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.mlt --- a/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.mlt +++ b/packages/hal/arm/edb7xxx/current/include/pkgconf/mlt_arm_edb7212_ram.mlt @@ -2,7 +2,7 @@ version 0 region ram 0 fd7000 0 ! region sram 60000000 9c00 0 ! section fixed_vectors 0 1 0 1 1 0 1 0 20 20 ! -section rom_vectors 0 1 0 1 1 1 1 1 8000 8000 text text ! +section rom_vectors 0 1 0 1 1 1 1 1 10000 10000 text text ! section text 0 4 0 1 0 1 0 1 fini fini ! section fini 0 4 0 1 0 1 0 1 rodata rodata ! section rodata 0 4 0 1 0 1 0 1 rodata1 rodata1 ! diff --git a/packages/hal/arm/edb7xxx/current/misc/edb7211_redboot.cfg b/packages/hal/arm/edb7xxx/current/misc/edb7211_redboot.cfg new file mode 100644 --- /dev/null +++ b/packages/hal/arm/edb7xxx/current/misc/edb7211_redboot.cfg @@ -0,0 +1,58 @@ +cdl_savefile_version 1; +cdl_savefile_command cdl_savefile_version {}; +cdl_savefile_command cdl_savefile_command {}; +cdl_savefile_command cdl_configuration { description hardware template package }; +cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value }; + +cdl_configuration eCos { + description "" ; + hardware edb7211 ; + template redboot ; + package -hardware CYGPKG_HAL_ARM current ; + package -hardware CYGPKG_HAL_ARM_EDB7XXX current ; + package -hardware CYGPKG_DEVS_ETH_ARM_EDB7XXX current ; + package -hardware CYGPKG_IO_SERIAL_ARM_EDB7XXX current ; + package -template CYGPKG_HAL current ; + package -template CYGPKG_INFRA current ; + package -template CYGPKG_REDBOOT current ; + package CYGPKG_IO_ETH_DRIVERS current ; + package CYGPKG_IO_FLASH current ; + package CYGPKG_DEVS_FLASH_EDB7XXX current ; +}; + +cdl_option CYGBLD_BUILD_GDB_STUBS { + user_value 0 +}; + +cdl_option CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT { + user_value 0 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS { + inferred_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT { + inferred_value 0 +}; + +cdl_option CYGSEM_HAL_USE_ROM_MONITOR { + inferred_value 0 0 +}; + +cdl_option CYGHWR_HAL_ARM_EDB7XXX_VARIANT { + user_value EP7211 +}; + +cdl_option CYGHWR_HAL_ARM_EDB7XXX_PROCESSOR_CLOCK { + user_value 73728 +}; + +cdl_option CYGBLD_BUILD_REDBOOT { + user_value 1 +}; + + diff --git a/packages/hal/arm/edb7xxx/current/misc/edb7211_redboot_ROM.cfg b/packages/hal/arm/edb7xxx/current/misc/edb7211_redboot_ROM.cfg new file mode 100644 --- /dev/null +++ b/packages/hal/arm/edb7xxx/current/misc/edb7211_redboot_ROM.cfg @@ -0,0 +1,62 @@ +cdl_savefile_version 1; +cdl_savefile_command cdl_savefile_version {}; +cdl_savefile_command cdl_savefile_command {}; +cdl_savefile_command cdl_configuration { description hardware template package }; +cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value }; + +cdl_configuration eCos { + description "" ; + hardware edb7211 ; + template redboot ; + package -hardware CYGPKG_HAL_ARM current ; + package -hardware CYGPKG_HAL_ARM_EDB7XXX current ; + package -hardware CYGPKG_DEVS_ETH_ARM_EDB7XXX current ; + package -hardware CYGPKG_IO_SERIAL_ARM_EDB7XXX current ; + package -template CYGPKG_HAL current ; + package -template CYGPKG_INFRA current ; + package -template CYGPKG_REDBOOT current ; + package CYGPKG_IO_ETH_DRIVERS current ; + package CYGPKG_IO_FLASH current ; + package CYGPKG_DEVS_FLASH_EDB7XXX current ; +}; + +cdl_option CYGBLD_BUILD_GDB_STUBS { + user_value 0 +}; + +cdl_option CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT { + user_value 0 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS { + inferred_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT { + inferred_value 0 +}; + +cdl_option CYGSEM_HAL_USE_ROM_MONITOR { + inferred_value 0 0 +}; + +cdl_option CYGHWR_HAL_ARM_EDB7XXX_VARIANT { + user_value EP7211 +}; + +cdl_component CYG_HAL_STARTUP { + user_value ROM +}; + +cdl_option CYGHWR_HAL_ARM_EDB7XXX_PROCESSOR_CLOCK { + user_value 73728 +}; + +cdl_option CYGBLD_BUILD_REDBOOT { + user_value 1 +}; + + diff --git a/packages/hal/arm/edb7xxx/current/misc/edb7212_redboot.cfg b/packages/hal/arm/edb7xxx/current/misc/edb7212_redboot.cfg new file mode 100644 --- /dev/null +++ b/packages/hal/arm/edb7xxx/current/misc/edb7212_redboot.cfg @@ -0,0 +1,58 @@ +cdl_savefile_version 1; +cdl_savefile_command cdl_savefile_version {}; +cdl_savefile_command cdl_savefile_command {}; +cdl_savefile_command cdl_configuration { description hardware template package }; +cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value }; + +cdl_configuration eCos { + description "" ; + hardware edb7212 ; + template redboot ; + package -hardware CYGPKG_HAL_ARM current ; + package -hardware CYGPKG_HAL_ARM_EDB7XXX current ; + package -hardware CYGPKG_DEVS_ETH_ARM_EDB7XXX current ; + package -hardware CYGPKG_IO_SERIAL_ARM_EDB7XXX current ; + package -template CYGPKG_HAL current ; + package -template CYGPKG_INFRA current ; + package -template CYGPKG_REDBOOT current ; + package CYGPKG_IO_ETH_DRIVERS current ; + package CYGPKG_IO_FLASH current ; + package CYGPKG_DEVS_FLASH_EDB7XXX current ; +}; + +cdl_option CYGBLD_BUILD_GDB_STUBS { + user_value 0 +}; + +cdl_option CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT { + user_value 0 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS { + inferred_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT { + inferred_value 0 +}; + +cdl_option CYGSEM_HAL_USE_ROM_MONITOR { + inferred_value 0 0 +}; + +cdl_option CYGHWR_HAL_ARM_EDB7XXX_VARIANT { + user_value EP7212 +}; + +cdl_option CYGHWR_HAL_ARM_EDB7XXX_PROCESSOR_CLOCK { + user_value 73728 +}; + +cdl_option CYGBLD_BUILD_REDBOOT { + user_value 1 +}; + + diff --git a/packages/hal/arm/edb7xxx/current/misc/edb7212_redboot_ROM.cfg b/packages/hal/arm/edb7xxx/current/misc/edb7212_redboot_ROM.cfg new file mode 100644 --- /dev/null +++ b/packages/hal/arm/edb7xxx/current/misc/edb7212_redboot_ROM.cfg @@ -0,0 +1,62 @@ +cdl_savefile_version 1; +cdl_savefile_command cdl_savefile_version {}; +cdl_savefile_command cdl_savefile_command {}; +cdl_savefile_command cdl_configuration { description hardware template package }; +cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value }; + +cdl_configuration eCos { + description "" ; + hardware edb7212 ; + template redboot ; + package -hardware CYGPKG_HAL_ARM current ; + package -hardware CYGPKG_HAL_ARM_EDB7XXX current ; + package -hardware CYGPKG_DEVS_ETH_ARM_EDB7XXX current ; + package -hardware CYGPKG_IO_SERIAL_ARM_EDB7XXX current ; + package -template CYGPKG_HAL current ; + package -template CYGPKG_INFRA current ; + package -template CYGPKG_REDBOOT current ; + package CYGPKG_IO_ETH_DRIVERS current ; + package CYGPKG_IO_FLASH current ; + package CYGPKG_DEVS_FLASH_EDB7XXX current ; +}; + +cdl_option CYGBLD_BUILD_GDB_STUBS { + user_value 0 +}; + +cdl_option CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT { + user_value 0 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS { + inferred_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT { + inferred_value 0 +}; + +cdl_option CYGSEM_HAL_USE_ROM_MONITOR { + inferred_value 0 0 +}; + +cdl_option CYGHWR_HAL_ARM_EDB7XXX_VARIANT { + user_value EP7212 +}; + +cdl_component CYG_HAL_STARTUP { + user_value ROM +}; + +cdl_option CYGHWR_HAL_ARM_EDB7XXX_PROCESSOR_CLOCK { + user_value 73728 +}; + +cdl_option CYGBLD_BUILD_REDBOOT { + user_value 1 +}; + + diff --git a/packages/hal/arm/edb7xxx/current/src/edb7xxx_misc.c b/packages/hal/arm/edb7xxx/current/src/edb7xxx_misc.c --- a/packages/hal/arm/edb7xxx/current/src/edb7xxx_misc.c +++ b/packages/hal/arm/edb7xxx/current/src/edb7xxx_misc.c @@ -78,6 +78,7 @@ static cyg_handle_t batlow_interrupt_ha #endif static cyg_uint32 _period; +void dram_delay_loop(void); // Use Timer/Counter #2 for system clock @@ -135,11 +136,7 @@ void hal_clock_reset(cyg_uint32 vector, #ifdef CYGHWR_HAL_ARM_EDB7XXX_SOFTWARE_DRAM_REFRESH do_DRAM_refresh(); #else - // Temporary fix for DRAM starvation problem - if (CYGHWR_HAL_ARM_EDB7XXX_PROCESSOR_CLOCK > 37000) { - int i; - for (i = 0; i < (CYGHWR_HAL_ARM_EDB7XXX_PROCESSOR_CLOCK*2)/24; i++) ; // approx 300 us - } + dram_delay_loop(); #endif #endif } @@ -156,6 +153,29 @@ void hal_clock_read(cyg_uint32 *pvalue) *pvalue = (cyg_uint32)(_period - clock_val); // 'clock_val' counts down and wraps } +// Delay for some number of useconds. Assume that the system clock +// has been set up to run at 512KHz (default). +void hal_delay_us(int us) +{ + volatile cyg_int32 *tc2d = (volatile cyg_int32 *)TC2D; + cyg_int32 val, prev; + while (us >= 2) { + prev = *tc2d & 0x0000FFFF; // Register has only 16 bits + if (prev & 0x00008000) prev |= 0xFFFF8000; // Extend sign bit + while (true) { + val = *tc2d & 0x0000FFFF; // Register has only 16 bits + if (val & 0x00008000) { + val |= 0xFFFF8000; // Extend sign bit + *tc2d = _period; // Need to reset counter + } + if (val != prev) { + break; // At least 2us have passed + } + } + us -= 2; + } +} + void dram_delay_loop(void) { @@ -394,6 +414,9 @@ void hal_hardware_init(void) cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_BLINT); #endif + // Initialize real-time clock (for delays, etc, even if kernel doesn't use it) + hal_clock_initialize(CYGNUM_HAL_RTC_PERIOD); + // Set up eCos/ROM interfaces hal_if_init(); } diff --git a/packages/hal/arm/edb7xxx/current/src/hal_diag.c b/packages/hal/arm/edb7xxx/current/src/hal_diag.c --- a/packages/hal/arm/edb7xxx/current/src/hal_diag.c +++ b/packages/hal/arm/edb7xxx/current/src/hal_diag.c @@ -104,11 +104,11 @@ void cyg_hal_plf_serial_putc(void *__ch_data, char c) { channel_data_t* chan = (channel_data_t*)__ch_data; + CYGARC_HAL_SAVE_GP(); // Wait for Tx FIFO not full - while ((chan->base->stat & SYSFLG1_UTXFF1) != 0) - dram_delay_loop(); + while ((chan->base->stat & SYSFLG1_UTXFF1) != 0) ; chan->base->data.write = c; @@ -132,10 +132,18 @@ cyg_uint8 cyg_hal_plf_serial_getc(void* __ch_data) { cyg_uint8 ch; + int delay_timer = 0; + CYGARC_HAL_SAVE_GP(); - while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch)) - dram_delay_loop(); + while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch)) { + CYGACC_CALL_IF_DELAY_US(50); // A reasonable time + // Only delay every 10ms or so + if (++delay_timer == 10*20) { + dram_delay_loop(); + delay_timer = 0; + } + } CYGARC_HAL_RESTORE_GP(); return ch; diff --git a/packages/hal/arm/pid/current/ChangeLog b/packages/hal/arm/pid/current/ChangeLog --- a/packages/hal/arm/pid/current/ChangeLog +++ b/packages/hal/arm/pid/current/ChangeLog @@ -1,3 +1,19 @@ +2000-07-25 Jonathan Larmour + + * include/pkgconf/mlt_arm_pid_ram.h: + * include/pkgconf/mlt_arm_pid_ram.ldi: + * include/pkgconf/mlt_arm_pid_ram.mlt: + * include/pkgconf/mlt_arm_pid_rom.h: + * include/pkgconf/mlt_arm_pid_rom.ldi: + * include/pkgconf/mlt_arm_pid_rom.mlt: + Add heap1 section to allow malloc to use it + +2000-07-22 Jonathan Larmour + + * cdl/hal_arm_pid.cdl: Fix comments about number of ports in + CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL and + CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL + 2000-07-17 Jesper Skov * src/pid_misc.c (hal_hardware_init): Hack to allow thumb tests to diff --git a/packages/hal/arm/pid/current/cdl/hal_arm_pid.cdl b/packages/hal/arm/pid/current/cdl/hal_arm_pid.cdl --- a/packages/hal/arm/pid/current/cdl/hal_arm_pid.cdl +++ b/packages/hal/arm/pid/current/cdl/hal_arm_pid.cdl @@ -134,7 +134,7 @@ cdl_package CYGPKG_HAL_ARM_PID { legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1 default_value 0 description " - The PID board has only one serial port. This option + The PID board has two serial ports. This option chooses which port will be used to connect to a host running GDB." } @@ -145,7 +145,7 @@ cdl_package CYGPKG_HAL_ARM_PID { legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1 default_value 0 description " - The PID board has only one serial port. This option + The PID board has two serial ports. This option chooses which port will be used for diagnostic output." } diff --git a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.h b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.h --- a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.h +++ b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.h @@ -1,4 +1,4 @@ -// eCos memory layout - Tue Feb 29 14:11:30 2000 +// eCos memory layout - Tue Jul 25 18:20:21 2000 // This is a generated file - do not edit @@ -8,6 +8,6 @@ #define CYGMEM_REGION_ram (0) #define CYGMEM_REGION_ram_SIZE (0x80000) #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) -extern char CYG_LABEL_NAME (_reserved) []; -#define CYGMEM_SECTION_reserved (CYG_LABEL_NAME (_reserved)) -#define CYGMEM_SECTION_reserved_SIZE (0x8000) +extern char CYG_LABEL_NAME (__heap1) []; +#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1)) +#define CYGMEM_SECTION_heap1_SIZE (0x80000 - (size_t) CYG_LABEL_NAME (__heap1)) diff --git a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.ldi b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.ldi --- a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.ldi +++ b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.ldi @@ -1,7 +1,9 @@ -// eCos memory layout - Tue Feb 29 14:11:30 2000 +// eCos memory layout - Tue Jul 25 18:20:21 2000 // This is a generated file - do not edit +#include + MEMORY { ram : ORIGIN = 0, LENGTH = 0x80000 @@ -20,5 +22,6 @@ SECTIONS SECTION_gcc_except_table (ram, ALIGN (0x4), LMA_EQ_VMA) SECTION_data (ram, ALIGN (0x4), LMA_EQ_VMA) SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA) + CYG_LABEL_DEFN(__heap1) = ALIGN (0x8); SECTIONS_END } diff --git a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.mlt b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.mlt --- a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.mlt +++ b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_ram.mlt @@ -9,4 +9,5 @@ section rodata1 0 4 0 1 0 1 0 1 fixup fi section fixup 0 4 0 1 0 1 0 1 gcc_except_table gcc_except_table ! section gcc_except_table 0 4 0 1 0 1 0 1 data data ! section data 0 4 0 1 0 1 0 1 bss bss ! -section bss 0 4 0 1 0 0 0 0 ! +section bss 0 4 0 1 0 1 0 1 heap1 heap1 ! +section heap1 0 8 0 0 0 0 0 0 ! diff --git a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.h b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.h --- a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.h +++ b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.h @@ -1,4 +1,4 @@ -// eCos memory layout - Tue Feb 29 14:25:49 2000 +// eCos memory layout - Tue Jul 25 18:27:20 2000 // This is a generated file - do not edit @@ -11,6 +11,6 @@ #define CYGMEM_REGION_rom (0x4000000) #define CYGMEM_REGION_rom_SIZE (0x80000) #define CYGMEM_REGION_rom_ATTR (CYGMEM_REGION_ATTR_R) -extern char CYG_LABEL_NAME (_reserved) []; -#define CYGMEM_SECTION_reserved (CYG_LABEL_NAME (_reserved)) -#define CYGMEM_SECTION_reserved_SIZE (0x800) +extern char CYG_LABEL_NAME (__heap1) []; +#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1)) +#define CYGMEM_SECTION_heap1_SIZE (0x80000 - (size_t) CYG_LABEL_NAME (__heap1)) diff --git a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.ldi b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.ldi --- a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.ldi +++ b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.ldi @@ -1,7 +1,9 @@ -// eCos memory layout - Tue Feb 29 14:25:49 2000 +// eCos memory layout - Tue Jul 25 18:27:20 2000 // This is a generated file - do not edit +#include + MEMORY { ram : ORIGIN = 0, LENGTH = 0x80000 @@ -21,5 +23,6 @@ SECTIONS SECTION_fixed_vectors (ram, 0x20, LMA_EQ_VMA) SECTION_data (ram, 0x800, FOLLOWING (.gcc_except_table)) SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA) + CYG_LABEL_DEFN(__heap1) = ALIGN (0x8); SECTIONS_END } diff --git a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.mlt b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.mlt --- a/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.mlt +++ b/packages/hal/arm/pid/current/include/pkgconf/mlt_arm_pid_rom.mlt @@ -3,7 +3,8 @@ region ram 0 80000 0 ! region rom 4000000 80000 1 ! section fixed_vectors 0 1 0 1 1 0 1 0 20 20 ! section data 0 1 1 1 1 1 0 0 800 bss ! -section bss 0 4 0 1 0 0 0 0 ! +section bss 0 4 0 1 0 1 0 1 heap1 heap1 ! +section heap1 0 8 0 0 0 0 0 0 ! section rom_vectors 0 1 0 1 1 1 1 1 4000000 4000000 text text ! section text 0 4 0 1 0 1 0 1 fini fini ! section fini 0 4 0 1 0 1 0 1 rodata rodata ! diff --git a/packages/hal/arm/sa11x0/assabet/current/ChangeLog b/packages/hal/arm/sa11x0/assabet/current/ChangeLog --- a/packages/hal/arm/sa11x0/assabet/current/ChangeLog +++ b/packages/hal/arm/sa11x0/assabet/current/ChangeLog @@ -1,3 +1,7 @@ +2000-07-14 Gary Thomas + + * cdl/hal_arm_sa11x0_assabet.cdl: Add rules for building RedBoot. + 2000-07-05 Jesper Skov * cdl/hal_arm_sa11x0_assabet.cdl: Cleanup channel options. diff --git a/packages/hal/arm/sa11x0/assabet/current/cdl/hal_arm_sa11x0_assabet.cdl b/packages/hal/arm/sa11x0/assabet/current/cdl/hal_arm_sa11x0_assabet.cdl --- a/packages/hal/arm/sa11x0/assabet/current/cdl/hal_arm_sa11x0_assabet.cdl +++ b/packages/hal/arm/sa11x0/assabet/current/cdl/hal_arm_sa11x0_assabet.cdl @@ -300,4 +300,41 @@ cdl_package CYGPKG_HAL_ARM_SA11X0_ASSABE the ROM monitor or boot ROM." } + cdl_component CYGPKG_REDBOOT_HAL_OPTIONS { + display "Redboot HAL options" + flavor none + no_define + parent CYGPKG_REDBOOT + active_if CYGPKG_REDBOOT + description " + This option lists the target's requirements for a valid Redboot + configuration." + + cdl_option CYGDAT_REDBOOT_CONSOLE_DEV { + display "Serial port for default console" + flavor data + default_value { "\"/dev/ser1\"" } + description " + This option selects the physical device to use as the default + console device for Redboot." + + } + + cdl_option CYGBLD_BUILD_REDBOOT_BIN { + display "Build Redboot ROM binary image" + active_if CYGBLD_BUILD_REDBOOT + default_value 1 + no_define + description "This option enables the conversion of the Redboot ELF + image to a binary image suitable for ROM programming." + + make -priority 325 { + /bin/redboot.bin : /bin/redboot.elf + $(OBJCOPY) --strip-debug $< $(@:.bin=.img) + $(OBJCOPY) -O srec $< $(@:.bin=.srec) + $(OBJCOPY) -O binary $< $@ + } + } + } + } diff --git a/packages/hal/arm/sa11x0/assabet/current/misc/cf_test.c b/packages/hal/arm/sa11x0/assabet/current/misc/cf_test.c --- a/packages/hal/arm/sa11x0/assabet/current/misc/cf_test.c +++ b/packages/hal/arm/sa11x0/assabet/current/misc/cf_test.c @@ -37,6 +37,8 @@ // Description: Tool used to test CF stuff //####DESCRIPTIONEND#### +#include +#ifdef CYGPKG_IO_PCMCIA #include // Configuration header #include #include @@ -45,6 +47,8 @@ #include // Register state info #include // HAL interrupt macros +#include + #include // Board definitions #include @@ -58,9 +62,6 @@ static char stack[STACK_SIZE]; static cyg_thread thread_data; static cyg_handle_t thread_handle; -static cyg_interrupt cf_interrupt; -static cyg_handle_t cf_interrupt_handle; - // FUNCTIONS static void @@ -69,41 +70,61 @@ cyg_test_exit(void) while (TRUE) ; } -// This ISR is called when a CompactFlash board is inserted -static int -cf_detect_isr(cyg_vector_t vector, cyg_addrword_t data, HAL_SavedRegisters *regs) -{ - cyg_interrupt_mask(SA1110_CF_DETECT); - return (CYG_ISR_HANDLED|CYG_ISR_CALL_DSR); // Run the DSR -} - -// This DSR handles the board insertion -static void -cf_detect_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data) -{ - unsigned long new_state = *SA11X0_GPIO_PIN_LEVEL; - diag_printf("CF card inserted, state: %x\n", new_state); - cyg_interrupt_acknowledge(SA1110_CF_DETECT); - cyg_interrupt_unmask(SA1110_CF_DETECT); -} - static void cf_test(cyg_addrword_t p) { - unsigned long cf_state; + int len, ptr; + unsigned char buf[256]; + unsigned char *en0; + unsigned long cor = 0, regs; + struct cf_cftable cftable; + struct cf_config config; + struct cf_slot *slot; + diag_printf("CF test here\n"); - // Disable CF bus & power (idle/off) - assabet_BCR(SA1110_BCR_CF_POWER | - SA1110_BCR_CF_RESET | - SA1110_BCR_CF_BUS, - SA1110_BCR_CF_POWER_OFF | - SA1110_BCR_CF_RESET_DISABLE | - SA1110_BCR_CF_BUS_OFF); + cf_init(); + slot = cf_get_slot(0); + en0 = slot->io; while (1) { - cf_state = *SA11X0_GPIO_PIN_LEVEL; - if ((cf_state & SA1110_GPIO_CF_DETECT) == SA1110_GPIO_CF_PRESENT) { + if (slot->state == CF_SLOT_STATE_Inserted) { diag_printf("Compact Flash card inserted!\n"); - diag_dump_buf(0x30000000, 0x100); + cf_change_state(slot, CF_SLOT_STATE_Ready); + diag_dump_buf(slot->attr, slot->attr_length); + len = sizeof(buf); + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_MANFID, buf, &len, &ptr)) { + diag_printf("CIS 0x20:\n"); + diag_dump_buf(buf, len); + } + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_VERS_1, buf, &len, &ptr)) { + diag_printf("CIS 0x15:\n"); + diag_dump_buf(buf, len); + } + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_CONFIG, buf, &len, &ptr)) { + diag_printf("CIS 0x1A:\n"); + diag_dump_buf(buf, len); + } + if (cf_parse_config(buf, len, &config)) { + cor = config.base; + diag_printf("COR = %x\n", cor); + } + ptr = 0; + while (cf_get_CIS(slot, CF_CISTPL_CFTABLE_ENTRY, buf, &len, &ptr)) { + diag_printf("CIS 0x1B:\n"); + diag_dump_buf(buf, len); + if (cf_parse_cftable(buf, len, &cftable)) { + regs = cftable.io_space.base[0]; + cf_set_COR(slot, cor, cftable.cor); + en0[regs+0x00] = 0x21; + en0[regs+0x0E] = 0x49; + en0[regs+0x00] = 0x61; + diag_dump_buf(en0+regs, 0x10); + en0[regs+0x00] = 0x21; + diag_dump_buf(en0+regs, 0x10); + } + } break; } } @@ -113,18 +134,6 @@ cf_test(cyg_addrword_t p) externC void cyg_start( void ) { - // Set up interrupts - cyg_interrupt_create(SA1110_CF_DETECT, - 99, // Priority - what goes here? - 0, // Data item passed to interrupt handler - (cyg_ISR_t *)cf_detect_isr, - (cyg_DSR_t *)cf_detect_dsr, - &cf_interrupt_handle, - &cf_interrupt); - cyg_interrupt_attach(cf_interrupt_handle); - cyg_interrupt_configure(SA1110_CF_DETECT, true, true); // Detect either edge - cyg_interrupt_acknowledge(SA1110_CF_DETECT); - cyg_interrupt_unmask(SA1110_CF_DETECT); // Create a main thread, so we can run the scheduler and have time 'pass' cyg_thread_create(10, // Priority - just a number cf_test, // entry @@ -138,3 +147,4 @@ cyg_start( void ) cyg_thread_resume(thread_handle); // Start it cyg_scheduler_start(); } // cyg_package_start() +#endif diff --git a/packages/hal/common/current/ChangeLog b/packages/hal/common/current/ChangeLog --- a/packages/hal/common/current/ChangeLog +++ b/packages/hal/common/current/ChangeLog @@ -1,3 +1,51 @@ +2000-08-14 Drew Moseley + + * src/hal_if.c: Added an extern declaration for + cyg_hal_plf_comms_init. + + * src/bplist-dynamic.c: Only use breakpoint lists when building + stubs. + +2000-08-10 Drew Moseley + + * include/generic-stub.h: Added support for register validity + checking. + * src/generic-stub.c: Ditto. + * src/hal_stub.c: Ditto. + + * include/drv_api.h: Added cyg_code_t. + +2000-08-03 Gary Thomas + + * include/hal_if.h (CYGNUM_CALL_IF_DBG_DATA): Move to avoid + conflict. + +2000-07-26 Gary Thomas + + * src/hal_stub.c (cyg_hal_gdb_diag_putc): Ignore any characters + other than the protocol chars of ACK/NAK/^C. + + * src/hal_if.c (hal_if_diag_init): Only reset console channel + if user has configured a non-default choice. + +2000-07-24 Drew Moseley + + * src/bplist-dynamic.c (__install_breakpoint_list): Call + HAL_ICACHE_SYNC() rather than HAL_ICACHE_INVALIDATE_ALL(). + +2000-07-21 Drew Moseley + + * src/hal_stub.c: Cleanup of #define's. + + * src/generic-stub.c: Rearrange the linkage between Cygmon and HAL so + that Cygmon needs HAL but not vice-versa. ie HAL no longer calls + any Cygmon functions. + * src/hal_misc.c: Ditto. + + * src/bplist-dynamic.c: Use HAL macros rather than Cygmon + functions for flushing the cache. + Also handle the case where target_register_t is not defined. + 2000-07-21 Gary Thomas * src/hal_if.c (CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS): Define to allow @@ -118,6 +166,14 @@ 2000-06-21 Jesper Skov + + * include/hal_stub.h: Added underscore to breakinst(). + + * include/hal_tables.h: + Added this file to contain macros for defining datatables in a + systematic and extensible way. + 2000-06-19 Gary Thomas * cdl/hal.cdl: Revert change below - GUARANTEED can exist @@ -141,6 +197,12 @@ 2000-06-15 Jesper Skov + + * src/drv_api.c: + * include/drv_api.h: Added boolean result to cyg_drv_cond_wait() + to match change to the kernel and KAPI functionality. + 2000-06-14 Jesper Skov * src/hal_stub.c: Added O-packetizer used by GDB stubs for virtual diff --git a/packages/hal/common/current/include/drv_api.h b/packages/hal/common/current/include/drv_api.h --- a/packages/hal/common/current/include/drv_api.h +++ b/packages/hal/common/current/include/drv_api.h @@ -105,6 +105,7 @@ typedef cyg_addrword_t cyg_handle_t; typedef cyg_uint32 cyg_priority_t; /* type for priorities */ typedef cyg_uint32 cyg_vector_t; /* Interrupt vector id */ typedef int cyg_bool_t; +typedef cyg_int32 cyg_code_t; /* type for various codes */ typedef cyg_uint32 cyg_ISR_t( cyg_vector_t vector, cyg_addrword_t data); typedef void cyg_DSR_t(cyg_vector_t vector, @@ -138,7 +139,7 @@ typedef struct externC void cyg_drv_cond_init( cyg_drv_cond_t *cond, cyg_drv_mutex_t *mutex ); externC void cyg_drv_cond_destroy( cyg_drv_cond_t *cond ); -externC void cyg_drv_cond_wait( cyg_drv_cond_t *cond ); +externC cyg_bool_t cyg_drv_cond_wait( cyg_drv_cond_t *cond ); externC void cyg_drv_cond_signal( cyg_drv_cond_t *cond ); externC void cyg_drv_cond_broadcast( cyg_drv_cond_t *cond ); diff --git a/packages/hal/common/current/include/generic-stub.h b/packages/hal/common/current/include/generic-stub.h --- a/packages/hal/common/current/include/generic-stub.h +++ b/packages/hal/common/current/include/generic-stub.h @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): Red Hat, nickg -// Contributors: Red Hat, nickg +// Contributors: Red Hat, nickg, dmoseley // Date: 1998-06-08 // Purpose: // Description: Definitions for the generic GDB remote stub @@ -89,6 +89,11 @@ struct gdb_packet /* Return the currently-saved value corresponding to register REG. */ extern target_register_t get_register (regnames_t reg); +#ifdef CYGHWR_REGISTER_VALIDITY_CHECKING +// Return the validity of register REG. +extern int get_register_valid (regnames_t reg); +#endif + /* Store VALUE in the register corresponding to WHICH. */ extern void put_register (regnames_t which, target_register_t value); diff --git a/packages/hal/common/current/include/hal_if.h b/packages/hal/common/current/include/hal_if.h --- a/packages/hal/common/current/include/hal_if.h +++ b/packages/hal/common/current/include/hal_if.h @@ -205,13 +205,13 @@ typedef cyg_bool (*__comm_if_getc_timeou #define CYGNUM_CALL_IF_SET_DEBUG_COMM 12 #define CYGNUM_CALL_IF_SET_CONSOLE_COMM 13 #define CYGNUM_CALL_IF_SET_SERIAL_BAUD 14 -#define CYGNUM_CALL_IF_DBG_DATA 15 -#define CYGNUM_CALL_IF_DBG_SYSCALL 15 // conflict! +#define CYGNUM_CALL_IF_DBG_SYSCALL 15 #define CYGNUM_CALL_IF_RESET 16 #define CYGNUM_CALL_IF_CONSOLE_INTERRUPT_FLAG 17 #define CYGNUM_CALL_IF_DELAY_US 18 +#define CYGNUM_CALL_IF_DBG_DATA 19 -#define CYGNUM_CALL_IF_LAST_ENTRY CYGNUM_CALL_IF_DELAY_US +#define CYGNUM_CALL_IF_LAST_ENTRY CYGNUM_CALL_IF_DBG_DATA #define CYGNUM_CALL_IF_INSTALL_BPT_FN 35 diff --git a/packages/hal/common/current/include/hal_stub.h b/packages/hal/common/current/include/hal_stub.h --- a/packages/hal/common/current/include/hal_stub.h +++ b/packages/hal/common/current/include/hal_stub.h @@ -167,7 +167,7 @@ extern void __install_traps (void); #ifndef BREAKINST_DEFINED #define BREAKINST_DEFINED -extern void CYG_LABEL_NAME(breakinst) (void); +extern void _breakinst (void); #endif /* The opcode for a breakpoint instruction. */ diff --git a/packages/hal/common/current/include/hal_tables.h b/packages/hal/common/current/include/hal_tables.h new file mode 100644 --- /dev/null +++ b/packages/hal/common/current/include/hal_tables.h @@ -0,0 +1,95 @@ +#ifndef CYGONCE_HAL_TABLES_H +#define CYGONCE_HAL_TABLES_H + +/*========================================================================== +// +// hal_tables.h +// +// Data table management +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Date: 1999-02-24 +// Purpose: Driver API +// Description: This file defines the API used by device drivers to access +// system services. When the kernel is present it maps directly +// to the Kernel C API. When the kernel is absent, it is provided +// by a set of HAL functions. +// +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//========================================================================*/ + +#include +#include + +#include + +/*------------------------------------------------------------------------*/ + +#define __string(_x) #_x +#define __xstring(_x) __string(_x) + +#ifndef CYG_HAL_TABLE_BEGIN +#define CYG_HAL_TABLE_BEGIN( _label, _name ) \ +__asm__(".section \"" __string(.ecos.table.##_name##.begin) "\",\"aw\"\n" \ + ".globl " __xstring(CYG_LABEL_DEFN(_label)) "\n" \ + ".type " __xstring(CYG_LABEL_DEFN(_label)) ",@object\n" \ + ".p2align 2\n" \ +__xstring(CYG_LABEL_DEFN(_label)) ":\n" \ + ".previous\n" \ + ) +#endif + +#ifndef CYG_HAL_TABLE_END +#define CYG_HAL_TABLE_END( _label, _name ) \ +__asm__(".section \"" __string(.ecos.table.##_name##.finish) "\",\"aw\"\n" \ + ".globl " __xstring(CYG_LABEL_DEFN(_label)) "\n" \ + ".type " __xstring(CYG_LABEL_DEFN(_label)) ",@object\n" \ + ".p2align 2\n" \ +__xstring(CYG_LABEL_DEFN(_label)) ":\n" \ + ".previous\n" \ + ) +#endif + +#ifndef CYG_HAL_TABLE_EXTRA +#define CYG_HAL_TABLE_EXTRA( _name ) \ + CYGBLD_ATTRIB_SECTION(.ecos.table.##_name##.extra) +#endif + +#ifndef CYG_HAL_TABLE_ENTRY +#define CYG_HAL_TABLE_ENTRY( _name ) \ + CYGBLD_ATTRIB_SECTION(.ecos.table.##_name##.data) +#endif + +/*------------------------------------------------------------------------*/ +/* EOF hal_tables.h */ +#endif // CYGONCE_HAL_TABLES_H diff --git a/packages/hal/common/current/src/bplist-dynamic.c b/packages/hal/common/current/src/bplist-dynamic.c --- a/packages/hal/common/current/src/bplist-dynamic.c +++ b/packages/hal/common/current/src/bplist-dynamic.c @@ -43,11 +43,15 @@ // //========================================================================= -#include +#include +#include CYGBLD_HAL_PLATFORM_H + +#if defined(CYGNUM_HAL_BREAKPOINT_LIST_SIZE) && (CYGNUM_HAL_BREAKPOINT_LIST_SIZE > 0) && defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) -#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS - -#if defined(CYGNUM_HAL_BREAKPOINT_LIST_SIZE) && (CYGNUM_HAL_BREAKPOINT_LIST_SIZE > 0) +#define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS +#include +#include +#include /* * A simple target breakpoint list without using malloc. @@ -165,11 +169,11 @@ void } l = l->next; } - flush_i_cache (); + HAL_ICACHE_SYNC(); } void -__clear_breakpoint_list () +__clear_breakpoint_list (void) { struct breakpoint_list *l = breakpoint_list; @@ -185,7 +189,7 @@ void } l = l->next; } - flush_i_cache (); + HAL_ICACHE_INVALIDATE_ALL(); } int @@ -206,6 +210,15 @@ int #include // Our header +#ifndef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS +// We don't know that type target_register_t is yet. +// Let's just pick a type so we can compile. Since +// these versions of the functions don't actually do +// anything with the parameters, the actualy types +// don't matter. +typedef unsigned long target_register_t; +#endif + int __set_breakpoint (target_register_t addr) { @@ -235,5 +248,3 @@ int } #endif // (CYGNUM_HAL_BREAKPOINT_LIST_SIZE > 0) -#endif // CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS - diff --git a/packages/hal/common/current/src/drv_api.c b/packages/hal/common/current/src/drv_api.c --- a/packages/hal/common/current/src/drv_api.c +++ b/packages/hal/common/current/src/drv_api.c @@ -403,7 +403,7 @@ externC void cyg_drv_cond_destroy( cyg_d // wakeup only happens if there is a thread actually waiting on the CV // when the signal is sent. -externC void cyg_drv_cond_wait( cyg_drv_cond_t *cond ) +externC cyg_bool cyg_drv_cond_wait( cyg_drv_cond_t *cond ) { CYG_REPORT_FUNCTION(); @@ -427,7 +427,9 @@ externC void cyg_drv_cond_wait( cyg_drv_ cyg_drv_dsr_unlock(); - CYG_REPORT_RETURN(); + CYG_REPORT_RETURN(); + + return true; } //-------------------------------------------------------------------------- diff --git a/packages/hal/common/current/src/generic-stub.c b/packages/hal/common/current/src/generic-stub.c --- a/packages/hal/common/current/src/generic-stub.c +++ b/packages/hal/common/current/src/generic-stub.c @@ -758,7 +758,7 @@ unlock_thread_scheduler () } #ifdef CYGPKG_CYGMON -extern int processing_breakpoint_function; +int processing_breakpoint_function = 0; #endif void @@ -891,8 +891,12 @@ stub_format_registers(char *ptr) if (_get_trace_register_hook) reg_valid = _get_trace_register_hook (regnum, &addr); else + { addr = get_register (regnum); - +#ifdef CYGHWR_REGISTER_VALIDITY_CHECKING + reg_valid = get_register_valid (regnum); +#endif + } vptr = ((char *) &addr); if (sizeof (addr) > REGSIZE(regnum)) { /* May need to cope with endian-ness */ diff --git a/packages/hal/common/current/src/hal_if.c b/packages/hal/common/current/src/hal_if.c --- a/packages/hal/common/current/src/hal_if.c +++ b/packages/hal/common/current/src/hal_if.c @@ -316,6 +316,7 @@ flush_dcache(void *__p, int __nbytes) // routines for that channel. The platform HAL also has the necessary // information to determine if the channel is already initialized by // a debug agent (either builtin or in ROM). +externC void cyg_hal_plf_comms_init(void); void hal_if_diag_init(void) { @@ -323,6 +324,12 @@ hal_if_diag_init(void) cyg_hal_plf_comms_init(); #endif +#ifdef CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT +#define _DEFAULT CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT +#else +#define _DEFAULT (CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL+1) +#endif +#if CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL != _DEFAULT // Set console channel. This should only be done when the console channel // differs from the debug channel to prevent removing the debug agent's // mangler procs. @@ -330,6 +337,8 @@ hal_if_diag_init(void) != CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL) CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL); +#endif +#undef _DEFAULT } void diff --git a/packages/hal/common/current/src/hal_misc.c b/packages/hal/common/current/src/hal_misc.c --- a/packages/hal/common/current/src/hal_misc.c +++ b/packages/hal/common/current/src/hal_misc.c @@ -68,6 +68,10 @@ #endif +#if defined(CYGPKG_CYGMON) +unsigned long cygmon_memsize = 0; +#endif + //-------------------------------------------------------------------------- // Functions to support the detection and execution of a user provoked // program break. These are usually called from interrupt routines. diff --git a/packages/hal/common/current/src/hal_stub.c b/packages/hal/common/current/src/hal_stub.c --- a/packages/hal/common/current/src/hal_stub.c +++ b/packages/hal/common/current/src/hal_stub.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): jskov (based on powerpc/cogent hal_stub.c) -// Contributors:jskov +// Contributors:jskov, dmoseley // Date: 1999-02-12 // Purpose: Helper functions for stub, specific to eCos HAL // Description: Parts of the GDB stub requirements are provided by @@ -64,9 +64,13 @@ #endif #ifdef USE_LONG_NAMES_FOR_ENUM_REGNAMES +#ifndef PC #define PC REG_PC +#endif +#ifndef SP #define SP REG_SP #endif +#endif //----------------------------------------------------------------------------- // Extra eCos data. @@ -77,6 +81,12 @@ target_register_t registers[NUMREGS]; target_register_t alt_registers[NUMREGS] ; // Thread or saved process state target_register_t * _registers = registers; // Pointer to current set of registers +// Register validity checking +#ifdef CYGHWR_REGISTER_VALIDITY_CHECKING +int registers_valid[NUMREGS]; +int *_registers_valid = registers_valid; +#endif + #ifndef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT // this should go away // Interrupt control. static volatile __PFI __interruptible_control; @@ -93,6 +103,15 @@ get_register (regnames_t reg) return _registers[reg]; } +#ifdef CYGHWR_REGISTER_VALIDITY_CHECKING +// Return the validity of register REG. +int +get_register_valid (regnames_t reg) +{ + return _registers_valid[reg]; +} +#endif + // Store VALUE in the register corresponding to WHICH in the exception // context. void @@ -351,7 +370,9 @@ cyg_hal_gdb_diag_putc(void* __ch_data, c CYGACC_COMM_IF_PUTC(*__chan, hex[(csum>>4)&0xF]); CYGACC_COMM_IF_PUTC(*__chan, hex[csum&0xF]); + nak: c1 = CYGACC_COMM_IF_GETC(*__chan); + if( c1 == '+' ) break; if( cyg_hal_is_break( &c1 , 1 ) ) { @@ -359,6 +380,7 @@ cyg_hal_gdb_diag_putc(void* __ch_data, c CYGACC_CALL_IF_CONSOLE_INTERRUPT_FLAG_SET(1); break; } + if( c1 != '-' ) goto nak; } pos = 0; diff --git a/packages/hal/i386/arch/current/ChangeLog b/packages/hal/i386/arch/current/ChangeLog --- a/packages/hal/i386/arch/current/ChangeLog +++ b/packages/hal/i386/arch/current/ChangeLog @@ -1,3 +1,18 @@ +2000-08-14 Jonathan Larmour + + From Fabrice Gautier: + * src/hal_misc.c (hal_zero_bss): Use __bss_end not _end + * src/i386.ld: Add __bss_end symbol to end of SECTION_bss + +2000-06-21 Nick Garnett + + * src/i386_stub.c: Removed use of CYG_LABEL_NAME() and added + underscore to _breakinst. + + * src/i386.ld: Switched to new table definition mechanism. + + * include/basetype.h: Removed definition of CYG_LABEL_NAME(). + 2000-06-08 Jesper Skov * include/hal_arch.h (CYGARC_HAL_SAVE_GP, CYGARC_HAL_RESTORE_GP): diff --git a/packages/hal/i386/arch/current/include/basetype.h b/packages/hal/i386/arch/current/include/basetype.h --- a/packages/hal/i386/arch/current/include/basetype.h +++ b/packages/hal/i386/arch/current/include/basetype.h @@ -50,10 +50,9 @@ #define CYG_BYTEORDER CYG_LSBFIRST // Little endian //----------------------------------------------------------------------------- -// I386 does not usually use labels with underscores. Some labels generated -// by the linker do, so add an underscore where required. +// I386 does not usually use labels with underscores. -#define CYG_LABEL_NAME(_name_) _##_name_ +//#define CYG_LABEL_NAME(_name_) _name_ //----------------------------------------------------------------------------- // Define the standard variable sizes diff --git a/packages/hal/i386/arch/current/src/hal_misc.c b/packages/hal/i386/arch/current/src/hal_misc.c --- a/packages/hal/i386/arch/current/src/hal_misc.c +++ b/packages/hal/i386/arch/current/src/hal_misc.c @@ -49,7 +49,7 @@ #include void hal_zero_bss(void) -{ extern char _end ; +{ extern char __bss_end ; extern char __bss_start ; asm( @@ -62,7 +62,7 @@ void hal_zero_bss(void) "rep stosl" /* Fill the region. */ : /* No outputs. */ - : "g" (&_end), "g" (&__bss_start) + : "g" (&__bss_end), "g" (&__bss_start) : "ecx", "edi", "eax" ); } diff --git a/packages/hal/i386/arch/current/src/i386.ld b/packages/hal/i386/arch/current/src/i386.ld --- a/packages/hal/i386/arch/current/src/i386.ld +++ b/packages/hal/i386/arch/current/src/i386.ld @@ -109,8 +109,7 @@ GROUP(libtarget.a libgcc.a) __DTOR_LIST__ = ABSOLUTE(.); \ KEEP(*(SORT(.dtors*))) __DTOR_END__ = ABSOLUTE(.); \ . = ALIGN(8); \ - __DEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.devtab*))) __DEVTAB_END__ = ABSOLUTE (.); \ - __NETDEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.netdevtab*))) __NETDEVTAB_END__ = ABSOLUTE (.); \ + KEEP(*( SORT (.ecos.table.*))); \ _GOT2_START_ = ABSOLUTE(.); *(.got2) _GOT2_END_ = ABSOLUTE(.); \ _GOT_START_ = ABSOLUTE(.); _GLOBAL_OFFSET_TABLE_ = ABSOLUTE(. + 32768); \ _SDA_BASE_ = ABSOLUTE(.); *(.got.plt) *(.got) \ @@ -134,7 +133,8 @@ GROUP(libtarget.a libgcc.a) #define SECTION_bss(_region_, _vma_, _lma_) \ .bss _vma_ : _lma_ \ { FORCE_OUTPUT; *(.dynbss*) *(.bss*) *(COMMON) } \ - > _region_ + > _region_ \ + __bss_end = .; #define SECTIONS_END . = ALIGN(4); _end = .; PROVIDE (end = .); diff --git a/packages/hal/i386/arch/current/src/i386_stub.c b/packages/hal/i386/arch/current/src/i386_stub.c --- a/packages/hal/i386/arch/current/src/i386_stub.c +++ b/packages/hal/i386/arch/current/src/i386_stub.c @@ -164,7 +164,7 @@ int isBreakpointFunction ; int __is_breakpoint_function () { - isBreakpointFunction = (get_register (PC) == (target_register_t)&CYG_LABEL_NAME(breakinst)); + isBreakpointFunction = (get_register (PC) == (target_register_t)&_breakinst); return isBreakpointFunction ; } diff --git a/packages/hal/i386/pc/current/ChangeLog b/packages/hal/i386/pc/current/ChangeLog --- a/packages/hal/i386/pc/current/ChangeLog +++ b/packages/hal/i386/pc/current/ChangeLog @@ -1,3 +1,10 @@ +2000-08-18 Nick Garnett + + * include/platform.inc: + * include/var_intr.h: + Fixed code to acknowledge interrupts to always ack on the master + controller and ack the slave controller when it is INT8 or higher. + 2000-06-20 Nick Garnett * include/var_intr.h: Added cast to _data_ argument in diff --git a/packages/hal/i386/pc/current/include/platform.inc b/packages/hal/i386/pc/current/include/platform.inc --- a/packages/hal/i386/pc/current/include/platform.inc +++ b/packages/hal/i386/pc/current/include/platform.inc @@ -385,10 +385,9 @@ pc_extended_memory_size: cmpl $0x20, %edx jl 8f cmpl $0x30, %edx - jge 9f - outb %al, $0x20 - jmp 8f -9: outb %al, $0xA0 + jl 9f + outb %al, $0xA0 +9: outb %al, $0x20 8: nop .endm diff --git a/packages/hal/i386/pc/current/include/var_intr.h b/packages/hal/i386/pc/current/include/var_intr.h --- a/packages/hal/i386/pc/current/include/var_intr.h +++ b/packages/hal/i386/pc/current/include/var_intr.h @@ -176,7 +176,7 @@ CYG_MACRO_START : "eax" \ ); \ } \ - if ((x >= 0) && (x < 8)) \ + if ((x >= 0) && (x < 16)) \ { \ asm( \ "movb $0x20, %%al;" \ diff --git a/packages/hal/mips/arch/current/ChangeLog b/packages/hal/mips/arch/current/ChangeLog --- a/packages/hal/mips/arch/current/ChangeLog +++ b/packages/hal/mips/arch/current/ChangeLog @@ -1,3 +1,8 @@ +2000-07-21 Drew Moseley + + * src/vectors.S: Only jump uncached to _start if CYGARC_START_FUNC_UNCACHED + is defined. + 2000-07-14 Drew Moseley * src/vectors.S: Added hal_reset_vector_first_code and @@ -16,6 +21,13 @@ 2000-07-14 Drew Moseley + + * src/mips-stub.c: Removed use of CYG_LABEL_NAME() and added + underscore to _breakinst. + + * include/basetype.h: Removed definition of CYG_LABEL_NAME(). + 2000-06-08 Jesper Skov * src/hal_misc.c (hal_arch_default_isr): Removed what's now a diff --git a/packages/hal/mips/arch/current/include/basetype.h b/packages/hal/mips/arch/current/include/basetype.h --- a/packages/hal/mips/arch/current/include/basetype.h +++ b/packages/hal/mips/arch/current/include/basetype.h @@ -65,10 +65,9 @@ #endif //----------------------------------------------------------------------------- -// MIPS does not usually use labels with undersores. Some labels generated -// by the linker do, so add an underscore where required. +// MIPS does not usually use labels with undersores. -#define CYG_LABEL_NAME(_name_) _##_name_ +//#define CYG_LABEL_NAME(_name_) _name_ //----------------------------------------------------------------------------- // Define the standard variable sizes diff --git a/packages/hal/mips/arch/current/src/mips-stub.c b/packages/hal/mips/arch/current/src/mips-stub.c --- a/packages/hal/mips/arch/current/src/mips-stub.c +++ b/packages/hal/mips/arch/current/src/mips-stub.c @@ -365,7 +365,7 @@ void __clear_breakpoints (void) int __is_breakpoint_function () { - return get_register (PC) == (target_register_t)(unsigned long)&CYG_LABEL_NAME(breakinst); + return get_register (PC) == (target_register_t)(unsigned long)&_breakinst; } diff --git a/packages/hal/mips/arch/current/src/vectors.S b/packages/hal/mips/arch/current/src/vectors.S --- a/packages/hal/mips/arch/current/src/vectors.S +++ b/packages/hal/mips/arch/current/src/vectors.S @@ -102,7 +102,10 @@ 2: mtc0 k0,config0 # to disable cache #endif lar v0,_start # jump to start +#ifdef CYGARC_START_FUNC_UNCACHED CYGARC_ADDRESS_REG_UNCACHED(v0) +#endif + jr v0 nop # (delay slot) diff --git a/packages/hal/mips/tx39/current/ChangeLog b/packages/hal/mips/tx39/current/ChangeLog --- a/packages/hal/mips/tx39/current/ChangeLog +++ b/packages/hal/mips/tx39/current/ChangeLog @@ -1,3 +1,13 @@ +2000-08-03 Jonathan Larmour + + * src/mips_tx39.ld: Revert below change. It was correct before. + +2000-06-21 Nick Garnett + + * src/mips_tx39.ld: + Added underscore to _stext and _etext. + Switched to new table definition mechanism. + 2000-06-06 Jesper Skov * include/var_intr.h (HAL_INTERRUPT_ACKNOWLEDGE, diff --git a/packages/hal/mips/tx39/current/src/mips_tx39.ld b/packages/hal/mips/tx39/current/src/mips_tx39.ld --- a/packages/hal/mips/tx39/current/src/mips_tx39.ld +++ b/packages/hal/mips/tx39/current/src/mips_tx39.ld @@ -267,12 +267,7 @@ GROUP(libtarget.a libgcc.a) .devtab _vma_ : _lma_ \ { \ FORCE_OUTPUT; \ - __DEVTAB__ = .; \ - KEEP (*(SORT(.devtab*))) \ - __DEVTAB_END__ = .; \ - __NETDEVTAB__ = .; \ - KEEP (*(SORT(.netdevtab*))) \ - __NETDEVTAB_END__ = .; \ + KEEP(*( SORT (.ecos.table.*))) ; \ } > _region_ #define SECTION_got(_region_, _vma_, _lma_) \ diff --git a/packages/hal/mips/vr4300/current/ChangeLog b/packages/hal/mips/vr4300/current/ChangeLog --- a/packages/hal/mips/vr4300/current/ChangeLog +++ b/packages/hal/mips/vr4300/current/ChangeLog @@ -1,3 +1,8 @@ +2000-06-21 Nick Garnett + + * src/mips_vr4300.ld: + Switched to new table definition mechanism. + 2000-02-23 Jonathan Larmour * include/var_cache.h: Don't need to conditionalize on vr4300 diff --git a/packages/hal/mips/vr4300/current/src/mips_vr4300.ld b/packages/hal/mips/vr4300/current/src/mips_vr4300.ld --- a/packages/hal/mips/vr4300/current/src/mips_vr4300.ld +++ b/packages/hal/mips/vr4300/current/src/mips_vr4300.ld @@ -151,8 +151,7 @@ GROUP(libtarget.a libgcc.a) _GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.); \ _GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); \ . = ALIGN (8); \ - __DEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.devtab*))) __DEVTAB_END__ = ABSOLUTE (.); \ - __NETDEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.netdevtab*))) __NETDEVTAB_END__ = ABSOLUTE (.); \ + KEEP(*( SORT (.ecos.table.*))) ; \ . = ALIGN (8); \ _GOT_START = ABSOLUTE (.); _gp = ABSOLUTE (.); __global = _gp; _GLOBAL_OFFSET_TABLE_ = ABSOLUTE (.); _SDA_BASE_ = ABSOLUTE (.); \ *(.got.plt) *(.got) _GOT_END_ = ABSOLUTE (.); \ diff --git a/packages/hal/mips/vrc4373/current/ChangeLog b/packages/hal/mips/vrc4373/current/ChangeLog --- a/packages/hal/mips/vrc4373/current/ChangeLog +++ b/packages/hal/mips/vrc4373/current/ChangeLog @@ -1,3 +1,18 @@ +2000-08-16 Nick Garnett + + * include/pkgconf/mlt_mips_vr4300_vrc4373_romram.mlt: + * include/pkgconf/mlt_mips_vr4300_vrc4373_romram.ldi: + * include/pkgconf/mlt_mips_vr4300_vrc4373_romram.h: + Fixed typo in last change. Forgot that the RAM base address + appears twice in these files. Also fixed .h file to match. + +2000-08-15 Nick Garnett + + * include/pkgconf/mlt_mips_vr4300_vrc4373_romram.mlt: + * include/pkgconf/mlt_mips_vr4300_vrc4373_romram.ldi: + RAM start on these configurations should be 0x80000000 not + 0x80100000. + 2000-05-22 Jesper Skov * src/hal_diag.c: Removed CTRLC init hacks. diff --git a/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.h b/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.h --- a/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.h +++ b/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.h @@ -5,6 +5,6 @@ #include #include -#define CYGMEM_REGION_ram (0x80100000) +#define CYGMEM_REGION_ram (0x80000000) #define CYGMEM_REGION_ram_SIZE (0x500000) #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) diff --git a/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.ldi b/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.ldi --- a/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.ldi +++ b/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.ldi @@ -4,13 +4,13 @@ MEMORY { - ram : ORIGIN = 0x80100000, LENGTH = 0x500000 + ram : ORIGIN = 0x80000000, LENGTH = 0x500000 } SECTIONS { SECTIONS_BEGIN - SECTION_rom_vectors (ram, 0x80100000, LMA_EQ_VMA) + SECTION_rom_vectors (ram, 0x80000000, LMA_EQ_VMA) SECTION_text (ram, ALIGN (0x1), LMA_EQ_VMA) SECTION_fini (ram, ALIGN (0x1), LMA_EQ_VMA) SECTION_ctors (ram, ALIGN (0x1), LMA_EQ_VMA) diff --git a/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.mlt b/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.mlt --- a/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.mlt +++ b/packages/hal/mips/vrc4373/current/include/pkgconf/mlt_mips_vr4300_vrc4373_romram.mlt @@ -1,6 +1,6 @@ version 0 -region ram 80100000 500000 0 ! -section rom_vectors 0 1 0 1 1 1 1 1 80100000 80100000 text text ! +region ram 80000000 500000 0 ! +section rom_vectors 0 1 0 1 1 1 1 1 80000000 80000000 text text ! section text 0 1 0 1 0 1 0 1 fini fini ! section fini 0 1 0 1 0 1 0 1 ctors ctors ! section ctors 0 1 0 1 0 1 0 1 dtors dtors ! diff --git a/packages/hal/mn10300/am31/current/ChangeLog b/packages/hal/mn10300/am31/current/ChangeLog --- a/packages/hal/mn10300/am31/current/ChangeLog +++ b/packages/hal/mn10300/am31/current/ChangeLog @@ -1,3 +1,20 @@ +2000-06-21 Nick Garnett + + * src/mn10300_am31.ld: + Added extra underscore to _stext and _etext. + Switched to new table definition mechanism. + +2000-06-07 Nick Garnett + + * src/mn10300_am31.ld: Added extra underscore to ___NETDEVTAB__. + +2000-06-02 Nick Garnett + + * src/mn10300_am31.ld: + Added support for FSTAB, MTAB and NSTAB analogous to the DEVTAB + and NETDEVTAB support already present. Perhaps we should have a + macro to make this kind of thing tidier. + 2000-03-20 Jonathan Larmour * include/variant.inc (SAVED_CONTEXT_PC_OFFSET): New macro to give diff --git a/packages/hal/mn10300/am31/current/src/mn10300_am31.ld b/packages/hal/mn10300/am31/current/src/mn10300_am31.ld --- a/packages/hal/mn10300/am31/current/src/mn10300_am31.ld +++ b/packages/hal/mn10300/am31/current/src/mn10300_am31.ld @@ -52,10 +52,10 @@ GROUP(libtarget.a libgcc.a) #define SECTION_text(_region_, _vma_, _lma_) \ .text _vma_ : _lma_ \ - { _stext = ABSOLUTE(.); \ + { __stext = ABSOLUTE(.); \ *(.text*) *(.gnu.warning) *(.gnu.linkonce*) *(.init) } \ > _region_ \ - _etext = .; PROVIDE (etext = .); + __etext = .; PROVIDE (etext = .); #define SECTION_fini(_region_, _vma_, _lma_) \ .fini _vma_ : _lma_ \ @@ -86,8 +86,8 @@ GROUP(libtarget.a libgcc.a) .data _vma_ : _lma_ \ { __ram_data_start = ABSOLUTE (.); *(.data*) *(.data1) \ . = ALIGN(4); \ - ___DEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.devtab*))) ___DEVTAB_END__ = ABSOLUTE (.); \ - __NETDEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.netdevtab*))) __NETDEVTAB_END__ = ABSOLUTE (.); \ + KEEP(*( SORT (.ecos.table.*))) ; \ + . = ALIGN(4); \ _GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.); \ _GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); \ . = ALIGN (4); \ diff --git a/packages/hal/mn10300/am33/current/ChangeLog b/packages/hal/mn10300/am33/current/ChangeLog --- a/packages/hal/mn10300/am33/current/ChangeLog +++ b/packages/hal/mn10300/am33/current/ChangeLog @@ -1,3 +1,29 @@ +2000-08-12 Drew Moseley + + * src/var_misc.c: More rearranging of GDB regnames. + +2000-08-11 Drew Moseley + + * src/var_misc.c: Rearranged regnames to correspond to what GDB is + expecting. + +2000-08-10 Drew Moseley + + * src/var_misc.c: Added Cygmon support. + + * include/var_intr.h: Added Cygmon support. + + * include/var_arch.h: Added some PSW bitmasks. + Added Cygmon support. + + * cdl/hal_mn10300_am33.cdl: Added option for AM33_REVISION + +2000-06-21 Nick Garnett + + * src/mn10300_am33.ld: + Added extra underscore to _stext and _etext. + Switched to new table definition mechanism. + 2000-03-20 Jonathan Larmour * include/variant.inc (SAVED_CONTEXT_PC_OFFSET): New macro to give @@ -175,4 +201,4 @@ 1999-06-30 Nick Garnett " } diff --git a/packages/hal/mn10300/am33/current/include/var_arch.h b/packages/hal/mn10300/am33/current/include/var_arch.h --- a/packages/hal/mn10300/am33/current/include/var_arch.h +++ b/packages/hal/mn10300/am33/current/include/var_arch.h @@ -35,7 +35,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): nickg -// Contributors: nickg +// Contributors: nickg, dmoseley // Date: 1999-02-17 // Purpose: Define architecture abstractions // Description: This file contains any extra or modified definitions for @@ -50,6 +50,12 @@ #include //-------------------------------------------------------------------------- +// Processor Status word bitmasks + +#define HAL_ARCH_AM33_PSW_nSL (1L << 16) +#define HAL_ARCH_AM33_PSW_ML (1L << 19) + +//-------------------------------------------------------------------------- // Processor saved states: typedef struct HAL_SavedRegisters @@ -113,7 +119,12 @@ CYG_MACRO_END //-------------------------------------------------------------------------- // The following macros copy the extra AM33 registers between a // HAL_SavedRegisters structure and a GDB register dump. +// The CYGMON version should handle the SSP and USP and MDRQ registers. +#ifdef CYGPKG_CYGMON +#define HAL_GET_GDB_EXTRA_REGISTERS( _regval_, _regs_ ) am33_get_gdb_extra_registers( _regval_, _regs_ ) +extern void am33_get_gdb_extra_registers(CYG_ADDRWORD *registers, HAL_SavedRegisters *regs); +#else // CYGPKG_CYGMON #define HAL_GET_GDB_EXTRA_REGISTERS( _regval_, _regs_ ) \ CYG_MACRO_START \ (_regval_)[15] = (_regs_)->e0; \ @@ -133,7 +144,12 @@ CYG_MACRO_START (_regval_)[27] = (_regs_)->mcrl; \ (_regval_)[28] = (_regs_)->mcvf; \ CYG_MACRO_END +#endif // CYGPKG_CYGMON +#ifdef CYGPKG_CYGMON +#define HAL_SET_GDB_EXTRA_REGISTERS( _regval_, _regs_ ) am33_set_gdb_extra_registers( _regs_, _regval_ ) +extern void am33_set_gdb_extra_registers(CYG_ADDRWORD *registers, HAL_SavedRegisters *regs); +#else // CYGPKG_CYGMON #define HAL_SET_GDB_EXTRA_REGISTERS( _regs_, _regval_ ) \ CYG_MACRO_START \ (_regs_)->e0 = (_regval_)[15]; \ @@ -153,6 +169,7 @@ CYG_MACRO_START (_regs_)->mcrl = (_regval_)[27]; \ (_regs_)->mcvf = (_regval_)[28]; \ CYG_MACRO_END +#endif // CYGPKG_CYGMON //-------------------------------------------------------------------------- #endif // CYGONCE_HAL_VAR_ARCH_H diff --git a/packages/hal/mn10300/am33/current/include/var_cache.h b/packages/hal/mn10300/am33/current/include/var_cache.h --- a/packages/hal/mn10300/am33/current/include/var_cache.h +++ b/packages/hal/mn10300/am33/current/include/var_cache.h @@ -35,7 +35,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): nickg -// Contributors: nickg +// Contributors: nickg, dmoseley // Date: 1998-02-17 // Purpose: Cache control API // Description: The macros defined here provide the HAL APIs for handling @@ -194,7 +194,7 @@ externC void cyg_hal_dcache_store(CYG_ADDRWORD base, int size); #define HAL_DCACHE_STORE( _base_ , _size_ ) \ - cyg_hal_dcache_store((_base_), (_size_)) + cyg_hal_dcache_store((CYG_ADDRWORD)(_base_), (_size_)) // Preread the given range into the cache with the intention of reading // from it later. diff --git a/packages/hal/mn10300/am33/current/include/var_intr.h b/packages/hal/mn10300/am33/current/include/var_intr.h --- a/packages/hal/mn10300/am33/current/include/var_intr.h +++ b/packages/hal/mn10300/am33/current/include/var_intr.h @@ -36,7 +36,7 @@ // // Author(s): nickg // Contributors: nickg, jskov, -// gthomas, jlarmour +// gthomas, jlarmour, dmoseley // Date: 1999-02-16 // Purpose: VR4300 Interrupt support // Description: The macros defined here provide the HAL APIs for handling @@ -148,6 +148,9 @@ #define CYGNUM_HAL_EXCEPTION_MAX CYGNUM_HAL_VSR_MAX #define CYGNUM_HAL_EXCEPTION_COUNT CYGNUM_HAL_VSR_COUNT +#define CYGNUM_HAL_EXCEPTION_INTERRUPT CYGNUM_HAL_EXCEPTION_SYSTEM_ERROR +#define CYGNUM_HAL_VECTOR_BREAKPOINT CYGNUM_HAL_EXCEPTION_SYSTEM_ERROR + // Canonical names for various exceptions. These are used // by generic exception handling code to make sense of // excptions that have been delivered. diff --git a/packages/hal/mn10300/am33/current/include/variant.inc b/packages/hal/mn10300/am33/current/include/variant.inc --- a/packages/hal/mn10300/am33/current/include/variant.inc +++ b/packages/hal/mn10300/am33/current/include/variant.inc @@ -34,7 +34,7 @@ #######DESCRIPTIONBEGIN#### ## ## Author(s): nickg -## Contributors: nickg +## Contributors: nickg, dmoseley ## Date: 1999-04-06 ## Purpose: AM33 definitions. ## Description: This file contains various definitions and macros that are @@ -140,6 +140,12 @@ .macro hal_intc_init .endm +#define CYGPKG_HAL_MN10300_INTC_DEFINED + +#endif + +#ifndef CYGPKG_HAL_MN10300_INTC_DECODE_DEFINED + #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN #define CYG_ISR_TABLE_SIZE 10 @@ -167,7 +173,7 @@ #endif -#define CYGPKG_HAL_MN10300_INTC_DEFINED +#define CYGPKG_HAL_MN10300_INTC_DECODE_DEFINED #endif diff --git a/packages/hal/mn10300/am33/current/src/mn10300_am33.ld b/packages/hal/mn10300/am33/current/src/mn10300_am33.ld --- a/packages/hal/mn10300/am33/current/src/mn10300_am33.ld +++ b/packages/hal/mn10300/am33/current/src/mn10300_am33.ld @@ -52,10 +52,10 @@ GROUP(libtarget.a libgcc.a) #define SECTION_text(_region_, _vma_, _lma_) \ .text _vma_ : _lma_ \ - { _stext = ABSOLUTE(.); \ + { __stext = ABSOLUTE(.); \ *(.text*) *(.gnu.warning) *(.gnu.linkonce*) *(.init) } \ > _region_ \ - _etext = .; PROVIDE (etext = .); + __etext = .; PROVIDE (etext = .); #define SECTION_fini(_region_, _vma_, _lma_) \ .fini _vma_ : _lma_ \ @@ -86,11 +86,11 @@ GROUP(libtarget.a libgcc.a) .data _vma_ : _lma_ \ { __ram_data_start = ABSOLUTE (.); *(.data*) *(.data1) \ . = ALIGN(4); \ - ___DEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.devtab*))) ___DEVTAB_END__ = ABSOLUTE (.); \ - __NETDEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.netdevtab*))) __NETDEVTAB_END__ = ABSOLUTE (.); \ _GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.); \ _GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); \ . = ALIGN (4); \ + KEEP(*( SORT (.ecos.table.*))) ; \ + . = ALIGN(4); \ __CTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.ctors*))) __CTOR_END__ = ABSOLUTE (.); \ __DTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.dtors*))) __DTOR_END__ = ABSOLUTE (.); \ _GOT_START = ABSOLUTE (.); _GLOBAL_OFFSET_TABLE_ = ABSOLUTE (.) + 32768; _SDA_BASE_ = ABSOLUTE (.); \ @@ -114,5 +114,15 @@ GROUP(libtarget.a libgcc.a) _mn10300_interrupt_control = 0xD4000000; _mn10300_interrupt_vectors = 0xC0000000; +#include CYGBLD_HAL_TARGET_H + +#if CYGHWR_HAL_MN10300_AM33_REVISION == 1 + _hal_vsr_table = 0x50000100; _hal_virtual_vector_table = 0x50000200; + +#else + +#error Unknown AM33 Revision + +#endif diff --git a/packages/hal/mn10300/am33/current/src/var_misc.c b/packages/hal/mn10300/am33/current/src/var_misc.c --- a/packages/hal/mn10300/am33/current/src/var_misc.c +++ b/packages/hal/mn10300/am33/current/src/var_misc.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): nickg -// Contributors: nickg, jlarmour +// Contributors: nickg, jlarmour, dmoseley // Date: 1999-01-21 // Purpose: HAL miscellaneous functions // Description: This file contains miscellaneous functions provided by the @@ -94,6 +94,149 @@ void cyg_hal_dcache_store(CYG_ADDRWORD b } #endif +#ifdef CYGPKG_CYGMON +/*------------------------------------------------------------------------*/ +/* GDB Register functions. */ +#include +#include + + +int msp_read = 0; + +extern int *_registers_valid; + +void am33_get_gdb_extra_registers(CYG_ADDRWORD *registers, HAL_SavedRegisters *regs) +{ + register CYG_ADDRWORD epsw; + asm volatile (" mov epsw, %0 " : "=r" (epsw) : ); + + registers[15] = regs->e0; + registers[16] = regs->e1; + registers[17] = regs->e2; + registers[18] = regs->e3; + registers[19] = regs->e4; + registers[20] = regs->e5; + registers[21] = regs->e6; + registers[22] = regs->e7; + + registers[26] = regs->mcrh; + registers[27] = regs->mcrl; + registers[28] = regs->mcvf; + + registers[14] = regs->mdrq; + + { + register CYG_ADDRWORD ssp, usp, msp; + asm volatile (" mov usp, %0 " : "=a" (usp) : ); + asm volatile (" mov ssp, %0 " : "=a" (ssp) : ); + if ((epsw & HAL_ARCH_AM33_PSW_ML) == HAL_ARCH_AM33_PSW_ML) + { + // We are running in Monitor mode. Go ahead and read the MSP. + asm volatile (" mov msp, %0 " : "=a" (msp) : ); + msp_read = 1; + } else { + msp = 0; + msp_read = 0; + } + + // Now we need to determine which sp was in effect when we hit this exception, + // since we want the register image to reflect the state at the time of the + // exception. + if ((regs->psw & HAL_ARCH_AM33_PSW_ML) == HAL_ARCH_AM33_PSW_ML) + { + msp = regs->sp; + } + else if ((regs->psw & HAL_ARCH_AM33_PSW_nSL) == 0) + { + ssp = regs->sp; + } + else + { + usp = regs->sp; + } + + registers[23] = ssp; + registers[24] = msp; + registers[25] = usp; + } + + +#ifdef CYGHWR_REGISTER_VALIDITY_CHECKING + { + int i; + + // Initially set all registers to valid + for (i = 0; i < NUMREGS; i++) + _registers_valid[i] = 1; + + if (msp_read == 0) + _registers_valid[MSP] = 0; + + if (fpu_regs_read == 0) + { + for (i = FP_START; i <= FP_END; i++) + _registers_valid[i] = 0; + } + } +#endif +} + +void am33_set_gdb_extra_registers(CYG_ADDRWORD *registers, HAL_SavedRegisters *regs) +{ + regs->e0 = registers[15]; + regs->e1 = registers[16]; + regs->e2 = registers[17]; + regs->e3 = registers[18]; + regs->e4 = registers[19]; + regs->e5 = registers[20]; + regs->e6 = registers[21]; + regs->e7 = registers[22]; + + regs->mcrh = registers[26]; + regs->mcrl = registers[27]; + regs->mcvf = registers[28]; + + regs->mdrq = registers[14]; + + { + register CYG_ADDRWORD ssp, usp, msp; + ssp = registers[23]; + msp = registers[24]; + usp = registers[25]; + if ((registers[11] & HAL_ARCH_AM33_PSW_ML) == HAL_ARCH_AM33_PSW_ML) + { + // We were running in monitor mode. + // Go ahead and manually restore ssp and usp. + // msp will be restored by the rti. + asm volatile (" mov %0, usp " : : "a" (usp)); + asm volatile (" mov %0, ssp " : : "a" (ssp)); + } + else if ((registers[11] & HAL_ARCH_AM33_PSW_nSL) == 0) + { + // We were running in system mode. + // Go ahead and manually restore msp and usp. + // ssp will be restored by the rti. + asm volatile (" mov %0, usp " : : "a" (usp)); + if (msp_read) + { + asm volatile (" mov %0, msp " : : "a" (msp)); + } + } + else + { + // We were running in user mode. + // Go ahead and manually restore msp and ssp. + // usp will be restored by the rti. + asm volatile (" mov %0, ssp " : : "a" (ssp)); + if (msp_read) + { + asm volatile (" mov %0, msp " : : "a" (msp)); + } + } + } + +} +#endif // CYGPKG_CYGMON /*------------------------------------------------------------------------*/ /* End of var_misc.c */ diff --git a/packages/hal/mn10300/arch/current/ChangeLog b/packages/hal/mn10300/arch/current/ChangeLog --- a/packages/hal/mn10300/arch/current/ChangeLog +++ b/packages/hal/mn10300/arch/current/ChangeLog @@ -1,3 +1,57 @@ +2000-08-15 Drew Moseley + + * src/mn10300_stub.c (__is_breakpoint_function): Prepend an _ to + breakinst. Apparently the symbol generation has changed requiring + this. + +2000-08-14 Drew Moseley + + * src/vectors.S: Use some generic MN10300 code rather than AM33-specific. + + * src/mn10300_stub.c (__computeSignal): Make sure SIGSYSCALL is + defined before returning it. + +2000-08-12 Drew Moseley + + * include/mn10300_stub.h: More rearranging of GDB regnames. + +2000-08-11 Drew Moseley + + * include/mn10300_stub.h: Rearranged regnames to correspond to + what GDB is expecting. + + * include/arch.inc: Fixed error in declaration of hal_intc_decode. + +2000-08-10 Drew Moseley + + * src/vectors.S: Added syscall handling. + Added HAL_EARLY_INIT. + Added CTRLC_SUPPORT. + Added CYGMON support. + + * src/mn10300_stub.c: Added breakpoint list handling. + Added syscall handling. + + * src/hal_misc.c (cyg_hal_exception_handler): Added support for + exceptions caused by the stubs which are passed transparently + back. + Also added VIRTUAL_VECTOR support. + + * include/hal_arch.h: Added HAL_BREAKINST_TYPE. + Added Cygmon support. + + * cdl/hal_mn10300.cdl: Added option for CTRLC_SUPPORT. + * include/pkgconf/hal_mn10300.h: Ditto. + +2000-06-21 Nick Garnett + + * include/hal_arch.h: Added underscores to label in + HAL_BREAKINST(). + + * include/basetype.h: + Removed definition of CYG_LABEL_NAME() and added one for + CYG_LABEL_DEFN(). + 2000-06-08 Jesper Skov * include/hal_arch.h (CYGARC_HAL_SAVE_GP, CYGARC_HAL_RESTORE_GP): diff --git a/packages/hal/mn10300/arch/current/cdl/hal_mn10300.cdl b/packages/hal/mn10300/arch/current/cdl/hal_mn10300.cdl --- a/packages/hal/mn10300/arch/current/cdl/hal_mn10300.cdl +++ b/packages/hal/mn10300/arch/current/cdl/hal_mn10300.cdl @@ -33,7 +33,7 @@ # # Author(s): jskov # Original data: bartv, nickg -# Contributors: +# Contributors: dmoseley # Date: 1999-11-02 # #####DESCRIPTIONEND#### @@ -57,6 +57,16 @@ cdl_package CYGPKG_HAL_MN10300 { requires 1 == CYGINT_HAL_MN10300_VARIANT } + cdl_option CYGDBG_HAL_MN10300_DEBUG_GDB_CTRLC_SUPPORT { + display "Architecture GDB CTRLC support" + calculated { CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT || CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT } + active_if { CYGINT_HAL_DEBUG_GDB_CTRLC_UNSUPPORTED == 0 } + description " + If either the CTRLC or BREAK support options in hal.h are set + then set our own option to turn on shared generic support for + control C handling." + } + compile hal_misc.c context.S mn10300_stub.c make { diff --git a/packages/hal/mn10300/arch/current/include/arch.inc b/packages/hal/mn10300/arch/current/include/arch.inc --- a/packages/hal/mn10300/arch/current/include/arch.inc +++ b/packages/hal/mn10300/arch/current/include/arch.inc @@ -34,7 +34,7 @@ #######DESCRIPTIONBEGIN#### ## ## Author(s): nickg -## Contributors: nickg +## Contributors: nickg, dmoseley ## Date: 1997-10-16 ## Purpose: Architecture definitions. ## Description: This file contains various definitions and macros that are @@ -108,7 +108,10 @@ .endm #endif - .macro hal_intc_decode vnum +#endif + +#ifndef CYGPKG_HAL_MN10300_INTC_DECODE_DEFINED + .macro hal_intc_decode dreg,areg,dreg1 .endm #endif diff --git a/packages/hal/mn10300/arch/current/include/basetype.h b/packages/hal/mn10300/arch/current/include/basetype.h --- a/packages/hal/mn10300/arch/current/include/basetype.h +++ b/packages/hal/mn10300/arch/current/include/basetype.h @@ -50,11 +50,10 @@ #define CYG_BYTEORDER CYG_LSBFIRST // Little endian //----------------------------------------------------------------------------- -// MN10300 usually uses labels with underscores. Some labels generated -// by the linker also have underscores, so there's no need to add one -// when accessing those labels from C code. +// MN10300 usually uses labels with underscores. So when defining a label +// in asm or linker scripts, we need to add one. -#define CYG_LABEL_NAME(_name_) _name_ +#define CYG_LABEL_DEFN(_name_) _##_name_ //----------------------------------------------------------------------------- // Define the standard variable sizes diff --git a/packages/hal/mn10300/arch/current/include/hal_arch.h b/packages/hal/mn10300/arch/current/include/hal_arch.h --- a/packages/hal/mn10300/arch/current/include/hal_arch.h +++ b/packages/hal/mn10300/arch/current/include/hal_arch.h @@ -34,7 +34,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): nickg -// Contributors: nickg +// Contributors: nickg, dmoseley // Date: 1999-02-18 // Purpose: Define architecture abstractions // Usage: #include @@ -133,10 +133,11 @@ externC void hal_thread_load_context( CY // happen if executed. // HAL_BREAKINST is the value of the breakpoint instruction and // HAL_BREAKINST_SIZE is its size in bytes. +// HAL_BREAKINST_TYPE is the type. #define HAL_BREAKPOINT(_label_) \ -asm volatile (" .globl " #_label_ ";" \ - #_label_":" \ +asm volatile (" .globl _" #_label_ ";" \ + "_"#_label_":" \ ".byte 0xFF" \ ); @@ -144,6 +145,8 @@ asm volatile (" .globl " #_label_ ";" #define HAL_BREAKINST_SIZE 1 +#define HAL_BREAKINST_TYPE cyg_uint8 + //-------------------------------------------------------------------------- // Thread register state manipulation for GDB support. @@ -175,8 +178,8 @@ asm volatile (" .globl " #_label_ ";" _regval_[6] = (_regs_)->a2; \ _regval_[7] = (_regs_)->a3; \ \ - _regval_[8] = (CYG_ADDRWORD)(_regs_) + \ - sizeof(HAL_SavedRegisters); \ + _regval_[8] = (_regs_)->sp = (CYG_ADDRWORD)(_regs_) + \ + sizeof(HAL_SavedRegisters); \ _regval_[9] = (_regs_)->pc; \ _regval_[10] = (_regs_)->mdr; \ _regval_[11] = (_regs_)->psw; \ @@ -187,6 +190,34 @@ asm volatile (" .globl " #_label_ ";" } // Copy a GDB ordered array into a HAL_SavedRegisters structure. +// +// The CYGMON version should differ by also handling SP and PSW +// since we will be using a different stack. +#ifdef CYGPKG_CYGMON +#define HAL_SET_GDB_REGISTERS( _regs_ , _aregval_ ) \ +{ \ + CYG_ADDRWORD *_regval_ = (CYG_ADDRWORD *)(_aregval_); \ + \ + (_regs_)->d0 = _regval_[0]; \ + (_regs_)->d1 = _regval_[1]; \ + (_regs_)->d2 = _regval_[2]; \ + (_regs_)->d3 = _regval_[3]; \ + (_regs_)->a0 = _regval_[4]; \ + (_regs_)->a1 = _regval_[5]; \ + (_regs_)->a2 = _regval_[6]; \ + (_regs_)->a3 = _regval_[7]; \ + \ + (_regs_)->sp = _regval_[8]; \ + (_regs_)->pc = _regval_[9]; \ + (_regs_)->mdr = _regval_[10]; \ + (_regs_)->psw = _regval_[11]; \ + \ + (_regs_)->lar = _regval_[12]; \ + (_regs_)->lir = _regval_[13]; \ + \ + HAL_SET_GDB_EXTRA_REGISTERS( _regs_, _regval_ ); \ +} +#else #define HAL_SET_GDB_REGISTERS( _regs_ , _aregval_ ) \ { \ CYG_ADDRWORD *_regval_ = (CYG_ADDRWORD *)(_aregval_); \ @@ -213,6 +244,7 @@ asm volatile (" .globl " #_label_ ";" \ HAL_SET_GDB_EXTRA_REGISTERS( _regs_, _regval_ ); \ } +#endif //------------------------------------------------------------------------- // HAL setjmp diff --git a/packages/hal/mn10300/arch/current/include/hal_io.h b/packages/hal/mn10300/arch/current/include/hal_io.h --- a/packages/hal/mn10300/arch/current/include/hal_io.h +++ b/packages/hal/mn10300/arch/current/include/hal_io.h @@ -35,7 +35,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): nickg -// Contributors: nickg +// Contributors: nickg, dmoseley // Date: 1998-02-17 // Purpose: Define IO register support // Description: The macros defined here provide the HAL APIs for handling @@ -50,13 +50,17 @@ // //============================================================================= +#ifndef __ASSEMBLER__ #include +#endif //----------------------------------------------------------------------------- // IO Register address. // This type is for recording the address of an IO register. +#ifndef __ASSEMBLER__ typedef volatile CYG_ADDRWORD HAL_IO_REGISTER; +#endif //----------------------------------------------------------------------------- // BYTE Register access. diff --git a/packages/hal/mn10300/arch/current/include/mn10300_stub.h b/packages/hal/mn10300/arch/current/include/mn10300_stub.h --- a/packages/hal/mn10300/arch/current/include/mn10300_stub.h +++ b/packages/hal/mn10300/arch/current/include/mn10300_stub.h @@ -34,7 +34,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): Red Hat, jskov -// Contributors: Red Hat, jskov +// Contributors: Red Hat, jskov, dmoseley // Date: 1998-11-06 // Purpose: // Description: MN10300-specific definitions for generic stub @@ -58,7 +58,7 @@ enum regnames { D0, D1, D2, D3, A0, A1, A2, A3, SP, PC, MDR, PSW, LIR, LAR #ifdef CYGPKG_HAL_MN10300_AM33 - , XXX, /* unused offset */ + , MDRQ, R0, R1, R2, R3, R4, R5, R6, R7, SSP, MSP, USP, MCRH, MCRL, MCVF #endif @@ -80,19 +80,26 @@ extern void put_register (regnames_t whi /* Set the currently-saved pc register value to PC. This also updates NPC as needed. */ +#if !defined(SET_PC_PROTOTYPE_EXISTS) && !defined(set_pc) +#define SET_PC_PROTOTYPE_EXISTS extern void set_pc (target_register_t pc); +#endif /* Set things up so that the next user resume will execute one instruction. This may be done by setting breakpoints or setting a single step flag in the saved user registers, for example. */ +#ifndef __single_step void __single_step (void); +#endif /* Clear the single-step state. */ void __clear_single_step (void); /* If the breakpoint we hit is in the breakpoint() instruction, return a non-zero value. */ +#ifndef __is_breakpoint_function extern int __is_breakpoint_function (void); +#endif /* Skip the current instruction. */ extern void __skipinst (void); @@ -101,6 +108,10 @@ extern void __install_breakpoints (void) extern void __clear_breakpoints (void); +extern void __install_breakpoint_list (void); + +extern void __clear_breakpoint_list (void); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/packages/hal/mn10300/arch/current/src/hal_misc.c b/packages/hal/mn10300/arch/current/src/hal_misc.c --- a/packages/hal/mn10300/arch/current/src/hal_misc.c +++ b/packages/hal/mn10300/arch/current/src/hal_misc.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): nickg -// Contributors: nickg, jlarmour +// Contributors: nickg, jlarmour, dmoseley // Date: 1999-02-18 // Purpose: HAL miscellaneous functions // Description: This file contains miscellaneous functions provided by the @@ -156,7 +156,9 @@ externC void __handle_exception (void); externC HAL_SavedRegisters *_hal_registers; -void +externC void *__mem_fault_handler; + +externC cyg_uint32 cyg_hal_exception_handler(HAL_SavedRegisters *regs, CYG_WORD32 isr) { CYG_WORD vector = regs->vector; @@ -174,6 +176,13 @@ cyg_hal_exception_handler(HAL_SavedRegis #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + // If we caught an exception inside the stubs, see if we were expecting it + // and if so jump to the saved address + if (__mem_fault_handler) { + regs->pc = (CYG_ADDRWORD)__mem_fault_handler; + return 0; // Caught an exception inside stubs + } + // Set the pointer to the registers of the current exception // context. At entry the GDB stub will expand the // HAL_SavedRegisters structure into a (bigger) register array. @@ -202,7 +211,7 @@ cyg_hal_exception_handler(HAL_SavedRegis isr(CYGNUM_HAL_INTERRUPT_WATCHDOG, hal_interrupt_data[CYGNUM_HAL_INTERRUPT_WATCHDOG] ); - return; + return 0; } } @@ -219,12 +228,13 @@ cyg_hal_exception_handler(HAL_SavedRegis #endif - return; + return 0; } /*------------------------------------------------------------------------*/ /* default ISR */ +#ifndef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT externC cyg_uint32 hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data) { #if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT) && \ @@ -246,6 +256,32 @@ externC cyg_uint32 hal_default_isr(CYG_A return 0; } +#else // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT + +#include +externC cyg_uint32 hal_arch_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data) +{ +#if defined(CYGDBG_HAL_MN10300_DEBUG_GDB_CTRLC_SUPPORT) && \ + defined(CYGHWR_HAL_GDB_PORT_VECTOR) && \ + defined(HAL_CTRLC_ISR) + +#if defined(CYGSEM_HAL_USE_ROM_MONITOR_CygMon) +#if defined(HAL_DIAG_IRQ_CHECK) + { + cyg_uint32 ret; + /* let ROM monitor handle unexpected interrupts */ + HAL_DIAG_IRQ_CHECK(vector, ret); + if (ret<=0) + return ret; + } +#endif // def HAL_DIAG_IRQ_CHECK +#endif // def CYGSEM_HAL_USE_ROM_MONITOR_CygMon +#endif + + return 0; +} +#endif + /*------------------------------------------------------------------------*/ /* Idle thread activity. */ diff --git a/packages/hal/mn10300/arch/current/src/mn10300_stub.c b/packages/hal/mn10300/arch/current/src/mn10300_stub.c --- a/packages/hal/mn10300/arch/current/src/mn10300_stub.c +++ b/packages/hal/mn10300/arch/current/src/mn10300_stub.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): Red Hat, jskov -// Contributors: Red Hat, jskov +// Contributors: Red Hat, jskov, dmoseley // Date: 1998-11-06 // Purpose: // Description: Helper functions for mn10300 stub @@ -98,6 +98,14 @@ int __computeSignal (unsigned int trap_n asyncBuffer.targetAddr = NULL; return SIGINT; } +#ifdef SIGSYSCALL + switch (trap_number) + { + case SIGSYSCALL: + /* System call */ + return SIGSYSCALL; + } +#endif return SIGTRAP; } @@ -404,9 +412,15 @@ void __install_breakpoints (void) { /* NOP since single-step HW exceptions are used instead of breakpoints. */ + + /* Install the breakpoints in the breakpoint list */ + __install_breakpoint_list(); } -void __clear_breakpoints (void) {} +void __clear_breakpoints (void) +{ + __clear_breakpoint_list(); +} /* If the breakpoint we hit is in the breakpoint() instruction, return a @@ -415,7 +429,7 @@ void __clear_breakpoints (void) {} int __is_breakpoint_function () { - return get_register (PC) == (target_register_t)&CYG_LABEL_NAME(breakinst); + return get_register (PC) == (target_register_t)&CYG_LABEL_NAME(_breakinst); } diff --git a/packages/hal/mn10300/arch/current/src/vectors.S b/packages/hal/mn10300/arch/current/src/vectors.S --- a/packages/hal/mn10300/arch/current/src/vectors.S +++ b/packages/hal/mn10300/arch/current/src/vectors.S @@ -32,7 +32,7 @@ #######DESCRIPTIONBEGIN#### ## ## Author(s): nickg -## Contributors: nickg +## Contributors: nickg, dmoseley ## Date: 1997-10-16 ## Purpose: MN10300 exception vectors ## Description: This file defines the code placed into the exception @@ -79,6 +79,18 @@ reset_vector: # Trap vector jmp __trap +#ifdef CYGPKG_CYGMON +#ifdef CYGPKG_HAL_MN10300_AM33 + // We need to put the syscall handler at 0x300 + // For cygmon, we will use the am33 "syscall 0" as the syscall trap. + .p2align 8 + .rept 0x200 + nop + .endr + jmp __nmi +#endif +#endif + ##----------------------------------------------------------------------------- ## NMI vector @@ -135,6 +147,9 @@ reset_vector: .globl _start _start: +#ifdef HAL_EARLY_INIT + HAL_EARLY_INIT +#endif # set up stack mov __interrupt_stack,a0 @@ -205,6 +220,11 @@ 8: call _initialize_stub,[],0 #endif +#ifdef CYGDBG_HAL_MIPS_DEBUG_GDB_CTRLC_SUPPORT + .extern hal_ctrlc_isr_init + call hal_ctrlc_isr_init,[],0 +#endif + # Call cyg_start clr d0 mov d0,(4,sp) @@ -470,22 +490,95 @@ 2: add 9,d1 # offset into exception number space +#ifdef CYGPKG_CYGMON + # Check to see if this was a syscall. + # If so, set d1 appropriately +#define TBR 0xC0000024 + mov (TBR), d0 + and 0x00FFFFFF, d0 + cmp 0x300, d0 + bne 0f + + # This was apparently a syscall. + mov SIGSYSCALL, d1 + +0: +#endif hal_cpu_clear_nmid + mov d1,(sp) # save initial vector in spare save slot + mov sp,a1 # a1 = saved state + +#ifdef CYGPKG_CYGMON + # Switch to interrupt stack to handle exception + # This should probably be done as the first thing in the exception + # handler to guard against the possibility of having a bad SP to + # begin with. ie if the user sets the SP to a bad location, we + # won't run properly. Ideally we should switch to monitor mode + # on entry to any exception. However, a lot of other code + # assumes things work this way. + mov __interrupt_stack-4,a0 + mov a0, sp + mov a1,(sp) + add -4,sp +#endif + mov a1,d0 # d0 = arg1 = saved state add -16,sp # return link + args - mov d1,(16,sp) # save initial vector in spare save slot mov d3,d1 # d1 = arg2 = ISR value calls _cyg_hal_exception_handler # call C code add 16,sp # pop args +#ifdef CYGPKG_CYGMON + add 4,sp # Restore the old stack + mov (sp),a1 + mov a1,sp +#endif + hal_cpu_load_all +#ifdef CYGPKG_CYGMON + mov d3,(d3_save) + mov a2,(a2_save) + mov a3,(a3_save) + + # Pop the potentially-new stack pointer into a2 + mov (sp),a2 add 4,sp + + # Check to see if sp has been modified. + # The exception processing pushes 8 bytes onto the stack. + # If sp+8 = (sp) then the stack has not been modified. + mov sp,a3 + add 8, a3 + cmp a2,a3 + beq 8f + + # The stack has been modified. We need to setup for a proper rti + # so the stack is in the correct place. We just hope that the user + # put the stack somewhere we can write to. + # + # Copy 8 bytes from the old stack to the new stack (ie the exception frame) + mov (-4,a3), d3 + mov d3, (-4,a2) + mov (-8,a3), d3 + mov d3, (-8,a2) + + # Set the sp register to the new exception frame. + add -8, a2 + mov a2, sp + +8: mov (d3_save),d3 + mov (a2_save),a2 + mov (a3_save),a3 +#else + add 4,sp +#endif + rti .globl hal_lsbit_table @@ -495,6 +588,16 @@ hal_lsbit_table: .byte 3, 0, 1, 0 .byte 2, 0, 1, 0 +#ifdef CYGPKG_CYGMON + .section ".bss" +d3_save: + .long 0 +a2_save: + .long 0 +a3_save: + .long 0 +#endif + ##----------------------------------------------------------------------------- ## Default TRAP VSR diff --git a/packages/hal/mn10300/stdeval1/current/ChangeLog b/packages/hal/mn10300/stdeval1/current/ChangeLog --- a/packages/hal/mn10300/stdeval1/current/ChangeLog +++ b/packages/hal/mn10300/stdeval1/current/ChangeLog @@ -1,3 +1,23 @@ +2000-07-25 Jonathan Larmour + + * include/pkgconf/mlt_mn10300_am31_stdeval1_ram.mlt: Add user-defined + heap1 section + * include/pkgconf/mlt_mn10300_am31_stdeval1_ram.h: regenerate + * include/pkgconf/mlt_mn10300_am31_stdeval1_ram.ldi: regenerate + * include/pkgconf/mlt_mn10300_am31_stdeval1_rom.mlt: Regenerate + due to updated MLT + * include/pkgconf/mlt_mn10300_am31_stdeval1_rom.h: Regenerate + due to updated MLT + * include/pkgconf/mlt_mn10300_am31_stdeval1_rom.ldi: Regenerate + due to updated MLT + +2000-07-04 Jonathan Larmour + + * include/pkgconf/mlt_mn10300_am31_stdeval1_rom.mlt: Add user-defined + heap1 section + * include/pkgconf/mlt_mn10300_am31_stdeval1_rom.h: regenerate + * include/pkgconf/mlt_mn10300_am31_stdeval1_rom.ldi: regenerate + 2000-03-03 Nick Garnett * src/hal_diag.c: Removed code to absorb ack character when diff --git a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.h b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.h --- a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.h +++ b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.h @@ -1,6 +1,6 @@ -// eCos memory layout - Wed Nov 24 11:23:10 1999 +// eCos memory layout - Tue Jul 25 19:35:27 2000 -// This is a generated file - changes will be lost if ConfigTool(MLT) is run +// This is a generated file - do not edit #include #include @@ -8,9 +8,6 @@ #define CYGMEM_REGION_ram (0x48008000) #define CYGMEM_REGION_ram_SIZE (0x1f8000) #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) -/* */ -/* */ -/* */ -/* */ -/* {{CFG_DATA */ -/* }}CFG_DATA */ +extern char CYG_LABEL_NAME (__heap1) []; +#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1)) +#define CYGMEM_SECTION_heap1_SIZE (0x48200000 - (size_t) CYG_LABEL_NAME (__heap1)) diff --git a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.ldi b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.ldi --- a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.ldi +++ b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.ldi @@ -1,32 +1,8 @@ -//=========================================================================== -// -// MLT linker script export - Tue Jan 12 10:55:38 1999 -// -//=========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations under -// the License. -// -// The Original Code is eCos - Embedded Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//=========================================================================== +// eCos memory layout - Tue Jul 25 19:35:27 2000 + +// This is a generated file - do not edit + +#include MEMORY { @@ -45,5 +21,6 @@ SECTIONS SECTION_gcc_except_table (ram, ALIGN (0x1), LMA_EQ_VMA) SECTION_data (ram, ALIGN (0x4), LMA_EQ_VMA) SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA) + CYG_LABEL_DEFN(__heap1) = ALIGN (0x8); SECTIONS_END } diff --git a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.mlt b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.mlt --- a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.mlt +++ b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_ram.mlt @@ -8,4 +8,5 @@ section rodata1 0 1 0 1 0 1 0 1 fixup fi section fixup 0 1 0 1 0 1 0 1 gcc_except_table gcc_except_table ! section gcc_except_table 0 1 0 1 0 1 0 1 data data ! section data 0 4 0 1 0 1 0 1 bss bss ! -section bss 0 4 0 1 0 0 0 0 ! +section bss 0 4 0 1 0 1 0 1 heap1 heap1 ! +section heap1 0 8 0 0 0 0 0 0 ! diff --git a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.h b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.h --- a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.h +++ b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.h @@ -1,6 +1,6 @@ -// eCos memory layout - Wed Nov 24 12:53:47 1999 +// eCos memory layout - Tue Jul 25 19:36:26 2000 -// This is a generated file - changes will be lost if ConfigTool(MLT) is run +// This is a generated file - do not edit #include #include @@ -11,7 +11,6 @@ #define CYGMEM_REGION_ram (0x48000000) #define CYGMEM_REGION_ram_SIZE (0x200000) #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W) -/* */ -/* */ -/* {{CFG_DATA */ -/* }}CFG_DATA */ +extern char CYG_LABEL_NAME (__heap1) []; +#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1)) +#define CYGMEM_SECTION_heap1_SIZE (0x48200000 - (size_t) CYG_LABEL_NAME (__heap1)) diff --git a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.ldi b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.ldi --- a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.ldi +++ b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.ldi @@ -1,32 +1,8 @@ -//=========================================================================== -// -// MLT linker script export - Tue Jan 13 10:14:27 1999 -// -//=========================================================================== -//####COPYRIGHTBEGIN#### -// -// ------------------------------------------- -// The contents of this file are subject to the Red Hat eCos Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.redhat.com/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations under -// the License. -// -// The Original Code is eCos - Embedded Configurable Operating System, -// released September 30, 1998. -// -// The Initial Developer of the Original Code is Red Hat. -// Portions created by Red Hat are -// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. -// All Rights Reserved. -// ------------------------------------------- -// -//####COPYRIGHTEND#### -//=========================================================================== +// eCos memory layout - Tue Jul 25 19:36:26 2000 + +// This is a generated file - do not edit + +#include MEMORY { @@ -46,5 +22,6 @@ SECTIONS SECTION_gcc_except_table (rom, ALIGN (0x1), LMA_EQ_VMA) SECTION_data (ram, 0x48000000, FOLLOWING (.gcc_except_table)) SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA) + CYG_LABEL_DEFN(__heap1) = ALIGN (0x8); SECTIONS_END } diff --git a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.mlt b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.mlt --- a/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.mlt +++ b/packages/hal/mn10300/stdeval1/current/include/pkgconf/mlt_mn10300_am31_stdeval1_rom.mlt @@ -9,4 +9,5 @@ section rodata1 0 1 0 1 0 1 0 1 fixup fi section fixup 0 1 0 1 0 1 0 1 gcc_except_table gcc_except_table ! section gcc_except_table 0 1 0 1 0 0 0 1 data ! section data 0 1 1 1 1 1 0 0 48000000 bss ! -section bss 0 4 0 1 0 0 0 0 ! +section bss 0 4 0 1 0 1 0 1 heap1 heap1 ! +section heap1 0 8 0 0 0 0 0 0 ! diff --git a/packages/hal/powerpc/arch/current/ChangeLog b/packages/hal/powerpc/arch/current/ChangeLog --- a/packages/hal/powerpc/arch/current/ChangeLog +++ b/packages/hal/powerpc/arch/current/ChangeLog @@ -1,8 +1,22 @@ +2000-08-15 Gary Thomas + + * src/hal_mk_defs.c: Export memory layout for use by assembly code. + 2000-06-27 Jesper Skov * src/vectors.S: Removed unnecessary CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT checks. +2000-06-21 Nick Garnett + + * src/ppc_stub.c (__is_breakpoint_function): Removed use of + CYG_LABEL_NAME() and added underscore to _breakinst. + + * src/powerpc.ld: + Switched to new table definition mechanism. + + * include/basetype.h: Removed definition of CYG_LABEL_NAME(). + 2000-06-15 Jesper Skov * include/hal_intr.h: Added HAL_DEFAULT_ISR. diff --git a/packages/hal/powerpc/arch/current/include/basetype.h b/packages/hal/powerpc/arch/current/include/basetype.h --- a/packages/hal/powerpc/arch/current/include/basetype.h +++ b/packages/hal/powerpc/arch/current/include/basetype.h @@ -50,10 +50,9 @@ #define CYG_BYTEORDER CYG_MSBFIRST // Big endian //----------------------------------------------------------------------------- -// Powerpc does not usually use labels with underscores. Some labels generated -// by the linker do, so add an underscore where required. +// Powerpc does not usually use labels with underscores. -#define CYG_LABEL_NAME(_name_) _##_name_ +//#define CYG_LABEL_NAME(_name_) _name_ //----------------------------------------------------------------------------- // Define the standard variable sizes diff --git a/packages/hal/powerpc/arch/current/src/hal_mk_defs.c b/packages/hal/powerpc/arch/current/src/hal_mk_defs.c --- a/packages/hal/powerpc/arch/current/src/hal_mk_defs.c +++ b/packages/hal/powerpc/arch/current/src/hal_mk_defs.c @@ -44,6 +44,7 @@ //========================================================================== #include +#include CYGHWR_MEMORY_LAYOUT_H #include // HAL header #include // HAL header @@ -124,6 +125,14 @@ main(void) #ifdef CYGPKG_HAL_POWERPC_MPC8xx DEFINE(CYGNUM_HAL_VECTOR_NMI, CYGNUM_HAL_VECTOR_NMI); #endif + + // Memory layout values (since these aren't "asm"-safe) +#ifdef CYGMEM_REGION_rom + DEFINE(CYGMEM_REGION_rom, CYGMEM_REGION_rom); +#endif +#ifdef CYGMEM_REGION_ram + DEFINE(CYGMEM_REGION_ram, CYGMEM_REGION_ram); +#endif } //-------------------------------------------------------------------------- diff --git a/packages/hal/powerpc/arch/current/src/powerpc.ld b/packages/hal/powerpc/arch/current/src/powerpc.ld --- a/packages/hal/powerpc/arch/current/src/powerpc.ld +++ b/packages/hal/powerpc/arch/current/src/powerpc.ld @@ -102,9 +102,8 @@ GROUP(libtarget.a libgcc.a) KEEP(*(SORT(.ctors*))) __CTOR_END__ = ABSOLUTE(.); \ __DTOR_LIST__ = ABSOLUTE(.); \ KEEP(*(SORT(.dtors*))) __DTOR_END__ = ABSOLUTE(.); \ - . = ALIGN(8); \ - __DEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.devtab*))) __DEVTAB_END__ = ABSOLUTE (.); \ - __NETDEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.netdevtab*))) __NETDEVTAB_END__ = ABSOLUTE (.); \ + . = ALIGN(8); \ + KEEP(*( SORT (.ecos.table.*))) ; \ __GOT2_START__ = ABSOLUTE(.); *(.got2) __GOT2_END__ = ABSOLUTE(.); \ __GOT_START = ABSOLUTE(.); _GLOBAL_OFFSET_TABLE_ = ABSOLUTE(. + 32768); \ _SDA_BASE_ = ABSOLUTE(.); *(.got.plt) *(.got) \ diff --git a/packages/hal/powerpc/arch/current/src/ppc_stub.c b/packages/hal/powerpc/arch/current/src/ppc_stub.c --- a/packages/hal/powerpc/arch/current/src/ppc_stub.c +++ b/packages/hal/powerpc/arch/current/src/ppc_stub.c @@ -235,7 +235,7 @@ void __clear_breakpoints (void) int __is_breakpoint_function () { - return get_register (PC) == (target_register_t)&CYG_LABEL_NAME(breakinst); + return get_register (PC) == (target_register_t)&_breakinst; } diff --git a/packages/hal/powerpc/mbx/current/ChangeLog b/packages/hal/powerpc/mbx/current/ChangeLog --- a/packages/hal/powerpc/mbx/current/ChangeLog +++ b/packages/hal/powerpc/mbx/current/ChangeLog @@ -1,3 +1,7 @@ +2000-08-15 Gary Thomas + + * src/mbx.S: Use actual ROM layout instead of magic numbers. + 2000-06-28 Jesper Skov * include/hal_diag.h: diff --git a/packages/hal/powerpc/mbx/current/src/mbx.S b/packages/hal/powerpc/mbx/current/src/mbx.S --- a/packages/hal/powerpc/mbx/current/src/mbx.S +++ b/packages/hal/powerpc/mbx/current/src/mbx.S @@ -404,7 +404,7 @@ FUNC_START( hal_hardware_init ) # move return address to where the ROM is mflr r3 andi. r3,r3,0xffff - oris r3,r3,0xfe00 + oris r3,r3,CYGMEM_REGION_rom>>16 mtlr r3 #endif diff --git a/packages/hal/sh/arch/current/ChangeLog b/packages/hal/sh/arch/current/ChangeLog --- a/packages/hal/sh/arch/current/ChangeLog +++ b/packages/hal/sh/arch/current/ChangeLog @@ -7,6 +7,8 @@ 2000-07-18 Gary Thomas * src/hal_misc.c (cyg_hal_exception_handler): Handle exception caused by @@ -19,6 +21,18 @@ 2000-07-16 Gary Thomas + + * include/sh_regs.h: Add additional 7707 registers. + +2000-07-06 Jesper Skov + + * src/vectors.S: + * include/mod_7707a.h: + * include/hal_intr.h: + * include/sh_regs.h: + Added additional 7707 interrupt vectors. + 2000-06-30 Jesper Skov * src/vectors.S (__reset): Jump to VMA for RAM startup. @@ -65,6 +79,19 @@ 2000-06-27 Jesper Skov + + * src/sh_stub.c (__is_breakpoint_function): Removed use of + CYG_LABEL_NAME() and added underscore to _breakinst. + + * src/context.S: Switched use of CYG_LABEL_NAME() to + CYG_LABEL_DEFN(). + + * include/basetype.h: Removed definition of CYG_LABEL_NAME() and + added CYG_LABEL_DEFN(). + + * src/sh.ld: Switched to new table definition mechanism. + 2000-06-15 Jesper Skov * include/hal_intr.h: Added HAL_DEFAULT_ISR. @@ -79,6 +106,13 @@ 2000-06-08 Jesper Skov + + * include/mod_7707a.h: + * src/vectors.S: + * cdl/hal_sh.cdl: + Added first level of support for 7707A variant. + 2000-06-06 Jesper Skov * src/vectors.S: INTEVT2 is not defined on all variants. Protect diff --git a/packages/hal/sh/arch/current/cdl/hal_sh.cdl b/packages/hal/sh/arch/current/cdl/hal_sh.cdl --- a/packages/hal/sh/arch/current/cdl/hal_sh.cdl +++ b/packages/hal/sh/arch/current/cdl/hal_sh.cdl @@ -91,6 +91,21 @@ cdl_package CYGPKG_HAL_SH { @rm target.tmp } + cdl_option CYGPKG_HAL_SH_7707A { + display "SH 7707A microprocessor" + implements CYGINT_HAL_SH_VARIANT + default_value 0 + no_define + define -file=system.h CYGPKG_HAL_SH_7707A + description " + The SH3 7707A microprocessor. This is an embedded part that in + addition to the SH3 processor core has built in peripherals + such as memory controllers, serial ports, LCD controller and + timers/counters." + define_proc { + puts $cdl_system_header "#define CYGBLD_HAL_CPU_MODULES_H " + } + } cdl_option CYGPKG_HAL_SH_7708 { display "SH 7708 microprocessor" diff --git a/packages/hal/sh/arch/current/include/basetype.h b/packages/hal/sh/arch/current/include/basetype.h --- a/packages/hal/sh/arch/current/include/basetype.h +++ b/packages/hal/sh/arch/current/include/basetype.h @@ -54,10 +54,9 @@ #endif //----------------------------------------------------------------------------- -// sh does not usually use labels with underscores. Some labels generated -// by the linker do, so add an underscore where required. +// sh usually uses labels with underscores. -#define CYG_LABEL_NAME(_name_) _##_name_ +#define CYG_LABEL_DEFN(_name_) _##_name_ //----------------------------------------------------------------------------- // Define the standard variable sizes diff --git a/packages/hal/sh/arch/current/include/hal_intr.h b/packages/hal/sh/arch/current/include/hal_intr.h --- a/packages/hal/sh/arch/current/include/hal_intr.h +++ b/packages/hal/sh/arch/current/include/hal_intr.h @@ -173,6 +173,21 @@ #endif // CYGARC_SH_MOD_INTC_V2 +//---------------------------------------------------------------------------- +// Additional vectors provided by INTC V3 + +//#ifdef CYGARC_SH_MOD_INTC_V3 // FIXME +#define CYGNUM_HAL_INTERRUPT_LCDC_LCDI 63 +#define CYGNUM_HAL_INTERRUPT_PCC_PCC0 64 +#define CYGNUM_HAL_INTERRUPT_PCC_PCC1 65 + +#ifdef CYGARC_SH_MOD_INTC_V3 // FIXME + +#undef CYGNUM_HAL_ISR_MAX +#define CYGNUM_HAL_ISR_MAX CYGNUM_HAL_INTERRUPT_PCC_PCC1 + +#endif // CYGARC_SH_MOD_INTC_V3 + // CYGNUM_HAL_ISR_COUNT must match CYG_ISR_TABLE_SIZE defined in vectors.S. #define CYGNUM_HAL_ISR_MIN CYGNUM_HAL_INTERRUPT_NMI @@ -575,6 +590,26 @@ externC cyg_uint8 cyg_hal_ILVL_table[]; HAL_WRITE_UINT16(CYGARC_REG_IPRE, iprX); \ break; \ \ + /* IPRF */ \ + case CYGNUM_HAL_INTERRUPT_LCDC_LCDI: \ + HAL_READ_UINT16(CYGARC_REG_IPRF, iprX); \ + iprX &= ~CYGARC_REG_IPRF_LCDI_MASK; \ + iprX |= (_level_)*CYGARC_REG_IPRF_LCDI_PRI1; \ + HAL_WRITE_UINT16(CYGARC_REG_IPRF, iprX); \ + break; \ + case CYGNUM_HAL_INTERRUPT_PCC_PCC0: \ + HAL_READ_UINT16(CYGARC_REG_IPRF, iprX); \ + iprX &= ~CYGARC_REG_IPRF_PCC0_MASK; \ + iprX |= (_level_)*CYGARC_REG_IPRF_PCC0_PRI1; \ + HAL_WRITE_UINT16(CYGARC_REG_IPRF, iprX); \ + break; \ + case CYGNUM_HAL_INTERRUPT_PCC_PCC1: \ + HAL_READ_UINT16(CYGARC_REG_IPRF, iprX); \ + iprX &= ~CYGARC_REG_IPRF_PCC1_MASK; \ + iprX |= (_level_)*CYGARC_REG_IPRF_PCC1_PRI1; \ + HAL_WRITE_UINT16(CYGARC_REG_IPRF, iprX); \ + break; \ + \ case CYGNUM_HAL_INTERRUPT_RESERVED_1E0: \ case CYGNUM_HAL_INTERRUPT_RESERVED_3E0: \ /* Do nothing for these reserved vectors. */ \ diff --git a/packages/hal/sh/arch/current/include/mod_7707a.h b/packages/hal/sh/arch/current/include/mod_7707a.h new file mode 100644 --- /dev/null +++ b/packages/hal/sh/arch/current/include/mod_7707a.h @@ -0,0 +1,81 @@ +#ifndef CYGONCE_HAL_MOD_77xx_H +#define CYGONCE_HAL_MOD_77xx_H + +//============================================================================= +// +// mod_7707a.h +// +// List modules available on CPU +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov +// Contributors:jskov +// Date: 2000-06-08 +// Purpose: Define modules (and versions) available on this CPU. +// Usage: Included from +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +//----------------------------------------------------------------------------- +// Modules provided by the CPU + +#define CYGARC_SH_MOD_BCN_V2 +#define CYGARC_SH_MOD_INTC_V2 +#define CYGARC_SH_MOD_INTC_V3 +#define CYGARC_SH_MOD_IRDA +#define CYGARC_SH_MOD_SCIF +#define CYGARC_SH_MOD_PFC + +//----------------------------------------------------------------------------- +// Extra details for Cache Module (CAC) + +// Cache dimenions - one unified cache +#define CYGARC_SH_MOD_CAC_SIZE 16384 // Size of cache in bytes +#define CYGARC_SH_MOD_CAC_LINE_SIZE 16 // Size of a cache line +#define CYGARC_SH_MOD_CAC_WAYS 4 // Associativity of the cache + +// Cache addressing information +// way: bits 13 - 12 +// entry: bits 11 - 4 +#define CYGARC_SH_MOD_CAC_ADDRESS_BASE 0xf0000000 +#define CYGARC_SH_MOD_CAC_ADDRESS_TOP 0xf0004000 +#define CYGARC_SH_MOD_CAC_ADDRESS_STEP 0x00000010 +// U : bit 1 +// V : bit 0 +// Writing zero to both forces a flush of the line if it is dirty. +#define CYGARC_SH_MOD_CAC_ADDRESS_FLUSH 0x00000000 + +//----------------------------------------------------------------------------- +// Extra details for interrupt handling +#define CYGARC_SH_SOFTWARE_IP_UPDATE + +#endif // CYGONCE_HAL_MOD_77xx_H diff --git a/packages/hal/sh/arch/current/include/sh_regs.h b/packages/hal/sh/arch/current/include/sh_regs.h --- a/packages/hal/sh/arch/current/include/sh_regs.h +++ b/packages/hal/sh/arch/current/include/sh_regs.h @@ -340,6 +340,11 @@ # define CYGARC_REG_IPRD 0xa4000018 # define CYGARC_REG_IPRE 0xa400001a //#endif +//#ifdef CYGARC_SH_MOD_INTC_V3 // FIXME: HAL_INTERRUPT_SET_LEVEL needs these +# define CYGARC_REG_IRR3 0xa400000a +# define CYGARC_REG_IRR4 0xa400000c +# define CYGARC_REG_IPRF 0xa400001c +//#endif #define CYGARC_REG_IPRA_TMU0_MASK 0xf000 @@ -410,6 +415,16 @@ //#endif +//#ifdef CYGARC_SH_MOD_INTC_V3 // FIXME: HAL_INTERRUPT_SET_LEVEL needs these +#define CYGARC_REG_IPRF_LCDI_MASK 0x0f00 +#define CYGARC_REG_IPRF_LCDI_PRI1 0x0100 +#define CYGARC_REG_IPRF_PCC0_MASK 0x00f0 +#define CYGARC_REG_IPRF_PCC0_PRI1 0x0010 +#define CYGARC_REG_IPRF_PCC1_MASK 0x000f +#define CYGARC_REG_IPRF_PCC1_PRI1 0x0001 + +//#endif + //++++++ Module RTC ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //-------------------------------------------------------------------------- diff --git a/packages/hal/sh/arch/current/src/context.S b/packages/hal/sh/arch/current/src/context.S --- a/packages/hal/sh/arch/current/src/context.S +++ b/packages/hal/sh/arch/current/src/context.S @@ -47,7 +47,7 @@ #include #include -#include // CYG_LABEL_NAME +#include // CYG_LABEL_DEFN #------------------------------------------------------------------------------ # Register allocation for the Hitachi calling convention: @@ -75,9 +75,9 @@ # function declaration macro #define FUNC_START(name) \ - .type CYG_LABEL_NAME(name),@function; \ - .globl CYG_LABEL_NAME(name); \ -CYG_LABEL_NAME(name): + .type CYG_LABEL_DEFN(name),@function; \ + .globl CYG_LABEL_DEFN(name); \ +CYG_LABEL_DEFN(name): #------------------------------------------------------------------------------ # hal_thread_switch_context diff --git a/packages/hal/sh/arch/current/src/sh.ld b/packages/hal/sh/arch/current/src/sh.ld --- a/packages/hal/sh/arch/current/src/sh.ld +++ b/packages/hal/sh/arch/current/src/sh.ld @@ -94,17 +94,16 @@ GROUP(libtarget.a libgcc.a) __EXCEPT_END__ = ABSOLUTE(.);} \ > _region_ -#define SECTION_data(_region_, _vma_, _lma_) \ - .data _vma_ : _lma_ \ - { __ram_data_start = ABSOLUTE(.); *(.data*) \ +#define SECTION_data(_region_, _vma_, _lma_) \ + .data _vma_ : _lma_ \ + { __ram_data_start = ABSOLUTE(.); *(.data*) \ . = ALIGN(8); ___CTOR_LIST__ = ABSOLUTE(.); \ KEEP(*(SORT(.ctors*))) ___CTOR_END__ = ABSOLUTE(.); \ ___DTOR_LIST__ = ABSOLUTE(.); \ KEEP(*(SORT(.dtors*))) ___DTOR_END__ = ABSOLUTE(.); \ . = ALIGN(8); \ - ___DEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.devtab*))) ___DEVTAB_END__ = ABSOLUTE (.); \ - ___NETDEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.netdevtab*))) ___NETDEVTAB_END__ = ABSOLUTE (.); \ - } > _region_ \ + KEEP(*( SORT (.ecos.table.*))) ; \ + } > _region_ \ __rom_data_start = LOADADDR(.data); \ __ram_data_end = .; PROVIDE(__ram_data_end = .); \ _edata = .; PROVIDE (edata = .); diff --git a/packages/hal/sh/arch/current/src/sh_stub.c b/packages/hal/sh/arch/current/src/sh_stub.c --- a/packages/hal/sh/arch/current/src/sh_stub.c +++ b/packages/hal/sh/arch/current/src/sh_stub.c @@ -266,7 +266,7 @@ void __clear_breakpoints (void) int __is_breakpoint_function () { - return get_register(PC) == (target_register_t)&CYG_LABEL_NAME(breakinst); + return get_register(PC) == (target_register_t)&_breakinst; } diff --git a/packages/hal/sh/arch/current/src/vectors.S b/packages/hal/sh/arch/current/src/vectors.S --- a/packages/hal/sh/arch/current/src/vectors.S +++ b/packages/hal/sh/arch/current/src/vectors.S @@ -701,6 +701,10 @@ restore_state: mov.w r0,@r1 mov.l $CYGARC_REG_IPRE,r1 mov.w r0,@r1 +#ifdef CYGARC_SH_MOD_INTC_V3 + mov.l $CYGARC_REG_IPRF,r1 + mov.w r0,@r1 +#endif mov.l $CYGARC_REG_ICR1,r1 ! Set interrupt controller to IRQ mode mov.w r0,@r1 #endif @@ -828,6 +832,10 @@ 1: mov.l @r0+,r3 $CYGARC_REG_ICR1: .long CYGARC_REG_ICR1 #endif +#ifdef CYGARC_SH_MOD_INTC_V2 +$CYGARC_REG_IPRF: + .long CYGARC_REG_IPRF +#endif $__reset: .long __reset diff --git a/packages/hal/sparclite/arch/current/ChangeLog b/packages/hal/sparclite/arch/current/ChangeLog --- a/packages/hal/sparclite/arch/current/ChangeLog +++ b/packages/hal/sparclite/arch/current/ChangeLog @@ -1,3 +1,18 @@ +2000-08-07 Jonathan Larmour + + * src/sparclite.ld: Remove extra underscore from below. It was + correct before. + +2000-06-21 Nick Garnett + + * include/basetype.h: + Removed definition of CYG_LABEL_NAME(). Now dealt with by default + definition in cyg_type.h. + + * src/sparclite.ld: + Added extra underscore to _stext and _etext. + Switched over to new table creation mechanism. + 2000-06-08 Jesper Skov * include/hal_arch.h (CYGARC_HAL_SAVE_GP, CYGARC_HAL_RESTORE_GP): diff --git a/packages/hal/sparclite/arch/current/include/basetype.h b/packages/hal/sparclite/arch/current/include/basetype.h --- a/packages/hal/sparclite/arch/current/include/basetype.h +++ b/packages/hal/sparclite/arch/current/include/basetype.h @@ -50,10 +50,9 @@ #define CYG_BYTEORDER CYG_MSBFIRST // Big endian //----------------------------------------------------------------------------- -// SPARC does not usually use labels with underscores. Some labels generated -// by the linker do, so add an underscore where required. +// SPARC does not usually use labels with underscores. -#define CYG_LABEL_NAME(_name_) _##_name_ +//#define CYG_LABEL_NAME(_name_) _name_ //----------------------------------------------------------------------------- // Define the standard variable sizes diff --git a/packages/hal/sparclite/arch/current/src/sparclite.ld b/packages/hal/sparclite/arch/current/src/sparclite.ld --- a/packages/hal/sparclite/arch/current/src/sparclite.ld +++ b/packages/hal/sparclite/arch/current/src/sparclite.ld @@ -93,8 +93,7 @@ GROUP(libtarget.a libgcc.a) _GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.); \ _GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); \ . = ALIGN (4); \ - __DEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.devtab*))) __DEVTAB_END__ = ABSOLUTE (.); \ - __NETDEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.netdevtab*))) __NETDEVTAB_END__ = ABSOLUTE (.); \ + KEEP(*( SORT (.ecos.table.*))) ; \ __CTOR_LIST__ = ABSOLUTE (.); \ KEEP(*(SORT(.ctors*))) \ __CTOR_END__ = ABSOLUTE (.); \ diff --git a/packages/hal/v85x/arch/current/ChangeLog b/packages/hal/v85x/arch/current/ChangeLog --- a/packages/hal/v85x/arch/current/ChangeLog +++ b/packages/hal/v85x/arch/current/ChangeLog @@ -1,3 +1,9 @@ +2000-07-24 Jonathan Larmour + + * include/basetype.h: Removed definition of CYG_LABEL_NAME(). + + * src/v85x.ld: Switched to new table definition mechanism. + 2000-07-21 Gary Thomas * src/vectors.S (_hal_plf_reset_board): Needs to be defined in all diff --git a/packages/hal/v85x/arch/current/include/basetype.h b/packages/hal/v85x/arch/current/include/basetype.h --- a/packages/hal/v85x/arch/current/include/basetype.h +++ b/packages/hal/v85x/arch/current/include/basetype.h @@ -51,10 +51,9 @@ #define CYG_BYTEORDER CYG_LSBFIRST // Little endian //----------------------------------------------------------------------------- -// NEC does not usually use labels with undersores. Some labels generated -// by the linker do, so add an underscore where required. +// NEC usually uses labels with undersores. -#define CYG_LABEL_NAME(_name_) _##_name_ +#define CYG_LABEL_DEFN(_name_) _##_name_ //----------------------------------------------------------------------------- // Define the standard variable sizes diff --git a/packages/hal/v85x/arch/current/src/v85x.ld b/packages/hal/v85x/arch/current/src/v85x.ld --- a/packages/hal/v85x/arch/current/src/v85x.ld +++ b/packages/hal/v85x/arch/current/src/v85x.ld @@ -100,8 +100,7 @@ GROUP(libtarget.a libgcc.a) _GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.); \ _GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); \ . = ALIGN (4); \ - __DEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.devtab*))) __DEVTAB_END__ = ABSOLUTE (.); \ - __NETDEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.netdevtab*))) __NETDEVTAB_END__ = ABSOLUTE (.); \ + KEEP(*( SORT (.ecos.table.*))) ; \ __CTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.ctors*))) __CTOR_END__ = ABSOLUTE (.); \ __DTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.dtors*))) __DTOR_END__ = ABSOLUTE (.); \ *(.dynamic) *(.sdata*) *(.sbss*) } \ diff --git a/packages/hal/v85x/v850/current/ChangeLog b/packages/hal/v85x/v850/current/ChangeLog --- a/packages/hal/v85x/v850/current/ChangeLog +++ b/packages/hal/v85x/v850/current/ChangeLog @@ -1,3 +1,11 @@ +2000-07-24 Jonathan Larmour + + * src/v850_stub.c (__is_breakpoint_function): Removed use + of CYG_LABEL_NAME() and added underscore to _breakinst. + + * src/nec.ld, src/v85x_v850.ld: + Switched to new table definition mechanism. + 2000-06-12 Gary Thomas * src/v850_misc.c (hal_interrupt_unmask): Remove [extra] diff --git a/packages/hal/v85x/v850/current/include/v850_common.h b/packages/hal/v85x/v850/current/include/v850_common.h --- a/packages/hal/v85x/v850/current/include/v850_common.h +++ b/packages/hal/v85x/v850/current/include/v850_common.h @@ -46,7 +46,7 @@ //===========================================================================*/ // Note: these defintions match the documentation, thus no attempt is made -// to sanitize (mangle) the names. Also, care should be taken to keep this +// to sanitise (mangle) the names. Also, care should be taken to keep this // clean for use in assembly code (no "C" constructs). #include diff --git a/packages/hal/v85x/v850/current/src/nec.ld b/packages/hal/v85x/v850/current/src/nec.ld --- a/packages/hal/v85x/v850/current/src/nec.ld +++ b/packages/hal/v85x/v850/current/src/nec.ld @@ -100,8 +100,7 @@ GROUP(libtarget.a libgcc.a) _GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.); \ _GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); \ . = ALIGN (4); \ - __DEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.devtab*))) __DEVTAB_END__ = ABSOLUTE (.); \ - __NETDEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.netdevtab*))) __NETDEVTAB_END__ = ABSOLUTE (.); \ + KEEP(*( SORT (.ecos.table.*))) ; \ __CTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.ctors*))) __CTOR_END__ = ABSOLUTE (.); \ __DTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.dtors*))) __DTOR_END__ = ABSOLUTE (.); \ *(.dynamic) *(.sdata*) *(.sbss*) } \ diff --git a/packages/hal/v85x/v850/current/src/v850_stub.c b/packages/hal/v85x/v850/current/src/v850_stub.c --- a/packages/hal/v85x/v850/current/src/v850_stub.c +++ b/packages/hal/v85x/v850/current/src/v850_stub.c @@ -296,7 +296,7 @@ void __clear_breakpoints (void) int __is_breakpoint_function () { - return get_register (PC) == (target_register_t)&CYG_LABEL_NAME(breakinst); + return get_register (PC) == (target_register_t)&_breakinst; } diff --git a/packages/hal/v85x/v850/current/src/v85x_v850.ld b/packages/hal/v85x/v850/current/src/v85x_v850.ld --- a/packages/hal/v85x/v850/current/src/v85x_v850.ld +++ b/packages/hal/v85x/v850/current/src/v85x_v850.ld @@ -100,8 +100,7 @@ GROUP(libtarget.a libgcc.a) _GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.); \ _GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); \ . = ALIGN (4); \ - ___DEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.devtab*))) ___DEVTAB_END__ = ABSOLUTE (.); \ - ___NETDEVTAB__ = ABSOLUTE (.); KEEP (*(SORT (.netdevtab*))) ___NETDEVTAB_END__ = ABSOLUTE (.); \ + KEEP(*( SORT (.ecos.table.*))) ; \ ___CTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.ctors*))) ___CTOR_END__ = ABSOLUTE (.); \ ___DTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.dtors*))) ___DTOR_END__ = ABSOLUTE (.); \ *(.dynamic) *(.sdata*) *(.sbss*) } \ diff --git a/packages/infra/current/ChangeLog b/packages/infra/current/ChangeLog --- a/packages/infra/current/ChangeLog +++ b/packages/infra/current/ChangeLog @@ -1,3 +1,13 @@ +2000-07-25 Jonathan Larmour + + * include/cyg_type.inc: Create. Used for the equivalent stuff of + cyg_type.h in assembler and linker scripts + +2000-07-19 Jonathan Larmour + + * src/pkgstart.cxx (cyg_package_start): Remove POSIX startup option + * cdl/startup.cdl: Likewise + 2000-07-18 Jonathan Larmour * src/buffer.cxx (increment_buffer_pos): Reset buffer pos *before* @@ -5,10 +15,54 @@ 2000-07-18 Jonathan Larmour + + * cdl/infra.cdl: Add CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS option + to control presence of empty C++ delete functions + + * src/delete.cxx: Move comments into above option, and simplify + the configuration now that it's more straightforward + +2000-06-21 Nick Garnett + + * src/simple.cxx: + * src/null.cxx: + * src/fancy.cxx: + * src/buffer.cxx: + Removed use of CYG_LABEL_NAME() and added extra underscores to + _stext and _etext. + + * include/cyg_type.h: Changed default for CYG_LABEL_DEFN() to + define labels without an extra underscore. This reflects the + practice of most of the targets we support. + +2000-06-19 Nick Garnett + + * include/cyg_type.h: + Added CYGBLD_ATTRIB_SECTION to assign variables to a named + section. + Added CYG_LABEL_DEFN() macro for defining labels in asm and linker + scripts. This is particularly useful for generating labels in + inline assembler fragments. + +2000-05-02 Jonathan Larmour + + * cdl/startup.cdl: + * src/pkgstart.cxx: + Remove CYGSEM_START_ISO_C_COMPATIBILITY: startup is now handled + via extras.o + * include/cyg_type.h: Define __externC alternative to externC + 2000-04-12 Jesper Skov * cdl/infra.cdl: Allow build flags to be tweaked. +2000-03-31 Nick Garnett + + * cdl/startup.cdl: + * src/pkgstart.cxx: + Added POSIX startup option. + 2000-03-28 Jonathan Larmour * include/cyg_trac.h: Also update internal documentation for below diff --git a/packages/infra/current/cdl/infra.cdl b/packages/infra/current/cdl/infra.cdl --- a/packages/infra/current/cdl/infra.cdl +++ b/packages/infra/current/cdl/infra.cdl @@ -153,6 +153,34 @@ cdl_package CYGPKG_INFRA { } # ======================================================================== + + cdl_option CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS { + display "Provide empty C++ delete functions" + default_value 1 + description " + To deal with virtual destructors, where the correct delete() + function must be called for the derived class in question, the + underlying delete is called when needed, from destructors. This + is regardless of whether the destructor is called by delete itself. + So there is a reference to delete() from all destructors. The + default builtin delete() attempts to call free() if there is + one defined. So, if you have destructors, and you have free(), + as in malloc() and free(), any destructor counts as a reference + to free(). So the dynamic memory allocation code is linked + in regardless of whether it gets explicitly called. This + increases code and data size needlessly. + + To defeat this undesirable behaviour, we define empty versions + of delete and delete[]. But doing this prevents proper use + of dynamic memory in C++ programs via C++'s new and delete + operators. + + Therefore, this option is provided + for explicitly disabling the provision of these empty functions, + so that new and delete can be used, if that is what is required." + } + + # ======================================================================== # Debugging-related miscellania. # # NOTE: this is not yet fully supported, by CDL nor by having a proper diff --git a/packages/infra/current/cdl/startup.cdl b/packages/infra/current/cdl/startup.cdl --- a/packages/infra/current/cdl/startup.cdl +++ b/packages/infra/current/cdl/startup.cdl @@ -46,12 +46,6 @@ # process. These can affect the environment in which the program # runs. # -# CYGSEM_START_ISO_C_COMPATIBILITY enables compatibility with ISO C, -# in particular in eCos it creates a thread that invokes the function -# main() which the user must supply. It does this by invoking the function -# cyg_iso_c_start(). For more information, refer to the C library -# documentation. -# # CYGSEM_START_UITRON_COMPATIBILITY enables compatibility with uItron. # You must configure uItron with the correct tasks, and then enabling this # option starts the uItron subsystem. It does this by invoking the function @@ -61,22 +55,6 @@ # cyg_package_start(), or cyg_prestart(). Refer to the documentation on # how and when to do this. -cdl_option CYGSEM_START_ISO_C_COMPATIBILITY { - display "Start ISO C library" - default_value 1 - requires CYGPKG_LIBC - active_if CYGPKG_LIBC - description " - Generate a call to initialize the ISO C library - (libc) within the system version of cyg_package_start(). - This enables compatibility with ISO C, in particular in - eCos it creates a thread that invokes the function main() - which the user must supply. - It does this by invoking the function cyg_iso_c_start(). - If this is disabled, and you want to use the C library, you - call cyg_iso_c_start() from your own cyg_package_start() - or cyg_userstart()." -} cdl_option CYGSEM_START_UITRON_COMPATIBILITY { display "Start uITRON subsystem" default_value 0 @@ -93,4 +71,3 @@ cdl_option CYGSEM_START_UITRON_COMPATIBI you must call cyg_uitron_start() from your own cyg_package_start() or cyg_userstart()." } - diff --git a/packages/infra/current/include/cyg_type.h b/packages/infra/current/include/cyg_type.h --- a/packages/infra/current/include/cyg_type.h +++ b/packages/infra/current/include/cyg_type.h @@ -51,15 +51,16 @@ // ------------------------------------------------------------------------- // Some useful macros. These are defined here by default. -// externC is used in mixed C/C++ headers to force C linkage on an external +// __externC is used in mixed C/C++ headers to force C linkage on an external // definition. It avoids having to put all sorts of ifdefs in. #ifdef __cplusplus -# define externC extern "C" +# define __externC extern "C" #else -# define externC extern +# define __externC extern #endif - +// Also define externC for now - but it is deprecated +#define externC __externC // ------------------------------------------------------------------------- // The header defines the base types used here. It is @@ -287,6 +288,9 @@ typedef cyg_haladdrword CYG_ADDRWORD; // note this can't be used if there are pointer args # define CYGBLD_ATTRIB_CONST __attribute__((const)) +// Assign a defined variable to a specific section +# define CYGBLD_ATTRIB_SECTION(__sect__) __attribute__((section (#__sect__))) + #else // non-GNU # define CYGBLD_ATTRIB_CONSTRUCTOR @@ -313,10 +317,14 @@ typedef cyg_haladdrword CYG_ADDRWORD; CYGBLD_ATTRIB_WEAK CYGBLD_ATTRIB_ALIAS(__symbol__) // ------------------------------------------------------------------------- -// Label name macro. Some toolsets generate labels with initial -// underscores and others don't. This macro should be used on labels -// that are defined in assembly code or linker scripts so that we can -// do the right thing. +// Label name macros. Some toolsets generate labels with initial +// underscores and others don't. CYG_LABEL_NAME should be used on +// labels in C/C++ code that are defined in assembly code or linker +// scripts. CYG_LABEL_DEFN is for use in assembly code and linker +// scripts where we need to manufacture labels that can be used from +// C/C++. +// These are default implementations that should work for most targets. +// They may be overridden in basetype.h if necessary. #ifndef CYG_LABEL_NAME @@ -324,6 +332,12 @@ typedef cyg_haladdrword CYG_ADDRWORD; #endif +#ifndef CYG_LABEL_DEFN + +#define CYG_LABEL_DEFN(_label) _label + +#endif + // ------------------------------------------------------------------------- // Various "flavours" of memory regions that can be described by the // Memory Layout Tool (MLT). diff --git a/packages/infra/current/include/cyg_type.inc b/packages/infra/current/include/cyg_type.inc new file mode 100644 --- /dev/null +++ b/packages/infra/current/include/cyg_type.inc @@ -0,0 +1,56 @@ +#ifndef CYGONCE_INFRA_CYG_TYPE_INC +#define CYGONCE_INFRA_CYG_TYPE_INC + +//========================================================================== +// +// cyg_type.inc +// +// Standard types, and some useful coding macros. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-07-25 +// Purpose: Define symbols for use in linker scripts and "generic" asm +// Description: This file should only use #defines - it should be safe +// to include from both linker scripts and assembler files +// Usage: #include +// +// +//####DESCRIPTIONEND#### + +#include + +#ifndef CYG_LABEL_DEFN +# define CYG_LABEL_DEFN(_label) _label +#endif + +#endif /* CYGONCE_INFRA_CYG_TYPE_INC */ + +// EOF cyg_type.inc diff --git a/packages/infra/current/src/buffer.cxx b/packages/infra/current/src/buffer.cxx --- a/packages/infra/current/src/buffer.cxx +++ b/packages/infra/current/src/buffer.cxx @@ -745,11 +745,11 @@ cyg_assert_fail( const char *psz_func, c extern "C" { -extern unsigned long CYG_LABEL_NAME(stext); -extern unsigned long CYG_LABEL_NAME(etext); +extern unsigned long _stext; +extern unsigned long _etext; -unsigned long stext_addr = (unsigned long)&CYG_LABEL_NAME(stext); -unsigned long etext_addr = (unsigned long)&CYG_LABEL_NAME(etext); +unsigned long stext_addr = (unsigned long)&_stext; +unsigned long etext_addr = (unsigned long)&_etext; }; externC cyg_bool cyg_check_data_ptr(void *ptr) diff --git a/packages/infra/current/src/delete.cxx b/packages/infra/current/src/delete.cxx --- a/packages/infra/current/src/delete.cxx +++ b/packages/infra/current/src/delete.cxx @@ -45,54 +45,12 @@ //========================================================================== #include +#include #include -// The configuration here is as follows: -// -// To deal with virtual destructors, where the correct delete() function -// must be called for the derived class in question, the underlying delete -// is called when needed, from destructors. This is regardless of whether -// the destructor is called by delete itself. So there is a reference to -// delete() from all destructors. The default builtin delete() attempts to -// call free() if there is one defined. So, if you have destructors, and -// you have free(), as in malloc() and free() in the C library, any -// destructor counts as a reference to free(). So the libc heap system is -// linked in regardless of whether it gets explicitly called. -// -// To defeat this undesirable behaviour, we define empty versions of delete -// and delete[]. But doing this prevents proper use of the libc heap in -// C++ programs via C++'s new and delete operators. -// -// Therefore, configuration is provided (in the libc package, near malloc -// et al) for explicitly disabling the provision of these empty functions, -// so that new and delete can be used, if that's what's required. -// -// It is also possible to override all this complexity anyway, but that is -// not yet represented in an external config option. - - - -// If this is already externally defined, go ahead and override the -// builtin delete functions. -#ifndef CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS - -# define CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS -# ifdef CYGPKG_LIBC -// then there is a libc: if there is a malloc, maybe do not supply empty -// delete functions. Get the libc config info to find out. - -# include - -// So, do NOT provide these functions if there is a malloc and we are not -// to provide these functions: -# ifdef CYGPKG_LIBC_MALLOC -# ifdef CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE -# undef CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS -# endif // CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE -# endif // CYGPKG_LIBC_MALLOC -# endif // CYGPKG_LIBC -#endif // CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS not already defined +// see the description comment in infra.cdl for +// CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS #ifdef CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS // then define these empty functions: diff --git a/packages/infra/current/src/fancy.cxx b/packages/infra/current/src/fancy.cxx --- a/packages/infra/current/src/fancy.cxx +++ b/packages/infra/current/src/fancy.cxx @@ -616,11 +616,11 @@ cyg_assert_fail( const char *psz_func, c extern "C" { -extern unsigned long CYG_LABEL_NAME(stext); -extern unsigned long CYG_LABEL_NAME(etext); +extern unsigned long _stext; +extern unsigned long _etext; -unsigned long stext_addr = (unsigned long)&CYG_LABEL_NAME(stext); -unsigned long etext_addr = (unsigned long)&CYG_LABEL_NAME(etext); +unsigned long stext_addr = (unsigned long)&_stext; +unsigned long etext_addr = (unsigned long)&_etext; }; externC cyg_bool cyg_check_data_ptr(void *ptr) diff --git a/packages/infra/current/src/null.cxx b/packages/infra/current/src/null.cxx --- a/packages/infra/current/src/null.cxx +++ b/packages/infra/current/src/null.cxx @@ -139,11 +139,11 @@ cyg_assert_fail( const char *psz_func, c extern "C" { -extern unsigned long CYG_LABEL_NAME(stext); -extern unsigned long CYG_LABEL_NAME(etext); +extern unsigned long _stext; +extern unsigned long _etext; -unsigned long stext_addr = (unsigned long)&CYG_LABEL_NAME(stext); -unsigned long etext_addr = (unsigned long)&CYG_LABEL_NAME(etext); +unsigned long stext_addr = (unsigned long)&_stext; +unsigned long etext_addr = (unsigned long)&_etext; }; externC cyg_bool cyg_check_data_ptr(void *ptr) diff --git a/packages/infra/current/src/pkgstart.cxx b/packages/infra/current/src/pkgstart.cxx --- a/packages/infra/current/src/pkgstart.cxx +++ b/packages/infra/current/src/pkgstart.cxx @@ -43,7 +43,7 @@ // cyg_package_start() is used to call into individual // packages' startup code. Alternatively leave it be and // use the configuration options to set the appropriate -// compatibility environment e.g. uItron, ISO C, etc. +// compatibility environment e.g. uItron, etc. // This may be automatically generated in the future. // //####DESCRIPTIONEND#### @@ -59,15 +59,10 @@ #include // Common type definitions and support #include // Default tracing support -#ifdef CYGSEM_START_ISO_C_COMPATIBILITY -# include -#endif - #ifdef CYGSEM_START_UITRON_COMPATIBILITY # include #endif - // FUNCTION PROTOTYPES externC void @@ -87,13 +82,6 @@ cyg_package_start( void ) cyg_uitron_start(); #endif - -#ifdef CYGSEM_START_ISO_C_COMPATIBILITY - // This works even if the kernel is there, but if not, then it - // calls the user main() and doesn't return until it does! - cyg_iso_c_start(); -#endif - CYG_EMPTY_STATEMENT; // don't let it complain about doing nothing CYG_REPORT_RETURN(); diff --git a/packages/infra/current/src/simple.cxx b/packages/infra/current/src/simple.cxx --- a/packages/infra/current/src/simple.cxx +++ b/packages/infra/current/src/simple.cxx @@ -517,11 +517,11 @@ cyg_assert_fail( const char *psz_func, c extern "C" { -extern unsigned long CYG_LABEL_NAME(stext); -extern unsigned long CYG_LABEL_NAME(etext); +extern unsigned long _stext; +extern unsigned long _etext; -unsigned long stext_addr = (unsigned long)&CYG_LABEL_NAME(stext); -unsigned long etext_addr = (unsigned long)&CYG_LABEL_NAME(etext); +unsigned long stext_addr = (unsigned long)&_stext; +unsigned long etext_addr = (unsigned long)&_etext; }; externC cyg_bool cyg_check_data_ptr(void *ptr) diff --git a/packages/io/common/current/ChangeLog b/packages/io/common/current/ChangeLog --- a/packages/io/common/current/ChangeLog +++ b/packages/io/common/current/ChangeLog @@ -1,3 +1,61 @@ +2000-08-01 Jonathan Larmour + + * include/config_keys.h: + Add keys to support flow control, line status callbacks, + hardware breaks and termios. + +2000-07-31 Nick Garnett + + * include/config_keys.h: Added generic keys for controlling + BLOCKING behaviour, and added aliases to retain compatibility. + +2000-07-25 Jonathan Larmour + + * include/devtab.h: Define cyg_devio_cwrite, _cread, _bwrite and _bread + with C linkage + +2000-07-21 Nick Garnett + + * include/io.h: + * include/devtab.h: + * src/iosys.c: + Added support for block devices. At present this is really just + exploiting the perturbations that the EL/IX branch merge will + cause to add placeholders for future developments. + These changes consist mainly of adding bwrite() and bread() + entries in the cyg_devio_table_t structure and adding a char/block + discriminator flags to the devtab entry status field. API calls + cyg_io_bwrite() and cyg_io_bread() have also been added. + Suitable definition of macros means that no existing driver code + needs to be changed to accomodate this addition. + +2000-06-19 Nick Garnett + + * src/iosys.c: + * include/devtab.h: + Converted to new table construction mechanism. + +2000-06-15 Nick Garnett + + * include/io.h: + * src/iosys.c: Added cyg_io_select(). + + * include/devtab.h: Added select() support function to + cyg_devio_table_t structure. Modified DEVIO_TABLE() macro + to match. + +2000-06-09 Nick Garnett + + * include/file.h: Added redefinition of CYG_SELINFO_TAG. + +2000-06-07 Nick Garnett + + * include/file.h: Added definitions to make this header work with + the fileio package. + + * cdl/io.cdl: Moved support for files into a sub-component that is + only active if the FILEIO package is not present. + 2000-05-05 Grant Edwards * include/config_keys.h: Add key to inquire about serial buffer info diff --git a/packages/io/common/current/cdl/io.cdl b/packages/io/common/current/cdl/io.cdl --- a/packages/io/common/current/cdl/io.cdl +++ b/packages/io/common/current/cdl/io.cdl @@ -51,7 +51,6 @@ cdl_package CYGPKG_IO { support which is the basis for all drivers." compile -library=libextras.a iosys.c ioinit.cxx io_diag.c - compile io_file.c cdl_option CYGDBG_IO_INIT { @@ -62,11 +61,22 @@ cdl_package CYGPKG_IO { system 'diag' device during I/O system initialization." } - cdl_option CYGPKG_IO_NFILE { - display "Number of open files" - flavor data - default_value 16 - description " - This option controls the number of open files." + cdl_component CYGPKG_IO_FILE_SUPPORT { + display "Basic support for file based I/O" + active_if !CYGPKG_IO_FILEIO + default_value 1 + description " + This option control support for simple file I/O primitives. It is only + present if the FILEIO package is not included." + + compile io_file.c + + cdl_option CYGPKG_IO_NFILE { + display "Number of open files" + flavor data + default_value 16 + description " + This option controls the number of open files." + } } } diff --git a/packages/io/common/current/include/config_keys.h b/packages/io/common/current/include/config_keys.h --- a/packages/io/common/current/include/config_keys.h +++ b/packages/io/common/current/include/config_keys.h @@ -34,7 +34,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas,jskov,grante +// Contributors: gthomas,jskov,grante,jlarmour // Date: 1999-02-04 // Purpose: Repository for all get/put config "keys" // Description: @@ -48,17 +48,29 @@ // ======== 0x0100 Serial ==================================================== // Get/Set configuration 'key' values for low-level serial I/O -#define CYG_IO_GET_CONFIG_SERIAL_INFO 0x0101 -#define CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN 0x0102 -#define CYG_IO_GET_CONFIG_SERIAL_OUTPUT_FLUSH 0x0103 -#define CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH 0x0104 -#define CYG_IO_GET_CONFIG_SERIAL_ABORT 0x0105 -#define CYG_IO_GET_CONFIG_SERIAL_READ_BLOCKING 0x0106 -#define CYG_IO_GET_CONFIG_SERIAL_WRITE_BLOCKING 0x0107 -#define CYG_IO_GET_CONFIG_SERIAL_BUFFER_INFO 0x0111 -#define CYG_IO_SET_CONFIG_SERIAL_INFO 0x0181 -#define CYG_IO_SET_CONFIG_SERIAL_READ_BLOCKING 0x0182 -#define CYG_IO_SET_CONFIG_SERIAL_WRITE_BLOCKING 0x0183 + +#define CYG_IO_GET_CONFIG_SERIAL_INFO 0x0101 +#define CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN 0x0102 +#define CYG_IO_GET_CONFIG_SERIAL_OUTPUT_FLUSH 0x0103 +#define CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH 0x0104 +#define CYG_IO_GET_CONFIG_SERIAL_ABORT 0x0105 +#define CYG_IO_GET_CONFIG_SERIAL_BUFFER_INFO 0x0111 +#define CYG_IO_GET_CONFIG_SERIAL_FLOW_CONTROL_METHOD 0x0112 + +#define CYG_IO_SET_CONFIG_SERIAL_INFO 0x0181 +#define CYG_IO_SET_CONFIG_SERIAL_HW_RX_FLOW_THROTTLE 0x0184 +#define CYG_IO_SET_CONFIG_SERIAL_HW_FLOW_CONFIG 0x0185 +#define CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_METHOD 0x0186 +#define CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_FORCE 0x0187 +#define CYG_IO_SET_CONFIG_SERIAL_STATUS_CALLBACK 0x0188 +#define CYG_IO_SET_CONFIG_SERIAL_HW_BREAK 0x0189 + +// Compatibility values. Use of these is deprecated, the generic symbols +// should be used instead. +#define CYG_IO_GET_CONFIG_SERIAL_READ_BLOCKING CYG_IO_GET_CONFIG_READ_BLOCKING +#define CYG_IO_GET_CONFIG_SERIAL_WRITE_BLOCKING CYG_IO_GET_CONFIG_WRITE_BLOCKING +#define CYG_IO_SET_CONFIG_SERIAL_READ_BLOCKING CYG_IO_SET_CONFIG_READ_BLOCKING +#define CYG_IO_SET_CONFIG_SERIAL_WRITE_BLOCKING CYG_IO_SET_CONFIG_WRITE_BLOCKING // ======== 0x0200 TTY ======================================================= // Get/Set configuration 'key' values for tty-like driver @@ -72,12 +84,31 @@ #define CYG_IO_GET_CONFIG_DSP_OUTPUT_FLUSH 0x0302 #define CYG_IO_GET_CONFIG_DSP_INPUT_FLUSH 0x0303 #define CYG_IO_GET_CONFIG_DSP_ABORT 0x0304 -#define CYG_IO_GET_CONFIG_DSP_READ_BLOCKING 0x0305 -#define CYG_IO_GET_CONFIG_DSP_WRITE_BLOCKING 0x0306 #define CYG_IO_GET_CONFIG_DSP_INPUT_OVERFLOW_RESET 0x0307 -#define CYG_IO_SET_CONFIG_DSP_READ_BLOCKING 0x0381 -#define CYG_IO_SET_CONFIG_DSP_WRITE_BLOCKING 0x0382 +// Compatibility values. Use of these is deprecated, the generic symbols +// should be used instead. +#define CYG_IO_GET_CONFIG_DSP_READ_BLOCKING CYG_IO_GET_CONFIG_READ_BLOCKING +#define CYG_IO_GET_CONFIG_DSP_WRITE_BLOCKING CYG_IO_GET_CONFIG_WRITE_BLOCKING +#define CYG_IO_SET_CONFIG_DSP_READ_BLOCKING CYG_IO_SET_CONFIG_READ_BLOCKING +#define CYG_IO_SET_CONFIG_DSP_WRITE_BLOCKING CYG_IO_SET_CONFIG_WRITE_BLOCKING + +// ======== 0x400 DSP ======================================================= +// Get/Set configuration 'key' values for termios emulation + +#define CYG_IO_GET_CONFIG_TERMIOS 0x0400 +#define CYG_IO_SET_CONFIG_TERMIOS 0x0401 + +// ======== 0x1000 Generic =================================================== +// Get/Set configuration 'key' values that can apply to more than one +// class of device. + +#define CYG_IO_GET_CONFIG_READ_BLOCKING 0x1001 +#define CYG_IO_GET_CONFIG_WRITE_BLOCKING 0x1002 + +#define CYG_IO_SET_CONFIG_READ_BLOCKING 0x1081 +#define CYG_IO_SET_CONFIG_WRITE_BLOCKING 0x1082 + #endif /* CYGONCE_CONFIG_KEYS_H */ /* EOF config_keys.h */ diff --git a/packages/io/common/current/include/devtab.h b/packages/io/common/current/include/devtab.h --- a/packages/io/common/current/include/devtab.h +++ b/packages/io/common/current/include/devtab.h @@ -49,6 +49,7 @@ #include #include #include +#include // Set of functions which handle top level I/O functions typedef struct { @@ -58,6 +59,17 @@ typedef struct { Cyg_ErrNo (*read)(cyg_io_handle_t handle, void *buf, cyg_uint32 *len); + Cyg_ErrNo (*bwrite)(cyg_io_handle_t handle, + const void *buf, + cyg_uint32 *len, + cyg_uint32 pos); + Cyg_ErrNo (*bread)(cyg_io_handle_t handle, + void *buf, + cyg_uint32 *len, + cyg_uint32 pos); + cyg_bool (*select)(cyg_io_handle_t handle, + cyg_uint32 which, + CYG_ADDRWORD info); Cyg_ErrNo (*get_config)(cyg_io_handle_t handle, cyg_uint32 key, void *buf, @@ -68,14 +80,48 @@ typedef struct { cyg_uint32 *len); } cyg_devio_table_t; -#define DEVIO_TABLE(_l,_write,_read,_get_config,_set_config) \ + +// Default functions + +__externC Cyg_ErrNo cyg_devio_cwrite(cyg_io_handle_t handle, + const void *buf, cyg_uint32 *len); +__externC Cyg_ErrNo cyg_devio_cread(cyg_io_handle_t handle, + void *buf, cyg_uint32 *len); +__externC Cyg_ErrNo cyg_devio_bwrite(cyg_io_handle_t handle, + const void *buf, cyg_uint32 *len, + cyg_uint32 pos); +__externC Cyg_ErrNo cyg_devio_bread(cyg_io_handle_t handle, + void *buf, cyg_uint32 *len, + cyg_uint32 pos); + + +// Initialization macros + +#define CHAR_DEVIO_TABLE(_l,_write,_read,_select,_get_config,_set_config) \ cyg_devio_table_t _l = { \ _write, \ _read, \ + cyg_devio_bwrite, \ + cyg_devio_bread, \ + _select, \ _get_config, \ _set_config, \ }; +#define BLOCK_DEVIO_TABLE(_l,_bwrite,_bread,_select,_get_config,_set_config) \ +cyg_devio_table_t _l = { \ + cyg_devio_cwrite, \ + cyg_devio_cread, \ + _bwrite, \ + _bread, \ + _select, \ + _get_config, \ + _set_config, \ +}; + +#define DEVIO_TABLE(_l,_write,_read,_select,_get_config,_set_config) \ + CHAR_DEVIO_TABLE(_l,_write,_read,_select,_get_config,_set_config) + typedef struct cyg_devtab_entry { const char *name; const char *dep_name; @@ -89,19 +135,37 @@ typedef struct cyg_devtab_entry { } cyg_devtab_entry_t; #define CYG_DEVTAB_STATUS_AVAIL 0x0001 +#define CYG_DEVTAB_STATUS_CHAR 0x1000 +#define CYG_DEVTAB_STATUS_BLOCK 0x2000 extern cyg_devtab_entry_t __DEVTAB__[], __DEVTAB_END__; -#define DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv) \ -cyg_devtab_entry_t _l __attribute__ ((section(".devtab"))) = { \ +#define CHAR_DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv) \ +cyg_devtab_entry_t _l CYG_HAL_TABLE_ENTRY(devtab) = { \ _name, \ _dep_name, \ _handlers, \ _init, \ _lookup, \ - _priv \ + _priv, \ + CYG_DEVTAB_STATUS_CHAR \ }; +#define BLOCK_DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv) \ +cyg_devtab_entry_t _l CYG_HAL_TABLE_ENTRY(devtab) = { \ + _name, \ + _dep_name, \ + _handlers, \ + _init, \ + _lookup, \ + _priv, \ + CYG_DEVTAB_STATUS_BLOCK \ +}; + +#define DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv) \ + CHAR_DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv) + + #define DEVTAB_ENTRY_NO_INIT(_l,_name,_dep_name,_handlers,_init,_lookup,_priv) \ cyg_devtab_entry_t _l = { \ _name, \ @@ -109,7 +173,8 @@ cyg_devtab_entry_t _l = { _handlers, \ _init, \ _lookup, \ - _priv \ + _priv, \ + CYG_DEVTAB_STATUS_CHAR \ }; #endif // CYGONCE_IO_DEVTAB_H diff --git a/packages/io/common/current/include/file.h b/packages/io/common/current/include/file.h --- a/packages/io/common/current/include/file.h +++ b/packages/io/common/current/include/file.h @@ -46,6 +46,40 @@ #ifndef _CYG_IO_FILE_H_ #define _CYG_IO_FILE_H_ +#include + +//========================================================================== +// If the fileio package is loaded, we need to go through that to do all +// basic IO operations. This code redefines the tags on the structures so +// that they have the names expected by BSD based code. + +#ifdef CYGPKG_IO_FILEIO + +#include + +#define CYG_IOVEC_TAG iovec +#define CYG_UIO_TAG uio +#define CYG_FILEOPS_TAG fileops +#define CYG_FILE_TAG file +#define CYG_SELINFO_TAG selinfo + +#include + +// File states +#define FREAD CYG_FREAD +#define FWRITE CYG_FWRITE +#define FNONBLOCK CYG_FNONBLOCK +#define FASYNC CYG_FASYNC + +// Type of "file" +#define DTYPE_VNODE CYG_FILE_TYPE_FILE /* file */ +#define DTYPE_SOCKET CYG_FILE_TYPE_SOCKET /* communications endpoint */ + +//========================================================================== +// Otherwise define all the structs here... + +#else // CYGPKG_IO_FILEIO + // High-level file I/O interfaces // Derived [in part] from OpenBSD , , @@ -113,4 +147,9 @@ externC cyg_bool getfp(int fdes, struct externC int falloc(struct file **fp, int *fd); externC void ffree(struct file *fp); +//========================================================================== + +#endif // CYGPKG_IO_FILEIO + +//========================================================================== #endif // _CYG_IO_FILE_H_ diff --git a/packages/io/common/current/include/io.h b/packages/io/common/current/include/io.h --- a/packages/io/common/current/include/io.h +++ b/packages/io/common/current/include/io.h @@ -74,6 +74,16 @@ Cyg_ErrNo cyg_io_write(cyg_io_handle_t h Cyg_ErrNo cyg_io_read(cyg_io_handle_t handle, void *buf, cyg_uint32 *len); +// Write data to a block device +Cyg_ErrNo cyg_io_bwrite(cyg_io_handle_t handle, + const void *buf, + cyg_uint32 *len, + cyg_uint32 pos); +// Read data from a block device +Cyg_ErrNo cyg_io_bread(cyg_io_handle_t handle, + void *buf, + cyg_uint32 *len, + cyg_uint32 pos); // Get the configuration of a device Cyg_ErrNo cyg_io_get_config(cyg_io_handle_t handle, cyg_uint32 key, @@ -84,6 +94,10 @@ Cyg_ErrNo cyg_io_set_config(cyg_io_handl cyg_uint32 key, const void *buf, cyg_uint32 *len); +// Test a device for readiness +cyg_bool cyg_io_select(cyg_io_handle_t handle, + cyg_uint32 which, + CYG_ADDRWORD info); #ifdef __cplusplus } diff --git a/packages/io/common/current/src/iosys.c b/packages/io/common/current/src/iosys.c --- a/packages/io/common/current/src/iosys.c +++ b/packages/io/common/current/src/iosys.c @@ -46,6 +46,10 @@ #include #include +// Define table boundaries +CYG_HAL_TABLE_BEGIN( __DEVTAB__, devtab ); +CYG_HAL_TABLE_END( __DEVTAB_END__, devtab ); + //extern void cyg_io_init(void) CYGBLD_ATTRIB_CONSTRUCTOR // CYG_INIT_PRIORITY(CYG_INIT_BEFORE(LIBC)); @@ -95,10 +99,11 @@ cyg_io_init(void) diag_printf("Init device '%s'\n", t->name); #endif if (t->init(t)) { - t->status = CYG_DEVTAB_STATUS_AVAIL; + t->status |= CYG_DEVTAB_STATUS_AVAIL; } else { // What to do if device init fails? - t->status = 0; // Device not [currently] available + // Device not [currently] available + t->status &= ~CYG_DEVTAB_STATUS_AVAIL; } } _init = true; @@ -184,6 +189,58 @@ cyg_io_read(cyg_io_handle_t handle, void return t->handlers->read(handle, buf, len); } +Cyg_ErrNo +cyg_io_bwrite(cyg_io_handle_t handle, const void *buf, cyg_uint32 *len, cyg_uint32 pos) +{ + cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle; + // Validate request + if (!t->handlers->bwrite) { + return -EDEVNOSUPP; + } + // Special check. If length is zero, this just verifies that the + // 'bwrite' method exists for the given device. + if (NULL != len && 0 == *len) { + return ENOERR; + } + return t->handlers->bwrite(handle, buf, len, pos); +} + +// +// 'read' data from a device. +// + +Cyg_ErrNo +cyg_io_bread(cyg_io_handle_t handle, void *buf, cyg_uint32 *len, cyg_uint32 pos) +{ + cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle; + // Validate request + if (!t->handlers->bread) { + return -EDEVNOSUPP; + } + // Special check. If length is zero, this just verifies that the + // 'bread' method exists for the given device. + if (NULL != len && 0 == *len) { + return ENOERR; + } + return t->handlers->bread(handle, buf, len, pos); +} + +// +// Check device for available input or space for output +// + +cyg_bool +cyg_io_select(cyg_io_handle_t handle, cyg_uint32 which, CYG_ADDRWORD info) +{ + cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle; + // Validate request + if (!t->handlers->select) { + return -EDEVNOSUPP; + } + + return t->handlers->select( handle, which, info ); +} + // // Get the configuration of a device. // @@ -225,4 +282,30 @@ cyg_io_set_config(cyg_io_handle_t handle } /*---------------------------------------------------------------------------*/ +// Default functions for devio tables + +Cyg_ErrNo cyg_devio_cwrite(cyg_io_handle_t handle, const void *buf, cyg_uint32 *len) +{ + return -EDEVNOSUPP; +} + +Cyg_ErrNo cyg_devio_cread(cyg_io_handle_t handle, void *buf, cyg_uint32 *len) +{ + return -EDEVNOSUPP; +} + +Cyg_ErrNo cyg_devio_bwrite(cyg_io_handle_t handle, const void *buf, + cyg_uint32 *len, cyg_uint32 pos) +{ + return -EDEVNOSUPP; +} + +Cyg_ErrNo cyg_devio_bread(cyg_io_handle_t handle, void *buf, + cyg_uint32 *len, cyg_uint32 pos) +{ + return -EDEVNOSUPP; +} + + +/*---------------------------------------------------------------------------*/ /* End of io/iosys.c */ diff --git a/packages/io/eth/current/ChangeLog b/packages/io/eth/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/io/eth/current/ChangeLog @@ -0,0 +1,124 @@ +2000-08-16 Gary Thomas + + * src/stand_alone/eth_drv.c: + * include/eth_drv.h: Clean up warnings (better protyping). + + * src/stand_alone/eth_drv.c (eth_drv_write): Abandon sending + packet if device goes not ready for a long time (in some cases, + this is the only indication that the link is down). + +2000-08-07 Gary Thomas + + * src/net/eth_drv.c (eth_drv_recv): Add safety in case this gets + called [from stand-alone code] while interface is not up. + + * src/stand_alone/eth_drv.c: + * include/eth_drv.h: Rework to more fully support mixed stand-alone + and system (eCos) stacks. + +2000-08-03 Gary Thomas + + * cdl/eth_drivers.cdl: Reparent within I/O, not NET. This allows + for stand-alone use as well as support for other stack implementations. + +2000-07-28 Hugo Tyson + + * src/eth_drv.c (eth_drv_recv): Assert that the length we're asked + to deal with is at least an ether header, and also be defensive in + any case; discard small packets. [CASE 104206] + +2000-07-26 Gary Thomas + + * src/eth_drv.c: + * include/eth_drv.h: Change interfaces used by hardware layer to + be "soft" (pointers to functions). This will allow those drivers + to be shared by applications and the ROM/debug environment. + +2000-07-15 Gary Thomas + + * include/eth_drv.h: Add [initial] extensions to let this + layer work either in an eCos environment or stand-alone. + +2000-07-11 Gary Thomas + + * include/eth_drv.h: Add minimal PCMCIA support. + + * src/eth_drv.c (eth_drv_netdev): New function - used to find the + ethernet device info for PCMCIA devices. + +2000-06-23 Hugo Tyson + + * src/eth_drv.c (eth_drv_send): Do not consume an SG entry for + zero length data; tolerate overflow of the SG. Before this, pings + of 6000 bytes crashed the system! + + You can now set net_debug to 2 to get quieter output; 1 gives the + whole packet dump as before. + + * include/eth_drv.h (MAX_ETH_DRV_SG): Make this 16 so that an MTU + made of all mbufs will not overflow. + +2000-03-28 Gary Thomas + + * src/eth_drv.c (eth_drv_recv): Tolerate running out of MBUFs + instead of "panic"ing. + +2000-03-08 Gary Thomas + + * src/eth_drv.c: Add some function [block] comments. + (eth_drv_send): Use eCos scheduler lock instead of interrupt lock. + +2000-03-08 Hugo Tyson + + * doc/driver_doc: Add some clarification about what's called when, + proofreading results, shorter lines so I can print it nicely. + +2000-03-06 Gary Thomas + + * src/eth_drv.c: + * include/eth_drv.h: + * doc/driver_doc: Remove generic "priv"ate references. + +2000-02-29 Gary Thomas + + * src/eth_drv.c: + * include/eth_drv.h: New expanded API for hardware drivers. + +2000-02-18 Gary Thomas + + * src/eth_drv.c (eth_drv_send): Disable interrupts while initiating + the buffer send - avoid a possible race. + +2000-02-08 John Dallaway + + * cdl/eth_drivers.cdl: + Reparent under CYGPKG_NET and tidy display strings. + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== + + + diff --git a/packages/io/eth/current/cdl/eth_drivers.cdl b/packages/io/eth/current/cdl/eth_drivers.cdl new file mode 100644 --- /dev/null +++ b/packages/io/eth/current/cdl/eth_drivers.cdl @@ -0,0 +1,83 @@ +# ==================================================================== +# +# eth_drivers.cdl +# +# Ethernet drivers - platform independent support +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): gthomas +# Original data: gthomas +# Contributors: +# Date: 2000-01-25 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_IO_ETH_DRIVERS { + display "Common ethernet support" + include_dir . + parent CYGPKG_IO + description "Platform independent ethernet drivers" + + cdl_component CYGPKG_IO_ETH_DRIVERS_NET { + display "Support for standard eCos TCP/IP stack." + flavor bool + active_if CYGPKG_NET + no_define + default_value 1 + compile net/eth_drv.c + } + + cdl_component CYGPKG_IO_ETH_DRIVERS_STAND_ALONE { + display "Support for stand-alone network stack." + flavor bool + active_if !CYGPKG_NET + default_value 1 + no_define + compile stand_alone/eth_drv.c + } + + cdl_component CYGPKG_IO_ETH_DRIVERS_OPTIONS { + display "Common ethernet support build options" + flavor none + no_define + + cdl_option CYGPKG_IO_ETH_DRIVERS_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "-D_KERNEL -D__ECOS" } + description " + This option modifies the set of compiler flags for + building the common ethernet support package. These flags are used in addition + to the set of global flags." + } + } +} diff --git a/packages/io/eth/current/doc/driver_doc b/packages/io/eth/current/doc/driver_doc new file mode 100644 --- /dev/null +++ b/packages/io/eth/current/doc/driver_doc @@ -0,0 +1,328 @@ +This file provides a simple description of how to write a low-level, +hardware dependent ethernet driver. + +The basic idea is that there is a high-level driver (which is only +code/functions) that is part of the stack. There will be one or more +low-level driver tied to the actual network hardware. Each of these +drivers contains one or more driver instances. The principal idea is +that the low-level drivers know nothing of the details of the stack that +will be using them. Thus, the same driver can be used by the eCos +supported TCP/IP stack, or any other, with no changes. + +A driver instance is contained within a "struct eth_drv_sc". + + struct eth_drv_funs { + // Initialize hardware (including startup) + void (*start)(struct eth_drv_sc *sc, + unsigned char *enaddr); + // Shut down hardware + void (*stop)(struct eth_drv_sc *sc); + // Control interface + int (*control)(struct eth_drv_sc *sc, + unsigned long cmd, + void *data, + int len); + // Query interface - can a packet be sent? + int (*can_send)(struct eth_drv_sc *sc); + // Send a packet of data + void (*send)(struct eth_drv_sc *sc, + struct eth_drv_sg *sg_list, + int sg_len, + int total_len, + unsigned long key); + // Receive [unload] a packet of data + void (*recv)(struct eth_drv_sc *sc, + struct eth_drv_sg *sg_list, + int sg_len); + }; + + struct eth_drv_sc { + struct eth_drv_funs *funs; + void *driver_private; + const char *dev_name; + struct arpcom sc_arpcom; /* ethernet common */ + }; + +You create one of these instances using the "ETH_DRV_SC()" macro which +sets up the structure, including the prototypes for the functions, etc. +By doing things this way, if the internal design of the ethernet drivers +changes (e.g. we need to add a new low-level implementation function), +existing drivers will no longer compile until updated. This is much +better than to have all of the definitions in the low-level drivers +themselves and have them be [quietly] broken if the interfaces change. + +The "magic" which gets the drivers started [and indeed, linked] is +similar to what is used for the I/O subsystem. [Note: I may try and +make it part of the I/O subsystem later.] This is done using the +"NETDEVTAB_ENTRY()" macro, which defines an initialization function +and the basic data structures for the low-level driver. + + typedef struct cyg_netdevtab_entry { + const char *name; + bool (*init)(struct cyg_netdevtab_entry *tab); + void *device_instance; + unsigned long status; + } cyg_netdevtab_entry_t; + +The "device_instance" entry here would point to the "struct +eth_drv_sc" entry previously defined. This allows the network driver +setup to work with any class of driver, not just ethernet drivers. In +the future, there will surely be serial PPP drivers, etc. These will +use the "NETDEVTAB" setup to create the basic driver, but they will +most likely be built on top of other high-level device driver layers. + +So, the bottom line is that a hardware driver will have a template +(boilerplate) which looks like this: + + #include + #include + #include + #include + #include + #include + + ETH_DRV_SC(DRV_sc, + 0, // No driver specific data needed + "eth0", // Name for this interface + HRDWR_start, + HRDWR_stop, + HRDWR_control, + HRDWR_can_send + HRDWR_send, + HRDWR_recv); + + NETDEVTAB_ENTRY(DRV_netdev, + "DRV", + DRV_HRDWR_init, + &DRV_sc); + +This, along with the referenced functions, completely define the driver. +Extensibility note: if one needed the same low-level driver to handle +multiple similar hardware interfaces, you would need multiple invocations +of the "ETH_DRV_SC()/NETDEVTAB_ENTRY()" macros. You would add a pointer +to some instance specific data, e.g. containing base addresses, interrupt +numbers, etc, where the "0, // No driver specific data" is currently. + +Now a quick waltz through the functions. This discussion will use the +generic names from above. + +static bool DRV_HDWR_init(struct cyg_netdevtab_entry *tab) +========================================================== + +This function is called as part of system initialization. Its primary +function is to decide if the hardware [as indicated via +tab->device_instance] is working and if the interface needs to be made +available in the system. If this is the case, this function needs to +finish with a call to the ethernet driver function: + + eth_drv_init((struct eth_drv_sc *)tab->device_instance, + unsigned char *enaddr); + +where 'enaddr' is a pointer to the ethernet station address for this +unit. Note: the ethernet station address is supposed to be a +world-unique, 48 bit address for this particular ethernet interface. +Typically it is provided by the board/hardware manufacturer in ROM. + +static void +HRDWR_start(struct eth_drv_sc *sc, unsigned char *enaddr, int flags) +==================================================================== + +This function is called, perhaps much later than system initialization +time, when the system (an application) is ready for the interface to +become active. The purpose of this function is to set up the hardware +interface to start accepting packets from the network and be able to +send packets out. Note: this function will be called whenever the +up/down state of the logical interface changes, e.g. when the IP address +changes. This may occur more than one time, so this function needs to +be prepared for that case. + +FUTURE: the "flags" field (currently unused) may be used to tell the +function how to start up, e.g. whether interrupts will be used, +selection of "promiscuous" mode etc. + +static void HRDWR_stop(struct eth_drv_sc *sc) +============================================= + +This function is the inverse of "start". It should shut down the +hardware and keep it from interacting with the physical network. + +static int +HRDWR_control(struct eth_drv_sc *sc, unsigned long key, void *data, int len) +============================================================================ + +This function is used to perform low-level "control" operations on the +interface. These operations would be initiated via 'ioctl()' in the BSD +stack, and would be anything that would require the hardware setup to +possibly change (i.e. cannot be performed totally by the +platform-independent layers). + +Current operations: + +ETH_DRV_SET_MAC_ADDRESS: + This function sets the ethernet station address (ESA or MAC) for the + device. Normally this address is kept in non-volatile memory and is + unique in the world. This function must at least set the interface to + use the new address. It may also update the NVM as appropriate. + +This function should return zero if the specified operation was +completed successfully. It should return non-zero if the operation +could not be performed, for any reason. + +static int HRDWR_can_send(struct eth_drv_sc *sc) +================================================ + +This function is called to determine if it is possible to start the +transmission of a packet on the interface. Some interfaces will allow +multiple packets to be "queued" and this function allows for the highest +possible utilization of that mode. + +Return the number of packets which could be accepted at this time, zero +implies that the interface is saturated/busy. + +static void +HRDWR_send(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len, + int total_len, unsigned long key) +========================================================================= + +This function is used to send a packet of data to the network. It is +the responsibility of this function to somehow hand the data over to the +hardware interface. This will most likely require copying, but just the +address/length values could be used by smart hardware. + +NOTE: All data in/out of the driver is specified via a "scatter-gather" +list. This is just an array of address/length pairs which describe +sections of data to move (in the order given by the array). + +Once the data has been successfully sent by the interface (or if an +error occurs), the driver should call 'eth_drv_tx_done()' using the +specified 'key'. Only then will the upper layers release the resources +for that packet and start another transmission. + +FUTURE: This function may be extended so that the data need not be +copied by having the function return a "disposition" code (done, send +pending, etc). At this point, you should move the data to some "safe" +location before returning. + +static void +HRDWR_recv(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len) +========================================================================= + +This function is actually a call back, only invoked after the +upper-level function + eth_drv_recv(struct eth_drv_sc *sc, int total_len) +has been called. This upper level function is called by the hardware +driver when it knows that a packet of data is available on the +interface. The 'eth_drv_recv()' function then arranges network buffers +and structures for the data and then calls "HRDWR_recv()" to actually +move the data from the interface. + + +Upper layer functions - called by drivers +========================================= + +These functions are defined by the upper layers (machine independent) of +the networking driver support. They are present to hide the interfaces +to the actual networking stack so that the hardware drivers may possibly +be used by any network stack implementation. + +These functions require a pointer to a "struct eth_drv_sc" table which +describes the interface at a logical level. It is assumed that the +driver [lowest level hardware support] will keep track of this pointer +so it may be passed "up" as appropriate. + + struct eth_drv_sc { + struct eth_drv_funs *funs; // Pointer to hardware functions (see above) + void *driver_private; // Device specific data + const char *dev_name; + struct arpcom sc_arpcom; // ethernet common + }; + +This structure is created, one per logical interface, via ETH_DRV_SC macro. + +void eth_drv_init(struct eth_drv_sc *sc, unsigned char *enaddr) +=============================================================== + +This function establishes the device at initialization time. The +hardware should be totally intialized (not "started") when this function +is called. + +void eth_drv_tx_done(struct eth_drv_sc *sc, unsigned long key, int status) +========================================================================== + +This function is called when a packet completes transmission on the +interface. The 'key' value must be one of the keys provided to +"HRDWR_send()" above. The value 'status' should be non-zero (currently +undefined) to indicate that an error occurred during the transmission. + +void eth_drv_recv(struct eth_drv_sc *sc, int len) +================================================= + +This function is called to indicate that a packet of length 'len' has +arrived at the interface. The callback "HRDWR_recv()" function +described above will be used to actually unload the data from the +interface into buffers used by the machine independent layers. + + + +Calling graph for Transmit and Receive +-------------------------------------- + +It may be worth clarifying further the flow of control in the transmit +and receive cases, where the hardware driver does use interrupts and so +DSRs to tell the "foreground" when something asynchronous has occurred. + +Transmit: + Foreground task calls into network stack to send a packet (or the + stack decides to send a packet in response to incoming traffic). + The driver calls the HRDWR_can_send() function in the hardware driver. + HRDWR_can_send() returns the number of available "slots" in which it + can store a pending transmit packet. + If it cannot send at this time, the packet is queued outside the + hardware driver for later; in this case, the hardware is already busy + transmitting, so expect an interrupt as described below for completion + of the packet currently outgoing. + If it can send right now, HRDWR_send() is called. + HRDWR_send() copies the data into special hardware buffers, or + instructs the hardware to "send that". + It also remembers the key that is associated with this tx request. + these calls return. + ... + + Asynchronously, the hardware makes an interrupt to say "transmit is + done"; the ISR quietens the interrupt source in the hardware and + requests that the associated DSR be run. + The DSR realizes that a transmit request has completed, and calls + eth_drv_tx_done() with the same key that it remembered for this tx. + eth_drv_tx_done() uses the key to find the resources associated with + this transmit request; thus the stack knows that the transmit has + completed and its resources can be freed. + eth_drv_tx_done() also enquires whether HRDWR_can_send() now says + "yes, we can send" and if so, dequeues a further transmit request + which may have been queued as described above. If so: + HRDWR_send() copies the data into the hardware buffers, or + instructs the hardware to "send that" and remembers the new key. + these calls return to the DSR and thus to the foreground. + ... + + +Receive: + ... + + Asynchronously, the hardware makes an interrupt to say "there is ready + data in a receive buffer"; the ISR quietens the interrupt source in + the hardware and requests that the associated DSR be run. + The DSR realizes that there is data ready and calls eth_drv_recv() + with the length of the data that is available. + eth_drv_recv() prepares a set of scatter-gather buffers that can + accommodate that data. + It then calls back into the hardware driver routine HRDWR_recv(). + HRDWR_recv() must copy the data from the hardware's buffers into + the scatter-gather buffers provided, and return. + eth_drv_recv() sends the new packet up the network stack and returns. + Back in the DSR now, the driver cleans the receive buffer and returns + it to the hardware's control, available to receive another packet from + the network. + The DSR returns to the foreground. + ... + + diff --git a/packages/io/eth/current/include/eth_drv.h b/packages/io/eth/current/include/eth_drv.h new file mode 100644 --- /dev/null +++ b/packages/io/eth/current/include/eth_drv.h @@ -0,0 +1,197 @@ +//========================================================================== +// +// include/eth_drv.h +// +// High level networking driver interfaces +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//####BSDCOPYRIGHTBEGIN#### +// +// ------------------------------------------- +// +// Portions of this software may have been derived from OpenBSD or other sources, +// and are covered by the appropriate copyright disclaimers included herein. +// +// ------------------------------------------- +// +//####BSDCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: High level networking driver interfaces +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +// Ethernet driver structure + +#ifndef _ETH_DRV_H_ +#define _ETH_DRV_H_ + +#include + +#ifdef CYGPKG_NET +#include +#include + +#include + +#ifdef INET +#include +#include +#include +#include +#include +#endif + +#if NBPFILTER > 0 +#include +#include +#endif +#endif + +struct eth_drv_sg { + CYG_ADDRESS buf; + CYG_ADDRWORD len; +}; + +// This is 16 to ensure that an MTU made of mbufs (not clusters) will fit. +// 1600 is more that the MTU of 1500; it must be right. +#define MAX_ETH_DRV_SG 16 + +struct eth_drv_sc; + +struct eth_drv_funs { + // Logical driver - initialization + void (*init)(struct eth_drv_sc *sc, + unsigned char *enaddr); + // Logical driver - incoming packet notifier + void (*recv)(struct eth_drv_sc *sc, + int total_len); + // Logical driver - outgoing packet notifier + void (*tx_done)(struct eth_drv_sc *sc, + CYG_ADDRESS key, + int status); +}; + +struct eth_hwr_funs { + // Initialize hardware (including startup) + void (*start)(struct eth_drv_sc *sc, + unsigned char *enaddr, + int flags); + // Shut down hardware + void (*stop)(struct eth_drv_sc *sc); + // Device control (ioctl pass-thru) + int (*control)(struct eth_drv_sc *sc, + unsigned long key, + void *data, + int data_length); + // Query - can a packet be sent? + int (*can_send)(struct eth_drv_sc *sc); + // Send a packet of data + void (*send)(struct eth_drv_sc *sc, + struct eth_drv_sg *sg_list, + int sg_len, + int total_len, + unsigned long key); + // Receive [unload] a packet of data + void (*recv)(struct eth_drv_sc *sc, + struct eth_drv_sg *sg_list, + int sg_len); + // Poll for interrupts/device service + void (*poll)(struct eth_drv_sc *sc); + // Logical driver interface + struct eth_drv_funs *eth_drv, *eth_drv_old; +}; + +#ifndef CYGPKG_NET +struct arpcom { + unsigned char esa[6]; +}; +#endif + +struct eth_drv_sc { + struct eth_hwr_funs *funs; + void *driver_private; + const char *dev_name; + int state; + struct arpcom sc_arpcom; /* ethernet common */ +}; + +#define ETH_DRV_SC(sc,priv,name,start,stop,control,can_send,send,recv,poll) \ +static void start(struct eth_drv_sc *sc, unsigned char *enaddr, int flags); \ +static void stop(struct eth_drv_sc *sc); \ +static int control(struct eth_drv_sc *sc, unsigned long key, void *data, int data_length); \ +static int can_send(struct eth_drv_sc *sc); \ +static void send(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len, int total, unsigned long key); \ +static void recv(struct eth_drv_sc *sc, struct eth_drv_sg *sg_list, int sg_len); \ +static void poll(struct eth_drv_sc *sc); \ +static struct eth_hwr_funs sc##_funs = { \ + start, \ + stop, \ + control, \ + can_send, \ + send, \ + recv, \ + poll, \ + ð_drv_funs, \ + (struct eth_drv_funs *)0 }; \ +struct eth_drv_sc sc = {&sc##_funs, priv, name}; + +#define ETH_DRV_STATE_ACTIVE 0x0001 +#define ETH_DRV_STATE_DEBUG 0x1000 + +extern struct eth_drv_funs eth_drv_funs; + +#ifdef CYGPKG_IO_PCMCIA +#ifdef CYGPKG_NET +#include +cyg_netdevtab_entry_t *eth_drv_netdev(char *name); +#endif +#endif // CYGPKG_IO_PCMCIA + +// Control 'key's +#define ETH_DRV_SET_MAC_ADDRESS 0x0100 + +#ifndef ETHER_ADDR_LEN +#define ETHER_ADDR_LEN 6 +#endif + +#ifndef CYGPKG_NET +extern void eth_drv_buffers_init(void); +extern int eth_drv_read(char *eth_hdr, char *buf, int len); +extern void eth_drv_write(char *eth_hdr, char *buf, int len); +extern unsigned char __local_enet_addr[]; +extern struct eth_drv_sc *__local_enet_sc; +#endif + +#endif // _ETH_DRV_H_ diff --git a/packages/io/eth/current/include/netdev.h b/packages/io/eth/current/include/netdev.h new file mode 100644 --- /dev/null +++ b/packages/io/eth/current/include/netdev.h @@ -0,0 +1,80 @@ +#ifndef _NETDEV_H_ +#define _NETDEV_H_ +//========================================================================== +// +// include/netdev.h +// +// Network device description +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//####BSDCOPYRIGHTBEGIN#### +// +// ------------------------------------------- +// +// Portions of this software may have been derived from OpenBSD or other sources, +// and are covered by the appropriate copyright disclaimers included herein. +// +// ------------------------------------------- +// +//####BSDCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include + +// Network device support + +typedef struct cyg_netdevtab_entry { + const char *name; + bool (*init)(struct cyg_netdevtab_entry *tab); + void *device_instance; // Local data, instance specific + unsigned long status; +} cyg_netdevtab_entry_t; + +#define CYG_NETDEVTAB_STATUS_AVAIL 0x0001 + +extern cyg_netdevtab_entry_t __NETDEVTAB__[], __NETDEVTAB_END__; + +#define NETDEVTAB_ENTRY(_l,_name,_init,_instance) \ +static bool _init(struct cyg_netdevtab_entry *tab); \ +cyg_netdevtab_entry_t _l CYG_HAL_TABLE_ENTRY( netdev ) = { \ + _name, \ + _init, \ + _instance \ +}; + +#endif // _NETDEV_H_ diff --git a/packages/io/eth/current/src/net/eth_drv.c b/packages/io/eth/current/src/net/eth_drv.c new file mode 100644 --- /dev/null +++ b/packages/io/eth/current/src/net/eth_drv.c @@ -0,0 +1,500 @@ +//========================================================================== +// +// ecos/eth_drv.c +// +// Hardware independent ethernet driver +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//####BSDCOPYRIGHTBEGIN#### +// +// ------------------------------------------- +// +// Portions of this software may have been derived from OpenBSD or other sources, +// and are covered by the appropriate copyright disclaimers included herein. +// +// ------------------------------------------- +// +//####BSDCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: Hardware independent ethernet driver +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +// High-level ethernet driver + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifdef INET +#include +#include +#include +#include +#include +#endif + +#if NBPFILTER > 0 +#include +#include +#endif + +#include +#include +#include +#include +#include + +static int eth_drv_ioctl(struct ifnet *, u_long, caddr_t); +static void eth_drv_send(struct ifnet *); + +extern int net_debug; // FIXME + +// Interfaces exported to drivers + +static void eth_drv_init(struct eth_drv_sc *sc, unsigned char *enaddr); +static void eth_drv_recv(struct eth_drv_sc *sc, int total_len); +static void eth_drv_tx_done(struct eth_drv_sc *sc, unsigned long key, int status); + +struct eth_drv_funs eth_drv_funs = {eth_drv_init, eth_drv_recv, eth_drv_tx_done}; + +// +// This function is called during system initialization to register a +// network interface with the system. +// +static void +eth_drv_init(struct eth_drv_sc *sc, unsigned char *enaddr) +{ + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + + // Set up hardware address + bcopy(enaddr, &sc->sc_arpcom.ac_enaddr, ETHER_ADDR_LEN); + + // Initialize ifnet structure + bcopy((void *)sc->dev_name, ifp->if_xname, IFNAMSIZ); + ifp->if_softc = sc; + ifp->if_start = eth_drv_send; + ifp->if_ioctl = eth_drv_ioctl; + ifp->if_flags = + IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; + sc->state = 0; + + // Attach the interface + if_attach(ifp); + ether_ifattach(ifp); + +#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_DIAG +// Set up interfaces so debug environment can share this device + { + void *dbg = CYGACC_CALL_IF_DBG_DATA(); + if (!dbg) { + CYGACC_CALL_IF_DBG_DATA_SET((void *)sc); + } + } +#endif +} + +// +// This [internal] function will be called to stop activity on an interface. +// +static void +eth_drv_stop(struct eth_drv_sc *sc) +{ + (sc->funs->stop)(sc); + sc->state &= ~ETH_DRV_STATE_ACTIVE; +} + +// +// This [internal] function will be called to start activity on an interface. +// +static void +eth_drv_start(struct eth_drv_sc *sc) +{ + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + // Perform any hardware initialization + (sc->funs->start)(sc, (unsigned char *)&sc->sc_arpcom.ac_enaddr, 0); + // Set 'running' flag, and clear output active flag. + ifp->if_flags |= IFF_RUNNING; + ifp->if_flags &= ~IFF_OACTIVE; + sc->state |= ETH_DRV_STATE_ACTIVE; + eth_drv_send(ifp); // Try and start up transmit +} + +// +// This function supports "I/O control" operations on an interface. +// +static int +eth_drv_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +{ + struct eth_drv_sc *sc = ifp->if_softc; + struct ifaddr *ifa = (struct ifaddr *) data; + struct ifreq *ifr = (struct ifreq *)data; + int s, error = 0; + + s = splnet(); + + if ((error = ether_ioctl(ifp, &sc->sc_arpcom, cmd, data)) > 0) { + splx(s); + return error; + } + + switch (cmd) { + + case SIOCSIFADDR: + ifp->if_flags |= IFF_UP; + + switch (ifa->ifa_addr->sa_family) { +#ifdef INET + case AF_INET: + eth_drv_start(sc); + arp_ifinit(&sc->sc_arpcom, ifa); + break; +#endif + default: + eth_drv_start(sc); + break; + } + break; + + case SIOCGIFHWADDR: + // Get hardware (MAC) address + ifr->ifr_hwaddr.sa_family = AF_INET; + bcopy(&sc->sc_arpcom.ac_enaddr, &ifr->ifr_hwaddr.sa_data, ETHER_ADDR_LEN); + break; + + case SIOCSIFHWADDR: + // Set hardware (MAC) address + bcopy(&ifr->ifr_hwaddr.sa_data, &sc->sc_arpcom.ac_enaddr, ETHER_ADDR_LEN); + if ((sc->funs->control)(sc, ETH_DRV_SET_MAC_ADDRESS, + &sc->sc_arpcom.ac_enaddr, ETHER_ADDR_LEN)) { + error = EINVAL; + } + break; + + case SIOCSIFFLAGS: + if ((ifp->if_flags & IFF_UP) == 0 && + (ifp->if_flags & IFF_RUNNING) != 0) { + /* + * If interface is marked down and it is running, then + * stop it. + */ + eth_drv_stop(sc); + ifp->if_flags &= ~IFF_RUNNING; + } else + if ((ifp->if_flags & IFF_UP) != 0 && + (ifp->if_flags & IFF_RUNNING) == 0) { + /* + * If interface is marked up and it is stopped, then + * start it. + */ + eth_drv_start(sc); + } else { + /* + * Reset the interface to pick up changes in any other + * flags that affect hardware registers. + */ + eth_drv_stop(sc); + eth_drv_start(sc); + } + break; + +#if 0 + case SIOCADDMULTI: + case SIOCDELMULTI: + /* Update our multicast list. */ + error = (cmd == SIOCADDMULTI) ? + ether_addmulti(ifr, &sc->sc_arpcom) : + ether_delmulti(ifr, &sc->sc_arpcom); + + if (error == ENETRESET) { + /* + * Multicast list has changed; set the hardware filter + * accordingly. + */ + eth_drv_stop(sc); /* XXX for ds_setmcaf? */ + eth_drv_start(sc); + error = 0; + } + break; +#endif + + default: + error = EINVAL; + break; + } + + splx(s); + return (error); +} + +// +// This routine is called to start transmitting if there is data +// available. +// +static void +eth_drv_send(struct ifnet *ifp) +{ + struct eth_drv_sc *sc = ifp->if_softc; + struct eth_drv_sg sg_list[MAX_ETH_DRV_SG]; + int sg_len; + struct mbuf *m0, *m; + int len, total_len; + unsigned char *data; + + cyg_scheduler_lock(); // Prevent DSRs from running + if ((ifp->if_flags & IFF_RUNNING) != IFF_RUNNING) { + cyg_scheduler_unlock(); + return; + } + + while ((sc->funs->can_send)(sc) > 0) { + IF_DEQUEUE(&ifp->if_snd, m0); + if (m0 == 0) { + break; + } + + if (net_debug) + diag_printf("Sending %d bytes\n", m0->m_pkthdr.len); + + /* We need to use m->m_pkthdr.len, so require the header */ + if ((m0->m_flags & M_PKTHDR) == 0) + panic("eth_drv_send: no header mbuf"); + +#if NBPFILTER > 0 + /* Tap off here if there is a BPF listener. */ + if (ifp->if_bpf) + bpf_mtap(ifp->if_bpf, m0); +#endif + + // Extract data pointers (don't actually move data here) + sg_len = 0; total_len = 0; + for (m = m0; m ; m = m->m_next) { + data = mtod(m, u_char *); + len = m->m_len; + total_len += len; + sg_list[sg_len].buf = (CYG_ADDRESS)data; + sg_list[sg_len].len = len; + if ( len ) + sg_len++; + if (net_debug) { + diag_printf("xmit %d bytes at %x sg[%d]\n", len, data, sg_len); + if ( 1 & net_debug ) + diag_dump_buf(data, len); + } + if ( MAX_ETH_DRV_SG < sg_len ) { + diag_printf("too many mbufs to tx, %d > %d\n", sg_len, MAX_ETH_DRV_SG ); + sg_len = 0; + break; // drop it on the floor + } + } + + // Tell hardware to send this packet + if ( sg_len ) + (sc->funs->send)(sc, sg_list, sg_len, total_len, (unsigned long)m0); + } + + cyg_scheduler_unlock(); // Allow DSRs to run +} + +// +// This function is called from the hardware driver when an output operation +// has completed - i.e. the packet has been sent. +// +static struct mbuf *mbuf_key; + +static void +eth_drv_tx_done(struct eth_drv_sc *sc, unsigned long key, int status) +{ + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + struct mbuf *m0 = (struct mbuf *)key; + // Check for errors here (via 'status') + // Done with packet + mbuf_key = m0; + m_freem(m0); + // Start another if possible + eth_drv_send(ifp); +} + +// +// This function is called from a hardware driver to indicate that an input +// packet has arrived. The routine will set up appropriate network resources +// (mbuf's) to hold the data and call back into the driver to retrieve the data. +// +static void +eth_drv_recv(struct eth_drv_sc *sc, int total_len) +{ + struct ifnet *ifp = &sc->sc_arpcom.ac_if; + struct ether_header _eh, *eh=&_eh; + struct mbuf *top, **mp, *m; + int i, mlen; + unsigned char *data; + struct eth_drv_sg sg_list[MAX_ETH_DRV_SG]; + int sg_len; + + if ((ifp->if_flags & IFF_RUNNING) != IFF_RUNNING) { + return; // Interface not up, ignore this request + } + + CYG_ASSERT( 0 != total_len, "total_len is zero!" ); + CYG_ASSERT( 0 <= total_len, "total_len is negative!" ); + CYG_ASSERT( sizeof( struct ether_header ) <= total_len, + "No ether header here!" ); + + if ( total_len < sizeof( struct ether_header ) ) + // Our arithmetic below would go wrong + return; + + /* Pull packet off interface. */ + MGETHDR(m, M_DONTWAIT, MT_DATA); + if (m == 0) { + diag_printf("warning: eth_recv out of MBUFs\n"); + } + + // Set up buffers + // Unload ethernet header separately so IP/UDP/TCP headers are aligned + sg_list[0].buf = (CYG_ADDRESS)eh; + sg_list[0].len = sizeof(*eh); + sg_len = 1; + + // Compute total length (minus ethernet header) + total_len -= sizeof(*eh); + + top = 0; + mlen = MHLEN; + mp = ⊤ + + if (m) { + m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.len = total_len; + } else { + sg_list[sg_len].buf = (CYG_ADDRESS)0; + sg_list[sg_len].len = min(total_len, MCLBYTES); + sg_len++; + total_len = 0; + } + + while (total_len > 0) { + if (top) { + MGET(m, M_DONTWAIT, MT_DATA); + if (m == 0) { + m_freem(top); + panic("out of MBUFs [2]"); + } + mlen = MLEN; + } + if (total_len >= MINCLSIZE) { + MCLGET(m, M_DONTWAIT); + if ((m->m_flags & M_EXT) == 0) { + m_freem(top); + diag_printf("warning: eth_recv out of MBUFs\n"); + sg_list[sg_len].buf = (CYG_ADDRESS)0; + sg_list[sg_len].len = min(total_len, MCLBYTES); + sg_len++; + top = 0; + break; + } + mlen = MCLBYTES; + } + m->m_len = mlen = min(total_len, mlen); + total_len -= mlen; + data = mtod(m, caddr_t); + sg_list[sg_len].buf = (CYG_ADDRESS)data; + sg_list[sg_len].len = mlen; + sg_len++; + *mp = m; + mp = &m->m_next; + } + + // Ask hardware to unload buffers + (sc->funs->recv)(sc, sg_list, sg_len); + + if (net_debug) { + for (i = 0; i < sg_len; i++) { + if (sg_list[i].buf) { + diag_printf("rx %d bytes at %x sg[%d]\n", sg_list[i].len, sg_list[i].buf, i); + if ( 1 & net_debug ) + diag_dump_buf((void *)sg_list[i].buf, sg_list[i].len); + } + } + } + + m = top; + if (m == 0) { + ifp->if_ierrors++; + return; + } + + ifp->if_ipackets++; + + +#if NBPFILTER > 0 +#error FIXME - Need mbuf with ethernet header attached + /* + * Check if there's a BPF listener on this interface. + * If so, hand off the raw packet to bpf. + */ + if (ifp->if_bpf) + bpf_mtap(ifp->if_bpf, m); +#endif + + // Push data into protocol stacks + ether_input(ifp, eh, m); +} + +#ifdef CYGPKG_IO_PCMCIA +// Lookup a 'netdev' entry, assuming that it is an ethernet device. +cyg_netdevtab_entry_t * +eth_drv_netdev(char *name) +{ + cyg_netdevtab_entry_t *t; + struct eth_drv_sc *sc; + for (t = &__NETDEVTAB__[0]; t != &__NETDEVTAB_END__; t++) { + sc = (struct eth_drv_sc *)t->device_instance; + if (strcmp(sc->dev_name, name) == 0) { + return t; + } + } + return (cyg_netdevtab_entry_t *)NULL; +} +#endif // CYGPKG_IO_PCMCIA + +// EOF eth_drv.c diff --git a/packages/io/eth/current/src/stand_alone/eth_drv.c b/packages/io/eth/current/src/stand_alone/eth_drv.c new file mode 100644 --- /dev/null +++ b/packages/io/eth/current/src/stand_alone/eth_drv.c @@ -0,0 +1,424 @@ +//========================================================================== +// +// eth_drv.c +// +// Stand-alone hardware independent networking support for RedBoot +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-14 +// Purpose: +// Description: +// +// This code is part of RedBoot (tm). +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include +#include +#include +#include +#include +#include + +// High-level ethernet driver + +// Define this to allow packets seen by this layer to be passed on to +// the previous logical layer, i.e. when stand-alone processing replaces +// system [eCos] processing. +// +// CAUTION! Observations indicate that this cannot work. When TCP packets +// destined for the stand-alone layer are passed up, the eCos stack treats +// them as evil and sends "disconnect" responses. +// +#undef ETH_DRV_PASS_PACKETS +#define ETH_DRV_PASS_PACKETS + +// Interfaces exported to drivers + +static void eth_drv_init(struct eth_drv_sc *sc, unsigned char *enaddr); +static void eth_drv_recv(struct eth_drv_sc *sc, int total_len); +static void eth_drv_tx_done(struct eth_drv_sc *sc, CYG_ADDRWORD key, int status); + +struct eth_drv_funs eth_drv_funs = {eth_drv_init, eth_drv_recv, eth_drv_tx_done}; + +int net_debug; // FIXME + +unsigned char __local_enet_addr[ETHER_ADDR_LEN+2]; +struct eth_drv_sc *__local_enet_sc; + +#ifdef ETH_DRV_PASS_PACKETS +// +// Horrible hack: In order to allow the stand-alone networking code to work +// alongside eCos (or any other stack), separate IP addresses must be used. +// When a packet arrives at the interface, we check to see which IP address +// it corresponds to and only pass it "up" if it's not for the stand-alone +// layer. +// +// tres degolas :-( +// +extern char __local_ip_addr[4]; +#endif + +// +// Buffer 'get' support. The problem is that this function only gets +// called when some data is required, but packets may arrive on the device +// at any time. More particularly, on some devices when data arrive, all +// of that data needs to be consumed immediately or be lost. This process +// is driven by interrupts, which in the stand-along case are simulated by +// calling the "poll" interface. +// +// Thus there will be a pool of buffers, some free and some full, to try +// and manage this. +// + +#define MAX_ETH_MSG 1540 +#define NUM_ETH_MSG 16 + +struct eth_msg { + struct eth_msg *next, *prev; + int len; // Actual number of bytes in message + unsigned char data[MAX_ETH_MSG]; +}; + +struct eth_msg_hdr { + struct eth_msg *first, *last; +}; + +static struct eth_msg_hdr eth_msg_free, eth_msg_full; +static struct eth_msg eth_msgs[NUM_ETH_MSG]; + +// Used to "empty" hardware, even if there are no free buffers +static unsigned char no_pkt[MAX_ETH_MSG]; + +// Prototypes for functions used in this module +static void eth_drv_start(struct eth_drv_sc *sc); + +extern int start_console(void); +extern void end_console(int); +extern void printf(char *fmt, ...); +extern void dump_buf(CYG_ADDRWORD, int); + +// Simple queue management functions + +static void +eth_drv_msg_put(struct eth_msg_hdr *hdr, struct eth_msg *msg) +{ + if (hdr->first != (struct eth_msg *)hdr) { + // Something already in queue + hdr->last->next = msg; + msg->prev = hdr->last; + msg->next = (struct eth_msg *)hdr; + hdr->last = msg; + } else { + hdr->first = hdr->last = msg; + msg->next = msg->prev = (struct eth_msg *)hdr; + } +} + +static struct eth_msg * +eth_drv_msg_get(struct eth_msg_hdr *hdr) +{ + struct eth_msg *msg; + if (hdr->first != (struct eth_msg *)hdr) { + msg = hdr->first; + hdr->first = msg->next; + msg->next->prev = (struct eth_msg *)hdr; + } else { + msg = (struct eth_msg *)NULL; + } + return msg; +} + +void +eth_drv_buffers_init(void) +{ + int i; + struct eth_msg *msg = eth_msgs; + + eth_msg_full.first = eth_msg_full.last = (struct eth_msg *)ð_msg_full; + eth_msg_free.first = eth_msg_free.last = (struct eth_msg *)ð_msg_free; + for (i = 0; i < NUM_ETH_MSG; i++, msg++) { + eth_drv_msg_put(ð_msg_free, msg); + } +} + +// +// This function is called during system initialization to register a +// network interface with the system. +// +static void +eth_drv_init(struct eth_drv_sc *sc, unsigned char *enaddr) +{ + // Set up hardware address + memcpy(&sc->sc_arpcom.esa, enaddr, ETHER_ADDR_LEN); + memcpy(__local_enet_addr, enaddr, ETHER_ADDR_LEN); + __local_enet_sc = sc; + eth_drv_start(sc); +} + +#if 0 // Not currently used. Left in case it's needed in the future +// +// This [internal] function will be called to stop activity on an interface. +// +static void +eth_drv_stop(struct eth_drv_sc *sc) +{ + (sc->funs->stop)(sc); +} +#endif + +// +// This [internal] function will be called to start activity on an interface. +// +static void +eth_drv_start(struct eth_drv_sc *sc) +{ + // Perform any hardware initialization + (sc->funs->start)(sc, (unsigned char *)&sc->sc_arpcom.esa, 0); +} + +// +// Send a packet of data to the hardware +// +static int packet_sent; + +void +eth_drv_write(char *eth_hdr, char *buf, int len) +{ + struct eth_drv_sg sg_list[MAX_ETH_DRV_SG]; + struct eth_drv_sc *sc = __local_enet_sc; + int sg_len = 2; + void *dbg = CYGACC_CALL_IF_DBG_DATA(); + int old_state; + int wait_time = 5; // Timeout before giving up + + if (dbg) { + sc = (struct eth_drv_sc *)dbg; // Use control from installed driver + sc->funs->eth_drv_old = sc->funs->eth_drv; + sc->funs->eth_drv = ð_drv_funs; // Substitute stand-alone driver + old_state = sc->state; + if (!old_state & ETH_DRV_STATE_ACTIVE) { + // This interface not fully initialized, do it now + (sc->funs->start)(sc, (unsigned char *)&__local_enet_addr, 0); + sc->state |= ETH_DRV_STATE_ACTIVE; + } + } + + while (!(sc->funs->can_send)(sc)) { + // Give driver a chance to service hardware + (sc->funs->poll)(sc); + CYGACC_CALL_IF_DELAY_US(2*100000); + if (--wait_time <= 0) return; // Give up on sending packet + } + + sg_list[0].buf = (CYG_ADDRESS)eth_hdr; + sg_list[0].len = 14; // FIXME + sg_list[1].buf = (CYG_ADDRESS)buf; + sg_list[1].len = len; + packet_sent = 0; + (sc->funs->send)(sc, sg_list, sg_len, len+14, (CYG_ADDRWORD)&packet_sent); + if (net_debug) { + int old_console; + old_console = start_console(); + printf("Ethernet send:\n"); + dump_buf((CYG_ADDRWORD)eth_hdr, 14); + dump_buf((CYG_ADDRWORD)buf, len); + end_console(old_console); + } + + while (!packet_sent) { + (sc->funs->poll)(sc); + } + + if (dbg) { +// if (!old_state & ETH_DRV_STATE_ACTIVE) { +// // This interface was not fully initialized, shut it back down +// (sc->funs->stop)(sc); +// } + sc->funs->eth_drv = sc->funs->eth_drv_old; + sc->funs->eth_drv_old = (struct eth_drv_funs *)0; + } +} + +// +// This function is called from the hardware driver when an output operation +// has completed - i.e. the packet has been sent. +// +static void +eth_drv_tx_done(struct eth_drv_sc *sc, CYG_ADDRWORD key, int status) +{ + if ((int *)key == &packet_sent) { + *(int *)key = 1; + } else { + // It's possible that this acknowledgement is for a different + // [logical] driver. Try and pass it on. +#ifdef DEBUG + int old_console; + old_console = start_console(); + printf("tx_done for other key: %x\n", key); + end_console(old_console); +#endif + (sc->funs->eth_drv_old->tx_done)(sc, key, status); + } +} + +// +// Receive one packet of data from the hardware, if available +// +int +eth_drv_read(char *eth_hdr, char *buf, int len) +{ + struct eth_drv_sc *sc = __local_enet_sc; + struct eth_msg *msg; + int res; + void *dbg = CYGACC_CALL_IF_DBG_DATA(); + int old_state; + + if (dbg) { + sc = (struct eth_drv_sc *)dbg; // Use control from installed driver + sc->funs->eth_drv_old = sc->funs->eth_drv; + sc->funs->eth_drv = ð_drv_funs; // Substitute stand-alone driver + old_state = sc->state; + if (!old_state & ETH_DRV_STATE_ACTIVE) { + // This interface not fully initialized, do it now + (sc->funs->start)(sc, (unsigned char *)&__local_enet_addr, 0); + sc->state |= ETH_DRV_STATE_ACTIVE; + } + } + (sc->funs->poll)(sc); // Give the driver a chance to fetch packets + msg = eth_drv_msg_get(ð_msg_full); + if (msg) { + memcpy(eth_hdr, msg->data, 14); + memcpy(buf, &msg->data[14], msg->len-14); + eth_drv_msg_put(ð_msg_free, msg); + res = msg->len; + } else { + res = 0; // No packets available + } + + if (dbg) { + sc->funs->eth_drv = sc->funs->eth_drv_old; + sc->funs->eth_drv_old = (struct eth_drv_funs *)0; +// if (!old_state & ETH_DRV_STATE_ACTIVE) { +// // This interface was not fully initialized, shut it back down +// (sc->funs->stop)(sc); +// } + } + return res; +} + +#ifdef ETH_DRV_PASS_PACKETS +// +// This function is called to copy a message up to the next level. +// It is only used when this driver has usurped the processing of +// network functions. +// +static unsigned char *eth_drv_copy_recv_buf; +static void +eth_drv_copy_recv(struct eth_drv_sc *sc, + struct eth_drv_sg *sg_list, + int sg_len) +{ + int i; + + for (i = 0; i < sg_len; i++) { + memcpy((unsigned char *)sg_list[i].buf, + eth_drv_copy_recv_buf, sg_list[i].len); + eth_drv_copy_recv_buf += sg_list[i].len; + } +} +#endif + +// +// This function is called from a hardware driver to indicate that an input +// packet has arrived. The routine will set up appropriate network resources +// to hold the data and call back into the driver to retrieve the data. +// +static void +eth_drv_recv(struct eth_drv_sc *sc, int total_len) +{ + struct eth_drv_sg sg_list[MAX_ETH_DRV_SG]; + int sg_len = 0; + struct eth_msg *msg; + unsigned char *buf; + + msg = eth_drv_msg_get(ð_msg_free); + if (msg) { + buf = msg->data; + } else { + int old_console; + old_console = start_console(); + printf("%s: packet of %d bytes dropped\n", __FUNCTION__, total_len); + end_console(old_console); + buf = &no_pkt[0]; + } + sg_list[0].buf = (CYG_ADDRESS)buf; + sg_list[0].len = total_len; + sg_len = 1; + + (sc->funs->recv)(sc, sg_list, sg_len); + if (net_debug) { + int old_console; + old_console = start_console(); + printf("Ethernet recv:\n"); + dump_buf((CYG_ADDRWORD)buf, 14); + dump_buf((CYG_ADDRWORD)buf+14, total_len-14); + end_console(old_console); + } +#ifdef ETH_DRV_PASS_PACKETS + if (sc->funs->eth_drv_old != (struct eth_drv_funs *)0) { + void (*hold_recv)(struct eth_drv_sc *sc, + struct eth_drv_sg *sg_list, + int sg_len); + // See if this packet was for us. If not, pass it upwards + // This is a major layering violation!! + if (memcmp(&__local_ip_addr, &buf[14+16], 4)) { + hold_recv = sc->funs->recv; + sc->funs->recv = eth_drv_copy_recv; + eth_drv_copy_recv_buf = buf; + // This calls into the 'other' driver, giving it a chance to + // do something with this data (since it wasn't for us) + (sc->funs->eth_drv_old->recv)(sc, total_len); + sc->funs->recv = hold_recv; + } + } +#endif + if (msg) { + msg->len = total_len; + eth_drv_msg_put(ð_msg_full, msg); + } else { + dump_buf(sg_list[0].buf, sg_list[0].len); + } +} diff --git a/packages/io/fileio/current/ChangeLog b/packages/io/fileio/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/ChangeLog @@ -0,0 +1,323 @@ +2000-08-18 Nick Garnett + + * include/fileio.h: Added CYG_FAPPEND flag for preservation in + file object flags. + Added prototype for cyg_timestamp(). + + * src/misc.cxx: Fixed bug in cyg_mtab_lookup() when dealing with + empty mount table entries. + Added cyg_timestamp() to provide timestamp support to client + filesystems. + +2000-08-09 Jonathan Larmour + + * src/misc.cxx: Don't define own strcmp() function (which had a bug + anyway). Use string.h. + * cdl/fileio.cdl: requires ISO C string functions + +2000-08-01 Jonathan Larmour + + * src/misc.cxx: Use correct initializer for mtab_extra + + * src/fio.h (FILEIO_RETURN_VOID): Surround in CYG_MACRO_START to + prevent problems when used with one-line if. + (FILEIO_RETURN_VALUE): Likewise + + * include/fileio.h: Make getinfo/setinfo take void *bufs, not char * + for easier casting (and more correct) + + * tests/testfs.c: Likewise + + * src/devfs.cxx: Likewise. + Also fix bug with Nick's change below that set non-blocking mode + in all cases. + +2000-07-31 Nick Garnett + + * src/devfs.cxx (dev_open): Added support for O_NONBLOCK. + +2000-07-27 Nick Garnett + + * tests/select.c: Wrapped include of pkgconf/io_serial.h in + #ifdef CYGPKG_IO_SERIAL. + +2000-07-25 Jonathan Larmour + + * tests/select.c (main): Wrap call to init_all_network_interfaces() + in #ifdef TEST_NET + +2000-07-25 Nick Garnett + + * tests/select.c (main): Added call to + init_all_network_interfaces(). + +2000-07-21 Nick Garnett + + * include/fileio.h: + * src/file.cxx: + * src/devfs.cxx: + * tests/testfs.c: + Added support for link() API call. This was the only major file + operation omitted. + +2000-07-20 Nick Garnett + + * include/fileio.h: Added some modes for fsync(). + + * src/file.cxx: Added access() function. + + * src/io.cxx: Added fdatasync() and isatty(). + + * src/devfs.cxx: Added fsync() support. + + * tests/fileio1.c: Added calls to access() to check (non-)existence + of files where appropriate. + +2000-07-13 Nick Garnett + + * src/select.cxx (select): Fixed return value when timing out. Now + returns zero and no error, it used to return -1 and ETIMEDOUT. + + * src/io.cxx: Fixed fsync() to match standard. + + * src/devfs.cxx: + Added lseek() support - all devices are always at position + zero. Added [f]stat() support - currently just fills in the stat + buffer with some predefined values. When we have more + sophisticated devices this may need to be improved. + + * tests/testfs.c (testfs_open): Added support for O_TRUNC open + flag. + + * tests/stdio.c: + * cdl/fileio.cdl: + Added stdio.c to test C library IO integration. This does not test + the C library functionality, just that it works with the fileio + package in certain limited ways. + +2000-06-30 Nick Garnett + + * src/misc.cxx: Fixed definition of mtab_extra[] so that it gets + emitted correctly into the object file. + + * tests/testfs.c: + Added support for dynamic mount()/umount(). + Added testfs_dump() to report state of filesystem, and to do a + little consistency checking. + + * tests/fileio1.c: Extended testing to mount() and maximum file + sizes. + +2000-06-28 Nick Garnett + + * include/dirent.h: Added this file to contain directory support + definitions. + + * include/fileio.h: + Introduced separate typedefs for all operation functions. + Added CYG_FDIR to mark directory streams. + Added some default operation functions. + + * src/fio.h (FILEIO_RETURN_VOID): Added this macro. + + * src/dir.cxx: Added this file to contain directory listing API + functions. + + * src/misc.cxx: + Added default operation functions. + + * src/file.cxx: + Fixed mkdir() to have correct prototype. + Moved opendir() to dir.cxx. + Added support in chdir() for deregistering the current directory. + + * cdl/fileio.cdl: Added dev.cxx to compile list. Added support for + dirent.h implementation. + + * tests/testfs.c: Lots of changes towards a more complete + implementation. + + * tests/select.c: Changed SHOW_RESULT() message a little. Fixed up + some warnings when no testing is possible. + + * tests/fileio1.c: + Largely rewritten to do more complete testing. + +2000-06-19 Nick Garnett + + * src/select.cxx: Added selwake_count variable to count select + wakeups. This allows us to avoid sleeping when a selectee calls + cyg_selwakeup() while we are still scanning the FD sets. + + * include/fileio.h: + * include/sockio.h: + * src/misc.cxx: + * src/socket.cxx: + Converted tables to new mechanism. + + * tests/select.c: Reduced buffer size to avoid buffer overflow in + serial devices. + +2000-06-15 Nick Garnett + + * include/fileio.h: + Added typedef for cyg_selinfo. + Added umount to fstab entry structure. + Added mount() and unmount() prototypes. + Added const in various places. + Changed some types from CYG_ADDRWORD to their ISO standard + equivalents. + Added si_thread field to cyg_selinfo structure, added + cyg_selinit() prototype. + + * src/socket.cxx: Converted an errant LOCK_NS() into the + UNLOCK_NS() it should be. + + * src/select.cxx: + Added cyg_selinit() which must be called by all selectees at + initialization to prepare a cyg_selinfo structure for use. + Modified cyg_selwakeup() to minimize the number for actual wakeup + operations it actually performs. + + * src/misc.cxx: + Added mtab_extra[] to contain dynamic mount table entries, + modified startup scan of mtab to cope with this. + changed matchlen() to cope with "/" mountpoint, this function is + rapidly ceasing to be the neat bit of code it started out as. + Added implementations of mount() and umount(). + + * src/devfs.cxx: Added dev_umount, various minor tweaks. + + * cdl/fileio.cdl: Added CYGNUM_FILEIO_MTAB_EXTRA to define how + many extra mount table entries should exist for dynamic mounts. + Added select.c to list of tests. + + * tests/select.c: Added this file to test select() functionality + on both sockets and (serial) devices. + + * tests/socket.c: Tidied some compilation warnings. + + * tests/testfs.c: Added umount stub function. + +2000-06-12 Nick Garnett + + * include/sockio.h: + * include/fileio.h: + * src/fio.h: + * tests/testfs.c: + * src/socket.cxx: + * src/misc.cxx: + * src/file.cxx: + * src/fd.cxx: + * src/io.cxx: + * src/devfs.cxx: + Tidied up and sorted out locking protocols and synchronization + mechanisms. + +2000-06-09 Nick Garnett + + * src/select.cxx: + * src/devfs.cxx: + * include/fileio.h: + * tests/testfs.c: + Added select() support. + + * src/socket.cxx: Fixed a resource management bug in accept(). + + * tests/socket.c: Extended to test that all API calls work, at + least minimally, as they should. Still some calls to add here. + +2000-06-07 Nick Garnett + + * tests/socket.c: Simple socket API test program. Needs much more + work to give full coverage. + + * src/socket.cxx: Filled in some implementations. Changed some + type specifications. + + * src/select.cxx: Added this file to contain select() + implementation. At present it does nothing. + + * include/sockio.h: + Added definition of socklen_t for use when the NET package is + absent - just so this file compiles. + Added macro to generate an nstab entry. + Changed prototypes of socket operation ffunctions to better match + both API definition and BSD stack implementation. + + * cdl/fileio.cdl: Added support for socket API. This is only + active if the NET package is present. + Added initial socket API test program. + +2000-06-02 Nick Garnett + + * src/socket.cxx: + Added this file to implement socket interface. This is still a + rough draft that has not yet been tested. + + * src/misc.cxx: + * src/io.cxx: + * src/fio.h: Various minor changes and bug fixes. + + * src/file.cxx: Various bug fixes. Added pathconf(). + + * src/fd.cxx: Various changes and bug fixes, mostly in the + handling of the locking mechanisms. + + * src/devfs.cxx: Added this filesystem to interface to the device + IO subsystem. Not yet tested. + + * include/sockio.h: Various minor changes prompted by + implementation. + + * include/fileio.h: + Added macros to instantiate filesystem and mount table entries. + Added mode mask for setting up f_flags. + Changed file object types, added device type. + + * cdl/fileio.cdl: + Added some extra files to compile. Some now go in libextras. + Added table maxima for fstab, mtab and nstab. + Added tests. + + * tests/fileio1.c: Added this simple test for the fileio + infrastructure. + + * tests/testfs.c: + Created this simple ROM filesystem to test out the fileio + infrastructure. This is not really usable for anything other than + this, and should not be used in "production" systems. Hence its + presence in tests rather than src. + At present this only has support for open(), close(), read(), + write(), lseek() and unlink(). Other parts will be implemented as + and when required. + +2000-05-31 Nick Garnett + + * src/fio.h: + * src/file.cxx: + * src/io.cxx: + * src/misc.cxx: + Roughed out most of the file IO infrastructure. While this code + compiles, none of it has actually been executed yet. A lot of this + was cut-and-paste-and-edit, so some minor blemishes are to be + expected. + + * src/fd.cxx: Several modifications in response to implementing + rest of infrastructure. Added dup() and dup2() API routines. + + * include/fileio.h: Many changes and tidies prompted by + infrastructure implementation. + + * cdl/fileio.cdl: Added "implements" directives for isoinfra + interfaces. Extended compile to new files. + +2000-05-26 Nick Garnett + + * include/fileio.h: + * include/sockio.h: + * src/fd.cxx: + * cdl/fileio.cdl: + Created these files as a start at defining the file IO package. + There is still a lot to do here, so expect radical changes to all + of these files in the near future. diff --git a/packages/io/fileio/current/cdl/fileio.cdl b/packages/io/fileio/current/cdl/fileio.cdl new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/cdl/fileio.cdl @@ -0,0 +1,148 @@ +# ==================================================================== +# +# fileio.cdl +# +# FILEIO layer configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): nickg +# Contributors: +# Date: 2000-5-25 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_IO_FILEIO { + display "POSIX File IO compatibility layer" + description "This package enables the POSIX compatibility + layer that implements IEEE 1003.1 file IO." + include_dir cyg/fileio + + requires CYGPKG_KERNEL + requires CYGPKG_ISOINFRA + requires CYGPKG_ERROR + requires CYGINT_ISO_ERRNO + requires CYGINT_ISO_ERRNO_CODES + requires CYGINT_ISO_STRING_STRFUNCS + + implements CYGINT_ISO_FCNTL + implements CYGINT_ISO_OPEN + implements CYGINT_ISO_DIRENT + + requires { CYGBLD_ISO_DIRENT_HEADER == "" } + + compile fd.cxx file.cxx io.cxx select.cxx dir.cxx + compile -library=libextras.a devfs.cxx misc.cxx + + cdl_option CYGPKG_IO_FILEIO_SOCKET_SUPPORT { + display "Enable socket support" + active_if CYGPKG_NET + default_value 1 + description " + This option enables support for the socket interface. It is + only present if the NET package is included." + + compile socket.cxx + } + + cdl_option CYGNUM_FILEIO_NFILE { + display "Maximum number of open files" + flavor data + default_value 16 + legal_values 1 to 9999999 + description "This option controls the number of open files + that are allowed for all filesystems." + } + + cdl_option CYGNUM_FILEIO_NFD { + display "Maximum number of open file descriptors" + flavor data + default_value 16 + legal_values CYGNUM_FILEIO_NFILE to 9999999 + description "This option controls the number of open file descriptors + that are allowed for all filesystems." + } + + cdl_option CYGNUM_FILEIO_FSTAB_MAX { + display "Maximum number of installed filesystems" + flavor data + default_value 4 + legal_values 1 to 9999999 + description "This option controls the maximum number of filesystems + that can be handled by the fileio system." + + } + + cdl_option CYGNUM_FILEIO_MTAB_MAX { + display "Maximum number of mounted filesystems" + flavor data + default_value 8 + legal_values CYGNUM_FILEIO_MTAB_EXTRA to 9999999 + description "This option controls the maximum number of mounted + filesystems that can be handled by the fileio system." + + } + + cdl_option CYGNUM_FILEIO_MTAB_EXTRA { + display "Number of dynamically mounted filesystems" + flavor data + default_value 8 + legal_values 0 to 9999999 + description "This option controls the number of mounted + filesystems that can be created dynamically." + } + + cdl_option CYGNUM_FILEIO_NSTAB_MAX { + display "Maximum number of installed network stacks" + flavor data + default_value 1 + legal_values 1 to 9999999 + description "This option controls the maximum number of installed + network stacks that can be handled by the fileio system." + } + + + # ---------------------------------------------------------------- + # Tests + + cdl_option CYGPKG_IO_FILEIO_TESTS { + display "Fileio tests" + flavor data + no_define + calculated { "tests/testfs.c tests/fileio1.c tests/socket.c tests/select.c tests/stdio.c" } + description " + This option specifies the set of tests for the FileIO package." + } +} + +# ==================================================================== +# End of fileio.cdl + + diff --git a/packages/io/fileio/current/doc/fileio.txt b/packages/io/fileio/current/doc/fileio.txt new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/doc/fileio.txt @@ -0,0 +1,598 @@ +File System Support Infrastructure +================================== + +Nick Garnett +v0.1 + + +This document describes the filesystem infrastructure provided in +eCos. This is implemented by the FILEIO package and provides POSIX +compliant file and IO operations together with the BSD socket +API. These APIs are described in the relevant standards and original +documentation and will not be described here. This document is, +instead, concerned with the interfaces presented to client +filesystems and network protocol stacks. + +The FILEIO infrastructure consist mainly of a set of tables containing +pointers to the primary interface functions of a file system. This +approach avoids problems of namespace pollution (several filesystems +can have a function called read(),so long as they are static). The +system is also structured to eliminate the need for dynamic memory +allocation. + +New filesystems can be written directly to the interfaces described +here. Existing filesystems can be ported very easily by the +introduction of a thin veneer porting layer that translates FILEIO +calls into native filesystem calls. + +The term filesystem should be read fairly loosely in this +document. Object accessed through these interfaces could equally be +network protocol sockets, device drivers, fifos, message queues or any +other object that can present a file-like interface. + + [Note: Additional notes and comments appear in square brackets, + just like this. They do not form part of the text of this + document.] + + [Note: Words and phrases that should be emphasized in some way are + surrounded by underscores, like _this_.] + +File System Table +----------------- + +The filesystem table is an array of entries that describe each +filesystem implementation that is part of the system image. Each +resident filesystem should export an entry to this table using the +FSTAB_ENTRY() macro. + + [Note: at present we do not support dynamic addition or removal of + table entries. If dynamic code loading is ever implemented, this + may need to change.] + +The table entries are described by the following structure: + +struct cyg_fstab_entry +{ + const char *name; // filesystem name + CYG_ADDRWORD data; // private data value + cyg_uint32 syncmode; // synchronization mode + + int (*mount) ( cyg_fstab_entry *fste, cyg_mtab_entry *mte ); + int (*umount) ( cyg_mtab_entry *mte ); + int (*open) ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int mode, cyg_file *fte ); + int (*unlink) ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); + int (*mkdir) ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); + int (*rmdir) ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); + int (*rename) ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2 ); + int (*link) ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2, int type ); + int (*opendir) ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_file *fte ); + int (*chdir) ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_dir *dir_out ); + int (*stat) ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + struct stat *buf); + int (*getinfo) ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, char *buf, int len ); + int (*setinfo) ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, char *buf, int len ); +}; + +The _name_ field points to a string that identifies this filesystem +implementation. Typical values might be "romfs", "msdos", "ext2" etc. + +The _data_ field contains any private data that the filesystem needs, +perhaps the root of its data structures. + +The _syncmode_ field contains a description of the locking protocol to +be used when accessing this filesystem. It will be described in more +detail in the "Synchronization" section. + +The remaining fields are pointers to functions that implement +filesystem operations that apply to files and directories as whole +objects. The operation implemented by each function should be obvious +from the names, with a few exceptions. + +The _opendir_ function opens a directory for reading. See the section +on Directories later for details. + +The _getinfo_ and _setinfo_ functions provide support for various +minor control and information functions such as pathconf() and +access(). + +With the exception of the _mount_ and _umount_ functions, all of these +functions take three standard arguments, a pointer to a mount table +entry (see later) a directory pointer (also see later) and a file name +relative to the directory. These should be used by the filesystem to +locate the object of interest. + +Mount Table +----------- + +The mount table records the filesystems that are actually active. +These can be seen as being analogous to mount points in Unix systems. + +There are two sources of mount table entries. Filesystems (or other +components) may export static entries to the table using the +MTAB_ENTRY() macro. Alternatively, new entries may be installed at run +time using the mount() function. Both types of entry may be unmounted +with the umount() function. + +A mount table entry has the following structure: + +struct cyg_mtab_entry +{ + const char *name; // name of mount point + const char *fsname; // name of implementing filesystem + const char *devname; // name of hardware device + CYG_ADDRWORD data; // private data value + cyg_bool valid; // Valid entry? + cyg_fstab_entry *fs; // pointer to fstab entry + cyg_dir root; // root directory pointer +}; + +The _name_ field identifies the mount point. This is used to translate +rooted filenames (filenames that begin with "/") into the correct +filesystem. When a file name that begins with "/" is submitted, it is +matched against the _name_ fields of all valid mount table +entries. The entry that yields the longest match terminating before a +"/", or end of string, wins and the appropriate function from the +filesystem table entry is then passed the remainder of the file name +together with a pointer to the table entry and the value of the _root_ +field as the directory pointer. + +For example, consider a mount table that contains the following +entries: + + { "/", "msdos", "/dev/hd0", ... } + { "/fd", "msdos", "/dev/fd0", ... } + { "/rom", "romfs", "", ... } + { "/tmp", "ramfs", "", ... } + { "/dev", "devfs", "", ... } + +An attempt to open "/tmp/foo" would be directed to the RAM filesystem +while an open of "/bar/bundy" would be directed to the hard disc MSDOS +filesystem. Opening "/dev/tty0" would be directed to the device +management filesystem for lookup in the device table. + +Unrooted file names (those that do not begin with a '/') are passed +straight to the current directory. The current directory is +represented by a pair consisting of a mount table entry and a +directory pointer. + +The _fsname_ field points to a string that should match the _name_ +field of the implementing filesystem. During initialization the mount +table is scanned and the _fsname_ entries looked up in the +filesystem table. For each match, the filesystem's _mount_ function +is called and if successful the mount table entry is marked as valid +and the _fs_ pointer installed. + +The _devname_ field contains the name of the device that this +filesystem is to use. This may match an entry in the device table (see +later) or may be a string that is specific to the filesystem if it has +its own internal device drivers. + +The _data_ field is a private data value. This may be installed either +statically when the table entry is defined, or may be installed during +the _mount_ operation. + +The _valid_ field indicates whether this mount point has actually been +mounted successfully. Entries with a false _valid_ field are ignored +when searching for a name match. + +The _fs_ field is installed after a successful mount operation to +point to the implementing filesystem. + +The _root_ field contains a directory pointer value that the +filesystem can interpret as the root of its directory tree. This is +passed as the _dir_ argument of filesystem functions that operate on +rooted filenames. This field must be initialized by the filesystem's +_mount_ function. + + + +File Table +---------- + +Once a file has been opened it is represented by an open file +object. These are allocated from an array of available file +objects. User code accesses these open file objects via a second array +of pointers which is indexed by small integer offsets. This gives the +usual Unix file descriptor functionality, complete with the various +duplication mechanisms. + +A file table entry has the following structure: + +struct CYG_FILE_TAG +{ + cyg_uint32 f_flag; /* file state */ + cyg_uint16 f_ucount; /* use count */ + cyg_uint16 f_type; /* descriptor type */ + cyg_uint32 f_syncmode; /* synchronization protocol */ + struct CYG_FILEOPS_TAG *f_ops; /* file operations */ + off_t f_offset; /* current offset */ + CYG_ADDRWORD f_data; /* file or socket */ + CYG_ADDRWORD f_xops; /* extra type specific ops */ + cyg_mtab_entry *f_mte; /* mount table entry */ +}; + +The _f_flag_ field contains some FILEIO control bits and some of the +bits from the open call (defined by CYG_FILE_MODE_MASK). + +The _f_ucount_ field contains a use count that controls when a file +will be closed. Each duplicate in the file descriptor array counts for +one reference here and it is also incremented around each I/O +operation. + +The _f_type_ field indicates the type of the underlying file +object. Some of the possible values here are CYG_FILE_TYPE_FILE, +CYG_FILE_TYPE_SOCKET or CYG_FILE_TYPE_DEVICE. + +The _f_syncmode_ field is copied from the _syncmode_ field of the +implementing filesystem. Its use is described in the "Synchronization" +section later. + +The _f_offset_ field records the current file position. It is the +responsibility of the file operation functions to keep this field up +to date. + +The _f_data_ field contains private data placed here by the underlying +filesystem. Normally this will be a pointer or handle on the +filesystem object that implements this file. + +The _f_xops_ field contains a pointer to any extra type specific +operation functions. For example, the socket I/O system installs a +pointer to a table of functions that implement the standard socket +operations. + +The _f_mte_ field contains a pointer to the parent mount table entry +for this file. It is used mainly to implement the synchronization +protocol. This may contain a pointer to some other data structure in +file objects not derived from a filesystem. + +The _f_ops_ field contains a pointer to a table of file I/O +operations. This has the following structure: + +struct CYG_FILEOPS_TAG +{ + int (*fo_read) (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); + int (*fo_write) (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); + int (*fo_lseek) (struct CYG_FILE_TAG *fp, off_t *pos, int whence ); + int (*fo_ioctl) (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com, + CYG_ADDRWORD data); + int (*fo_select) (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info); + int (*fo_fsync) (struct CYG_FILE_TAG *fp, int mode ); + int (*fo_close) (struct CYG_FILE_TAG *fp); + int (*fo_fstat) (struct CYG_FILE_TAG *fp, struct stat *buf ); + int (*fo_getinfo) (struct CYG_FILE_TAG *fp, int key, char *buf, int len ); + int (*fo_setinfo) (struct CYG_FILE_TAG *fp, int key, char *buf, int len ); +}; + +It should be obvious from the names of most of these functions what +their responsibilities are. The _fo_getinfo_ and _fo_setinfo_ +function, like their counterparts in the filesystem structure, +implement minor control and info functions such as fpathconf(). + +The second argument to _fo_read_ and _fo_write_ is a pointer to a UIO +structure: + +struct CYG_UIO_TAG +{ + struct CYG_IOVEC_TAG *uio_iov; /* pointer to array of iovecs */ + int uio_iovcnt; /* number of iovecs in array */ + off_t uio_offset; /* offset into file this uio corresponds to */ + ssize_t uio_resid; /* residual i/o count */ + enum cyg_uio_seg uio_segflg; /* see above */ + enum cyg_uio_rw uio_rw; /* see above */ +}; + +struct CYG_IOVEC_TAG +{ + void *iov_base; /* Base address. */ + ssize_t iov_len; /* Length. */ +}; + +This structure encapsulates the parameters of any data transfer +operation. It provides support for scatter/gather operations and +records the progress of any data transfer. It is also compatible with +the I/O operations of any BSD-derived network stacks and filesystems. + + +When a file is opened (or a file object created by some other means, +such as socket() or accept()) it is the responsibility of the +filesystem open operation to initialize all the fields of the object +except the _f_ucount_, _f_syncmode_ and _f_mte_ fields. Since the +_f_flag_ field will already contain bits belonging to the FILEIO +infrastructure, any changes to it must be made with the appropriate +logical operations. + + +Directories +----------- + +Filesystem operations all take a directory pointer as one of their +arguments. A directory pointer is an opaque handle managed by the +filesystem. It should encapsulate a reference to a specific directory +within the filesystem. For example, it may be a pointer to the data +structure that represents that directory, or a pointer to a pathname +for the directory. + +The _chdir_ filesystem function has two modes of use. When passed a +pointer in the _dir_out_ argument, it should locate the named +directory and place a directory pointer there. If the _dir_out_ +argument is NULL then the _dir_ argument is a previously generated +directory pointer that can now be disposed of. When the infrastructure +is implementing the chdir() function it makes two calls to filesystem +_chdir_ functions. The first is to get a directory pointer for the new +current directory. If this succeeds the second is to dispose of the +old current directory pointer. + +The _opendir_ function is used to open a directory for reading. This +results in an open file object that can be read to return a sequence +of _struct dirent_ objects. The only operation that are allowed on +this file are _read_, _lseek_ and _close_. Each read operation on this +file should return a single _struct dirent_ object. When the end of +the directory is reached, zero should be returned. The only seek +operation allowed is a rewind to the start of the directory, by +supplying an offset of zero and a _whence_ specifier of _SEEK_SET_. + +Most of these considerations are invisible to clients of a filesystem +since they will access directories via the POSIX +opendir()/readdir()/closedir() functions. + + + +Synchronization +--------------- + +The FILEIO infrastructure provides a synchronization mechanism for +controlling concurrent access to filesystems. This allows existing +filesystems to be ported to eCos, even if they do not have their own +synchronization mechanisms. It also allows new filesystems to be +implemented easily without having to consider the synchronization +issues. + +The infrastructure maintains a mutex for each entry in each of +the main tables: filesystem table, mount table and file table. For +each class of operation each of these mutexes may be locked before the +corresponding filesystem operation is invoked. + +The synchronization protocol implemented by a filesystem is described +by the _syncmode_ field of the filesystem table entry. This is a +combination of the following flags: + +CYG_SYNCMODE_FILE_FILESYSTEM Lock the filesystem table entry mutex + during all filesystem level operations. + +CYG_SYNCMODE_FILE_MOUNTPOINT Lock the mount table entry mutex + during all filesystem level operations. + +CYG_SYNCMODE_IO_FILE Lock the file table entry mutex during all + I/O operations. + +CYG_SYNCMODE_IO_FILESYSTEM Lock the filesystem table entry mutex + during all I/O operations. + +CYG_SYNCMODE_IO_MOUNTPOINT Lock the mount table entry mutex during + all I/O operations. + +CYG_SYNCMODE_SOCK_FILE Lock the file table entry mutex during + all socket operations. + +CYG_SYNCMODE_SOCK_NETSTACK Lock the network stack table entry mutex + during all socket operations. + +CYG_SYNCMODE_NONE Perform no locking at all during any + operations. + + +The value of the _syncmode_ in the filesystem table entry will be +copied by the infrastructure to the open file object after a +successful open() operation. + + +Initialization and Mounting +--------------------------- + +As mentioned previously, mount table entries can be sourced from two +places. Static entries may be defined by using the MTAB_ENTRY() +macro. Such entries will be automatically mounted on system startup. +For each entry in the mount table that has a non-null _name_ field the +filesystem table is searched for a match with the _fsname_ field. If a +match is found the filesystem's _mount_ entry is called and if +successful the mount table entry marked valid and the _fs_ field +initialized. The _mount_ function is responsible for initializing the +_root_ field. + +The size of the mount table is defined by the configuration value +CYGNUM_FILEIO_MTAB_MAX. Any entries that have not been statically +defined are available for use by dynamic mounts. + +A filesystem may be mounted dynamically by calling mount(). This +function has the following prototype: + +int mount( const char *devname, + const char *dir, + const char *fsname); + +The _devname_ argument identifies a device that will be used by this +filesystem and will be assigned to the _devname_ field of the mount +table entry. + +The _dir_ argument is the mount point name, it will be assigned to the +_name_ field of the mount table entry. + +The _fsname_ argument is the name of the implementing filesystem, it +will be assigned to the _fsname_ entry of the mount table entry. + +The process of mounting a filesystem dynamically is as follows. First +a search is made of the mount table for an entry with a NULL _name_ +field to be used for the new mount point. The filesystem table is then +searched for an entry whose name matches _fsname_. If this is +successful then the mount table entry is initialized and the +filesystem's _mount_ operation called. If this is successful, the +mount table entry is marked valid and the _fs_ field initialized. + +Unmounting a filesystem is done by the umount() function. This can +unmount filesystems whether they were mounted statically or +dynamically. + +The umount() function has the following prototype: + +int umount( const char *name ); + +The mount table is searched for a match between the _name_ argument +and the entry _name_ field. When a match is found the filesystem's +_umount_ operation is called and if successful, the mount table entry +is invalidated by setting its _valid_ field false and the _name_ field +to NULL. + + [Note: The umount() function could also match on the _devname_ + field when searching. This would be compatible with various + flavors of Unix.] + + [Note: These calls fall outside the scope of any standard. The + mount() function given above is most similar to the Linux + function, with the omission of the rwflag and data arguments. It + remains to be seen whether these need to be introduced.] + +Sockets +------- + +If a network stack is present, then the FILEIO infrastructure also +provides access to the standard BSD socket calls. + +The netstack table contains entries which describe the network +protocol stacks that are in the system image. Each resident stack +should export an entry to this table using the NSTAB_ENTRY() macro. + +Each table entry has the following structure: + +struct cyg_nstab_entry +{ + cyg_bool valid; // true if stack initialized + cyg_uint32 syncmode; // synchronization protocol + char *name; // stack name + char *devname; // hardware device name + CYG_ADDRWORD data; // private data value + + int (*init)( cyg_nstab_entry *nste ); + int (*socket)( cyg_nstab_entry *nste, int domain, int type, + int protocol, cyg_file *file ); +}; + +This table is analogous to the filesystem and mount tables combined. + +The _valid_ field is set true if the stack's _init_ function returned +successfully and the _syncmode_ field contains the CYG_SYNCMODE_SOCK_* +bits described above. + + [Note: Currently there are no plans to support the dynamic loading + of network protocol stacks.] + +The _name_ field contains the name of the protocol stack. + + [Note: This field is currently unused, but may be used in the + future to allow direct access to a specific stack via an as-yet + unspecified API.] + +The _devname_ field names the device that the stack is using. This may +reference a device under "/dev", or may be a name that is only +meaningful to the stack itself. + + [Note: Many network protocol stacks may have several concurrent + devices, and have their own mechanisms for attaching to them, so + it is not clear that this field is actually very useful.] + +The _init_ function is called during system initialization to start +the protocol stack running. If it returns non-zero the _valid_ field +is set false and the stack will be ignored subsequently. + +The _socket_ function is called to attempt to create a socket in the +stack. When the socket() API function is called the netstack table is +scanned and for each valid entry the _socket_ function is called. If +this returns non-zero then the scan continues to the next valid stack, +or terminates with an error if the end of the table is reached. + +The result of a successful socket call is an initialized file object +with the _f_xops_ field pointing to the following structure: + +struct cyg_sock_ops +{ + int (*bind) ( cyg_file *fp, const sockaddr *sa, socklen_t len ); + int (*connect) ( cyg_file *fp, const sockaddr *sa, socklen_t len ); + int (*accept) ( cyg_file *fp, cyg_file *new_fp, + struct sockaddr *name, socklen_t *anamelen ); + int (*listen) ( cyg_file *fp, int len ); + int (*getname) ( cyg_file *fp, sockaddr *sa, socklen_t *len, int peer ); + int (*shutdown) ( cyg_file *fp, int flags ); + int (*getsockopt)( cyg_file *fp, int level, int optname, + void *optval, socklen_t *optlen); + int (*setsockopt)( cyg_file *fp, int level, int optname, + const void *optval, socklen_t optlen); + int (*sendmsg) ( cyg_file *fp, const struct msghdr *m, + int flags, ssize_t *retsize ); + int (*recvmsg) ( cyg_file *fp, struct msghdr *m, + socklen_t *namelen, ssize_t *retsize ); +}; + +It should be obvious from the names of these functions which API calls +they provide support for. The _getname_ function provides support for +both getsockname() and getpeername() while the _sendmsg_ and _recvmsg_ +functions provide support for send(), sendto(), sendmsg(), recv(), +recvfrom() and recvmsg() as appropriate. + + + +Select +------ + +The infrastructure provides support for implementing a select +mechanism. This is modeled on the mechanism in the BSD kernel, but has +been modified to make it implementation independent. + +The main part of the mechanism is the select() API call. This +processes its arguments and calls the _fo_select_ function on all file +objects referenced by the file descriptor sets passed to it. If the +same descriptor appears in more than one descriptor set, the +_fo_select_ function will be called for each appearance. + +The _which_ argument of the _fo_select_ function will either be +CYG_FREAD to test for read conditions, CYG_FWRITE to test for write +conditions or zero to test for exceptions. For each of these options +the function should test whether the condition is satisfied and if so +return true. If it is not satisfied then it should call +cyg_selrecord() with the _info_ argument that was passed to the +function and a pointer to a cyg_selinfo structure. + +The cyg_selinfo structure is used to record information about current +select operations. Any object that needs to support select must +contain an instance of this structure. Separate cyg_selinfo +structures should be kept for each of the options that the object can +select on - read, write or exception. + +If none of the file objects report that the select condition is +satisfied, then the select() API function puts the calling thread to +sleep waiting either for a condition to become satisfied, or for the +optional timeout to expire. + +A selectable object must have some asynchronous activity that may +cause a select condition to become true - either via interrupts or the +activities of other threads. Whenever a selectable condition is +satisfied, the object should call cyg_selwakeup() with a pointer to +the appropriate cyg_selinfo structure. If the thread is still waiting, +this will cause it to wake up and return from the select() function. + + +Devices +------- + +Devices are accessed by means of a pseudo-filesystem, "devfs", that is +mounted on "/dev". Open operations are translated into calls to +cyg_io_lookup() and if successful result in a file object whose +_f_ops_ functions translate filesystem API functions into calls into +the device API. + +// EOF fileio.txt diff --git a/packages/io/fileio/current/include/dirent.h b/packages/io/fileio/current/include/dirent.h new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/include/dirent.h @@ -0,0 +1,82 @@ +#ifndef CYGONCE_FILEIO_DIRENT_H +#define CYGONCE_FILEIO_DIRENT_H +/*======================================================================== +// +// dirent.h +// +// POSIX directory functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: +// Date: 2000-06-26 +// Purpose: This file provides the macros, types and functions +// for directory operations required by POSIX 1003.1. +// Description: Implementations of the types needed for directory +// reading. +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +#include + +#include +#include + +//====================================================================== + +#ifdef __cplusplus +extern "C" { +#endif + +//====================================================================== +// dirent structure. + +struct dirent +{ + char d_name[NAME_MAX+1]; +}; + +//====================================================================== +// DIR pointer object. + +typedef void *DIR; + +//====================================================================== + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +//====================================================================== +#endif /* CYGONCE_FILEIO_DIRENT_H multiple inclusion protection */ +/* EOF dirent.h */ diff --git a/packages/io/fileio/current/include/fileio.h b/packages/io/fileio/current/include/fileio.h new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/include/fileio.h @@ -0,0 +1,410 @@ +#ifndef CYGONCE_FILEIO_H +#define CYGONCE_FILEIO_H +//============================================================================= +// +// fileio.h +// +// Fileio header +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Fileio header +// Description: This header contains the external definitions of the general file +// IO subsystem for POSIX and EL/IX compatability. +// +// Usage: +// #include +// ... +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include +#include +#include + +#include +#include + +#include // NULL, size_t +#include +#include +#include +#include + +//============================================================================= +// forward definitions + +struct cyg_mtab_entry; +typedef struct cyg_mtab_entry cyg_mtab_entry; + +struct cyg_fstab_entry; +typedef struct cyg_fstab_entry cyg_fstab_entry; + +struct CYG_FILEOPS_TAG; +typedef struct CYG_FILEOPS_TAG cyg_fileops; + +struct CYG_FILE_TAG; +typedef struct CYG_FILE_TAG cyg_file; + +struct CYG_IOVEC_TAG; +typedef struct CYG_IOVEC_TAG cyg_iovec; + +struct CYG_UIO_TAG; +typedef struct CYG_UIO_TAG cyg_uio; + +struct CYG_SELINFO_TAG; +typedef struct CYG_SELINFO_TAG cyg_selinfo; + +//============================================================================= +// Directory pointer + +typedef CYG_ADDRWORD cyg_dir; + +#define CYG_DIR_NULL 0 + +//============================================================================= +// Filesystem table entry + +typedef int cyg_fsop_mount ( cyg_fstab_entry *fste, cyg_mtab_entry *mte ); +typedef int cyg_fsop_umount ( cyg_mtab_entry *mte ); +typedef int cyg_fsop_open ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int mode, cyg_file *fte ); +typedef int cyg_fsop_unlink ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +typedef int cyg_fsop_mkdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +typedef int cyg_fsop_rmdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +typedef int cyg_fsop_rename ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2 ); +typedef int cyg_fsop_link ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2, int type ); +typedef int cyg_fsop_opendir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_file *fte ); +typedef int cyg_fsop_chdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_dir *dir_out ); +typedef int cyg_fsop_stat ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + struct stat *buf); +typedef int cyg_fsop_getinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ); +typedef int cyg_fsop_setinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ); + + +struct cyg_fstab_entry +{ + const char *name; // filesystem name + CYG_ADDRWORD data; // private data value + cyg_uint32 syncmode; // synchronization mode + + cyg_fsop_mount *mount; + cyg_fsop_umount *umount; + cyg_fsop_open *open; + cyg_fsop_unlink *unlink; + cyg_fsop_mkdir *mkdir; + cyg_fsop_rmdir *rmdir; + cyg_fsop_rename *rename; + cyg_fsop_link *link; + cyg_fsop_opendir *opendir; + cyg_fsop_chdir *chdir; + cyg_fsop_stat *stat; + cyg_fsop_getinfo *getinfo; + cyg_fsop_setinfo *setinfo; +}; + +//----------------------------------------------------------------------------- +// Keys for getinfo() and setinfo() + +#define FS_INFO_CONF 1 /* pathconf() */ +#define FS_INFO_ACCESS 2 /* access() */ + +//----------------------------------------------------------------------------- +// Types for link() + +#define CYG_FSLINK_HARD 1 /* form a hard link */ +#define CYG_FSLINK_SOFT 2 /* form a soft link */ + +//----------------------------------------------------------------------------- +// Macro to define an initialized fstab entry + +#define FSTAB_ENTRY( _l, _name, _data, _syncmode, _mount, _umount, \ + _open, _unlink, _mkdir, _rmdir, _rename, _link, \ + _opendir, _chdir, _stat, _getinfo, _setinfo) \ +struct cyg_fstab_entry _l CYG_HAL_TABLE_ENTRY( fstab ) = \ +{ \ + _name, \ + _data, \ + _syncmode, \ + _mount, \ + _umount, \ + _open, \ + _unlink, \ + _mkdir, \ + _rmdir, \ + _rename, \ + _link, \ + _opendir, \ + _chdir, \ + _stat, \ + _getinfo, \ + _setinfo \ +}; + +//============================================================================= +// Mount table entry + +struct cyg_mtab_entry +{ + const char *name; // name of mount point + const char *fsname; // name of implementing filesystem + const char *devname; // name of hardware device + CYG_ADDRWORD data; // private data value + + // The following are filled in after a successful mount operation + cyg_bool valid; // Valid entry? + cyg_fstab_entry *fs; // pointer to fstab entry + cyg_dir root; // root directory pointer +}; + + +// This macro defines an initialized mtab entry + +#define MTAB_ENTRY( _l, _name, _fsname, _devname, _data ) \ +struct cyg_mtab_entry _l CYG_HAL_TABLE_ENTRY( mtab ) = \ +{ \ + _name, \ + _fsname, \ + _devname, \ + _data, \ + false, \ + NULL, \ + CYG_DIR_NULL \ +}; + +//============================================================================= +// IO vector descriptors + +struct CYG_IOVEC_TAG +{ + void *iov_base; /* Base address. */ + ssize_t iov_len; /* Length. */ +}; + +enum cyg_uio_rw { UIO_READ, UIO_WRITE }; + +/* Segment flag values. */ +enum cyg_uio_seg +{ + UIO_USERSPACE, /* from user data space */ + UIO_SYSSPACE /* from system space */ +}; + +struct CYG_UIO_TAG +{ + struct CYG_IOVEC_TAG *uio_iov; /* pointer to array of iovecs */ + int uio_iovcnt; /* number of iovecs in array */ + off_t uio_offset; /* offset into file this uio corresponds to */ + ssize_t uio_resid; /* residual i/o count */ + enum cyg_uio_seg uio_segflg; /* see above */ + enum cyg_uio_rw uio_rw; /* see above */ +}; + +// Limits +#define UIO_SMALLIOV 8 /* 8 on stack, else malloc */ + +//============================================================================= +// Description of open file + +typedef int cyg_fileop_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +typedef int cyg_fileop_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +typedef int cyg_fileop_lseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence ); +typedef int cyg_fileop_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com, + CYG_ADDRWORD data); +typedef int cyg_fileop_select (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info); +typedef int cyg_fileop_fsync (struct CYG_FILE_TAG *fp, int mode ); +typedef int cyg_fileop_close (struct CYG_FILE_TAG *fp); +typedef int cyg_fileop_fstat (struct CYG_FILE_TAG *fp, struct stat *buf ); +typedef int cyg_fileop_getinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ); +typedef int cyg_fileop_setinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ); + +struct CYG_FILEOPS_TAG +{ + cyg_fileop_read *fo_read; + cyg_fileop_write *fo_write; + cyg_fileop_lseek *fo_lseek; + cyg_fileop_ioctl *fo_ioctl; + cyg_fileop_select *fo_select; + cyg_fileop_fsync *fo_fsync; + cyg_fileop_close *fo_close; + cyg_fileop_fstat *fo_fstat; + cyg_fileop_getinfo *fo_getinfo; + cyg_fileop_setinfo *fo_setinfo; +}; + +struct CYG_FILE_TAG +{ + cyg_uint32 f_flag; /* file state */ + cyg_uint16 f_ucount; /* use count */ + cyg_uint16 f_type; /* descriptor type */ + cyg_uint32 f_syncmode; /* synchronization protocol */ + struct CYG_FILEOPS_TAG *f_ops; /* file operations */ + off_t f_offset; /* current offset */ + CYG_ADDRWORD f_data; /* file or socket */ + CYG_ADDRWORD f_xops; /* extra type specific ops */ + cyg_mtab_entry *f_mte; /* mount table entry */ +}; + +//----------------------------------------------------------------------------- +// File flags + +// Allocation here is that bits 0..15 are copies of bits from the open +// flags, bits 16..23 are extra bits that are visible to filesystems but +// are not derived from the open call, and bits 24..31 are reserved for +// the fileio infrastructure. +#define CYG_FREAD O_RDONLY +#define CYG_FWRITE O_WRONLY +#define CYG_FNONBLOCK O_NONBLOCK +#define CYG_FAPPEND O_APPEND +#define CYG_FASYNC 0x00010000 +#define CYG_FDIR 0x00020000 + +#define CYG_FLOCKED 0x01000000 // Set if file is locked +#define CYG_FLOCK 0x02000000 // Lock during file ops +#define CYG_FALLOC 0x80000000 // File is "busy", i.e. allocated + +// Mask for open mode bits stored in file object +#define CYG_FILE_MODE_MASK (CYG_FREAD|CYG_FWRITE|CYG_FNONBLOCK|CYG_FAPPEND) + +//----------------------------------------------------------------------------- +// Type of file + +#define CYG_FILE_TYPE_FILE 1 /* file */ +#define CYG_FILE_TYPE_SOCKET 2 /* communications endpoint */ +#define CYG_FILE_TYPE_DEVICE 3 /* device */ + +//----------------------------------------------------------------------------- +// Keys for getinf() and setinfo() + +#define FILE_INFO_CONF 1 /* fpathconf() */ + +//----------------------------------------------------------------------------- +// Modes for fsync() + +#define CYG_FSYNC 1 +#define CYG_FDATASYNC 2 + +//----------------------------------------------------------------------------- +// Get/set info buffer structures + +// This is used for pathconf() and fpathconf() +struct cyg_pathconf_info +{ + int name; // POSIX defined variable name + long value; // Returned variable value +}; + +//============================================================================= +// Synchronization modes +// These values are filled into the syncmode fields of the above structures +// and define the synchronization protocol used when accessing the object in +// question. + +#define CYG_SYNCMODE_NONE (0) // no locking required + +#define CYG_SYNCMODE_FILE_FILESYSTEM 0x0002 // lock fs during file ops +#define CYG_SYNCMODE_FILE_MOUNTPOINT 0x0004 // lock mte during file ops +#define CYG_SYNCMODE_IO_FILE 0x0010 // lock file during io ops +#define CYG_SYNCMODE_IO_FILESYSTEM 0x0020 // lock fs during io ops +#define CYG_SYNCMODE_IO_MOUNTPOINT 0x0040 // lock mte during io ops +#define CYG_SYNCMODE_SOCK_FILE 0x0100 // lock socket during socket ops +#define CYG_SYNCMODE_SOCK_NETSTACK 0x0800 // lock netstack during socket ops + +#define CYG_SYNCMODE_IO_SHIFT (4) // shift for IO to file bits +#define CYG_SYNCMODE_SOCK_SHIFT (8) // shift for sock to file bits + +//============================================================================= +// Mount and umount functions + +__externC int mount( const char *devname, + const char *dir, + const char *fsname); + +__externC int umount( const char *name); + +//============================================================================= +// Select support + +//----------------------------------------------------------------------------- +// Data structure for embedding in client data structures. A pointer to this +// must be passed to cyg_selrecord() and cyg_selwakeup(). + +struct CYG_SELINFO_TAG +{ + CYG_ADDRWORD si_info; // info passed through from fo_select() + CYG_ADDRESS si_thread; // selecting thread pointer +}; + +//----------------------------------------------------------------------------- +// Select support functions. + +// cyg_selinit() is used to initialize a selinfo structure. +__externC void cyg_selinit( struct CYG_SELINFO_TAG *sip ); + +// cyg_selrecord() is called when a client device needs to register +// the current thread for selection. +__externC void cyg_selrecord( CYG_ADDRWORD info, struct CYG_SELINFO_TAG *sip ); + +// cyg_selwakeup() is called when the client device matches the select +// criterion, and needs to wake up a selector. +__externC void cyg_selwakeup( struct CYG_SELINFO_TAG *sip ); + +//============================================================================= +// Timestamp support + +// Provides the current time as a time_t timestamp for use in filesystem +// data strucures. + +__externC time_t cyg_timestamp(void); + +//============================================================================= +// Default functions. +// Cast to the appropriate type, these functions can be put into any of +// the operation table slots to provide the defined error code. + +__externC int cyg_fileio_enosys(void); +__externC int cyg_fileio_erofs(void); +__externC int cyg_fileio_enoerr(void); +__externC int cyg_fileio_enotdir(void); +__externC cyg_fileop_select cyg_fileio_seltrue; + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_FILEIO_H +// End of fileio.h diff --git a/packages/io/fileio/current/include/sockio.h b/packages/io/fileio/current/include/sockio.h new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/include/sockio.h @@ -0,0 +1,136 @@ +#ifndef CYGONCE_SOCKIO_H +#define CYGONCE_SOCKIO_H +//============================================================================= +// +// sockio.h +// +// Socket IO header +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Socket IO header +// Description: This header contains the external definitions of the general +// socket IO subsystem for POSIX and EL/IX compatability. +// +// Usage: +// #include +// ... +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include +#include +#include + +#include + +#include // NULL, size_t +#include +#include + +#include + +//============================================================================= +// Forward definitions + +struct cyg_nstab_entry; +typedef struct cyg_nstab_entry cyg_nstab_entry; + +struct cyg_sock_ops; +typedef struct cyg_sock_ops cyg_sock_ops; + +struct sockaddr; +typedef struct sockaddr sockaddr; + +struct msghdr; +typedef struct msghdr msghdr; + +#ifndef CYGPKG_NET + +typedef cyg_uint32 socklen_t; /* length type for network syscalls */ + +#endif + +//============================================================================= +// network stack entry + +struct cyg_nstab_entry +{ + cyg_bool valid; // true if stack initialized + cyg_uint32 syncmode; // synchronization protocol + char *name; // stack name + char *devname; // hardware device name + CYG_ADDRWORD data; // private data value + + int (*init)( cyg_nstab_entry *nste ); + int (*socket)( cyg_nstab_entry *nste, int domain, int type, + int protocol, cyg_file *file ); +}; + +#define NSTAB_ENTRY( _l, _syncmode, _name, _devname, _data, _init, _socket ) \ +struct cyg_nstab_entry _l CYG_HAL_TABLE_ENTRY(nstab) = \ +{ \ + false, \ + _syncmode, \ + _name, \ + _devname, \ + _data, \ + _init, \ + _socket \ +}; + +//============================================================================= + +struct cyg_sock_ops +{ + int (*bind) ( cyg_file *fp, const sockaddr *sa, socklen_t len ); + int (*connect) ( cyg_file *fp, const sockaddr *sa, socklen_t len ); + int (*accept) ( cyg_file *fp, cyg_file *new_fp, + struct sockaddr *name, socklen_t *anamelen ); + int (*listen) ( cyg_file *fp, int len ); + int (*getname) ( cyg_file *fp, sockaddr *sa, socklen_t *len, int peer ); + int (*shutdown) ( cyg_file *fp, int flags ); + int (*getsockopt)( cyg_file *fp, int level, int optname, + void *optval, socklen_t *optlen); + int (*setsockopt)( cyg_file *fp, int level, int optname, + const void *optval, socklen_t optlen); + int (*sendmsg) ( cyg_file *fp, const struct msghdr *m, + int flags, ssize_t *retsize ); + int (*recvmsg) ( cyg_file *fp, struct msghdr *m, + socklen_t *namelen, ssize_t *retsize ); +}; + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_SOCKIO_H +// End of sockio.h diff --git a/packages/io/fileio/current/src/devfs.cxx b/packages/io/fileio/current/src/devfs.cxx new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/src/devfs.cxx @@ -0,0 +1,470 @@ +//========================================================================== +// +// devfs.cxx +// +// Fileio device filesystem +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Fileio device filesystem +// Description: This file implements a simple filesystem that interfaces +// to the existing device IO subsystem. +// +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include "fio.h" // Private header + +#include // device subsystem +#include // CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN + +//========================================================================== +// Forward definitions + +// Filesystem operations +static int dev_mount ( cyg_fstab_entry *fste, cyg_mtab_entry *mte ); +static int dev_umount ( cyg_mtab_entry *mte ); +static int dev_open ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int mode, cyg_file *fte ); +static int dev_unlink ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +static int dev_mkdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +static int dev_rmdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +static int dev_rename ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2 ); +static int dev_link ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2, int type ); +static int dev_opendir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_file *fte ); +static int dev_chdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_dir *dir_out ); +static int dev_stat ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + struct stat *buf); +static int dev_getinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ); +static int dev_setinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ); + +// File operations +static int dev_fo_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +static int dev_fo_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +static int dev_fo_lseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence ); +static int dev_fo_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com, + CYG_ADDRWORD data); +static int dev_fo_select (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info); +static int dev_fo_fsync (struct CYG_FILE_TAG *fp, int mode ); +static int dev_fo_close (struct CYG_FILE_TAG *fp); +static int dev_fo_fstat (struct CYG_FILE_TAG *fp, struct stat *buf ); +static int dev_fo_getinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ); +static int dev_fo_setinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ); + + +//========================================================================== +// Filesystem table entries + +FSTAB_ENTRY( dev_fste, "devfs", 0, + CYG_SYNCMODE_NONE, // dev system has its own sync mechanism + dev_mount, + dev_umount, + dev_open, + dev_unlink, + dev_mkdir, + dev_rmdir, + dev_rename, + dev_link, + dev_opendir, + dev_chdir, + dev_stat, + dev_getinfo, + dev_setinfo); + +MTAB_ENTRY( dev_mte, + "/dev", + "devfs", + "", + 0); + +static cyg_fileops dev_fileops = +{ + dev_fo_read, + dev_fo_write, + dev_fo_lseek, + dev_fo_ioctl, + dev_fo_select, + dev_fo_fsync, + dev_fo_close, + dev_fo_fstat, + dev_fo_getinfo, + dev_fo_setinfo +}; + +//========================================================================== +// Filesystem operations + +// ------------------------------------------------------------------------- + +static int dev_mount ( cyg_fstab_entry *fste, cyg_mtab_entry *mte ) +{ + // Nothing to do here. The device IO subsystem has already initialized + // iteslf, and the fileio infrastructure will do the rest. + + return 0; +} + +// ------------------------------------------------------------------------- + +static int dev_umount ( cyg_mtab_entry *mte ) +{ + // Nothing to do here. + + return 0; +} + +// ------------------------------------------------------------------------- + +static int dev_open ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int mode, cyg_file *file ) +{ + Cyg_ErrNo err; + cyg_io_handle_t handle; + + // The name we are passed will point to the first character after + // "/dev/". We know that the full string contains the prefix string, + // so we back the pointer up by 5 chars. + // A better approach would be for the device table entries to only + // contain the part of the string after the prefix. + + name -= 5; + + err = cyg_io_lookup( name, &handle ); + + if( err < 0 ) + return -err; + + // If we want non-blocking mode, configure the device for it. + if( (mode & (O_NONBLOCK|O_RDONLY)) == (O_NONBLOCK|O_RDONLY) ) + { + cyg_uint32 f = 0; + cyg_uint32 fsize = sizeof(f); + err = cyg_io_set_config( handle, CYG_IO_SET_CONFIG_READ_BLOCKING, + (void *)&f, &fsize); + if( err < 0 ) + return -err; + } + + if( (mode & (O_NONBLOCK|O_WRONLY)) == (O_NONBLOCK|O_WRONLY) ) + { + cyg_uint32 f = 0; + cyg_uint32 fsize = sizeof(f); + err = cyg_io_set_config( handle, CYG_IO_SET_CONFIG_WRITE_BLOCKING, + (void *)&f, &fsize); + if( err < 0 ) + return -err; + } + + // Initialize the file object + + file->f_flag |= mode & CYG_FILE_MODE_MASK; + file->f_type = CYG_FILE_TYPE_FILE; + file->f_ops = &dev_fileops; + file->f_offset = 0; + file->f_data = (CYG_ADDRWORD)handle; + file->f_xops = 0; + + return 0; +} + +// ------------------------------------------------------------------------- + +static int dev_unlink ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ) +{ + return EROFS; +} + +// ------------------------------------------------------------------------- + +static int dev_mkdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ) +{ + return EROFS; +} + +// ------------------------------------------------------------------------- + +static int dev_rmdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ) +{ + return EROFS; +} + +// ------------------------------------------------------------------------- + +static int dev_rename ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2 ) +{ + return EROFS; +} + +// ------------------------------------------------------------------------- + +static int dev_link ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2, int type ) +{ + return EROFS; +} + +// ------------------------------------------------------------------------- + +static int dev_opendir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_file *fte ) +{ + return ENOTDIR; +} + +// ------------------------------------------------------------------------- + +static int dev_chdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_dir *dir_out ) +{ + return ENOTDIR; +} + +// ------------------------------------------------------------------------- + +static int dev_stat ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + struct stat *buf) +{ + Cyg_ErrNo err; + cyg_io_handle_t handle; + + name -= 5; // See comment in dev_open() + + err = cyg_io_lookup( name, &handle ); + + if( err < 0 ) + return -err; + + // Just fill in the stat buffer with some constant values. + + // FIXME: change this when block devices are available + buf->st_mode = __stat_mode_CHR; + + buf->st_ino = (ino_t)handle; // map dev handle to inode + buf->st_dev = (dev_t)handle; // same with dev id + buf->st_nlink = 0; + buf->st_uid = 0; + buf->st_gid = 0; + buf->st_size = 0; + buf->st_atime = 0; + buf->st_mtime = 0; + buf->st_ctime = 0; + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int dev_getinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ) +{ + return ENOSYS; +} + +// ------------------------------------------------------------------------- + +static int dev_setinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ) +{ + return ENOSYS; +} + +//========================================================================== +// File operations + + +// ------------------------------------------------------------------------- + +static int dev_fo_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio) +{ + Cyg_ErrNo err = 0; + int i; + + // Now loop over the iovecs until they are all done, or + // we get an error. + for( i = 0; i < uio->uio_iovcnt; i++ ) + { + cyg_iovec *iov = &uio->uio_iov[i]; + cyg_uint32 len = iov->iov_len; + + err = cyg_io_read( (cyg_io_handle_t)fp->f_data, + iov->iov_base, + &len); + + if( err < 0 ) break; + + uio->uio_resid -= len; + } + + return -err; +} + +// ------------------------------------------------------------------------- + +static int dev_fo_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio) +{ + Cyg_ErrNo err = 0; + int i; + + // Now loop over the iovecs until they are all done, or + // we get an error. + for( i = 0; i < uio->uio_iovcnt; i++ ) + { + cyg_iovec *iov = &uio->uio_iov[i]; + cyg_uint32 len = iov->iov_len; + + err = cyg_io_write( (cyg_io_handle_t)fp->f_data, + iov->iov_base, + &len); + + if( err < 0 ) break; + + uio->uio_resid -= len; + } + + return -err; +} + +// ------------------------------------------------------------------------- + +static int dev_fo_lseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence ) +{ + // All current devices have no notion of position. Just return zero + // as the new position. + + *pos = 0; + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int dev_fo_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com, + CYG_ADDRWORD data) +{ + return ENOSYS; +} + +// ------------------------------------------------------------------------- + +static cyg_bool dev_fo_select (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info) +{ + return cyg_io_select( (cyg_io_handle_t)fp->f_data, + which, + info); +} + +// ------------------------------------------------------------------------- + +static int dev_fo_fsync (struct CYG_FILE_TAG *fp, int mode ) +{ + Cyg_ErrNo err; + + err = cyg_io_get_config((cyg_io_handle_t)fp->f_data, + CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN, + NULL, NULL); + + return -err; +} + +// ------------------------------------------------------------------------- + +static int dev_fo_close (struct CYG_FILE_TAG *fp) +{ + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int dev_fo_fstat (struct CYG_FILE_TAG *fp, struct stat *buf ) +{ + // Just fill in the stat buffer with some constant values. + + // FIXME: change this when block devices are available + buf->st_mode = __stat_mode_CHR; + + buf->st_ino = (ino_t)fp->f_data; // map dev handle to inode + buf->st_dev = (dev_t)fp->f_data; // same with dev id + buf->st_nlink = 0; + buf->st_uid = 0; + buf->st_gid = 0; + buf->st_size = 0; + buf->st_atime = 0; + buf->st_mtime = 0; + buf->st_ctime = 0; + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int dev_fo_getinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ) +{ + Cyg_ErrNo err = 0; + cyg_uint32 ll = len; + + err = cyg_io_get_config( (cyg_io_handle_t)fp->f_data, key, buf, &ll ); + + return -err; +} + +// ------------------------------------------------------------------------- + +static int dev_fo_setinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ) +{ + Cyg_ErrNo err = 0; + cyg_uint32 ll = len; + + err = cyg_io_set_config( (cyg_io_handle_t)fp->f_data, key, buf, &ll ); + + return -err; +} + +// ------------------------------------------------------------------------- +// EOF devfs.cxx diff --git a/packages/io/fileio/current/src/dir.cxx b/packages/io/fileio/current/src/dir.cxx new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/src/dir.cxx @@ -0,0 +1,211 @@ +//========================================================================== +// +// dir.cxx +// +// Fileio directory support +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Fileio directory support +// Description: Support for directory operations. +// +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include // for fcntl() + +#include "fio.h" // Private header + +#include // struct dirent + +//========================================================================== + +#define DIROPEN_RETURN_ERR( err ) \ +CYG_MACRO_START \ + errno = err; \ + CYG_REPORT_RETVAL( NULL ); \ + return NULL; \ +CYG_MACRO_END + +//========================================================================== +// Implement filesystem locking protocol. + +#define LOCK_FS( _mte_ ) cyg_fs_lock( _mte_, (_mte_)->fs->syncmode) + +#define UNLOCK_FS( _mte_ ) cyg_fs_unlock( _mte_, (_mte_)->fs->syncmode) + +//========================================================================== +// Open a directory for reading + +extern DIR *opendir( const char *dirname ) +{ + FILEIO_ENTRY(); + + CYG_CANCELLATION_POINT; + + int ret = 0; + int fd; + cyg_file *file; + cyg_mtab_entry *mte = cdir_mtab_entry; + cyg_dir dir = cdir_dir; + const char *name = dirname; + + fd = cyg_fd_alloc(1); // Never return fd 0 + + if( fd < 0 ) + DIROPEN_RETURN_ERR(EMFILE); + + file = cyg_file_alloc(); + + if( file == NULL ) + { + cyg_fd_free(fd); + DIROPEN_RETURN_ERR(ENFILE); + } + + ret = cyg_mtab_lookup( &dir, &name, &mte ); + + if( 0 != ret ) + { + cyg_fd_free(fd); + cyg_file_free(file); + DIROPEN_RETURN_ERR(ENOENT); + } + + LOCK_FS( mte ); + + ret = mte->fs->opendir( mte, dir, name, file ); + + UNLOCK_FS( mte ); + + if( 0 != ret ) + { + cyg_fd_free(fd); + cyg_file_free(file); + DIROPEN_RETURN_ERR(ret); + } + + file->f_flag |= CYG_FDIR|CYG_FREAD; + file->f_mte = mte; + file->f_syncmode = mte->fs->syncmode; + + cyg_fd_assign( fd, file ); + + DIR *dirp = (DIR *)fd; + + FILEIO_RETURN_VALUE(dirp); +} + +//========================================================================== +// Read a directory entry. +// This is the thread-unsafe version that uses a static result buffer. +// It just calls the thread-safe version to do the work. + +extern struct dirent *readdir( DIR *dirp ) +{ + FILEIO_ENTRY(); + + static struct dirent ent; + struct dirent *result; + int err; + + err = readdir_r( dirp, &ent, &result ); + + if( err != 0 ) + { + errno = err; + FILEIO_RETURN_VALUE( NULL ); + } + + return result; +} + +//========================================================================== + +extern int readdir_r( DIR *dirp, struct dirent *entry, struct dirent **result ) +{ + FILEIO_ENTRY(); + + int fd = (int)dirp; + ssize_t res; + + *result = NULL; + + res = read( fd, (void *)entry, sizeof(struct dirent)); + + if( res < 0 ) + return errno; + + if( res > 0 ) + *result = entry; + + FILEIO_RETURN( ENOERR ); +} + +//========================================================================== + +extern void rewinddir( DIR *dirp ) +{ + FILEIO_ENTRY(); + + int fd = (int)dirp; + + lseek( fd, 0, SEEK_SET ); + + FILEIO_RETURN_VOID(); +} + +//========================================================================== + +extern int closedir( DIR *dirp ) +{ + FILEIO_ENTRY(); + + int fd = (int)dirp; + int err = close( fd ); + + FILEIO_RETURN_VALUE( err ); +} + +// ------------------------------------------------------------------------- +// EOF dir.cxx diff --git a/packages/io/fileio/current/src/fd.cxx b/packages/io/fileio/current/src/fd.cxx new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/src/fd.cxx @@ -0,0 +1,373 @@ +//========================================================================== +// +// fd.cxx +// +// Fileio file descriptor implementation +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Fileio file descriptor implementation +// Description: This file contains the implementation of the file +// descriptor functions. +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include "fio.h" // Private header + +#include // mutex definitions + +//----------------------------------------------------------------------------- +// File data structures + +// Mutex for controlling access to file desriptor arrays +Cyg_Mutex fdlock; + +// Array of open file objects +static cyg_file file[CYGNUM_FILEIO_NFILE]; + +// Array of per-file mutexes +static Cyg_Mutex file_lock[CYGNUM_FILEIO_NFILE]; + +// Descriptor array +static cyg_file *desc[CYGNUM_FILEIO_NFD]; + +#define FD_ALLOCATED ((cyg_file *)1) + +//========================================================================== +// Initialization + +__externC void cyg_fd_init() +{ + int i; + + for( i = 0; i < CYGNUM_FILEIO_NFILE; i++ ) + file[i].f_flag = 0; + + for( i = 0; i < CYGNUM_FILEIO_NFD; i++ ) + desc[i] = NULL; +} + +//========================================================================== +// File object allocation + +//-------------------------------------------------------------------------- +// Locate and allocate a free file object. + +__externC cyg_file *cyg_file_alloc() +{ + int i; + cyg_file *fp = NULL; + + fdlock.lock(); + + for( i = 0; i < CYGNUM_FILEIO_NFILE; i++ ) + { + if( (file[i].f_flag & CYG_FALLOC) == 0 ) + { + fp = &file[i]; + fp->f_flag = CYG_FALLOC; + fp->f_ucount = 0; + break; + } + } + + fdlock.unlock(); + + return fp; +} + +//-------------------------------------------------------------------------- +// Free a file object. This is a straightforward freeing, usually used +// during error recovery. File objects are normally freed as a side +// effect of cyg_fd_assign() or cyg_fd_free(). + +__externC void cyg_file_free(cyg_file * fp) +{ + fdlock.lock(); + + fp->f_flag = 0; + + fdlock.unlock(); +} + +//========================================================================== +// Internal routines for handling descriptor deallocation +// These must all be called with the fdlock already locked. + +//-------------------------------------------------------------------------- +// Decrement the use count on a file object and if it goes to zero, +// close the file and deallocate the file object. + +static int fp_ucount_dec( cyg_file *fp ) +{ + int error = 0; + if( (--fp->f_ucount) <= 0 ) + { + cyg_file_lock( fp, fp->f_syncmode ); + + error = fp->f_ops->fo_close(fp); + + cyg_file_unlock( fp, fp->f_syncmode ); + + if( error == 0 ) + fp->f_flag = 0; + } + + return error; +} + +//-------------------------------------------------------------------------- +// Clear out a descriptor. If this is the last reference to the file +// object, then that will be closed and deallocated. + +static int fd_close( int fd ) +{ + int error = 0; + cyg_file *fp = desc[fd]; + + if( fp != FD_ALLOCATED && fp != NULL) + { + // The descriptor is occupied, decrement its usecount and + // close the file if it goes zero. + + error = fp_ucount_dec( fp ); + } + + desc[fd] = FD_ALLOCATED; + + return error; +} + + +//========================================================================== +// File descriptor allocation + +//-------------------------------------------------------------------------- +// Allocate a file descriptor. The allocated descriptor is set to the value +// FD_ALLOCATED to prevent it being reallocated by another thread. + +__externC int cyg_fd_alloc(int low) +{ + int fd; + + fdlock.lock(); + + for( fd = low; fd < CYGNUM_FILEIO_NFD; fd++ ) + { + if( desc[fd] == NULL ) + { + desc[fd] = FD_ALLOCATED; + fdlock.unlock(); + return fd; + } + } + + fdlock.unlock(); + + return -1; +} + +//-------------------------------------------------------------------------- +// Assign a file object to a descriptor. If the descriptor is already +// occupied, the occupying files usecount is decrement and it may be +// closed. + +__externC void cyg_fd_assign(int fd, cyg_file *fp) +{ + fdlock.lock(); + + fd_close( fd ); + + fp->f_ucount++; + desc[fd] = fp; + + fdlock.unlock(); +} + +//-------------------------------------------------------------------------- +// Free a descriptor. Any occupying files usecount is decremented and +// it may be closed. + +__externC int cyg_fd_free(int fd) +{ + int error; + + fdlock.lock(); + + error = fd_close( fd ); + + desc[fd] = NULL; + + fdlock.unlock(); + + return error; +} + +//========================================================================== +// Descriptor to file object mapping + + +//-------------------------------------------------------------------------- +// Map a descriptor to a file object. This is just a straightforward index +// into the descriptor array complicated by the need to lock the mutex and +// increment the usecount. + +__externC cyg_file *cyg_fp_get( int fd ) +{ + fdlock.lock(); + + cyg_file *fp = desc[fd]; + + if( fp != FD_ALLOCATED && fp != NULL) + { + // Increment use count while we work on this file + + fp->f_ucount++; + } + else fp = NULL; + + fdlock.unlock(); + + return fp; +} + +//-------------------------------------------------------------------------- +// Free the usecount reference we acquired in cyg_fp_get(). If the usecount +// is zeroed, the file will be closed. + +__externC void cyg_fp_free( cyg_file *fp ) +{ + fdlock.lock(); + + fp_ucount_dec( fp ); + + fdlock.unlock(); +} + +//========================================================================== +// File locking protocol + +void cyg_file_lock( cyg_file *fp , cyg_uint32 syncmode ) +{ + cyg_fs_lock( fp->f_mte, syncmode>>CYG_SYNCMODE_IO_SHIFT); + + if( syncmode & CYG_SYNCMODE_IO_FILE ) + { + fp->f_flag |= CYG_FLOCKED; + file_lock[fp-&file[0]].lock(); + } +} + +void cyg_file_unlock( cyg_file *fp, cyg_uint32 syncmode ) +{ + cyg_fs_unlock( fp->f_mte, syncmode>>CYG_SYNCMODE_IO_SHIFT); + + if( syncmode & CYG_SYNCMODE_IO_FILE ) + { + fp->f_flag &= ~CYG_FLOCKED; + file_lock[fp-&file[0]].unlock(); + } +} + + +//========================================================================== +// POSIX API routines + +//-------------------------------------------------------------------------- +// dup() - duplicate an FD into a random descriptor + +__externC int dup( int fd ) +{ + cyg_file *fp = cyg_fp_get( fd ); + + if( fp == NULL ) + { + errno = EBADF; + return -1; + } + + int fd2 = cyg_fd_alloc(0); + + if( fd2 == -1 ) + { + errno = EMFILE; + return -1; + } + + cyg_fd_assign( fd2, fp ); + + cyg_fp_free(fp); + + return fd2; +} + +//-------------------------------------------------------------------------- +// dup2() - duplicate an FD into a chosen descriptor + +__externC int dup2( int fd, int fd2 ) +{ + if( fd2 == fd ) return fd2; + + if( fd2 < 0 || fd2 >= OPEN_MAX ) + { + errno = EBADF; + return -1; + } + + cyg_file *fp = cyg_fp_get( fd ); + + if( fp == NULL ) + { + errno = EBADF; + return -1; + } + + cyg_fd_assign( fd2, fp ); + + cyg_fp_free(fp); + + return fd2; +} + +// ------------------------------------------------------------------------- +// EOF fd.cxx diff --git a/packages/io/fileio/current/src/file.cxx b/packages/io/fileio/current/src/file.cxx new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/src/file.cxx @@ -0,0 +1,428 @@ +//========================================================================== +// +// file.cxx +// +// Fileio file operations +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Fileio file operations +// Description: These are the functions that operate on files as a whole, +// such as open(), creat(), mkdir() etc. +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include "fio.h" // Private header + +#include // mutex definitions + +//========================================================================== +// Implement filesystem locking protocol. + +#define LOCK_FS( _mte_ ) cyg_fs_lock( _mte_, (_mte_)->fs->syncmode) + +#define UNLOCK_FS( _mte_ ) cyg_fs_unlock( _mte_, (_mte_)->fs->syncmode) + +//========================================================================== +// Open a file + +__externC int open( const char *path, int oflag, ... ) +{ + FILEIO_ENTRY(); + + CYG_CANCELLATION_POINT; + + int ret = 0; + int fd; + cyg_file *file; + cyg_mtab_entry *mte = cdir_mtab_entry; + cyg_dir dir = cdir_dir; + const char *name = path; + + fd = cyg_fd_alloc(0); + + if( fd < 0 ) + FILEIO_RETURN(EMFILE); + + file = cyg_file_alloc(); + + if( file == NULL ) + { + cyg_fd_free(fd); + FILEIO_RETURN(ENFILE); + } + + ret = cyg_mtab_lookup( &dir, &name, &mte ); + + if( 0 != ret ) + { + cyg_fd_free(fd); + cyg_file_free(file); + FILEIO_RETURN(ENOENT); + } + + LOCK_FS( mte ); + + ret = mte->fs->open( mte, dir, name, oflag, file ); + + UNLOCK_FS( mte ); + + if( 0 != ret ) + { + cyg_fd_free(fd); + cyg_file_free(file); + FILEIO_RETURN(ret); + } + + file->f_mte = mte; + file->f_syncmode = mte->fs->syncmode; + + cyg_fd_assign( fd, file ); + + FILEIO_RETURN_VALUE(fd); +} + +//========================================================================== +// create a file + +__externC int creat( const char *path, mode_t mode ) +{ + return open( path, O_WRONLY | O_CREAT | O_TRUNC, mode ); +} + + +//========================================================================== +// Unlink/remove a file + +__externC int unlink( const char *path ) +{ + FILEIO_ENTRY(); + + int ret = 0; + cyg_mtab_entry *mte = cdir_mtab_entry; + cyg_dir dir = cdir_dir; + const char *name = path; + + ret = cyg_mtab_lookup( &dir, &name, &mte ); + + if( 0 != ret ) + FILEIO_RETURN(ENOENT); + + LOCK_FS( mte ); + + ret = mte->fs->unlink( mte, dir, name ); + + UNLOCK_FS( mte ); + + FILEIO_RETURN(ret); +} + +//========================================================================== +// Make a directory + +__externC int mkdir( const char *path, mode_t mode ) +{ + FILEIO_ENTRY(); + + int ret = 0; + cyg_mtab_entry *mte = cdir_mtab_entry; + cyg_dir dir = cdir_dir; + const char *name = path; + + mode=mode; + + ret = cyg_mtab_lookup( &dir, &name, &mte ); + + if( 0 != ret ) + FILEIO_RETURN(ENOENT); + + LOCK_FS( mte ); + + ret = mte->fs->mkdir( mte, dir, name ); + + UNLOCK_FS( mte ); + + FILEIO_RETURN(ret); +} + +//========================================================================== +// Remove a directory + +__externC int rmdir( const char *path ) +{ + FILEIO_ENTRY(); + + int ret = 0; + cyg_mtab_entry *mte = cdir_mtab_entry; + cyg_dir dir = cdir_dir; + const char *name = path; + + ret = cyg_mtab_lookup( &dir, &name, &mte ); + + if( 0 != ret ) + FILEIO_RETURN(ENOENT); + + LOCK_FS( mte ); + + ret = mte->fs->rmdir( mte, dir, name ); + + UNLOCK_FS( mte ); + + FILEIO_RETURN(ret); +} + +//========================================================================== +// Rename a file + +__externC int rename( const char *path1, const char *path2 ) +{ + FILEIO_ENTRY(); + + int ret = 0; + cyg_mtab_entry *mte1 = cdir_mtab_entry; + cyg_mtab_entry *mte2 = cdir_mtab_entry; + cyg_dir dir1 = cdir_dir; + cyg_dir dir2 = cdir_dir; + const char *name1 = path1; + const char *name2 = path2; + + ret = cyg_mtab_lookup( &dir1, &name1, &mte1 ); + + if( 0 != ret ) + FILEIO_RETURN(ENOENT); + + ret = cyg_mtab_lookup( &dir2, &name2, &mte2 ); + + if( 0 != ret ) + FILEIO_RETURN(ENOENT); + + // Cannot rename between different filesystems + if( mte1 != mte2 ) + FILEIO_RETURN(EXDEV); + + LOCK_FS( mte1 ); + + ret = mte1->fs->rename( mte1, dir1, name1, dir2, name2 ); + + UNLOCK_FS( mte1 ); + + FILEIO_RETURN(ret); +} + +//========================================================================== +// Create a link from an existing file (path1) to a new one (path2) + +__externC int link( const char *path1, const char *path2 ) +{ + FILEIO_ENTRY(); + + int ret = 0; + cyg_mtab_entry *mte1 = cdir_mtab_entry; + cyg_mtab_entry *mte2 = cdir_mtab_entry; + cyg_dir dir1 = cdir_dir; + cyg_dir dir2 = cdir_dir; + const char *name1 = path1; + const char *name2 = path2; + + ret = cyg_mtab_lookup( &dir1, &name1, &mte1 ); + + if( 0 != ret ) + FILEIO_RETURN(ENOENT); + + ret = cyg_mtab_lookup( &dir2, &name2, &mte2 ); + + if( 0 != ret ) + FILEIO_RETURN(ENOENT); + + // Cannot hard-link between different filesystems + if( mte1 != mte2 ) + FILEIO_RETURN(EXDEV); + + LOCK_FS( mte1 ); + + ret = mte1->fs->link( mte1, dir1, name1, dir2, name2, CYG_FSLINK_HARD ); + + UNLOCK_FS( mte1 ); + + FILEIO_RETURN(ret); +} + +//========================================================================== +// Change current directory + +__externC int chdir( const char *path ) +{ + FILEIO_ENTRY(); + + int ret = 0; + cyg_mtab_entry *mte = cdir_mtab_entry; + cyg_dir dir = cdir_dir; + const char *name = path; + + ret = cyg_mtab_lookup( &dir, &name, &mte ); + + if( 0 != ret ) + FILEIO_RETURN(ENOENT); + + LOCK_FS(mte); + + ret = mte->fs->chdir( mte, dir, name, &dir ); + + UNLOCK_FS(mte); + + if( 0 != ret ) + FILEIO_RETURN(ret); + + if( cdir_mtab_entry != NULL ) + { + // Now detach from current cdir. We call the current directory's + // chdir routine with a NULL dir_out pointer. + + LOCK_FS(cdir_mtab_entry); + + ret = cdir_mtab_entry->fs->chdir( cdir_mtab_entry, cdir_dir, NULL, NULL ); + + UNLOCK_FS(cdir_mtab_entry); + + // We really shouldn't get an error here. + if( 0 != ret ) + FILEIO_RETURN(ret); + } + + cdir_mtab_entry = mte; + cdir_dir = dir; + + FILEIO_RETURN(ENOERR); +} + +//========================================================================== +// Get file statistics + +__externC int stat( const char *path, struct stat *buf ) +{ + FILEIO_ENTRY(); + + int ret = 0; + cyg_mtab_entry *mte = cdir_mtab_entry; + cyg_dir dir = cdir_dir; + const char *name = path; + + ret = cyg_mtab_lookup( &dir, &name, &mte ); + + if( 0 != ret ) + FILEIO_RETURN(ENOENT); + + LOCK_FS( mte ); + + ret = mte->fs->stat( mte, dir, name, buf ); + + UNLOCK_FS( mte ); + + FILEIO_RETURN(ret); +} + +//========================================================================== +// Get file configurable pathname variables + +__externC long pathconf( const char *path, int vname ) +{ + FILEIO_ENTRY(); + + int ret = 0; + cyg_mtab_entry *mte = cdir_mtab_entry; + cyg_dir dir = cdir_dir; + const char *name = path; + + ret = cyg_mtab_lookup( &dir, &name, &mte ); + + if( 0 != ret ) + FILEIO_RETURN(ENOENT); + + struct cyg_pathconf_info info; + + info.name = vname; + info.value = 0; + + LOCK_FS( mte ); + + ret = mte->fs->getinfo( mte, dir, name, + FS_INFO_CONF, (char *)&info, sizeof(info) ); + + UNLOCK_FS( mte ); + + if( 0 != ret ) + FILEIO_RETURN(ret); + + FILEIO_RETURN_VALUE(info.value); +} + +//========================================================================== +// Access() function. +// This simply piggybacks onto stat(). + +extern int access(const char *path, int amode) +{ + FILEIO_ENTRY(); + + int ret; + struct stat buf; + + ret = stat( path, &buf ); + + // Translate not found into EACCES if the F_OK bit is + // set. + if( (amode & F_OK) && (ret < 0) && (errno == ENOENT) ) + FILEIO_RETURN(EACCES); + + // All other errors go straight back to the user. + if( ret < 0 ) + FILEIO_RETURN_VALUE(ret); + + // At present we do not have any access modes, so there is nothing + // to test. Just return success for all access modes. + + FILEIO_RETURN(ENOERR); +} + +// ------------------------------------------------------------------------- +// EOF file.cxx diff --git a/packages/io/fileio/current/src/fio.h b/packages/io/fileio/current/src/fio.h new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/src/fio.h @@ -0,0 +1,166 @@ +#ifndef CYGONCE_FIO_H +#define CYGONCE_FIO_H +//============================================================================= +// +// fio.h +// +// Fileio private header +// +//============================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//============================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Fileio private header +// Description: This file contains private definitions for communication +// between the parts of the fileio package. +// +// Usage: +// #include "fio.h" +// ... +// +// +//####DESCRIPTIONEND#### +// +//============================================================================= + +#include +#include +#include + +#include + +#include // NULL, size_t +#include +#include +#include + +#include +#include + +#include + +#include // mutex definitions + +//============================================================================= +// Fileio function entry and return macros. + + +// Handle entry to a fileio package function. +#define FILEIO_ENTRY() CYG_REPORT_FUNCTYPE( "returning %d" ); + +// Do a fileio package defined return. This requires the error code +// to be placed in errno, and if it is non-zero, -1 returned as the +// result of the function. This also gives us a place to put any +// generic tidyup handling needed for things like signal delivery and +// cancellation. +#define FILEIO_RETURN(err) \ +CYG_MACRO_START \ + int __retval = 0; \ + if( err != 0 ) __retval = -1, errno = err; \ + CYG_REPORT_RETVAL( __retval ); \ + return __retval; \ +CYG_MACRO_END + +#define FILEIO_RETURN_VALUE(val) \ +CYG_MACRO_START \ + CYG_REPORT_RETVAL( val ); \ + return val; \ +CYG_MACRO_END + +#define FILEIO_RETURN_VOID() \ +CYG_MACRO_START \ + CYG_REPORT_RETURN(); \ + return; \ +CYG_MACRO_END + +//============================================================================= +// Cancellation support +// If the POSIX package is present we want to include cancellation points +// in the routines that are defined to contain them. +// The macro CYG_CANCELLATION_POINT does this. + +#ifdef CYGPKG_POSIX + +#include + +#define CYG_CANCELLATION_POINT pthread_testcancel() + +#else + +#define CYG_CANCELLATION_POINT CYG_EMPTY_STATEMENT + +#endif + +//============================================================================= +// Internal exports + +//----------------------------------------------------------------------------- +// Exports from misc.cxx + +// Current directory info +__externC cyg_mtab_entry *cdir_mtab_entry; +__externC cyg_dir cdir_dir; + +__externC int cyg_mtab_lookup( cyg_dir *dir, const char **name, cyg_mtab_entry **mte); + +__externC void cyg_fs_lock( cyg_mtab_entry *mte, cyg_uint32 syncmode ); + +__externC void cyg_fs_unlock( cyg_mtab_entry *mte, cyg_uint32 syncmode ); + +//----------------------------------------------------------------------------- +// Exports from fd.cxx + +__externC void cyg_fd_init(); + +__externC cyg_file *cyg_file_alloc(); + +__externC void cyg_file_free(cyg_file * fp); + +__externC int cyg_fd_alloc(int low); + +__externC void cyg_fd_assign(int fd, cyg_file *fp); + +__externC int cyg_fd_free(int fd); + +__externC cyg_file *cyg_fp_get( int fd ); + +__externC void cyg_fp_free( cyg_file *fp ); + +__externC void cyg_file_lock( cyg_file *fp, cyg_uint32 syncmode ); + +__externC void cyg_file_unlock( cyg_file *fp, cyg_uint32 syncmode ); + +//----------------------------------------------------------------------------- +// Exports from socket.cxx + +__externC void cyg_nstab_init(); + +//----------------------------------------------------------------------------- +#endif // ifndef CYGONCE_FIO_H +// End of fio.h diff --git a/packages/io/fileio/current/src/io.cxx b/packages/io/fileio/current/src/io.cxx new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/src/io.cxx @@ -0,0 +1,472 @@ +//========================================================================== +// +// io.cxx +// +// Fileio IO operations +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Fileio IO operations +// Description: These are the functions that operate on open files, +// such as read(), write(), fstat() etc. +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include // for fcntl() + +#include "fio.h" // Private header + +#include // mutex definitions + +//========================================================================== +// File object locking + +#define LOCK_FILE( fp ) cyg_file_lock( fp, fp->f_syncmode ) + +#define UNLOCK_FILE( fp ) cyg_file_unlock( fp, fp->f_syncmode ) + +//========================================================================== +// Read from a file + +__externC ssize_t read( int fd, void *buf, size_t len ) +{ + FILEIO_ENTRY(); + + CYG_CANCELLATION_POINT; + + ssize_t cnt; + int ret; + cyg_file *fp; + + if( len > SSIZE_MAX ) + FILEIO_RETURN(EINVAL); + + fp = cyg_fp_get( fd ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( (fp->f_flag & CYG_FREAD) == 0 ) + { + cyg_fp_free( fp ); + FILEIO_RETURN(EBADF); + } + + cyg_uio uio; + cyg_iovec iov; + + iov.iov_base = buf; + iov.iov_len = len; + uio.uio_iov = &iov; + uio.uio_iovcnt = 1; + uio.uio_resid = len; + uio.uio_rw = UIO_READ; + uio.uio_segflg = UIO_USERSPACE; + + cnt = len; + + LOCK_FILE( fp ); + + ret = fp->f_ops->fo_read( fp, &uio ); + + UNLOCK_FILE( fp ); + + cnt -= uio.uio_resid; + + cyg_fp_free( fp ); + + CYG_CANCELLATION_POINT; + + CYG_REPORT_RETVAL(cnt); + return cnt; +} + +//========================================================================== +// Write to a file + +__externC ssize_t write( int fd, const void *buf, size_t len ) +{ + FILEIO_ENTRY(); + + CYG_CANCELLATION_POINT; + + ssize_t cnt; + int ret; + cyg_file *fp; + + if( len > SSIZE_MAX ) + FILEIO_RETURN(EINVAL); + + fp = cyg_fp_get( fd ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( (fp->f_flag & CYG_FWRITE) == 0) + { + cyg_fp_free( fp ); + FILEIO_RETURN(EBADF); + } + cyg_uio uio; + cyg_iovec iov; + + iov.iov_base = (void *)buf; + iov.iov_len = len; + uio.uio_iov = &iov; + uio.uio_iovcnt = 1; + uio.uio_resid = len; + uio.uio_rw = UIO_WRITE; + uio.uio_segflg = UIO_USERSPACE; + + cnt = len; + + LOCK_FILE( fp ); + + ret = fp->f_ops->fo_write( fp, &uio ); + + UNLOCK_FILE( fp ); + + cnt -= uio.uio_resid; + + cyg_fp_free( fp ); + + CYG_CANCELLATION_POINT; + + CYG_REPORT_RETVAL(cnt); + return cnt; +} + +//========================================================================== +// Close a file + +__externC int close( int fd ) +{ + FILEIO_ENTRY(); + + CYG_CANCELLATION_POINT; + + int ret; + cyg_file *fp; + + fp = cyg_fp_get( fd ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + cyg_fp_free( fp ); + + // The file's fo_close entry may be called as a side + // effect of this operation... + ret = cyg_fd_free( fd ); + + CYG_CANCELLATION_POINT; + + FILEIO_RETURN(ret); +} + +//========================================================================== +// Seek a file + +__externC off_t lseek( int fd, off_t pos, int whence ) +{ + FILEIO_ENTRY(); + + int ret; + cyg_file *fp; + + fp = cyg_fp_get( fd ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + LOCK_FILE( fp ); + + ret = fp->f_ops->fo_lseek( fp, &pos, whence ); + + UNLOCK_FILE( fp ); + + cyg_fp_free( fp ); + + if( ret != 0 ) + FILEIO_RETURN(ret); + + CYG_REPORT_RETVAL(pos); + return pos; +} + +//========================================================================== +// ioctl + +__externC int ioctl( int fd, CYG_ADDRWORD com, CYG_ADDRWORD data ) +{ + FILEIO_ENTRY(); + + int ret; + cyg_file *fp; + + fp = cyg_fp_get( fd ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + LOCK_FILE( fp ); + + ret = fp->f_ops->fo_ioctl( fp, com, data ); + + UNLOCK_FILE( fp ); + + cyg_fp_free( fp ); + + FILEIO_RETURN(ret); +} + +//========================================================================== +// fsync + +__externC int fsync( int fd ) +{ + FILEIO_ENTRY(); + + CYG_CANCELLATION_POINT; + + int ret; + cyg_file *fp; + + fp = cyg_fp_get( fd ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + LOCK_FILE( fp ); + + ret = fp->f_ops->fo_fsync( fp, CYG_FSYNC ); + + UNLOCK_FILE( fp ); + + cyg_fp_free( fp ); + + CYG_CANCELLATION_POINT; + + FILEIO_RETURN(ret); +} + +//========================================================================== +// fdatasync() + +__externC int fdatasync( int fd ) +{ + FILEIO_ENTRY(); + + CYG_CANCELLATION_POINT; + + int ret; + cyg_file *fp; + + fp = cyg_fp_get( fd ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + LOCK_FILE( fp ); + + ret = fp->f_ops->fo_fsync( fp, CYG_FDATASYNC ); + + UNLOCK_FILE( fp ); + + cyg_fp_free( fp ); + + CYG_CANCELLATION_POINT; + + FILEIO_RETURN(ret); +} + +//========================================================================== +// fstat + +__externC int fstat( int fd, struct stat *buf ) +{ + FILEIO_ENTRY(); + + int ret; + cyg_file *fp; + + fp = cyg_fp_get( fd ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + LOCK_FILE( fp ); + + ret = fp->f_ops->fo_fstat( fp, buf ); + + UNLOCK_FILE( fp ); + + cyg_fp_free( fp ); + + FILEIO_RETURN(ret); +} + +//========================================================================== +// fpathconf + +__externC long fpathconf( int fd, int name ) +{ + FILEIO_ENTRY(); + + int ret; + cyg_file *fp; + + fp = cyg_fp_get( fd ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + struct cyg_pathconf_info info; + + info.name = name; + info.value = 0; + + LOCK_FILE( fp ); + + ret = fp->f_ops->fo_getinfo( fp, FILE_INFO_CONF, (char *)&info, sizeof(info) ); + + UNLOCK_FILE( fp ); + + cyg_fp_free( fp ); + + if( ret != 0 ) + FILEIO_RETURN(ret); + + CYG_REPORT_RETVAL(info.value); + return info.value; +} + +//========================================================================== +// fcntl + +__externC int fcntl( int fd, int cmd, ... ) +{ + FILEIO_ENTRY(); + + CYG_CANCELLATION_POINT; + + int ret = 0; + cyg_file *fp; + va_list a; + + fp = cyg_fp_get( fd ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + va_start( a, cmd ); + + switch( cmd ) + { + case F_DUPFD: + { + int fda = va_arg(a, int); + + if( fda < 0 || fda >= OPEN_MAX ) + { + errno = EBADF; + break; + } + + int fd2 = cyg_fd_alloc( fda ); + + if( fd2 == -1 ) + { + ret = EMFILE; + break; + } + + cyg_fd_assign( fd2, fp ); + + break; + } + + default: + ret = ENOTSUP; + break; + } + + va_end(a); + + cyg_fp_free( fp ); + + CYG_CANCELLATION_POINT; + + FILEIO_RETURN(ret); +} + +//========================================================================== +// isatty() + +__externC int isatty( int fd ) +{ + FILEIO_ENTRY(); + + int ret = 0; + struct stat buf; + int err; + + err = fstat( fd, &buf ); + + // Any error and we return zero. If the client wants to + // they can always pick up the error code from errno. + if( err < 0 ) + FILEIO_RETURN_VALUE(0); + + // For now we assume that all char devices are ttys. + // In future we may need to have a special getinfo() + // call to decide this more specifically. + + if( S_ISCHR( buf.st_mode ) ) + ret = 1; + + FILEIO_RETURN_VALUE(ret); +} + +// ------------------------------------------------------------------------- +// EOF io.cxx diff --git a/packages/io/fileio/current/src/misc.cxx b/packages/io/fileio/current/src/misc.cxx new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/src/misc.cxx @@ -0,0 +1,432 @@ +//========================================================================== +// +// misc.cxx +// +// Fileio miscellaneous functions +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Fileio miscellaneous functions +// Description: This file contains various miscellaneous functions +// for use with the fileio system. These include startup, +// table management, and other service routines. +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include +#include +#ifdef CYGPKG_LIBC_TIME +#include +#endif + + +#include // base kernel types +#include // tracing macros +#include // assertion macros +#include // strcmp() +#include // time() + +#ifdef CYGPKG_IO_WALLCLOCK +# include // Wallclock class +#endif + +#include "fio.h" // Private header + +//========================================================================== +// forward definitions + +static void cyg_mtab_init(); + +__externC int chdir( const char *path ); + +//========================================================================== +// Filesystem tables + +// ------------------------------------------------------------------------- +// Filesystem table. + +// This array contains entries for all filesystem that are installed in +// the system. +__externC cyg_fstab_entry fstab[]; +CYG_HAL_TABLE_BEGIN( fstab, fstab ); + +// end of filesystem table, set in linker script. +__externC cyg_fstab_entry fstab_end; +CYG_HAL_TABLE_END( fstab_end, fstab ); + +// Array of mutexes for locking the fstab entries +Cyg_Mutex fstab_lock[CYGNUM_FILEIO_FSTAB_MAX]; + +// ------------------------------------------------------------------------- +// Mount table. + +// This array contains entries for all valid running filesystems. +__externC cyg_mtab_entry mtab[]; +CYG_HAL_TABLE_BEGIN( mtab, mtab ); + +// Extra entries at end of mtab for dynamic mount points. +cyg_mtab_entry mtab_extra[CYGNUM_FILEIO_MTAB_EXTRA] CYG_HAL_TABLE_EXTRA(mtab) = { { NULL } }; + +// End of mount table, set in the linker script. +__externC cyg_mtab_entry mtab_end; +CYG_HAL_TABLE_END( mtab_end, mtab ); + +// Array of mutexes for locking the mtab entries +Cyg_Mutex mtab_lock[CYGNUM_FILEIO_MTAB_MAX]; + +//========================================================================== +// Current directory + +cyg_mtab_entry *cdir_mtab_entry = NULL; +cyg_dir cdir_dir = CYG_DIR_NULL; + +//========================================================================== +// Initialization object + +class Cyg_Fileio_Init_Class +{ +public: + Cyg_Fileio_Init_Class(); +}; + +static Cyg_Fileio_Init_Class fileio_initializer CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_IO); + +Cyg_Fileio_Init_Class::Cyg_Fileio_Init_Class() +{ + cyg_fd_init(); + + cyg_mtab_init(); + + chdir("/"); +} + +//========================================================================== +// Mount table initializer + +static void cyg_mtab_init() +{ + cyg_mtab_entry *m; + + for( m = &mtab[0]; m != &mtab_end; m++ ) + { + const char *fsname = m->fsname; + cyg_fstab_entry *f; + + // Ignore empty entries + if( m->name == NULL ) + continue; + + // stop if there are more than the configured maximum + if( m-&mtab[0] >= CYGNUM_FILEIO_MTAB_MAX ) + break; + + for( f = &fstab[0]; f != &fstab_end; f++ ) + { + // stop if there are more than the configured maximum + if( f-&fstab[0] >= CYGNUM_FILEIO_FSTAB_MAX ) + break; + + if( strcmp( fsname, f->name) == 0 ) + { + // We have a match. + + if( f->mount( f, m ) == 0 ) + { + m->valid = true; + m->fs = f; + // m->root installed by fs. + } + else + { + m->valid = false; + } + + break; + } + } + } +} + +//========================================================================== +// Mount table matching + +// ------------------------------------------------------------------------- +// matchlen() compares two strings and returns the number of bytes by which +// they match. + +static int matchlen( const char *s1, const char *s2 ) +{ + int len = 0; + while( s1[len] == s2[len] && s1[len] && s2[len] ) len++; + + // Return length only if s2 is an initial substring of s1, + // and it terminates in s1 at end-of-string or a '/'. + + // Special case for s2 == "/" + if( len == 1 && s2[0] == '/' && s2[1] == 0 ) + return len; + + if( (s2[len] == 0) && (s1[len] == 0 || s1[len] == '/')) + return len; + else return 0; +} + +// ------------------------------------------------------------------------- +// Search the mtab for the entry that matches the longest substring of +// **name. + +__externC int cyg_mtab_lookup( cyg_dir *dir, const char **name, cyg_mtab_entry **mte) +{ + cyg_mtab_entry *m, *best = NULL; + int best_len = 0; + + // Unrooted file names go straight to current dir + if( **name != '/' ) return 0; + + // Otherwise search the mount table. + for( m = &mtab[0]; m != &mtab_end; m++ ) + { + if( m->name != NULL ) + { + int len = matchlen(*name,m->name); + if( len > best_len ) + best = m, best_len = len; + } + } + + // No match found, bad path name... + if( best_len == 0 ) return -1; + + *name += best_len; + if( **name == '/' ) + (*name)++; + *mte = best; + *dir = best->root; + + return 0; +} + +//========================================================================== +// mount filesystem + +__externC int mount( const char *devname, + const char *dir, + const char *fsname) +{ + + FILEIO_ENTRY(); + + cyg_mtab_entry *m; + cyg_fstab_entry *f; + + // Search the mount table for an empty entry + for( m = &mtab[0]; m != &mtab_end; m++ ) + { + // stop if there are more than the configured maximum + if( m-&mtab[0] >= CYGNUM_FILEIO_MTAB_MAX ) + { + m = &mtab_end; + break; + } + + if( m->name == NULL ) break; + } + + if( m == &mtab_end ) + FILEIO_RETURN(ENOMEM); + + // Now search the fstab for the filesystem implementation + for( f = &fstab[0]; f != &fstab_end; f++ ) + { + // stop if there are more than the configured maximum + if( f-&fstab[0] >= CYGNUM_FILEIO_FSTAB_MAX ) + break; + + if( strcmp( fsname, f->name) == 0 ) + break; + } + + if( f == &fstab_end ) + FILEIO_RETURN(ENODEV); + + // We have a match. + + m->name = dir; + m->fsname = fsname; + m->devname = devname; + + if( f->mount( f, m ) == 0 ) + { + m->valid = true; + m->fs = f; + // m->root installed by fs. + } + else + { + m->valid = false; + m->name = NULL; + } + + FILEIO_RETURN(ENOERR); +} + +//========================================================================== +// unmount filesystem + +__externC int umount( const char *name) +{ + int err = ENOERR; + + FILEIO_ENTRY(); + + cyg_mtab_entry *m; + + // Search the mount table for a matching entry + for( m = &mtab[0]; m != &mtab_end; m++ ) + { + // stop if there are more than the configured maximum + if( m-&mtab[0] >= CYGNUM_FILEIO_MTAB_MAX ) + { + m = &mtab_end; + break; + } + + // Ignore empty entries + if( m->name == NULL ) continue; + + // match names. + if( strcmp(name,m->name) == 0 ) break; + + // Match device name too? + } + + if( m == &mtab_end ) + FILEIO_RETURN(EINVAL); + + // We have a match, call the umount function + + err = m->fs->umount( m ); + + if( err == ENOERR ) + { + m->valid = false; + m->name = NULL; + } + + FILEIO_RETURN(err); +} + +//========================================================================== +// Implement filesystem locking protocol. + +void cyg_fs_lock( cyg_mtab_entry *mte, cyg_uint32 syncmode ) +{ + if( syncmode & CYG_SYNCMODE_FILE_FILESYSTEM ) + fstab_lock[mte->fs-&fstab[0]].lock(); + + if( syncmode & CYG_SYNCMODE_FILE_MOUNTPOINT ) + mtab_lock[mte-&mtab[0]].lock(); +} + +void cyg_fs_unlock( cyg_mtab_entry *mte, cyg_uint32 syncmode ) +{ + if( syncmode & CYG_SYNCMODE_FILE_FILESYSTEM ) + fstab_lock[mte->fs-&fstab[0]].unlock(); + + if( syncmode & CYG_SYNCMODE_FILE_MOUNTPOINT ) + mtab_lock[mte-&mtab[0]].unlock(); +} + +//========================================================================== +// Timestamp support +// This provides access to the current time/date, expressed as a +// time_t. It uses a number of mechanisms to do this, selecting +// whichever is available in the current configuration. + +__externC time_t cyg_timestamp() +{ +#if defined(CYGPKG_IO_WALLCLOCK) + + // First, try to get the time from the wallclock device. + + return (time_t) Cyg_WallClock::wallclock->get_current_time(); + +#elif CYGINT_ISO_POSIX_TIMERS + + // If POSIX is present, use the current value of the realtime + // clock. + + struct timespec tp; + + clock_gettime( CLOCK_REALTIME, &tp ); + + return (time_t) tp.tv_sec; + +#else + + // If all else fails, get the current realtime clock value and + // convert it to seconds ourself. + + static struct Cyg_Clock::converter sec_converter; + struct cyg_bool initialized = false; + cyg_tick_count ticks; + + if( !initialized ) + { + Cyg_Clock::real_time_clock->get_clock_to_other_converter( 1000000000, &sec_converter ); + initialized = true; + } + + ticks = Cyg_Clock::real_time_clock->current_value(); + + return (time_t) Cyg_Clock::convert( ticks, &sec_converter ) + +#endif + +} + +//========================================================================== +// Default functions + +__externC int cyg_fileio_enosys() { return ENOSYS; } +__externC int cyg_fileio_erofs() { return EROFS; } +__externC int cyg_fileio_enoerr() { return ENOERR; } +__externC int cyg_fileio_enotdir() { return ENOTDIR; } + +__externC int cyg_fileio_seltrue (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info) +{ return 1; } + +// ------------------------------------------------------------------------- +// EOF misc.cxx diff --git a/packages/io/fileio/current/src/select.cxx b/packages/io/fileio/current/src/select.cxx new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/src/select.cxx @@ -0,0 +1,318 @@ +//========================================================================== +// +// select.cxx +// +// Fileio select() support +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Fileio select() support +// Description: Support for select(). +// +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include // for fcntl() + +#include "fio.h" // Private header + +#include // scheduler definitions +#include // thread definitions +#include // mutex definitions +#include // clock definitions + +#include +#include +#include + +//========================================================================== +// File object locking + +#define LOCK_FILE( fp ) cyg_file_lock( fp ) + +#define UNLOCK_FILE( fp ) cyg_file_unlock( fp ) + +//========================================================================== +// Local variables + +// Mutex for serializing select processing. This essntially controls +// access to the contents of the selinfo structures embedded in the +// client system data structures. +static Cyg_Mutex select_mutex; + +// Condition variable where any thread that is waiting for a select to +// fire is suspended. Note that select is not intended to be a real time +// operation. Whenever any selectable event occurs, all selecting threads +// will be resumed. They must then rescan their selectees and resuspend if +// necessary. +static Cyg_Condition_Variable selwait( select_mutex ); + +static volatile cyg_uint32 selwake_count = 0; + +//========================================================================== +// Timeval to ticks conversion support + +// Converters from sec and us to ticks +static struct Cyg_Clock::converter us_converter, sec_converter; + +static cyg_bool converters_initialized = false; + +externC cyg_tick_count cyg_timeval_to_ticks( const struct timeval *tv ) +{ + if( !converters_initialized ) + { + // Create the converters we need. + Cyg_Clock::real_time_clock->get_other_to_clock_converter( 1000, &us_converter ); + Cyg_Clock::real_time_clock->get_other_to_clock_converter( 1000000000, &sec_converter ); + + converters_initialized = true; + } + + // Short circuit zero timeval + if( tv->tv_sec == 0 && tv->tv_usec == 0 ) + { + return 0; + } + + // Convert the seconds field to ticks. + cyg_tick_count ticks = Cyg_Clock::convert( tv->tv_sec, &sec_converter ); + + // Convert the nanoseconds. This will round down to nearest whole tick. + ticks += Cyg_Clock::convert( (cyg_tick_count)tv->tv_usec, &us_converter ); + + return ticks; +} + +//========================================================================== +// Select API function + +__externC int +select(int nfd, fd_set *in, fd_set *out, fd_set *ex, struct timeval *tv) +{ + FILEIO_ENTRY(); + + int error = ENOERR; + int fd, mode, num; + cyg_file *fp; + fd_set in_res, out_res, ex_res; // Result sets + fd_set *selection[3], *result[3]; + cyg_tick_count ticks; + int mode_type[] = {CYG_FREAD, CYG_FWRITE, 0}; + cyg_uint32 wake_count; + + FD_ZERO(&in_res); + FD_ZERO(&out_res); + FD_ZERO(&ex_res); + + // Set up sets + selection[0] = in; result[0] = &in_res; + selection[1] = out; result[1] = &out_res; + selection[2] = ex; result[2] = &ex_res; + + // Compute end time + if (tv) + ticks = Cyg_Clock::real_time_clock->current_value() + + cyg_timeval_to_ticks( tv ); + else ticks = 0; + + // Lock the mutex + select_mutex.lock(); + + // Scan sets for possible I/O until something found, timeout or error. + while (!error) + { + wake_count = selwake_count; + + num = 0; // Total file descriptors "ready" + for (mode = 0; !error && mode < 3; mode++) + { + if (selection[mode]) { + for (fd = 0; !error && fd < nfd; fd++) + { + if (FD_ISSET(fd, selection[mode])) + { + fp = cyg_fp_get( fd ); + if( fp == NULL ) + { + error = EBADF; + break; + } + + if ((*fp->f_ops->fo_select)(fp, mode_type[mode], 0)) + { + FD_SET(fd, result[mode]); + num++; + } + + cyg_fp_free( fp ); + } + } + } + } + + if (num) + { + // Found something, update user's sets + if (in) FD_COPY( &in_res, in ); + if (out) FD_COPY( &out_res, out ); + if (ex) FD_COPY( &ex_res, ex ); + select_mutex.unlock(); + FILEIO_RETURN_VALUE(num); + } + + Cyg_Scheduler::lock(); + + if( wake_count == selwake_count ) + { + // Nothing found, see if we want to wait + if (tv) + { + if (ticks == 0) + { + // Special case of "poll" + select_mutex.unlock(); + Cyg_Scheduler::unlock(); + FILEIO_RETURN_VALUE(0); + } + + if( !selwait.wait( ticks ) ) + { + // A non-standard wakeup, if the current time is equal to + // or past the timeout, return zero. Otherwise return + // EINTR, since we have been released. + if( Cyg_Clock::real_time_clock->current_value() >= ticks ) + { + select_mutex.unlock(); + FILEIO_RETURN_VALUE(0); + } + else error = EINTR; + } + } + else + { + // Wait forever (until something happens) + + if( !selwait.wait() ) + error = EINTR; + } + } + + Cyg_Scheduler::unlock(); + + } // while(!error) + + select_mutex.unlock(); + + FILEIO_RETURN(error); +} + +//========================================================================== +// Select support functions. + +// ------------------------------------------------------------------------- +// cyg_selinit() is used to initialize a selinfo structure + +void cyg_selinit( struct CYG_SELINFO_TAG *sip ) +{ + sip->si_info = 0; + sip->si_thread = 0; +} + +// ------------------------------------------------------------------------- +// cyg_selrecord() is called when a client device needs to register +// the current thread for selection. + +void cyg_selrecord( CYG_ADDRWORD info, struct CYG_SELINFO_TAG *sip ) +{ + sip->si_info = info; + sip->si_thread = (CYG_ADDRESS)Cyg_Thread::self(); +} + +// ------------------------------------------------------------------------- +// cyg_selwakeup() is called when the client device matches the select +// criterion, and needs to wake up a selector. + +void cyg_selwakeup( struct CYG_SELINFO_TAG *sip ) +{ + // We don't actually use the si_info field of selinfo at present. + // A potential use would be to select one of several selwait condition + // variables to signal. However, that would only be necessary if we + // end up having lots of threads in select. + + Cyg_Scheduler::lock(); + + if( sip->si_thread != 0 ) + { + // If the thread pointer is still present, this selection has + // not been fired before. Test whether the thread is still + // waiting on the selwait condvar and if so, wake all waiters + // on it. + + // Note that this code has to be a bit careful with accessing + // the thread. Since there is no select cancel mechanism, the + // information in si_thread may be old, and the thread may + // have been deleted in the meantime. However, we do know that + // any address in si_thread was for a thread object at some + // time in the past, so will not be an illegal address, and + // the get_current_queue() member is a simple memory + // access. Hence the worse that this code could do is give a + // false positive and wake up some selectors when it + // shouldn't. However, care should be taken in making any + // changes to this code to avoid adding assumptions that the + // thread pointer is always valid. + + Cyg_Thread *thread = (Cyg_Thread *)sip->si_thread; + + if( thread->get_current_queue() == selwait.get_queue() ) + { + sip->si_thread = 0; + selwait.broadcast(); + selwake_count++; + } + } + + Cyg_Scheduler::unlock(); +} + +// ------------------------------------------------------------------------- +// EOF select.cxx diff --git a/packages/io/fileio/current/src/socket.cxx b/packages/io/fileio/current/src/socket.cxx new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/src/socket.cxx @@ -0,0 +1,725 @@ +//========================================================================== +// +// socket.cxx +// +// Fileio socket operations +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Fileio socket operations +// Description: These are the functions that operate on sockets, +// such as socket(), bind(), accept() etc. +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include +#include + +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include // for fcntl() + +#include // struct iovec + +#include "fio.h" // Private header + +#include // mutex definitions + +#ifdef CYGPKG_NET + +#include // struct msghdr + +#endif + +//========================================================================== +// Forward definitions + +static void cyg_ns_lock( cyg_nstab_entry *ns ); +static void cyg_ns_unlock( cyg_nstab_entry *ns ); +static void cyg_sock_lock( cyg_file *fp ); +static void cyg_sock_unlock( cyg_file *fp ); + +//========================================================================== +// Local entry/return macros + +#define SOCKET_ENTRY() FILEIO_ENTRY() + +#define SOCKET_RETURN(err) FILEIO_RETURN(err) + +#define SOCKET_RETURN_VALUE(val) FILEIO_RETURN_VALUE(val) + +//========================================================================== +// Locking protocols + +#define LOCK_NS( _n ) cyg_ns_lock( _n ) + +#define UNLOCK_NS( _n ) cyg_ns_unlock( _n ) + +#define LOCK_SOCKET( _fp ) cyg_sock_lock( _fp ) + +#define UNLOCK_SOCKET( _fp ) cyg_sock_unlock( _fp ) + +//========================================================================== +// Tables and local variables + +// Array of network stacks installed +__externC cyg_nstab_entry nstab[]; +CYG_HAL_TABLE_BEGIN( nstab, nstab ); + +// End of array marker +__externC cyg_nstab_entry nstab_end; +CYG_HAL_TABLE_END( nstab_end, nstab ); + +Cyg_Mutex nstab_lock[CYGNUM_FILEIO_NSTAB_MAX]; + +//========================================================================== +// Initialization + +__externC void cyg_nstab_init() +{ + cyg_nstab_entry *n; + + for( n = &nstab[0]; n != &nstab_end; n++ ) + { + // stop if there are more than the configured maximum + if( n-&nstab[0] >= CYGNUM_FILEIO_NSTAB_MAX ) + break; + + if( n->init( n ) == 0 ) + { + n->valid = true; + } + } +} + +//========================================================================== +// Socket API calls + +// ------------------------------------------------------------------------- + +__externC int socket (int domain, int type, int protocol) +{ + SOCKET_ENTRY(); + + int err = 0; + int fd; + cyg_file *file; + + fd = cyg_fd_alloc(0); + + if( fd < 0 ) + SOCKET_RETURN(EMFILE); + + file = cyg_file_alloc(); + + if( file == NULL ) + { + cyg_fd_free(fd); + SOCKET_RETURN(ENFILE); + } + + cyg_nstab_entry *n; + + for( n = &nstab[0]; n != &nstab_end; n++ ) + { + LOCK_NS( n ); + + err = n->socket( n, domain, type, protocol, file ); + + UNLOCK_NS( n ); + + if( err == 0 ) break; + } + + if( err != 0 ) + { + cyg_fd_free(fd); + cyg_file_free(file); + SOCKET_RETURN( err ); + } + + file->f_syncmode = n->syncmode; + file->f_mte = (cyg_mtab_entry *)n; + + cyg_fd_assign( fd, file ); + + SOCKET_RETURN_VALUE(fd); +} + + +// ------------------------------------------------------------------------- + +__externC int accept (int s, struct sockaddr *sa, socklen_t *addrlen) +{ + SOCKET_ENTRY(); + + int err = 0; + int fd; + cyg_file *fp; + cyg_file *new_fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + fd = cyg_fd_alloc(0); + + if( fd < 0 ) + { + cyg_fp_free( fp ); + SOCKET_RETURN(EMFILE); + } + + new_fp = cyg_file_alloc(); + + if( new_fp == NULL ) + { + cyg_fp_free( fp ); + cyg_fd_free(fd); + SOCKET_RETURN(ENFILE); + } + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + LOCK_SOCKET( fp ); + + err = ops->accept( fp, new_fp, sa, addrlen ); + + UNLOCK_SOCKET( fp ); + + } + else err = EBADF; + + if( err != 0 ) + { + cyg_fp_free( fp ); + cyg_fd_free(fd); + cyg_file_free(new_fp); + SOCKET_RETURN( err ); + } + + new_fp->f_syncmode = fp->f_syncmode; + new_fp->f_mte = fp->f_mte; + + cyg_fd_assign( fd, new_fp ); + + cyg_fp_free( fp ); + + SOCKET_RETURN_VALUE(fd); +} + + +// ------------------------------------------------------------------------- + +__externC int bind (int s, const struct sockaddr *sa, unsigned int len) +{ + SOCKET_ENTRY(); + + int ret = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + LOCK_SOCKET( fp ); + + ret = ops->bind( fp, sa, len ); + + UNLOCK_SOCKET( fp ); + + } + + cyg_fp_free( fp ); + + SOCKET_RETURN(ret); +} + + +// ------------------------------------------------------------------------- + +__externC int connect (int s, const struct sockaddr *sa, socklen_t len) +{ + SOCKET_ENTRY(); + + int ret = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + LOCK_SOCKET( fp ); + + ret = ops->connect( fp, sa, len ); + + UNLOCK_SOCKET( fp ); + + } + + cyg_fp_free( fp ); + + SOCKET_RETURN(ret); +} + + +// ------------------------------------------------------------------------- + +__externC int getpeername (int s, struct sockaddr *sa, socklen_t *len) +{ + SOCKET_ENTRY(); + + int ret = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + LOCK_SOCKET( fp ); + + ret = ops->getname( fp, sa, len, 1 ); + + UNLOCK_SOCKET( fp ); + } + + cyg_fp_free( fp ); + + SOCKET_RETURN(ret); +} + + +// ------------------------------------------------------------------------- + +__externC int getsockname (int s, struct sockaddr *sa, socklen_t *len) +{ + SOCKET_ENTRY(); + + int ret = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + LOCK_SOCKET( fp ); + + ret = ops->getname( fp, sa, len, 0 ); + + UNLOCK_SOCKET( fp ); + } + + cyg_fp_free( fp ); + + SOCKET_RETURN(ret); +} + + +// ------------------------------------------------------------------------- + +__externC int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen) +{ + SOCKET_ENTRY(); + + int ret = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + LOCK_SOCKET( fp ); + + ret = ops->getsockopt( fp, level, optname, optval, optlen ); + + UNLOCK_SOCKET( fp ); + } + + cyg_fp_free( fp ); + + SOCKET_RETURN(ret); +} + + +// ------------------------------------------------------------------------- + +__externC int listen (int s, int len) +{ + SOCKET_ENTRY(); + + int ret = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + LOCK_SOCKET( fp ); + + ret = ops->listen( fp, len ); + + UNLOCK_SOCKET( fp ); + } + + cyg_fp_free( fp ); + + SOCKET_RETURN(ret); +} + + +// ------------------------------------------------------------------------- + +__externC ssize_t recvmsg (int s, struct msghdr *msg, int flags) +{ + SOCKET_ENTRY(); + + ssize_t ret = 0; + int error = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + LOCK_SOCKET( fp ); + + msg->msg_flags = flags; + + error = ops->recvmsg( fp, msg, NULL, &ret ); + + UNLOCK_SOCKET( fp ); + } + + cyg_fp_free( fp ); + + if( error != ENOERR ) + SOCKET_RETURN(error); + + SOCKET_RETURN_VALUE( ret ); +} + +// ------------------------------------------------------------------------- + +__externC ssize_t recvfrom (int s, void *buf, size_t len, int flags, + struct sockaddr *from, socklen_t *fromlen) +{ + SOCKET_ENTRY(); + + struct msghdr msg; + struct iovec iov; + ssize_t ret = 0; + int error = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + // Set up a message header... + msg.msg_name = (caddr_t)from; + msg.msg_namelen = *fromlen; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + iov.iov_base = buf; + iov.iov_len = len; + msg.msg_control = 0; + msg.msg_flags = flags; + + LOCK_SOCKET( fp ); + + error = ops->recvmsg( fp, &msg, fromlen, &ret ); + + UNLOCK_SOCKET( fp ); + } + + cyg_fp_free( fp ); + + if( error != ENOERR ) + SOCKET_RETURN(error); + + SOCKET_RETURN_VALUE( ret ); + +} + +// ------------------------------------------------------------------------- + +__externC ssize_t recv (int s, void *buf, size_t len, int flags) +{ + return recvfrom( s, buf, len, flags, NULL, NULL ); +} + +// ------------------------------------------------------------------------- + +__externC ssize_t sendmsg (int s, const struct msghdr *msg, int flags) +{ + SOCKET_ENTRY(); + + ssize_t ret = 0; + int error = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + LOCK_SOCKET( fp ); + + error = ops->sendmsg( fp, msg, flags, &ret ); + + UNLOCK_SOCKET( fp ); + } + + cyg_fp_free( fp ); + + if( error != ENOERR ) + SOCKET_RETURN(error); + + SOCKET_RETURN_VALUE( ret ); +} + + +// ------------------------------------------------------------------------- + +__externC ssize_t sendto (int s, const void *buf, + size_t len, int flags, const struct sockaddr *to, socklen_t tolen) +{ + SOCKET_ENTRY(); + + ssize_t ret = 0; + int error = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + + struct msghdr msg; + struct iovec iov; + + msg.msg_name = (caddr_t)to; + msg.msg_namelen = tolen; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + msg.msg_control = 0; + msg.msg_flags = 0; + iov.iov_base = (char *)buf; + iov.iov_len = len; + + LOCK_SOCKET( fp ); + + error = ops->sendmsg( fp, &msg, flags, &ret ); + + UNLOCK_SOCKET( fp ); + } + + cyg_fp_free( fp ); + + if( error != ENOERR ) + SOCKET_RETURN(error); + + SOCKET_RETURN_VALUE( ret ); +} + +// ------------------------------------------------------------------------- + +__externC ssize_t send (int s, const void *buf, size_t len, int flags) +{ + return sendto( s, buf, len, flags, NULL, 0 ); +} + + +// ------------------------------------------------------------------------- + +__externC int setsockopt (int s, int level, int optname, + const void *optval, socklen_t optlen) +{ + SOCKET_ENTRY(); + + int ret = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + LOCK_SOCKET( fp ); + + ret = ops->setsockopt( fp, level, optname, optval, optlen ); + + UNLOCK_SOCKET( fp ); + } + + cyg_fp_free( fp ); + + SOCKET_RETURN(ret); +} + +// ------------------------------------------------------------------------- + +__externC int shutdown (int s, int how) +{ + SOCKET_ENTRY(); + + int ret = 0; + cyg_file *fp; + + fp = cyg_fp_get( s ); + + if( fp == NULL ) + FILEIO_RETURN(EBADF); + + if( fp->f_type == CYG_FILE_TYPE_SOCKET ) + { + cyg_sock_ops *ops = (cyg_sock_ops *)fp->f_xops; + + LOCK_SOCKET( fp ); + + ret = ops->shutdown( fp, how ); + + UNLOCK_SOCKET( fp ); + } + + cyg_fp_free( fp ); + + SOCKET_RETURN(ret); +} + +//========================================================================== +// Locking protocol + +static void cyg_ns_lock( cyg_nstab_entry *ns ) +{ + if( ns->syncmode & CYG_SYNCMODE_SOCK_NETSTACK ) + { + nstab_lock[ns-&nstab[0]].lock(); + } +} + +static void cyg_ns_unlock( cyg_nstab_entry *ns ) +{ + if( ns->syncmode & CYG_SYNCMODE_SOCK_NETSTACK ) + { + nstab_lock[ns-&nstab[0]].unlock(); + } +} + +static void cyg_sock_lock( cyg_file *fp ) +{ + cyg_nstab_entry *ns = (cyg_nstab_entry *)fp->f_mte; + + if( fp->f_syncmode & CYG_SYNCMODE_SOCK_NETSTACK ) + nstab_lock[ns-&nstab[0]].lock(); + + cyg_file_lock( fp, fp->f_syncmode>>CYG_SYNCMODE_SOCK_SHIFT); +} + +static void cyg_sock_unlock( cyg_file *fp ) +{ + cyg_nstab_entry *ns = (cyg_nstab_entry *)fp->f_mte; + + if( fp->f_syncmode & CYG_SYNCMODE_SOCK_NETSTACK ) + nstab_lock[ns-&nstab[0]].unlock(); + + cyg_file_lock( fp, fp->f_syncmode>>CYG_SYNCMODE_SOCK_SHIFT); +} + + +// ------------------------------------------------------------------------- +// EOF socket.cxx diff --git a/packages/io/fileio/current/tests/fileio1.c b/packages/io/fileio/current/tests/fileio1.c new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/tests/fileio1.c @@ -0,0 +1,466 @@ +//========================================================================== +// +// fileio1.c +// +// Test fileio system +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Test fileio system +// Description: This test uses the testfs to check out the initialization +// and basic operation of the fileio system +// +// +// +// +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include +#include +#include +#include +#include + +#include +#include // HAL polled output + +//========================================================================== +// Include the test filesystem. +// If we could make tests out of multiple files, then we could just link +// against the object file for this rather than including it. + +#include "testfs.c" + +//========================================================================== + +#define SHOW_RESULT( _fn, _res ) \ +diag_printf(": " #_fn "() returned %d %s\n", _res, _res<0?strerror(errno):""); + +//========================================================================== + +#define IOSIZE 100 + +//========================================================================== + +static char *strcat( char *s1, const char *s2 ) +{ + char *s = s1; + while( *s1 ) s1++; + while( (*s1++ = *s2++) != 0); + return s; +} + +//========================================================================== + +static void listdir( char *name, int statp ) +{ + int err; + DIR *dirp; + + diag_printf(": reading directory %s\n",name); + + dirp = opendir( name ); + if( dirp == NULL ) SHOW_RESULT( opendir, -1 ); + + for(;;) + { + struct dirent *entry = readdir( dirp ); + + if( entry == NULL ) + break; + + diag_printf(": entry %14s",entry->d_name); + if( statp ) + { + char fullname[PATH_MAX]; + struct stat sbuf; + + if( name[0] ) + { + strcpy(fullname, name ); + if( !(name[0] == '/' && name[1] == 0 ) ) + strcat(fullname, "/" ); + } + else fullname[0] = 0; + + strcat(fullname, entry->d_name ); + + err = stat( fullname, &sbuf ); + if( err < 0 ) + { + if( errno == ENOSYS ) + diag_printf(" "); + else SHOW_RESULT( stat, err ); + } + else + { + diag_printf(" [mode %08x nlink %d size %d]", + sbuf.st_mode,sbuf.st_nlink,sbuf.st_size); + } + } + + diag_printf("\n"); + } + + err = closedir( dirp ); + if( err < 0 ) SHOW_RESULT( stat, err ); +} + +//========================================================================== + +static void createfile( char *name, size_t size ) +{ + char buf[IOSIZE]; + int fd; + ssize_t wrote; + int i; + int err; + + diag_printf(": create file %s size %d\n",name,size); + + err = access( name, F_OK ); + if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err ); + + for( i = 0; i < IOSIZE; i++ ) buf[i] = i%256; + + fd = open( name, O_WRONLY|O_CREAT ); + if( fd < 0 ) SHOW_RESULT( open, fd ); + + while( size > 0 ) + { + ssize_t len = size; + if ( len > IOSIZE ) len = IOSIZE; + + wrote = write( fd, buf, len ); + if( wrote != len ) SHOW_RESULT( write, wrote ); + + size -= wrote; + } + + err = close( fd ); + if( err < 0 ) SHOW_RESULT( close, err ); +} + +//========================================================================== + +static void maxfile( char *name ) +{ + char buf[IOSIZE]; + int fd; + ssize_t wrote; + int i; + int err; + size_t size = 0; + + diag_printf(": create maximal file %s\n",name); + + err = access( name, F_OK ); + if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err ); + + for( i = 0; i < IOSIZE; i++ ) buf[i] = i%256; + + fd = open( name, O_WRONLY|O_CREAT ); + if( fd < 0 ) SHOW_RESULT( open, fd ); + + do + { + wrote = write( fd, buf, IOSIZE ); + if( wrote < 0 ) SHOW_RESULT( write, wrote ); + + size += wrote; + + } while( wrote == IOSIZE ); + + diag_printf(": file size == %d\n",size); + + err = close( fd ); + if( err < 0 ) SHOW_RESULT( close, err ); +} + +//========================================================================== + +static void checkfile( char *name ) +{ + char buf[IOSIZE]; + int fd; + ssize_t done; + int i; + int err; + + diag_printf(": check file %s\n",name); + + err = access( name, F_OK ); + if( err != 0 ) SHOW_RESULT( access, err ); + + fd = open( name, O_RDONLY ); + if( fd < 0 ) SHOW_RESULT( open, fd ); + + for(;;) + { + done = read( fd, buf, IOSIZE ); + if( done < 0 ) SHOW_RESULT( read, done ); + + if( done == 0 ) break; + + for( i = 0; i < done; i++ ) + if( buf[i] != i%256 ) + { + diag_printf("buf[%d](%02x) != %02x\n",i,buf[i],i%256); + CYG_TEST_FAIL("Data read not equal to data written\n"); + } + } + + err = close( fd ); + if( err < 0 ) SHOW_RESULT( close, err ); +} + +//========================================================================== + +static void copyfile( char *name2, char *name1 ) +{ + + int err; + char buf[IOSIZE]; + int fd1, fd2; + ssize_t done, wrote; + + diag_printf(": copy file %s -> %s\n",name2,name1); + + err = access( name1, F_OK ); + if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err ); + + err = access( name2, F_OK ); + if( err != 0 ) SHOW_RESULT( access, err ); + + fd1 = open( name1, O_WRONLY|O_CREAT ); + if( fd1 < 0 ) SHOW_RESULT( open, fd1 ); + + fd2 = open( name2, O_RDONLY ); + if( fd2 < 0 ) SHOW_RESULT( open, fd2 ); + + for(;;) + { + done = read( fd2, buf, IOSIZE ); + if( done < 0 ) SHOW_RESULT( read, done ); + + if( done == 0 ) break; + + wrote = write( fd1, buf, done ); + if( wrote != done ) SHOW_RESULT( write, wrote ); + + if( wrote != done ) break; + } + + err = close( fd1 ); + if( err < 0 ) SHOW_RESULT( close, err ); + + err = close( fd2 ); + if( err < 0 ) SHOW_RESULT( close, err ); + +} + +//========================================================================== + +static void comparefiles( char *name2, char *name1 ) +{ + int err; + char buf1[IOSIZE]; + char buf2[IOSIZE]; + int fd1, fd2; + ssize_t done1, done2; + int i; + + diag_printf(": compare files %s == %s\n",name2,name1); + + err = access( name1, F_OK ); + if( err != 0 ) SHOW_RESULT( access, err ); + + err = access( name1, F_OK ); + if( err != 0 ) SHOW_RESULT( access, err ); + + fd1 = open( name1, O_RDONLY ); + if( fd1 < 0 ) SHOW_RESULT( open, fd1 ); + + fd2 = open( name2, O_RDONLY ); + if( fd2 < 0 ) SHOW_RESULT( open, fd2 ); + + for(;;) + { + done1 = read( fd1, buf1, IOSIZE ); + if( done1 < 0 ) SHOW_RESULT( read, done1 ); + + done2 = read( fd2, buf2, IOSIZE ); + if( done2 < 0 ) SHOW_RESULT( read, done2 ); + + if( done1 != done2 ) + diag_printf("Files different sizes\n"); + + if( done1 == 0 ) break; + + for( i = 0; i < done1; i++ ) + if( buf1[i] != buf2[i] ) + { + diag_printf("buf1[%d](%02x) != buf1[%d](%02x)\n",i,buf1[i],i,buf2[i]); + CYG_TEST_FAIL("Data in files not equal\n"); + } + } + + err = close( fd1 ); + if( err < 0 ) SHOW_RESULT( close, err ); + + err = close( fd2 ); + if( err < 0 ) SHOW_RESULT( close, err ); + +} + +//========================================================================== +// main + +int main( int argc, char **argv ) +{ + int err; + + CYG_TEST_INIT(); + + // -------------------------------------------------------------- + + createfile( "/foo", 202 ); + checkfile( "foo" ); + copyfile( "foo", "fee"); + checkfile( "fee" ); + comparefiles( "foo", "/fee" ); + + err = mkdir( "/bar", 0 ); + if( err < 0 ) SHOW_RESULT( mkdir, err ); + + listdir( "/" , false); + + copyfile( "fee", "/bar/fum" ); + checkfile( "bar/fum" ); + comparefiles( "/fee", "bar/fum" ); + + + err = chdir( "bar" ); + if( err < 0 ) SHOW_RESULT( chdir, err ); + + err = rename( "/foo", "bundy" ); + if( err < 0 ) SHOW_RESULT( rename, err ); + + listdir( "/", true ); + listdir( "" , true ); + + checkfile( "/bar/bundy" ); + comparefiles("/fee", "bundy" ); + + testfs_dump(); + + // -------------------------------------------------------------- + + err = unlink( "/fee" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + err = unlink( "fum" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + err = unlink( "/bar/bundy" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + err = chdir( "/" ); + if( err < 0 ) SHOW_RESULT( chdir, err ); + + err = rmdir( "/bar" ); + if( err < 0 ) SHOW_RESULT( rmdir, err ); + + listdir( "/", false ); + + // -------------------------------------------------------------- + + err = mount( "", "/ram", "testfs" ); + if( err < 0 ) SHOW_RESULT( mount, err ); + + createfile( "/ram/tinky", 456 ); + copyfile( "/ram/tinky", "/ram/laalaa" ); + checkfile( "/ram/tinky"); + checkfile( "/ram/laalaa"); + comparefiles( "/ram/tinky", "/ram/laalaa" ); + + err = chdir( "/ram" ); + if( err < 0 ) SHOW_RESULT( chdir, err ); + + createfile( "tinky", 678 ); + checkfile( "tinky" ); + + maxfile( "dipsy" ); + checkfile( "dipsy" ); + copyfile( "dipsy", "po" ); + checkfile( "po" ); + comparefiles( "dipsy", "po" ); + + testfs_dump(); + + // -------------------------------------------------------------- + + err = unlink( "tinky" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + err = unlink( "dipsy" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + err = unlink( "po" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + err = unlink( "laalaa" ); + if( err < 0 ) SHOW_RESULT( unlink, err ); + + err = chdir( "/" ); + if( err < 0 ) SHOW_RESULT( chdir, err ); + + err = umount( "/ram" ); + if( err < 0 ) SHOW_RESULT( umount, err ); + + CYG_TEST_PASS_FINISH("fileio1"); +} + +// ------------------------------------------------------------------------- +// EOF fileio1.c diff --git a/packages/io/fileio/current/tests/select.c b/packages/io/fileio/current/tests/select.c new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/tests/select.c @@ -0,0 +1,618 @@ +//========================================================================== +// +// select.c +// +// Test select implementation +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Test select implementation +// Description: +// +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include +#include + +#ifdef CYGPKG_IO_SERIAL +#include +#endif + +#define __ECOS 1 // dont like this at all + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include + +#if 1 //defined(CYGPKG_NET) && defined(CYGPKG_POSIX) && defined(CYGPKG_IO_SERIAL_LOOP) + +#include +#include +#include +#include +#include + +#ifdef CYGPKG_NET +#include +#include +#define TEST_NET +#endif + +#ifdef CYGPKG_IO_SERIAL_LOOP +#define TEST_DEV +#endif + +#include +#include + + +#include // HAL polled output + +//-------------------------------------------------------------------------- + +#define SHOW_RESULT( _fn, _res ) \ +diag_printf(": " #_fn "() returned %d %s\n", _res, _res<0?strerror(errno):""); + +//-------------------------------------------------------------------------- +// Thread stack. + +char thread1_stack[PTHREAD_STACK_MIN*2]; +char thread2_stack[PTHREAD_STACK_MIN*2]; + +//-------------------------------------------------------------------------- +// Local variables + +// Thread IDs +pthread_t thread1; +pthread_t thread2; + +#ifdef TEST_NET +struct sockaddr_in sa; +#endif + +//-------------------------------------------------------------------------- +// Test buffers +// The buffer size here must be less that the size of the serial device +// buffers since the serial devices do not currently implement flow +// control. + +#define TEST_BUFSIZE 100 + +#ifdef TEST_NET +static char buf1[TEST_BUFSIZE]; +static char buf2[TEST_BUFSIZE]; +static char buf3[TEST_BUFSIZE]; +#endif +#ifdef TEST_DEV +static char sbuf1[TEST_BUFSIZE]; +static char sbuf2[TEST_BUFSIZE]; +static char sbuf3[TEST_BUFSIZE]; +#endif + + +//-------------------------------------------------------------------------- + +void show_fdsets( char *s, int nfd, fd_set *rd, fd_set *wr, fd_set *ex ) +{ + int i; + diag_printf("INFO:<%s nfd %d",s,nfd); + + if( rd ) + { + diag_printf("rd: "); + for( i = 0; i < nfd ; i++ ) + if( FD_ISSET( i, rd ) ) diag_printf("%d ",i); + } + if( wr ) + { + diag_printf("wr: "); + for( i = 0; i < nfd ; i++ ) + if( FD_ISSET( i, wr ) ) diag_printf("%d ",i); + } + if( ex ) + { + diag_printf("ex: "); + for( i = 0; i < nfd ; i++ ) + if( FD_ISSET( i, ex ) ) diag_printf("%d ",i); + } + + diag_printf(">\n"); +} + + +//-------------------------------------------------------------------------- + +void *pthread_entry1( void *arg) +{ +#ifdef TEST_NET + int fd = 0, fd2 = -1; + struct sockaddr_in accsa; + socklen_t accsa_len = sizeof(accsa); + int netstate = 0; +#endif +#ifdef TEST_DEV + int ser0; + int serstate = 0; +#endif +#if defined(TEST_DEV) || defined(TEST_NET) + int i; + ssize_t done; +#endif + int netdone = 0; + int serdone = 0; + int err; + fd_set rd, wr; + + CYG_TEST_INFO( "Thread 1 running" ); + + FD_ZERO( &rd ); + FD_ZERO( &wr ); + +#ifdef TEST_DEV + + CYG_TEST_INFO( "Thread1: calling open()"); + ser0 = open("/dev/ser0", O_RDWR ); + if( ser0 < 0 ) SHOW_RESULT( open, ser0 ); + CYG_TEST_CHECK( ser0 >= 0, "open(/dev/ser0) returned error"); + + FD_SET( ser0, &rd ); +#else + serdone = 1; +#endif + +#ifdef TEST_NET + + for( i = 0; i < TEST_BUFSIZE; i++ ) buf1[i] = i; + + CYG_TEST_INFO( "Thread1: calling socket()"); + fd = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + if( fd < 0 ) SHOW_RESULT( socket, fd ); + CYG_TEST_CHECK( fd >= 0, "socket() returned error"); + + CYG_TEST_INFO( "Thread1: calling bind()"); + err = bind( fd, (struct sockaddr *)&sa, sizeof(sa)); + if( err < 0 ) SHOW_RESULT( bind, err ); + CYG_TEST_CHECK( err == 0, "bind() returned error"); + + CYG_TEST_INFO( "Thread1: calling listen()"); + err = listen( fd, 3); + if( err < 0 ) SHOW_RESULT( listen, err ); + CYG_TEST_CHECK( err == 0, "listen() returned error"); + + FD_SET( fd, &rd ); + +#else + netdone = 1; +#endif + + while(!(netdone && serdone)) + { + fd_set rd_res = rd; + fd_set wr_res = wr; + + CYG_TEST_INFO( "Thread1: calling select()"); + show_fdsets( "Thread1 request: ", 8, &rd_res, &wr_res, NULL ); + err = select( 8, &rd_res, &wr_res, NULL, NULL ); + if( err < 0 ) SHOW_RESULT( select, err ); + CYG_TEST_CHECK( err >= 0, "select() returned error"); + show_fdsets( "Thread1 result: ", 8, &rd_res, &wr_res, NULL ); + +#ifdef TEST_NET + switch( netstate ) + { + case 0: + CYG_TEST_INFO( "Thread1: netstate 0"); + if( FD_ISSET( fd, &rd_res ) ) + { + CYG_TEST_INFO( "Thread1: calling accept(fd)"); + fd2 = accept( fd, (struct sockaddr *)&accsa, &accsa_len ); + if( fd2 < 0 ) SHOW_RESULT( accept, fd2 ); + CYG_TEST_CHECK( fd2 >= 0, "accept() returned error"); + + FD_CLR( fd, &rd ); + FD_SET( fd2, &wr ); + + netstate++; + } + break; + + + case 1: + CYG_TEST_INFO( "Thread1: netstate 1"); + if( FD_ISSET( fd2, &wr_res ) ) + { + + CYG_TEST_INFO( "Thread1: calling write(fd2)"); + done = write( fd2, buf1, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( write, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "write() returned bad size"); + + FD_CLR( fd2, &wr ); + FD_SET( fd2, &rd ); + + netstate++; + } + break; + + case 2: + CYG_TEST_INFO( "Thread1: netstate 2"); + if( FD_ISSET( fd2, &rd_res ) ) + { + CYG_TEST_INFO( "Thread1: calling read(fd2)"); + done = read( fd2, buf3, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( read, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "read() returned bad size"); + + for( i = 0; i < TEST_BUFSIZE; i++ ) + if( buf1[i] != buf3[i] ) + diag_printf("buf1[%d](%02x) != buf3[%d](%02x)\n",i,buf1[i],i,buf3[i]); + + FD_CLR( fd2, &rd ); + + netstate++; + netdone = 1; + CYG_TEST_INFO( "Thread1: netdone"); + } + break; + + } +#endif + +#ifdef TEST_DEV + switch( serstate ) + { + case 0: + CYG_TEST_INFO( "Thread1: serstate 0"); + if( FD_ISSET( ser0, &rd_res ) ) + { + CYG_TEST_INFO( "Thread1: calling read(ser0)"); + done = read( ser0, sbuf2, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( read, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "read() returned bad size"); + + for( i = 0; i < TEST_BUFSIZE; i++ ) + if( sbuf1[i] != sbuf2[i] ) + diag_printf("buf1[%d](%02x) != buf2[%d](%02x)\n",i,sbuf1[i],i,sbuf2[i]); + + FD_CLR( ser0, &rd ); + FD_SET( ser0, &wr ); + serstate++; + + } + break; + + case 1: + CYG_TEST_INFO( "Thread1: serstate 1"); + if( FD_ISSET( ser0, &wr_res ) ) + { + CYG_TEST_INFO( "Thread1: calling write(ser0)"); + done = write( ser0, sbuf2, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( write, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "write() returned bad size"); + + FD_CLR( ser0, &wr ); + + serstate++; + serdone = 1; + CYG_TEST_INFO( "Thread1: serdone"); + } + else FD_SET( ser0, &wr ); + break; + } +#endif + } + +#ifdef TEST_NET + CYG_TEST_INFO( "Thread1: calling close(fd)"); + err = close(fd); + if( err < 0 ) SHOW_RESULT( close, err ); + CYG_TEST_CHECK( err == 0, "close() returned error"); + + if( fd2 >= 0 ) + { + CYG_TEST_INFO( "Thread1: calling close(fd2)"); + err = close(fd2); + if( err < 0 ) SHOW_RESULT( close, err ); + CYG_TEST_CHECK( err == 0, "close() returned error"); + } +#endif +#ifdef TEST_DEV + CYG_TEST_INFO( "Thread1: calling close(ser0)"); + err = close(ser0); + if( err < 0 ) SHOW_RESULT( close, err ); + CYG_TEST_CHECK( err == 0, "close() returned error"); +#endif + + CYG_TEST_INFO( "Thread1: calling pthread_exit()"); + pthread_exit( arg ); +} + +//-------------------------------------------------------------------------- + +void *pthread_entry2( void *arg) +{ +#ifdef TEST_NET + int fd; + int netstate = 0; +#endif +#ifdef TEST_DEV + int ser1; + int serstate = 0; +#endif +#if defined(TEST_DEV) || defined(TEST_NET) + int i; + ssize_t done; +#endif + int netdone = 0; + int serdone = 0; + int err; + fd_set rd, wr; + + CYG_TEST_INFO( "Thread 2 running" ); + + FD_ZERO( &rd ); + FD_ZERO( &wr ); + +#ifdef TEST_NET + CYG_TEST_INFO( "Thread2: calling socket()"); + fd = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + if( fd < 0 ) SHOW_RESULT( socket, fd ); + CYG_TEST_CHECK( fd >= 0, "socket() returned error"); + + CYG_TEST_INFO( "Thread2: calling connect()"); + err = connect( fd, (struct sockaddr *)&sa, sizeof(sa)); + if( err < 0 ) SHOW_RESULT( connect, err ); + CYG_TEST_CHECK( err == 0, "connect() returned error"); + + FD_SET( fd, &rd ); +#else + netdone = 1; +#endif + +#ifdef TEST_DEV + for( i = 0; i < TEST_BUFSIZE; i++ ) sbuf1[i] = i; + + CYG_TEST_INFO( "Thread2: calling open(/dev/ser1)"); + ser1 = open("/dev/ser1", O_RDWR ); + if( ser1 < 0 ) SHOW_RESULT( open, ser1 ); + CYG_TEST_CHECK( ser1 >= 0, "open(/dev/ser1) returned error"); + + CYG_TEST_INFO( "Thread2: calling write(ser1)"); + done = write( ser1, sbuf1, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( write, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "write() returned bad size"); + + FD_SET( ser1, &wr ); + +#else + serdone = 1; +#endif + + while(!(netdone && serdone)) + { + fd_set rd_res = rd; + fd_set wr_res = wr; + + CYG_TEST_INFO( "Thread2: calling select()"); + show_fdsets( "Thread2 request: ", 8, &rd_res, &wr_res, NULL ); + err = select( 8, &rd_res, &wr_res, NULL, NULL ); + if( err < 0 ) SHOW_RESULT( select, err ); + CYG_TEST_CHECK( err >= 0, "select() returned error"); + show_fdsets( "Thread2 result: ", 8, &rd_res, &wr_res, NULL ); + +#ifdef TEST_NET + switch( netstate ) + { + case 0: + CYG_TEST_INFO( "Thread2: netstate 0"); + if( FD_ISSET( fd, &rd_res ) ) + { + CYG_TEST_INFO( "Thread2: calling read()"); + done = read( fd, buf2, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( read, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "read() returned bad size"); + + for( i = 0; i < TEST_BUFSIZE; i++ ) + if( buf1[i] != buf2[i] ) + diag_printf("buf1[%d](%02x) != buf2[%d](%02x)\n",i,buf1[i],i,buf2[i]); + + netstate++; + + FD_CLR( fd, &rd ); + FD_SET( fd, &wr ); + } + break; + + case 1: + CYG_TEST_INFO( "Thread2: netstate 1"); + if( FD_ISSET( fd, &wr_res ) ) + { + + CYG_TEST_INFO( "Thread2: calling write()"); + done = write( fd, buf2, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( write, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "write() returned bad size"); + + FD_CLR( fd, &wr ); + + netstate++; + netdone = 1; + CYG_TEST_INFO( "Thread2: netdone"); + } + break; + + } +#endif + +#ifdef TEST_DEV + switch( serstate ) + { + case 0: + CYG_TEST_INFO( "Thread2: serstate 0"); + if( FD_ISSET( ser1, &wr_res ) ) + { + FD_CLR( ser1, &wr ); + FD_SET( ser1, &rd ); + serstate++; + } + break; + + case 1: + CYG_TEST_INFO( "Thread2: serstate 1"); + if( FD_ISSET( ser1, &rd_res ) ) + { + CYG_TEST_INFO( "Thread2: calling read(ser1)"); + done = read( ser1, sbuf3, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( read, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "read() returned bad size"); + + for( i = 0; i < TEST_BUFSIZE; i++ ) + if( sbuf1[i] != sbuf3[i] ) + diag_printf("sbuf1[%d](%02x) != sbuf3[%d](%02x)\n",i,sbuf1[i],i,sbuf3[i]); + + FD_CLR( ser1, &rd ); + + serstate++; + serdone = 1; + CYG_TEST_INFO( "Thread2: serdone"); + } + break; + } +#endif + } + +#ifdef TEST_NET + CYG_TEST_INFO( "Thread2: calling close(fd)"); + err = close(fd); + if( err < 0 ) SHOW_RESULT( close, err ); + CYG_TEST_CHECK( err == 0, "close() returned error"); +#endif +#ifdef TEST_DEV + CYG_TEST_INFO( "Thread2: calling close(ser1)"); + err = close(ser1); + if( err < 0 ) SHOW_RESULT( close, err ); + CYG_TEST_CHECK( err == 0, "close(ser1) returned error"); +#endif + + + CYG_TEST_INFO( "Thread2: calling pthread_exit()"); + pthread_exit( arg ); +} + +//========================================================================== +// main + +int main( int argc, char **argv ) +{ + void *retval; + pthread_attr_t attr; + struct sched_param schedparam; + + CYG_TEST_INIT(); + +#ifdef TEST_NET + sa.sin_family = AF_INET; + inet_aton("127.0.0.1", &sa.sin_addr); + sa.sin_port = htons(1234); + init_all_network_interfaces(); +#endif + + // Create test threads + + { + pthread_attr_init( &attr ); + + schedparam.sched_priority = 10; + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + pthread_attr_setschedparam( &attr, &schedparam ); + pthread_attr_setstackaddr( &attr, (void *)&thread1_stack[sizeof(thread1_stack)] ); + pthread_attr_setstacksize( &attr, sizeof(thread1_stack) ); + + pthread_create( &thread1, + &attr, + pthread_entry1, + (void *)0x12345671); + } + + { + pthread_attr_init( &attr ); + + schedparam.sched_priority = 5; + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + pthread_attr_setschedparam( &attr, &schedparam ); + pthread_attr_setstackaddr( &attr, (void *)&thread2_stack[sizeof(thread2_stack)] ); + pthread_attr_setstacksize( &attr, sizeof(thread2_stack) ); + + pthread_create( &thread2, + &attr, + pthread_entry2, + (void *)0x12345672); + } + + // Now join with thread1 + CYG_TEST_INFO( "Main: calling pthread_join(thread1)"); + pthread_join( thread1, &retval ); + + // And thread 2 + CYG_TEST_INFO( "Main: calling pthread_join(thread2)"); + pthread_join( thread2, &retval ); + + CYG_TEST_PASS_FINISH("select"); +} + +#else + +//========================================================================== +// main + +int main( int argc, char **argv ) +{ + CYG_TEST_INIT(); + + CYG_TEST_NA("socket"); +} + +#endif + + +// ------------------------------------------------------------------------- +// EOF socket.c diff --git a/packages/io/fileio/current/tests/socket.c b/packages/io/fileio/current/tests/socket.c new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/tests/socket.c @@ -0,0 +1,340 @@ +//========================================================================== +// +// socket.c +// +// Test socket API +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Test socket API +// Description: This program tests the socket API. Note that it is only +// intended to test the API and not the functionality of +// the underlying network stack. That is assumed to have +// been established by other tests elsewhere. +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + + +#define __ECOS 1 + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include + +#if defined(CYGPKG_NET) && defined(CYGPKG_POSIX) + +#include +#include +#include +#include + +#include +#include + +#include +#include + + +#include // HAL polled output + +//-------------------------------------------------------------------------- + +#define SHOW_RESULT( _fn, _res ) \ +diag_printf(#_fn " returned %d %s\n", _res, _res<0?strerror(errno):""); + +//-------------------------------------------------------------------------- +// Thread stack. + +char thread1_stack[PTHREAD_STACK_MIN*2]; +char thread2_stack[PTHREAD_STACK_MIN*2]; + +//-------------------------------------------------------------------------- +// Local variables + +// Thread IDs +pthread_t thread1; +pthread_t thread2; + +struct sockaddr_in sa; + +//-------------------------------------------------------------------------- +// test buffers + +#define TEST_BUFSIZE 512 + +static char buf1[TEST_BUFSIZE]; +static char buf2[TEST_BUFSIZE]; +static char buf3[TEST_BUFSIZE]; + +//-------------------------------------------------------------------------- + +void *pthread_entry1( void *arg) +{ + int fd, fd2; + struct sockaddr_in accsa; + socklen_t accsa_len = sizeof(accsa); + int err; +// int one = 1; +// int so1 = sizeof(one); + fd_set rd; + int i; + ssize_t done; + + CYG_TEST_INFO( "Thread 1 running" ); + + CYG_TEST_INFO( "Thread1: calling socket()"); + fd = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + if( fd < 0 ) SHOW_RESULT( socket, fd ); + CYG_TEST_CHECK( fd >= 0, "socket() returned error"); + +// err = setsockopt( fd, SOL_SOCKET, SO_DONTROUTE, (void *)&one, so1); +// if( err < 0 ) SHOW_RESULT( setsockopt, err ); +// CYG_TEST_CHECK( err == 0, "setsockopt() returned error"); + + CYG_TEST_INFO( "Thread1: calling bind()"); + err = bind( fd, (struct sockaddr *)&sa, sizeof(sa)); + if( err < 0 ) SHOW_RESULT( bind, err ); + CYG_TEST_CHECK( err == 0, "bind() returned error"); + + CYG_TEST_INFO( "Thread1: calling listen()"); + err = listen( fd, 1); + if( err < 0 ) SHOW_RESULT( listen, err ); + CYG_TEST_CHECK( err == 0, "listen() returned error"); + + FD_ZERO( &rd ); + FD_SET( fd, &rd ); + + CYG_TEST_INFO( "Thread1: calling select()"); + err = select( fd+1, &rd, NULL, NULL, NULL ); + if( err < 0 ) SHOW_RESULT( select, err ); + CYG_TEST_CHECK( err >= 0, "select() returned error"); + CYG_TEST_CHECK( FD_ISSET( fd, &rd ), "Fd not set in select() result"); + + CYG_TEST_INFO( "Thread1: calling accept()"); + fd2 = accept( fd, (struct sockaddr *)&accsa, &accsa_len ); + if( fd2 < 0 ) SHOW_RESULT( accept, fd2 ); + CYG_TEST_CHECK( fd2 >= 0, "accept() returned error"); + + + for( i = 0; i < TEST_BUFSIZE; i++ ) buf1[i] = i; + + CYG_TEST_INFO( "Thread1: calling write()"); + done = write( fd2, buf1, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( write, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "write() returned bad size"); + + FD_ZERO( &rd ); + FD_SET( fd2, &rd ); + + CYG_TEST_INFO( "Thread1: calling select()"); + err = select( fd2+1, &rd, NULL, NULL, NULL ); + if( err < 0 ) SHOW_RESULT( select, err ); + CYG_TEST_CHECK( err >= 0, "select() returned error"); + CYG_TEST_CHECK( FD_ISSET( fd2, &rd ), "Fd2 not set in select() result"); + + CYG_TEST_INFO( "Thread1: calling read()"); + done = read( fd2, buf3, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( read, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "read() returned bad size"); + + for( i = 0; i < TEST_BUFSIZE; i++ ) + if( buf1[i] != buf3[i] ) + diag_printf("buf1[%d](%02x) != buf3[%d](%02x)\n",i,buf1[i],i,buf3[i]); + + CYG_TEST_INFO( "Thread1: calling close(fd)"); + err = close(fd); + if( err < 0 ) SHOW_RESULT( close, err ); + CYG_TEST_CHECK( err == 0, "close() returned error"); + + CYG_TEST_INFO( "Thread1: calling close(fd2)"); + err = close(fd2); + if( err < 0 ) SHOW_RESULT( close, err ); + CYG_TEST_CHECK( err == 0, "close() returned error"); + + CYG_TEST_INFO( "Thread1: calling pthread_exit()"); + pthread_exit( arg ); +} + +//-------------------------------------------------------------------------- + +void *pthread_entry2( void *arg) +{ + int fd; + int err; +// int one = 1; +// int so1 = sizeof(one); + int i; + ssize_t done; + fd_set rd; + + CYG_TEST_INFO( "Thread 2 running" ); + + CYG_TEST_INFO( "Thread2: calling socket()"); + fd = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + if( fd < 0 ) SHOW_RESULT( socket, fd ); + CYG_TEST_CHECK( fd >= 0, "socket() returned error"); + +// err = setsockopt( fd, SOL_SOCKET, SO_DONTROUTE, (void *)&one, so1); +// if( err < 0 ) SHOW_RESULT( setsockopt, err ); +// CYG_TEST_CHECK( err == 0, "setsockopt() returned error"); + + CYG_TEST_INFO( "Thread2: calling connect()"); + err = connect( fd, (struct sockaddr *)&sa, sizeof(sa)); + if( err < 0 ) SHOW_RESULT( connect, err ); + CYG_TEST_CHECK( err == 0, "connect() returned error"); + + FD_ZERO( &rd ); + FD_SET( fd, &rd ); + + CYG_TEST_INFO( "Thread2: calling select()"); + err = select( fd+1, &rd, NULL, NULL, NULL ); + if( err < 0 ) SHOW_RESULT( select, err ); + CYG_TEST_CHECK( err >= 0, "select() returned error"); + CYG_TEST_CHECK( FD_ISSET( fd, &rd ), "Fd not set in select() result"); + + CYG_TEST_INFO( "Thread2: calling read()"); + done = read( fd, buf2, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( read, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "read() returned bad size"); + + for( i = 0; i < TEST_BUFSIZE; i++ ) + if( buf1[i] != buf2[i] ) + diag_printf("buf1[%d](%02x) != buf2[%d](%02x)\n",i,buf1[i],i,buf2[i]); + + CYG_TEST_INFO( "Thread2: calling write()"); + done = write( fd, buf2, TEST_BUFSIZE); + if( done != TEST_BUFSIZE ) SHOW_RESULT( write, done ); + CYG_TEST_CHECK( done == TEST_BUFSIZE, "write() returned bad size"); + + CYG_TEST_INFO( "Thread2: calling close(fd)"); + err = close(fd); + if( err < 0 ) SHOW_RESULT( close, err ); + CYG_TEST_CHECK( err == 0, "close() returned error"); + + CYG_TEST_INFO( "Thread2: calling pthread_exit()"); + pthread_exit( arg ); +} + +//========================================================================== +// main + +int main( int argc, char **argv ) +{ + struct in_addr ina; + char *addr1 = "127.0.255.106"; + char *addr2; + void *retval; + pthread_attr_t attr; + struct sched_param schedparam; + + sa.sin_family = AF_INET; + inet_aton("127.0.0.1", &sa.sin_addr); + sa.sin_port = htons(1234); + + CYG_TEST_INIT(); + + // Test inet_ntoa() and inet_aton() + + inet_aton(addr1, &ina); + addr2 = inet_ntoa(ina); + CYG_TEST_CHECK( strcmp(addr1, addr2) == 0, "Bad inet adderess conversion"); + + + // Create test threads + + { + pthread_attr_init( &attr ); + + schedparam.sched_priority = 10; + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + pthread_attr_setschedparam( &attr, &schedparam ); + pthread_attr_setstackaddr( &attr, (void *)&thread1_stack[sizeof(thread1_stack)] ); + pthread_attr_setstacksize( &attr, sizeof(thread1_stack) ); + + pthread_create( &thread1, + &attr, + pthread_entry1, + (void *)0x12345671); + } + + { + pthread_attr_init( &attr ); + + schedparam.sched_priority = 5; + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + pthread_attr_setschedparam( &attr, &schedparam ); + pthread_attr_setstackaddr( &attr, (void *)&thread2_stack[sizeof(thread2_stack)] ); + pthread_attr_setstacksize( &attr, sizeof(thread2_stack) ); + + pthread_create( &thread2, + &attr, + pthread_entry2, + (void *)0x12345672); + } + + // Now join with thread1 + CYG_TEST_INFO( "Main: calling pthread_join(thread1)"); + pthread_join( thread1, &retval ); + + // And thread 2 + CYG_TEST_INFO( "Main: calling pthread_join(thread2)"); + pthread_join( thread2, &retval ); + + CYG_TEST_PASS_FINISH("socket"); +} + +#else + +//========================================================================== +// main + +int main( int argc, char **argv ) +{ + CYG_TEST_INIT(); + + CYG_TEST_NA("socket"); +} + +#endif + + +// ------------------------------------------------------------------------- +// EOF socket.c diff --git a/packages/io/fileio/current/tests/stdio.c b/packages/io/fileio/current/tests/stdio.c new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/tests/stdio.c @@ -0,0 +1,170 @@ +//========================================================================== +// +// stdio.c +// +// Test stdio integration of fileio system +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Test stdio integration of fileio system +// Description: This test uses the testfs to check that the options +// in the STDIO package that enable use of the fileio +// API work correctly. +// +// +// +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include + +#include +#include // HAL polled output + +//========================================================================== +// Include the test filesystem. +// If we could make tests out of multiple files, then we could just link +// against the object file for this rather than including it. + +#include "testfs.c" + +//========================================================================== + +#define SHOW_RESULT( _fn, _res ) \ +diag_printf(": " #_fn "() returned %d %s\n", _res, _res<0?strerror(errno):""); + + +#ifdef CYGPKG_LIBC_STDIO + +//========================================================================== +// main + +int main( int argc, char **argv ) +{ + int err; + FILE *f; + fpos_t fpos; + + int flibble = 4567; + char *wibble = "abcdefghijk"; + + int flibble1; + char wibble1[20]; + + CYG_TEST_INIT(); + + + f = fopen("/foo", "w" ); + if( f == NULL ) SHOW_RESULT( fopen, -1 ); + + err = fprintf(f, "flibble %d wibble %s\n", flibble, wibble ); + if( err < 0 ) SHOW_RESULT( fprintf, err ); + + err = fprintf(f, "another flibble %d another wibble %s\n", flibble, wibble ); + if( err < 0 ) SHOW_RESULT( fprintf, err ); + + err = fclose( f ); + if( err == EOF ) SHOW_RESULT( fclose, -1 ); + + + + f = fopen("/foo", "r" ); + if( f == NULL ) SHOW_RESULT( fopen, -1 ); + + err = fscanf(f, "flibble %d wibble %s\n", &flibble1, wibble1 ); + if( err < 0 ) SHOW_RESULT( fscanf, err ); + + diag_printf(": flibble1 %d wibble1 %s\n",flibble1,wibble1); + + CYG_TEST_CHECK( flibble1 == flibble , "Bad flibble result from fscanf"); + CYG_TEST_CHECK( strcmp(wibble,wibble1) == 0, "Bad wibble result from fscanf"); + + + err = fgetpos( f, &fpos ); + if( err < 0 ) SHOW_RESULT( fgetpos, err ); + + err = fseek( f, 0, SEEK_SET ); + if( err < 0 ) SHOW_RESULT( fseek, err ); + + err = fscanf(f, "flibble %d wibble %s\n", &flibble1, wibble1 ); + if( err < 0 ) SHOW_RESULT( fscanf, err ); + + diag_printf(": flibble1 %d wibble1 %s\n",flibble1,wibble1); + + CYG_TEST_CHECK( flibble1 == flibble , "Bad flibble result from fscanf"); + CYG_TEST_CHECK( strcmp(wibble,wibble1) == 0, "Bad wibble result from fscanf"); + + + err = fseek( f, 0, SEEK_END ); + if( err < 0 ) SHOW_RESULT( fseek, err ); + + err = fsetpos( f, &fpos ); + if( err < 0 ) SHOW_RESULT( fsetpos, err ); + + err = fscanf(f, "another flibble %d another wibble %s\n", &flibble1, wibble1 ); + if( err < 0 ) SHOW_RESULT( fscanf, err ); + + diag_printf(": flibble1 %d wibble1 %s\n",flibble1,wibble1); + + CYG_TEST_CHECK( flibble1 == flibble , "Bad flibble result from fscanf"); + CYG_TEST_CHECK( strcmp(wibble,wibble1) == 0, "Bad wibble result from fscanf"); + + + + err = fclose( f ); + + + + CYG_TEST_PASS_FINISH("stdio"); + + return 0; +} + +#else + +// ------------------------------------------------------------------------- + +int main( int argc, char **argv ) +{ + + CYG_TEST_INIT(); + + CYG_TEST_NA("stdio"); +} + +#endif + +// ------------------------------------------------------------------------- +// EOF stdio.c diff --git a/packages/io/fileio/current/tests/testfs.c b/packages/io/fileio/current/tests/testfs.c new file mode 100644 --- /dev/null +++ b/packages/io/fileio/current/tests/testfs.c @@ -0,0 +1,1240 @@ +//========================================================================== +// +// testfs.c +// +// Test file system +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-05-25 +// Purpose: Test file system +// Description: This is a very simple implementation of a RAM file system. +// This implementation is not "industrial strength" or suitable +// for production use, it is too wasteful of both memory and time. +// Its primary purpose is to support testing of the fileio +// infrastructure and API. It can, however, serve as a model +// and source of code fragments for the implementation +// of further filesystems. +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#include // base kernel types +#include // tracing macros +#include // assertion macros + +#include +#include +#include +#include +#include + +#include + +#include +#include + +//========================================================================== +// Configuration parameters + +#define TESTFS_NFILE 10 // Max number of files/directories +#define TESTFS_NBLOCK 20 // Number of data blocks available +#define TESTFS_BLOCKSIZE 128 // Bytes stored per block +#define TESTFS_FILEBLOCKS 8 // Max blocks per file +#define TESTFS_NAMESIZE 32 // Length of file names in bytes + + +// Maximum file size is blocksize*blocks +#define TESTFS_FILESIZE_MAX (TESTFS_BLOCKSIZE*TESTFS_FILEBLOCKS) + +//========================================================================== +// Data structures + +struct testfs_node; +typedef struct testfs_node testfs_node; + +struct testfs_block; +typedef struct testfs_block testfs_block; + + +struct testfs_node +{ + testfs_node *next; // next node in list + testfs_node *parent; // Back pointer to parent + int refcnt; // reference count + char name[TESTFS_NAMESIZE]; // file name + struct stat status; // status data + union + { + struct + { + testfs_block *data[TESTFS_FILEBLOCKS]; // array of blocks + } file; + + struct + { + testfs_node *nodes[TESTFS_FILEBLOCKS]; // array of nodes + } dir; + } u; +}; + +struct testfs_block +{ + union + { + testfs_block *next; // next block in free list + testfs_node *file; // back pointer to file + } u; + off_t pos; // position in file of first byte + size_t size; // number of bytes in buffer + char data[TESTFS_BLOCKSIZE]; // the data +}; + +//========================================================================== +// Local data + +// Array of nodes +static testfs_node node[TESTFS_NFILE]; + +// node free list. +static testfs_node *free_node = NULL; + +// Array of data blocks +static testfs_block block[TESTFS_NBLOCK]; + +// block free list. +static testfs_block *free_block = NULL; + +// Init flag +cyg_bool testfs_initialized = false; + +//========================================================================== +// Forward definitions + +// Filesystem operations +static int testfs_mount ( cyg_fstab_entry *fste, cyg_mtab_entry *mte ); +static int testfs_umount ( cyg_mtab_entry *mte ); +static int testfs_open ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int mode, cyg_file *fte ); +static int testfs_unlink ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +static int testfs_mkdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +static int testfs_rmdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name ); +static int testfs_rename ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2 ); +static int testfs_link ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1, + cyg_dir dir2, const char *name2, int type ); +static int testfs_opendir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_file *fte ); +static int testfs_chdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + cyg_dir *dir_out ); +static int testfs_stat ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + struct stat *buf); +static int testfs_getinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ); +static int testfs_setinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name, + int key, void *buf, int len ); + +// File operations +static int testfs_fo_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +static int testfs_fo_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +static int testfs_fo_lseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence ); +static int testfs_fo_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com, + CYG_ADDRWORD data); +//static int testfs_fo_select (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info); +static int testfs_fo_fsync (struct CYG_FILE_TAG *fp, int mode ); +static int testfs_fo_close (struct CYG_FILE_TAG *fp); +static int testfs_fo_fstat (struct CYG_FILE_TAG *fp, struct stat *buf ); +static int testfs_fo_getinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ); +static int testfs_fo_setinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ); + +// Directory operations +static int testfs_fo_dirread (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +static int testfs_fo_dirlseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence ); + +//========================================================================== +// Filesystem table entries + +FSTAB_ENTRY( testfs_fste, "testfs", 0, + CYG_SYNCMODE_FILE_FILESYSTEM|CYG_SYNCMODE_IO_FILESYSTEM, + testfs_mount, + testfs_umount, + testfs_open, + testfs_unlink, + testfs_mkdir, + testfs_rmdir, + testfs_rename, + testfs_link, + testfs_opendir, + testfs_chdir, + testfs_stat, + testfs_getinfo, + testfs_setinfo); + +MTAB_ENTRY( testfs_mte1, + "/", + "testfs", + "", + 0); + +#if 0 +MTAB_ENTRY( testfs_mte2, + "/ram", + "testfs", + "", + 0); +#endif + +static cyg_fileops testfs_fileops = +{ + testfs_fo_read, + testfs_fo_write, + testfs_fo_lseek, + testfs_fo_ioctl, + cyg_fileio_seltrue, + testfs_fo_fsync, + testfs_fo_close, + testfs_fo_fstat, + testfs_fo_getinfo, + testfs_fo_setinfo +}; + +static cyg_fileops testfs_dirops = +{ + testfs_fo_dirread, + (cyg_fileop_write *)cyg_fileio_enosys, + testfs_fo_dirlseek, + (cyg_fileop_ioctl *)cyg_fileio_enosys, + cyg_fileio_seltrue, + (cyg_fileop_fsync *)cyg_fileio_enosys, + testfs_fo_close, + (cyg_fileop_fstat *)cyg_fileio_enosys, + (cyg_fileop_getinfo *)cyg_fileio_enosys, + (cyg_fileop_setinfo *)cyg_fileio_enosys +}; + +//========================================================================== +// Support routines + +// ------------------------------------------------------------------------- +// Local strcmp() and strcpy() + +static int strcmp( const char *s1, const char *s2 ) +{ + while( *s1 == *s2 && *s1 != '\0' && *s2 != '\0' ) + s1++, s2++; + + return (*s2)-(*s1); +} + +static char *strcpy( char *s1, const char *s2 ) +{ + char *s = s1; + while( (*s1++ = *s2++) != 0); + return s; +} + +// ------------------------------------------------------------------------- +// Follow a path through the directory structure + +static int testfs_find( testfs_node *dir, // dir to start search in + const char *path, // path to follow + testfs_node **found, // return node found + testfs_node **parent, // return last dir searched + char *name, // name fragment buffer + cyg_bool *lastp) // last name in path ? +{ + testfs_node *nd = dir; + + *lastp = false; + *found = NULL; + + while( *path != '\0' ) + { + const char *p = path; + char *n = name; + testfs_node *nd1; + int i; + + // check nd is a directory + if( !S_ISDIR(nd->status.st_mode) ) return ENOTDIR; + + // Isolate the next element of the path name. + while( *p != '\0' && *p != '/' && (n-&name[0]) < TESTFS_NAMESIZE) + *n++ = *p++; + + if( (n-&name[0]) >= TESTFS_NAMESIZE ) + return ENAMETOOLONG; + + // Step path on past the separator + // If this is the last name element in the path, + // set *lastp to indicate this. + if( *(path=p) == '/' ) path++; + else *lastp = true; + + // teminate name + *n = '\0'; + + // name now contains the next path element, search the node + // in nd for it. + + *parent = nd; + nd1 = NULL; + + for( i = 0; i < TESTFS_FILEBLOCKS; i++ ) + { + testfs_node *n = nd->u.dir.nodes[i]; + if( n == NULL ) + continue; + + if( strcmp( name, n->name ) == 0 ) + { + nd1 = n; + break; + } + } + + if( nd1 == NULL ) return ENOENT; + + nd = nd1; + } + + // Return what we have found + *found = nd; + + return ENOERR; +} + +// ------------------------------------------------------------------------- +// Get current time since epoch + +static time_t testfs_time(void) +{ + // FIXME: !!!!Temporary!!!! + return cyg_current_time(); +} + +// ------------------------------------------------------------------------- + +static int testfs_delnode( testfs_node *nd ) +{ + + testfs_node *parent; + int i; + + // Non-unitary ref count means this node is either open + // or is a dir with entries in it. + if( nd->refcnt > 1 ) + return EBUSY; + + // Remove from parent's node list. + + parent = nd->parent; + + for( i = 0; i < TESTFS_FILEBLOCKS; i++ ) + if( parent->u.dir.nodes[i] == nd ) + { + parent->u.dir.nodes[i] = NULL; + break; + } + + parent->refcnt--; + + if( S_ISREG(nd->status.st_mode) ) + { + // for a file, return blocks to free list + for( i = 0; i < TESTFS_FILEBLOCKS; i++ ) + { + testfs_block *b = nd->u.file.data[i]; + if( b != NULL ) + { + b->u.next = free_block; + b->pos = -1; + free_block = b; + } + } + } + + // and finally return nd to free node list + + nd->next = free_node; + nd->refcnt = -1; + free_node = nd; + + return ENOERR; +} + +//========================================================================== +// Filesystem operations + +// ------------------------------------------------------------------------- + +static int testfs_mount ( cyg_fstab_entry *fste, cyg_mtab_entry *mte ) +{ + testfs_node *root; + int i; + + if( !testfs_initialized ) + { + int i; + + for( i = 0; i < TESTFS_NFILE; i++ ) + { + node[i].next = free_node; + node[i].refcnt = -1; + free_node = &node[i]; + } + + for( i = 0; i < TESTFS_NBLOCK; i++ ) + { + block[i].u.next = free_block; + block[i].pos = -1; + free_block = &block[i]; + } + + testfs_initialized = true; + } + + // Allocate a node to be the root of this filesystem and + // initialize it. + + root = free_node; + + if( root == NULL ) return ENOSPC; + + free_node = root->next; + + root->next = root; // form circular list + root->parent = root; // I'm my own parent! + root->refcnt = 1; // don't want to ever lose root + strcpy( root->name, "root"); + root->status.st_mode = __stat_mode_DIR; + root->status.st_ino = root-&node[0]; + root->status.st_dev = 0; + root->status.st_nlink = 1; + root->status.st_uid = 0; + root->status.st_gid = 0; + root->status.st_size = 0; + root->status.st_atime = testfs_time(); + root->status.st_mtime = testfs_time(); + root->status.st_ctime = testfs_time(); + + for( i = 0; i < TESTFS_FILEBLOCKS; i++ ) + root->u.dir.nodes[i] = NULL; + + mte->root = (cyg_dir)root; + + return 0; +} + +// ------------------------------------------------------------------------- + +static int testfs_umount ( cyg_mtab_entry *mte ) +{ + testfs_node *root = (testfs_node *)mte->root; + + // Non-empty filesystem, do not unmount + if( root->refcnt != 1 ) + return EBUSY; + + // Otherwise just return it to the free pool + root->next = free_node; + root->refcnt = -1; + free_node = root; + + // Clear root pointer + mte->root = CYG_DIR_NULL; + + // That's all folks. + + return ENOERR; +} +// ------------------------------------------------------------------------- + +static int testfs_open ( cyg_mtab_entry *mte, cyg_dir dir, const char *path, + int mode, cyg_file *file ) +{ + testfs_node *nd, *parent; + int err; + char name[TESTFS_NAMESIZE]; + cyg_bool lastp; + + err = testfs_find( (testfs_node *)dir, path, &nd, &parent, name, &lastp ); + + if( lastp && err == ENOENT && (mode & O_CREAT) ) + { + int i; + // No node there, if the O_CREAT bit is set then we must + // create a new one. The parent and name results will have been filled + // in, so we know where to put it. + + // first check that there is space for it + for( i = 0; i < TESTFS_FILEBLOCKS; i++ ) + if( parent->u.dir.nodes[i] == NULL ) + break; + + if( i == TESTFS_FILEBLOCKS ) return ENOSPC; + + // Allocate a new node + nd = free_node; + if( nd == NULL ) return ENOSPC; + free_node = nd->next; + + // Add to directory list + parent->u.dir.nodes[i] = nd; + + parent->refcnt++; + + // Fill in details + nd->parent = parent; + nd->refcnt = 1; // 1 for directory reference + strcpy( nd->name, name); + nd->status.st_mode = __stat_mode_REG; + nd->status.st_ino = nd-&node[0]; + nd->status.st_dev = 0; + nd->status.st_nlink = 1; + nd->status.st_uid = 0; + nd->status.st_gid = 0; + nd->status.st_size = 0; + nd->status.st_atime = testfs_time(); + nd->status.st_mtime = testfs_time(); + nd->status.st_ctime = testfs_time(); + + for( i = 0; i < TESTFS_FILEBLOCKS; i++ ) + nd->u.file.data[i] = NULL; + + err = ENOERR; + } + + if( err == ENOERR && (mode & O_TRUNC ) ) + { + // Clean out any blocks in the file... + + int i; + + for( i = 0; i < TESTFS_FILEBLOCKS; i++ ) + { + testfs_block *b = nd->u.file.data[i]; + if( b != NULL ) + { + b->u.next = free_block; + b->pos = -1; + free_block = b; + nd->u.file.data[i] = NULL; + } + } + + nd->status.st_size = 0; + } + + if( err != ENOERR ) return err; + + if( S_ISDIR(nd->status.st_mode) ) return EISDIR; + + nd->refcnt++; // Count successful open as a ref + + // Initialize the file object + + file->f_flag |= mode & CYG_FILE_MODE_MASK; + file->f_type = CYG_FILE_TYPE_FILE; + file->f_ops = &testfs_fileops; + file->f_offset = 0; + file->f_data = (CYG_ADDRWORD)nd; + file->f_xops = 0; + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int testfs_unlink ( cyg_mtab_entry *mte, cyg_dir dir, const char *path ) +{ + testfs_node *nd, *parent; + int err; + char name[TESTFS_NAMESIZE]; + cyg_bool lastp; + + err = testfs_find( (testfs_node *)dir, path, &nd, &parent, name, &lastp ); + + if( err != ENOERR ) return err; + + // Cannot unlink directories, use rmdir() instead + if( S_ISDIR(nd->status.st_mode) ) + return EPERM; + + err = testfs_delnode( nd ); + + return err; +} + +// ------------------------------------------------------------------------- + +static int testfs_mkdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *path ) +{ + + testfs_node *nd, *parent; + int err; + char name[TESTFS_NAMESIZE]; + cyg_bool lastp; + + err = testfs_find( (testfs_node *)dir, path, &nd, &parent, name, &lastp ); + + if( lastp && err == ENOENT ) + { + int i; + // No node there, create a new one. The parent and name + // results will have been filled in, so we know where to put + // it. + + // first check that there is space for it + for( i = 0; i < TESTFS_FILEBLOCKS; i++ ) + if( parent->u.dir.nodes[i] == NULL ) + break; + + if( i == TESTFS_FILEBLOCKS ) return ENOSPC; + + // Allocate a new node + nd = free_node; + if( nd == NULL ) return ENOSPC; + free_node = nd->next; + + // Add to directory list + parent->u.dir.nodes[i] = nd; + + parent->refcnt++; + + // Fill in details + nd->parent = parent; + nd->refcnt = 1; // 1 for directory reference + strcpy( nd->name, name); + nd->status.st_mode = __stat_mode_DIR; + nd->status.st_ino = nd-&node[0]; + nd->status.st_dev = 0; + nd->status.st_nlink = 1; + nd->status.st_uid = 0; + nd->status.st_gid = 0; + nd->status.st_size = 0; + nd->status.st_atime = testfs_time(); + nd->status.st_mtime = testfs_time(); + nd->status.st_ctime = testfs_time(); + + for( i = 0; i < TESTFS_FILEBLOCKS; i++ ) + nd->u.dir.nodes[i] = NULL; + + err = ENOERR; + } + + return err; +} + +// ------------------------------------------------------------------------- + +static int testfs_rmdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *path ) +{ + testfs_node *nd, *parent; + int err; + char name[TESTFS_NAMESIZE]; + cyg_bool lastp; + + err = testfs_find( (testfs_node *)dir, path, &nd, &parent, name, &lastp ); + + if( err != ENOERR ) return err; + + // Check that it is a directory + if( !S_ISDIR(nd->status.st_mode) ) + return EPERM; + + err = testfs_delnode( nd ); + + return err; +} + +// ------------------------------------------------------------------------- + +static int testfs_rename ( cyg_mtab_entry *mte, cyg_dir dir1, const char *path1, + cyg_dir dir2, const char *path2 ) +{ + testfs_node *nd1, *parent1; + testfs_node *nd2, *parent2; + int err; + char name1[TESTFS_NAMESIZE]; + char name2[TESTFS_NAMESIZE]; + cyg_bool lastp; + int i,j; + + err = testfs_find( (testfs_node *)dir1, path1, &nd1, &parent1, name1, &lastp ); + + if( err != ENOERR ) return err; + + err = testfs_find( (testfs_node *)dir2, path2, &nd2, &parent2, name2, &lastp ); + + // Allow through renames to non-existent objects. + if( lastp && err == ENOENT ) + err = ENOERR; + + if( err != ENOERR ) return err; + + // Null rename, just return + if( nd1 == nd2 ) + return ENOERR; + + + // First deal with any node that is at the destination + if( nd2 ) + { + // Check that we are renaming like-for-like + + if( !S_ISDIR(nd1->status.st_mode) && S_ISDIR(nd2->status.st_mode) ) + return EISDIR; + + if( S_ISDIR(nd1->status.st_mode) && !S_ISDIR(nd2->status.st_mode) ) + return ENOTDIR; + + // Now delete the destination node. + err = testfs_delnode( nd2 ); + if( err != ENOERR ) return err; + } + + // Now we know that there is no clashing node at the destination. + // Move the node over and change its name. + + // first check that there is space for it + for( i = 0; i < TESTFS_FILEBLOCKS; i++ ) + if( parent2->u.dir.nodes[i] == NULL ) + break; + + if( i == TESTFS_FILEBLOCKS ) return ENOSPC; + + // Now remove node from old parent. + for( j = 0; j < TESTFS_FILEBLOCKS; j++ ) + if( parent1->u.dir.nodes[j] == nd1 ) + { + parent1->u.dir.nodes[j] = NULL; + break; + } + + parent1->refcnt--; + + // Add to directory list + parent2->u.dir.nodes[i] = nd1; + parent2->refcnt++; + nd1->parent = parent2; + + // And give it a new name. + strcpy( nd1->name, name2 ); + + return err; +} + +// ------------------------------------------------------------------------- + +static int testfs_link ( cyg_mtab_entry *mte, cyg_dir dir1, const char *path1, + cyg_dir dir2, const char *path2, int type ) +{ + // The data structures of this file system do not support the + // creation of links. + + return ENOSYS; +} + +// ------------------------------------------------------------------------- + +static int testfs_opendir ( cyg_mtab_entry *mte, cyg_dir dir, const char *path, + cyg_file *file ) +{ + testfs_node *nd, *parent; + int err; + char name[TESTFS_NAMESIZE]; + cyg_bool lastp; + + err = testfs_find( (testfs_node *)dir, path, &nd, &parent, name, &lastp ); + + if( err != ENOERR ) return err; + + if( !S_ISDIR(nd->status.st_mode) ) + return ENOTDIR; + + nd->refcnt++; // Count successful open as a ref + + // Initialize the file object + + file->f_type = CYG_FILE_TYPE_FILE; + file->f_ops = &testfs_dirops; + file->f_offset = 0; + file->f_data = (CYG_ADDRWORD)nd; + file->f_xops = 0; + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int testfs_chdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *path, + cyg_dir *dir_out ) +{ + if( dir_out != NULL ) + { + // This is a request to get a new directory pointer in + // *dir_out. + + testfs_node *nd, *parent; + int err; + char name[TESTFS_NAMESIZE]; + cyg_bool lastp; + + err = testfs_find( (testfs_node *)dir, path, &nd, &parent, name, &lastp ); + + if( err != ENOERR ) return err; + + if( !S_ISDIR(nd->status.st_mode) ) + return ENOTDIR; + + // Increment ref count to keep this directory in existent + // while it is the current cdir. + nd->refcnt++; + + // Pass it out + *dir_out = (cyg_dir)nd; + } + else + { + // If no output dir is required, this means that the mte and + // dir arguments are the current cdir setting and we should + // forget this fact. + + testfs_node *nd = (testfs_node *)dir; + + // Just decrement reference count. + nd->refcnt--; + } + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int testfs_stat ( cyg_mtab_entry *mte, cyg_dir dir, const char *path, + struct stat *buf) +{ + testfs_node *nd, *parent; + int err; + char name[TESTFS_NAMESIZE]; + cyg_bool lastp; + + err = testfs_find( (testfs_node *)dir, path, &nd, &parent, name, &lastp ); + + if( err != ENOERR ) return err; + + *buf = nd->status; + + return err; +} + +// ------------------------------------------------------------------------- + +static int testfs_getinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *path, + int key, void *buf, int len ) +{ + return ENOSYS; +} + +// ------------------------------------------------------------------------- + +static int testfs_setinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *path, + int key, void *buf, int len ) +{ + return ENOSYS; +} + + +//========================================================================== +// File operations + + +// ------------------------------------------------------------------------- + +static int testfs_fo_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio) +{ + testfs_node *nd = (testfs_node *)fp->f_data; + int i; + off_t pos = fp->f_offset; + + for( i = 0; i < uio->uio_iovcnt; i++ ) + { + cyg_iovec *iov = &uio->uio_iov[i]; + char *buf = (char *)iov->iov_base; + off_t len = iov->iov_len; + + while( len > 0 && pos < nd->status.st_size ) + { + testfs_block *b = nd->u.file.data[pos/TESTFS_BLOCKSIZE]; + off_t l = len; + off_t bpos = pos%TESTFS_BLOCKSIZE; + + // If there is no block in that pos, we have reached + // the end of the file. + if( b == NULL ) return ENOERR; + + // adjust size to this block + if( l > (b->size-bpos) ) + l = (b->size-bpos); + + // copy data out + memcpy( buf, &b->data[bpos], l ); + + uio->uio_resid -= l; + len -= l; + buf += l; + pos += l; + + // keep offset up to date incase of errors + fp->f_offset = pos; + } + } + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int testfs_fo_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio) +{ + testfs_node *nd = (testfs_node *)fp->f_data; + int i; + off_t pos = fp->f_offset; + + // Check we are not at end of allowed max file size + if( pos >= TESTFS_FILESIZE_MAX ) + return EFBIG; + + // Check that pos is within current file size, or at the very end. + if( pos < 0 || pos > nd->status.st_size ) + return EINVAL; + + // Now loop over the iovecs until they are all done, or + // we get an error. + for( i = 0; i < uio->uio_iovcnt; i++ ) + { + cyg_iovec *iov = &uio->uio_iov[i]; + char *buf = (char *)iov->iov_base; + off_t len = iov->iov_len; + + while( len > 0 ) + { + testfs_block *b = nd->u.file.data[pos/TESTFS_BLOCKSIZE]; + off_t l = len; + off_t bpos = pos%TESTFS_BLOCKSIZE; + + // If there is no block in that pos, allocate one + // and initialize it + if( b == NULL ) + { + b = free_block; + if( b == NULL ) return ENOSPC; + free_block = b->u.next; + nd->u.file.data[pos/TESTFS_BLOCKSIZE] = b; + b->u.file = nd; + b->pos = pos; + b->size = 0; + } + + // adjust size to this block + if( l > (TESTFS_BLOCKSIZE-bpos) ) + l = (TESTFS_BLOCKSIZE-bpos); + + // copy data in + memcpy( &b->data[bpos], buf, l ); + + // adjust buffer info + if( b->size < bpos+l ) + b->size = bpos+l; + + uio->uio_resid -= l; + len -= l; + buf += l; + pos += l; + + // keep node size and file offset up to date + //in case of an error. + if( pos > nd->status.st_size ) + nd->status.st_size = pos; + fp->f_offset = pos; + + if( pos >= TESTFS_FILESIZE_MAX ) + return EFBIG; + } + } + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int testfs_fo_lseek (struct CYG_FILE_TAG *fp, off_t *apos, int whence ) +{ + testfs_node *nd = (testfs_node *)fp->f_data; + off_t pos = *apos; + + switch( whence ) + { + case SEEK_SET: + // we are already where we want to be. + break; + + case SEEK_CUR: + pos += fp->f_offset; + break; + + case SEEK_END: + pos += nd->status.st_size; + break; + + default: + return EINVAL; + } + + // Check that pos is within current file size, or at the very end. + if( pos < 0 || pos > nd->status.st_size ) + return EINVAL; + + // All OK, set fp offset. + *apos = fp->f_offset = pos; + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int testfs_fo_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com, + CYG_ADDRWORD data) +{ + return ENOSYS; +} + +// ------------------------------------------------------------------------- + +static int testfs_fo_fsync (struct CYG_FILE_TAG *fp, int mode ) +{ + // Nothing to do + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int testfs_fo_close (struct CYG_FILE_TAG *fp) +{ + testfs_node *nd = (testfs_node *)fp->f_data; + + nd->refcnt--; // remove open count + + fp->f_data = 0; // clear data pointer + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int testfs_fo_fstat (struct CYG_FILE_TAG *fp, struct stat *buf ) +{ + testfs_node *nd = (testfs_node *)fp->f_data; + + *buf = nd->status; + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int testfs_fo_getinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ) +{ + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int testfs_fo_setinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len ) +{ + return ENOERR; +} + + +//========================================================================== +// Directory operations + +static int testfs_fo_dirread (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio) +{ + testfs_node *nd = (testfs_node *)fp->f_data; + off_t pos = fp->f_offset; + cyg_iovec *iov = &uio->uio_iov[0]; + char *buf = (char *)iov->iov_base; + off_t len = iov->iov_len; + + // End of directory + if( pos >= TESTFS_FILEBLOCKS ) + return ENOERR; + + if( len < sizeof(struct dirent) ) + return EINVAL; + + for( ; pos < TESTFS_FILEBLOCKS; pos++ ) + if( nd->u.dir.nodes[pos] != NULL ) + { + struct dirent *ent = (struct dirent *)buf; + strcpy( ent->d_name, nd->u.dir.nodes[pos]->name ); + uio->uio_resid -= sizeof(struct dirent); + break; + } + + fp->f_offset = pos+1; + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int testfs_fo_dirlseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence ) +{ + if( whence != SEEK_SET || *pos != 0) + return EINVAL; + + *pos = fp->f_offset = 0; + + return ENOERR; +} + +//========================================================================== +// Filesystem dump +// Dumps out the node and block arrays in a readable format, and does +// a little consistency checking as it goes. + +void testfs_dump(void) +{ + int errors = 0; + int i; + char *indent = "\n |"; + + diag_printf("Nodes:\n"); + for( i = 0; i < TESTFS_NFILE; i++ ) + { + testfs_node *nd = &node[i]; + + diag_printf("%3d : ",i); + if( nd->refcnt < 0 ) + diag_printf(""); + else if( !S_ISDIR(nd->status.st_mode) ) + { + // Regular file + int j; + diag_printf("f %8s %4d |",nd->name,nd->status.st_size); + for( j = 0; j < TESTFS_FILEBLOCKS; j++ ) + { + testfs_block *b = nd->u.file.data[j]; + if( b != NULL ) + { + if( j > 0 && (j%4) == 0 ) + diag_printf(indent); + diag_printf(" %3d[%3d,%3d]",b-block,b->pos,b->size); + if( b->u.file != nd ) + { + errors++; + diag_printf("!"); + } + } + } + } + else + { + // Directory + int j; + int rc = 1; + diag_printf("d %8s |",nd->name); + + for( j = 0; j < TESTFS_FILEBLOCKS; j++ ) + { + testfs_node *n = nd->u.dir.nodes[j]; + if( n != NULL ) + { + if( j > 0 && (j%4) == 0 ) + diag_printf(indent); + diag_printf(" %3d[%7s]",n-node,n->name); + rc++; + } + } + + if( nd->refcnt != rc ) + { + diag_printf("%s refcount is %d should be %d",indent,nd->refcnt,rc); + if( nd->refcnt == rc+1 ) + diag_printf(" (but may be current dir)"); + } + } + + diag_printf("\n"); + } + + diag_printf("Blocks:\n"); + + for( i = 0; i < TESTFS_NBLOCK; i++ ) + { + testfs_block *b = &block[i]; + + diag_printf("%3d :",i); + if( b->pos == -1 ) + diag_printf(" "); + else + { + int j; + testfs_node *nd = b->u.file; + diag_printf(" %3d %3d %d[%7s]",b->pos,b->size,nd-node,nd->name); + for( j = 0; j < TESTFS_FILEBLOCKS; j++ ) + { + if( nd->u.file.data[j] == b ) + break; + } + if( j == TESTFS_FILEBLOCKS ) + { + errors++; + diag_printf(" block not in file!"); + } + } + diag_printf("\n"); + } + + if( errors != 0 ) + diag_printf("%d errors detected\n",errors); +} + +// ------------------------------------------------------------------------- +// EOF testfs.c diff --git a/packages/io/flash/current/ChangeLog b/packages/io/flash/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/io/flash/current/ChangeLog @@ -0,0 +1,37 @@ +2000-08-14 Gary Thomas + + * include/flash.h: Add block size mask for finding block boundaries. + + * src/flash.c: Use block size properly. + +2000-07-29 Gary Thomas + + * include/flash.h: + * src/flash.c (flash_get_block_info): New function. + (flash_program): Program in block_size chunks as much as possible. + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/io/flash/current/cdl/io_flash.cdl b/packages/io/flash/current/cdl/io_flash.cdl new file mode 100644 --- /dev/null +++ b/packages/io/flash/current/cdl/io_flash.cdl @@ -0,0 +1,66 @@ +# ==================================================================== +# +# io_flash.cdl +# +# eCos IO configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): gthomas +# Original data: gthomas +# Contributors: +# Date: 2000-07-06 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_IO_FLASH { + display "FLASH device drivers" + include_dir cyg/io + description " + This option enables drivers for basic I/O services on + flash devices." + doc redirect/ecos-device-drivers.html + + compile flash.c + + define_proc { + puts $::cdl_header "#include " + puts $::cdl_header "#ifdef CYGDAT_IO_FLASH_DEVICE_HEADER" + puts $::cdl_header "# include CYGDAT_IO_FLASH_DEVICE_HEADER" + puts $::cdl_header "#endif " + } + + cdl_interface CYGHWR_IO_FLASH_DEVICE { + display "Hardware FLASH device drivers" + description " + This option enables the hardware device drivers + for the current platform." + } +} diff --git a/packages/io/flash/current/include/flash.h b/packages/io/flash/current/include/flash.h new file mode 100644 --- /dev/null +++ b/packages/io/flash/current/include/flash.h @@ -0,0 +1,86 @@ +//========================================================================== +// +// flash.h +// +// Flash programming - external interfaces +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-14 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#ifndef _IO_FLASH_H_ +#define _IO_FLASH_H_ + +#define FLASH_MIN_WORKSPACE 0x10000 // Space used by FLASH code + +extern int flash_init(void *work_space, int work_space_length); +extern int flash_erase(void *base, int len, void **err_address); +extern int flash_program(void *flash_base, void *ram_base, int len, void **err_address); +extern int flash_verify_addr(void *base); +extern int flash_get_limits(void *base, void **start, void **end); +extern int flash_get_block_info(int *block_size, int *blocks); +extern bool flash_code_overlaps(void *start, void *end); +extern char *flash_errmsg(int err); + +#define FLASH_ERR_OK 0x00 // No error - operation complete +#define FLASH_ERR_INVALID 0x01 // Invalid FLASH address +#define FLASH_ERR_ERASE 0x02 // Error trying to erase +#define FLASH_ERR_LOCK 0x03 // Error trying to lock/unlock +#define FLASH_ERR_PROGRAM 0x04 // Error trying to program +#define FLASH_ERR_PROTOCOL 0x05 // Generic error +#define FLASH_ERR_PROTECT 0x06 // Device/region is write-protected +#define FLASH_ERR_NOT_INIT 0x07 // FLASH info not yet initialized +#define FLASH_ERR_HWR 0x08 // Hardware (configuration?) problem + +#ifdef _FLASH_PRIVATE_ + +struct flash_info { + void *work_space; + int work_space_size; + int block_size; // Assuming fixed size "blocks" + int blocks; // Number of blocks + unsigned long block_mask; + void *start, *end; // Address range + int init; +}; + +extern struct flash_info flash_info; +extern int flash_hwr_init(void); +extern int flash_hwr_map_error(int err); + +#endif + +#endif // _IO_FLASH_H_ diff --git a/packages/io/flash/current/src/flash.c b/packages/io/flash/current/src/flash.c new file mode 100644 --- /dev/null +++ b/packages/io/flash/current/src/flash.c @@ -0,0 +1,208 @@ +//========================================================================== +// +// flash.c +// +// Flash programming +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-26 +// Purpose: +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include +#include +#include + +#define _FLASH_PRIVATE_ +#include + +struct flash_info flash_info; + +int +flash_init(void *work_space, int work_space_size) +{ + int err; + + if (flash_info.init) return FLASH_ERR_OK; + flash_info.work_space = work_space; + flash_info.work_space_size = flash_info.work_space_size; + if ((err = flash_hwr_init()) != FLASH_ERR_OK) { + return err; + } + flash_info.block_mask = ~(flash_info.block_size-1); + flash_info.init = 1; + return FLASH_ERR_OK; +} + +int +flash_verify_addr(void *target) +{ + if (!flash_info.init) { + return FLASH_ERR_NOT_INIT; + } + if (((unsigned long)target >= (unsigned long)flash_info.start) && + ((unsigned long)target < (unsigned long)flash_info.end)) { + return FLASH_ERR_OK; + } else { + return FLASH_ERR_INVALID; + } +} + +int +flash_get_limits(void *target, void **start, void **end) +{ + if (!flash_info.init) { + return FLASH_ERR_NOT_INIT; + } + *start = flash_info.start; + *end = flash_info.end; + return FLASH_ERR_OK; +} + +int +flash_get_block_info(int *block_size, int *blocks) +{ + if (!flash_info.init) { + return FLASH_ERR_NOT_INIT; + } + *block_size = flash_info.block_size; + *blocks = flash_info.blocks; + return FLASH_ERR_OK; +} + +int +flash_erase(void *addr, int len, void **err_addr) +{ + unsigned short *block, *end_addr; + int stat = 0; + extern char flash_erase_block, flash_erase_block_end; + int code_len; + typedef int code_fun(unsigned short *); + code_fun *_flash_erase_block; + + if (!flash_info.init) { + return FLASH_ERR_NOT_INIT; + } + + // Copy 'erase' code to RAM for execution + code_len = (unsigned long)&flash_erase_block_end - (unsigned long)&flash_erase_block; + _flash_erase_block = (code_fun *)flash_info.work_space; + memcpy(_flash_erase_block, &flash_erase_block, code_len); + HAL_DCACHE_SYNC(); // Should guarantee this code will run + + block = (unsigned short *)((unsigned long)addr & flash_info.block_mask); + end_addr = (unsigned short *)((unsigned long)addr+len); + + printf("... Erase from %p-%p: ", block, end_addr); + + while (block < end_addr) { + stat = (*_flash_erase_block)(block); + stat = flash_hwr_map_error(stat); + if (stat) { + *err_addr = (void *)block; + break; + } + block += flash_info.block_size / sizeof(*block); + printf("."); + } + printf("\n"); + return (stat); +} + +int +flash_program(void *_addr, void *_data, int len, void **err_addr) +{ + int stat = 0; + int code_len, size; + extern char flash_program_buf, flash_program_buf_end; + typedef int code_fun(unsigned short *, unsigned short *, int); + code_fun *_flash_program_buf; + unsigned short *addr = (unsigned short *)_addr; + unsigned short *data = (unsigned short *)_data; + + if (!flash_info.init) { + return FLASH_ERR_NOT_INIT; + } + + // Copy 'program' code to RAM for execution + code_len = (unsigned long)&flash_program_buf_end - (unsigned long)&flash_program_buf; + _flash_program_buf = (code_fun *)flash_info.work_space; + memcpy(_flash_program_buf, &flash_program_buf, code_len); + HAL_DCACHE_SYNC(); // Should guarantee this code will run + + printf("... Program from %p-%p at %p: ", data, ((unsigned long)data)+len, addr); + + while (len > 0) { + size = len; + if (size > flash_info.block_size) size = flash_info.block_size; + stat = (*_flash_program_buf)(addr, data, size); + stat = flash_hwr_map_error(stat); + if (stat) { + *err_addr = (void *)addr; + break; + } + printf("."); + len -= size; + addr += size/sizeof(*addr); + data += size/sizeof(*data); + } + printf("\n"); + return (stat); +} + +char * +flash_errmsg(int err) +{ + switch (err) { + case FLASH_ERR_OK: + return "No error - operation complete"; + case FLASH_ERR_INVALID: + return "Invalid FLASH address"; + case FLASH_ERR_ERASE: + return "Error trying to erase"; + case FLASH_ERR_LOCK: + return "Error trying to lock/unlock"; + case FLASH_ERR_PROGRAM: + return "Error trying to program"; + case FLASH_ERR_PROTOCOL: + return "Generic error"; + case FLASH_ERR_PROTECT: + return "Device/region is write-protected"; + case FLASH_ERR_NOT_INIT: + return "FLASH sub-system not initialized"; + default: + return "Unknown error"; + } +} diff --git a/packages/io/flash/current/src/flash.h b/packages/io/flash/current/src/flash.h new file mode 100644 --- /dev/null +++ b/packages/io/flash/current/src/flash.h @@ -0,0 +1,19 @@ + +#define FLASH_Read_ID 0x90 +#define FLASH_Read_Query 0x98 +#define FLASH_Read_Status 0x70 +#define FLASH_Clear_Status 0x50 +#define FLASH_Status_Ready 0x80 +#define FLASH_Write 0xE8 +#define FLASH_Program 0x10 +#define FLASH_Block_Erase 0x20 +#define FLASH_Clear_Locks 0x60 +#define FLASH_Confirm 0xD0 +#define FLASH_Configure 0xB8 +#define FLASH_Configure_ReadyWait 0x00 +#define FLASH_Configure_PulseOnErase 0x01 +#define FLASH_Configure_PulseOnProgram 0x02 +#define FLASH_Configure_PulseOnBoth 0x03 +#define FLASH_Reset 0xFF + +#define FLASH_BLOCK_SIZE 0x10000 diff --git a/packages/io/pcmcia/current/ChangeLog b/packages/io/pcmcia/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/io/pcmcia/current/ChangeLog @@ -0,0 +1,42 @@ +2000-07-16 Gary Thomas + + * cdl/io_pcmcia.cdl: + * include/pcmcia.h: + * src/pcmcia.c: Remove dependency on generic I/O package. + +2000-07-15 Gary Thomas + + * include/pcmcia.h: + * src/pcmcia.c: Change notion of interrupts to be slot oriented. + This fits with more hardware. Now need to "register" an IRQ + handler when initializing a card device. + +2000-07-11 Gary Thomas + + * src/pcmcia.c: Remove noisy messages. + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/io/pcmcia/current/cdl/io_pcmcia.cdl b/packages/io/pcmcia/current/cdl/io_pcmcia.cdl new file mode 100644 --- /dev/null +++ b/packages/io/pcmcia/current/cdl/io_pcmcia.cdl @@ -0,0 +1,66 @@ +# ==================================================================== +# +# io_pcmcia.cdl +# +# eCos IO configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): gthomas +# Original data: gthomas +# Contributors: +# Date: 2000-07-06 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_IO_PCMCIA { + display "PCMCIA device drivers" + include_dir cyg/io + description " + This option enables drivers for basic I/O services on + pcmcia devices." + doc redirect/ecos-device-drivers.html + + compile pcmcia.c + + define_proc { + puts $::cdl_header "#include " + puts $::cdl_header "#ifdef CYGDAT_IO_PCMCIA_DEVICE_HEADER" + puts $::cdl_header "# include CYGDAT_IO_PCMCIA_DEVICE_HEADER" + puts $::cdl_header "#endif " + } + + cdl_interface CYGHWR_IO_PCMCIA_DEVICE { + display "Hardware PCMCIA device drivers" + description " + This option enables the hardware device drivers + for the current platform." + } +} diff --git a/packages/io/pcmcia/current/include/pcmcia.h b/packages/io/pcmcia/current/include/pcmcia.h new file mode 100644 --- /dev/null +++ b/packages/io/pcmcia/current/include/pcmcia.h @@ -0,0 +1,121 @@ +#ifndef CYGONCE_PCMCIA_H +#define CYGONCE_PCMCIA_H +// ==================================================================== +// +// pcmcia.h +// +// Device I/O +// +// ==================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +// ==================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-06 +// Purpose: Interfaces for PCMCIA I/O drivers +// Description: +// +//####DESCRIPTIONEND#### +// +// ==================================================================== + +// PCMCIA I/O interfaces + +#include +#include + +#include +#include + +struct cf_irq_handler { + void (*handler)(void *); + void *param; +}; + +// Basic information about a slot/device +struct cf_slot { + int index; // In case hardware layer needs it + int state; + unsigned char *attr; + int attr_length; + unsigned char *io; + int io_length; + unsigned char *mem; + int mem_length; + int int_num; // Hardware interrupt number + struct cf_irq_handler irq_handler; +}; + +#define CF_SLOT_STATE_Empty 0 +#define CF_SLOT_STATE_Inserted 1 +#define CF_SLOT_STATE_Powered 2 +#define CF_SLOT_STATE_Reset 3 +#define CF_SLOT_STATE_Ready 4 +#define CF_SLOT_STATE_Removed 5 + +#define CF_CISTPL_VERS_1 0x15 +#define CF_CISTPL_CONFIG 0x1A +#define CF_CISTPL_CFTABLE_ENTRY 0x1B +#define CF_CISTPL_MANFID 0x20 +#define CF_CISTPL_FUNCID 0x21 + +#define CF_MAX_IO_ADDRS 8 +struct cf_io_space { + unsigned long base[CF_MAX_IO_ADDRS]; // Base address of I/O registers + unsigned long size[CF_MAX_IO_ADDRS]; // Length(-1) of I/O registers + int num_addrs; + unsigned char mode; +}; + +// Corresponds to CISTPL_CFTABLE_ENTRY +struct cf_cftable { + unsigned char cor; // Value to write to COR register + unsigned char interface; + unsigned char feature_select; + struct cf_io_space io_space; +}; + +// Corresponds to CISTPL_CONFIG +struct cf_config { + unsigned long base; + int mask_length; + unsigned char mask[16]; +}; + +// Function prototypes + +bool cf_get_CIS(struct cf_slot *slot, unsigned char id, + unsigned char *buf, int *len, int *ptr); +void cf_set_COR(struct cf_slot *slot, unsigned long cor, unsigned char val); +bool cf_parse_cftable(unsigned char *buf, int len, struct cf_cftable *cftable); +bool cf_parse_config(unsigned char *buf, int len, struct cf_config *config); +struct cf_slot *cf_get_slot(int indx); +void cf_change_state(struct cf_slot *slot, int desired_state); +void cf_register_handler(struct cf_slot *, void (*handler)(void *), void *); +void cf_init(void); + +#endif // CYGONCE_PCMCIA_H diff --git a/packages/io/pcmcia/current/src/pcmcia.c b/packages/io/pcmcia/current/src/pcmcia.c new file mode 100644 --- /dev/null +++ b/packages/io/pcmcia/current/src/pcmcia.c @@ -0,0 +1,285 @@ +//========================================================================== +// +// io/pcmcia/pcmcia.c +// +// PCMCIA support (Card Services) +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-07-06 +// Purpose: PCMCIA support +// Description: +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include + +#include +#include + +#if CYGHWR_IO_PCMCIA_DEVICE == 0 +#error Need hardware package for PCMCIA support +#endif + +#define CF_NUM_SLOTS CYGHWR_IO_PCMCIA_DEVICE +static struct cf_slot cf_slots[CF_NUM_SLOTS]; + +// Implementation routines +void cf_hwr_init(struct cf_slot *slot); +void cf_hwr_change_state(struct cf_slot *slot, int desired_state); + +bool +cf_get_CIS(struct cf_slot *slot, unsigned char id, + unsigned char *buf, int *len, int *ptr) +{ + int i, size; + unsigned char *cis = slot->attr; + unsigned char *cis_end = cis + slot->attr_length; + cis += *ptr; + while (cis < cis_end) { + if (*cis == 0xFF) { + break; + } + if (*cis == id) { + size = *(cis+2) + 2; + for (i = 0; i < size; i++) { + *buf++ = *cis; + cis += 2; + } + *len = size; + *ptr = (unsigned long)(cis - slot->attr); + return true; + } else { + // Skip to next entry + cis += (*(cis+2) * 2) + 4; + } + } + return false; +} + +void +cf_set_COR(struct cf_slot *slot, unsigned long cor, unsigned char val) +{ + volatile unsigned char *cfg = slot->attr; + cfg[cor] = val; +} + +static void +cf_parse_power_structure(unsigned char **buf) +{ + unsigned char *bp = *buf; + unsigned char tpce_pd = *bp++; + unsigned char settings; + int indx; + for (indx = 6; indx >= 0; indx--) { + if (tpce_pd & (1<>2, *bp); + bp++; + } + if ((tpce_td & 0x03) != 0x03) { +// diag_printf("WAIT = %x.%x\n",(tpce_td & 0x03)>>0, *bp); + bp++; + } + *buf = bp; +} + +static void +cf_parse_IO_space_structure(unsigned char **buf, struct cf_io_space *io_space) +{ + unsigned char *bp = *buf; + unsigned char tpce_io = *bp++; + unsigned char rd; + unsigned long base = 0, length = 0; + int i; + io_space->mode = (tpce_io & 0x60) >> 5; + if (tpce_io & 0x80) { + rd = *bp++; + io_space->num_addrs = (rd & 0x0F) + 1; + for (i = 0; i < io_space->num_addrs; i++) { + // Address + switch ((rd & 0x30) >> 4) { + case 0: + break; // Not present (shouldn't happen) + case 1: + base = *bp++; + break; + case 2: + base = (bp[1] << 8) | bp[0]; + bp += 2; + break; + case 3: + base = (bp[3] << 24) | (bp[2] << 16) | (bp[1] << 8) | bp[0]; + bp += 4; + break; + } + io_space->base[i] = base; + // Length + switch ((rd & 0xC0) >> 6) { + case 0: + break; // Not present (shouldn't happen) + case 1: + length = *bp++; + break; + case 2: + length = (bp[1] << 8) | bp[0]; + bp += 2; + break; + case 3: + length = (bp[3] << 24) | (bp[2] << 16) | (bp[1] << 8) | bp[0]; + bp += 4; + break; + } + length++; + io_space->size[i] = length; +// diag_printf("IO addr %d - base: %x, length: %x\n", i, base, length); + } + } + *buf = bp; +} + +bool +cf_parse_cftable(unsigned char *buf, int len, struct cf_cftable *cftable) +{ + unsigned char tpce_indx, tpce_fs; + if (*buf++ != CF_CISTPL_CFTABLE_ENTRY) { + diag_printf("%s - called with invalid CIS: %x\n", __FUNCTION__, *--buf); + return false; + } + buf++; // Skip length/link + tpce_indx = *buf++; + cftable->cor = tpce_indx & 0x3F; + if (tpce_indx & 0x80) { + cftable->interface = *buf++; + } + cftable->feature_select = tpce_fs = *buf++; + if (tpce_fs & 0x01) { + cf_parse_power_structure(&buf); + } + if (tpce_fs & 0x02) { + cf_parse_power_structure(&buf); + } + if (tpce_fs & 0x04) { + cf_parse_timing_structure(&buf); + } + if (tpce_fs & 0x08) { + cf_parse_IO_space_structure(&buf, &cftable->io_space); + } + return true; +} + +bool +cf_parse_config(unsigned char *buf, int len, struct cf_config *config) +{ + unsigned char tpcc_sz; + int i; + if (*buf++ != CF_CISTPL_CONFIG) { + diag_printf("%s - called with invalid CIS: %x\n", __FUNCTION__, *--buf); + return false; + } + buf++; // Skip length/link + tpcc_sz = *buf++; + buf++; // Skip 'last' pointer + config->base = 0; + for (i = (tpcc_sz & 0x03); i >= 0; i--) { + config->base = (config->base << 8) | buf[i]; + } + buf += (tpcc_sz & 0x03) + 1; + config->mask_length = ((tpcc_sz & 0x3C) >> 2) + 1; + for (i = 0; i < config->mask_length; i++) { + config->mask[i] = *buf++; + } + return true; +} + +// +// Return a pointer to the slot descriptor for a given slot +// +struct cf_slot * +cf_get_slot(int indx) +{ + if ((indx >= 0) && (indx < CF_NUM_SLOTS)) { + return &cf_slots[indx]; + } else { + diag_printf("PCMCIA: Invalid slot %d\n", indx); + return (struct cf_slot *)0; + } +} + +// +// Initialize all PCMCIA (Compact Flash) slots +// +void +cf_init(void) +{ + int i; + for (i = 0; i < CF_NUM_SLOTS; i++) { + cf_slots[i].index = i; + cf_hwr_init(&cf_slots[i]); + } +} + +// +// Transition a card/slot +// +void +cf_change_state(struct cf_slot *slot, int desired_state) +{ + cf_hwr_change_state(slot, desired_state); +} + +// +// Register an interrupt handler +// +void +cf_register_handler(struct cf_slot *slot, + void (*handler)(void *), + void *param) +{ + slot->irq_handler.handler = handler; + slot->irq_handler.param = param; +} + diff --git a/packages/io/serial/current/ChangeLog b/packages/io/serial/current/ChangeLog --- a/packages/io/serial/current/ChangeLog +++ b/packages/io/serial/current/ChangeLog @@ -1,3 +1,63 @@ +2000-08-09 Jonathan Larmour + + * src/common/serial.c (serial_indicate_status): Treat flow control + case conditionally + +2000-08-08 Jonathan Larmour + + * src/common/serial.c (serial_data_rcv_req): Adjust nb in correct + direction + +2000-08-04 Jonathan Larmour + + * cdl/io_serial.cdl: Default software flow control to on (but keep + flow control overall default off) + + * tests/flow1.c (cyg_start): Fix N_A_MSG -> NA_MSG typo + * tests/flow2.c (cyg_start): Ditto + +2000-08-03 Jonathan Larmour + + * cdl/io_serial.cdl: Should default flow control to off + + * src/common/serial.c (serial_data_xmt_req): Update cbuf->nb + (serial_data_rcv_req): Update cbuf->nb + +2000-08-01 Jonathan Larmour + + * cdl/io_serial.cdl: Add support for line status queries, + software flow control, hardware flow control and POSIX termios + * include/serial.h: Likewise. Also change prototype for set_config + hardware operations to use keys to be more flexible. + * include/serialio.h: Add lots of types and constants to support + new line status and flow control config key queries + + * src/common/haldiag.c (haldiag_set_config): Use keys to be more + flexible. + + * src/common/serial.c: Many changes to support software/hardware + flow control (with low and high water points), line status and + fix some omissions with select. Also fix bugs in block transfer + functions resulting from EL/IX merge. + + * tests/flow1.c, tests/flow2.c: New tests for flow control + + * cdl/termios.cdl: Add to configure termios + * src/termios.c: Add new POSIX Termios API + * src/termiostty.c: Add POSIX Termios tty driver + + * tests/ser_test_protocol.inl (change_config): Add support for + hardware and software flow control testing, indicated to the + host by an extra CONFIG argument. + + * tests/serial3.c: Add flow control config + * tests/serial5.c: Add flow control config + +2000-07-31 Nick Garnett + + * src/common/serial.c: Changed BLOCKING control definitions to + generic versions. + 2000-07-03 Jesper Skov * src/common/serial.c (serial_data_rcv_req): Fix off-by-1 bug. @@ -6,6 +66,31 @@ 2000-06-23 Jesper Skov + + * include/serial.h: + * src/common/serial.c: + Added nb field to cbuf_t structure. This keeps track of the number of + bytes currently in the buffer. Without this counter, there is no + way to distinguish a totally full buffer from one that is totally + empty, since in both cases put==get. + +2000-06-15 Nick Garnett + + * include/serial.h: Added selinfo field to cbuf structure when + select support is enabled. + + * src/common/serial.c: + * src/common/tty.c: + Added select support. + + * cdl/io_serial.cdl: Added CYGPKG_IO_SERIAL_SELECT_SUPPORT to + enable select() support. Defaults to on. + Also added component for loopback driver. + + * tests/ser_test_protocol.inl: Added test setup for loopback + driver. + 2000-05-28 Gary Thomas * tests/ser_test_protocol.inl: Rename NEC V85x drivers. diff --git a/packages/io/serial/current/cdl/io_serial.cdl b/packages/io/serial/current/cdl/io_serial.cdl --- a/packages/io/serial/current/cdl/io_serial.cdl +++ b/packages/io/serial/current/cdl/io_serial.cdl @@ -50,8 +50,7 @@ cdl_package CYGPKG_IO_SERIAL { serial devices." doc redirect/ecos-device-drivers.html - compile -library=libextras.a common/serial.c common/tty.c \ - common/haldiag.c + compile -library=libextras.a common/serial.c define_proc { puts $::cdl_header "/***** proc output start *****/" @@ -79,16 +78,146 @@ cdl_package CYGPKG_IO_SERIAL { rely on a hardware FIFO of some sort." } + cdl_interface CYGINT_IO_SERIAL_LINE_STATUS_HW { + display "Serial driver supports line status" + } + + cdl_option CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS { + display "Support line status callbacks" + requires { CYGINT_IO_SERIAL_LINE_STATUS_HW > 0 } + default_value { 0 != CYGINT_IO_SERIAL_LINE_STATUS_HW } + description " + This option indicates that if the serial driver supports it, + serial line status and modem status information should be + propagated to higher layers via callbacks." + } + + cdl_component CYGPKG_IO_SERIAL_FLOW_CONTROL { + display "Flow control" + description " + This component contains options related to flow control." + flavor bool + requires (CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE || \ + CYGOPT_IO_SERIAL_FLOW_CONTROL_HW) + default_value 0 + + cdl_component CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE { + display "Software flow control" + default_value 1 + description " + This component enables support of software flow control." + + cdl_option CYGDAT_IO_SERIAL_FLOW_CONTROL_XON_CHAR { + display "Start character" + flavor data + default_value 17 + legal_values 0 to 255 + description " + This option specifies the ascii character used to + indicate that transmission should start." + } + + cdl_option CYGDAT_IO_SERIAL_FLOW_CONTROL_XOFF_CHAR { + display "Stop character" + flavor data + default_value 19 + legal_values 0 to 255 + description " + This option specifies the ascii character used to + indicate that transmission should stop." + } + } + + cdl_option CYGOPT_IO_SERIAL_FLOW_CONTROL_HW { + display "Hardware flow control" + active_if { CYGINT_IO_SERIAL_FLOW_CONTROL_HW > 0 } + requires { CYGINT_IO_SERIAL_FLOW_CONTROL_HW > 0 } + requires CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS + default_value { CYGINT_IO_SERIAL_FLOW_CONTROL_HW > 0 ? \ + CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS : 0 } + description " + If the hardware supports it, this option allows hardware + flow control to be enabled. This may be in the form of + either or both of RTS/CTS, or DSR/DTR flow control." + } + + cdl_interface CYGINT_IO_SERIAL_FLOW_CONTROL_HW { + display "Serial h/w supports hardware flow control" + } + + cdl_option CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT { + display "Default flow control method" + flavor data + legal_values { "NONE" "XONXOFF" "RTSCTS" "DSRDTR" } + default_value { "NONE" } + description "This option allows a default flow control method + to be defined. Combinations of flow control methods + may also be set, but this is only possible by + using the cyg_io_set_config() API in source code." + } + + cdl_option CYGNUM_IO_SERIAL_FLOW_CONTROL_LOW_WATER_PERCENT { + display "Rx flow control low water mark" + flavor data + legal_values 1 to 100 + default_value 33 + description "This sets the water mark used for determining + when to disable flow control, expressed + as a percentage of the buffer size. When the + receive buffer size is lower than this percentage, + if the transmitter had previously been throttled, it + will now be informed it can restart." + } + + cdl_option CYGNUM_IO_SERIAL_FLOW_CONTROL_HIGH_WATER_PERCENT { + display "Rx flow control high water mark" + flavor data + legal_values 1 to 100 + default_value 66 + requires { CYGNUM_IO_SERIAL_FLOW_CONTROL_HIGH_WATER_PERCENT >= \ + CYGNUM_IO_SERIAL_FLOW_CONTROL_LOW_WATER_PERCENT } + description "This sets the water mark used for determining + when to enable flow control, expressed + as a percentage of the buffer size. When the + receive buffer size exceeds this percentage, + signals are sent to the transmitter to tell it + to throttle tranmission." + } + + } + cdl_component CYGPKG_IO_SERIAL_TTY { display "TTY-mode serial device drivers" flavor bool default_value 1 description " - This option enables the terminal-like device driver - used for serial devices that interact with humans, + This option enables a simple terminal-like device driver + that can be used for serial devices that interact with humans, such as a system console." script tty.cdl + compile -library=libextras.a common/tty.c + } + + cdl_component CYGPKG_IO_SERIAL_TERMIOS { + display "Termios compatible TTY drivers" + flavor bool + requires CYGPKG_ISOINFRA + requires CYGPKG_IO_FILEIO + requires CYGINT_ISO_ERRNO_CODES + requires CYGINT_ISO_ERRNO + requires CYGINT_ISO_MALLOC + default_value { 0 != CYGPKG_ISOINFRA && 0 != CYGPKG_IO_FILEIO && \ + 0 != CYGINT_ISO_ERRNO_CODES && \ + 0 != CYGINT_ISO_ERRNO } + implements CYGINT_ISO_TERMIOS + description " + This option enables terminal drivers compatible with + POSIX termios." + + script termios.cdl + compile -library=libextras.a common/termiostty.c + compile common/termios.c } cdl_component CYGPKG_IO_SERIAL_DEVICES { @@ -158,9 +287,23 @@ cdl_package CYGPKG_IO_SERIAL { display "Serial device driver tests" flavor data no_define - calculated { CYGPKG_IO_SERIAL_DEVICES ? "tests/serial1 tests/serial2 tests/serial3 tests/serial4 tests/serial5 tests/tty1 tests/tty2" : "" } + calculated { CYGPKG_IO_SERIAL_DEVICES ? "tests/serial1 tests/serial2 tests/serial3 tests/serial4 tests/serial5 tests/tty1 tests/tty2 tests/flow1 tests/flow2" : "" } description " This option specifies the set of tests for the serial device drivers." } } + + cdl_option CYGPKG_IO_SERIAL_SELECT_SUPPORT { + display "Enable serial device select support" + flavor bool + active_if CYGPKG_IO_FILEIO + requires CYGPKG_IO_FILEIO + default_value 1 + description " + This option enables support for the select() API function on all + serial devices." + } + } + +# EOF io_serial.cdl diff --git a/packages/io/serial/current/cdl/termios.cdl b/packages/io/serial/current/cdl/termios.cdl new file mode 100644 --- /dev/null +++ b/packages/io/serial/current/cdl/termios.cdl @@ -0,0 +1,108 @@ +# ==================================================================== +# +# termios.cdl +# +# eCos POSIX termios compatible terminal configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jlarmour, gthomas +# Contributors: +# Date: 2000-07-22 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_component CYGPKG_IO_SERIAL_TERMIOS_TERMIOS0 { + display "Termios TTY channel #0" + flavor bool + default_value 0 + description " + This option causes '/dev/termios0' to be included in the standard + drivers." + + cdl_option CYGDAT_IO_SERIAL_TERMIOS_TERMIOS0_DEV { + display "Termios TTY channel #0 device" + flavor data + default_value { "\"/dev/ser0\"" } + description " + This option selects the physical device to use for + '/dev/termios0'." + } +} +cdl_component CYGPKG_IO_SERIAL_TERMIOS_TERMIOS1 { + display "Termios TTY channel #1" + flavor bool + default_value 0 + description " + This option causes '/dev/termios1' to be included in the standard + drivers." + + cdl_option CYGDAT_IO_SERIAL_TERMIOS_TERMIOS1_DEV { + display "Termios TTY channel #1 device" + flavor data + default_value {"\"/dev/ser1\""} + description " + This option selects the physical device to use for + '/dev/termios1'." + } +} + +cdl_component CYGPKG_IO_SERIAL_TERMIOS_TERMIOS2 { + display "Termios TTY channel #2" + flavor bool + default_value 0 + description " + This option causes '/dev/termios2' to be included in the standard + drivers." + + cdl_option CYGDAT_IO_SERIAL_TERMIOS_TERMIOS2_DEV { + display "Termios TTY channel #2 device" + flavor data + default_value {"\"/dev/ser2\""} + description " + This option selects the physical device to use for + '/dev/termios2'." + } +} + +cdl_option CYGSEM_IO_SERIAL_TERMIOS_USE_SIGNALS { + display "Support signals" + flavor bool + requires CYGINT_ISO_SIGNAL_NUMBERS + requires CYGINT_ISO_SIGNAL_IMPL + default_value { CYGINT_ISO_SIGNAL_NUMBERS != 0 && \ + CYGINT_ISO_SIGNAL_IMPL != 0 } + description "This option selects whether those parts of the termios + interface involving signals is supported. This includes + BRKINT mode, the INTR and QUIT characters, and whether + SIGHUP is sent on terminal close." +} + +# EOF termios.cdl diff --git a/packages/io/serial/current/cdl/tty.cdl b/packages/io/serial/current/cdl/tty.cdl --- a/packages/io/serial/current/cdl/tty.cdl +++ b/packages/io/serial/current/cdl/tty.cdl @@ -47,6 +47,7 @@ cdl_component CYGPKG_IO_SERIAL_HALDIAG { description " This option enables the use of the HAL diagnostic channel via the standard I/O drivers." + compile -library=libextras.a common/haldiag.c } cdl_option CYGDAT_IO_SERIAL_TTY_CONSOLE { diff --git a/packages/io/serial/current/include/serial.h b/packages/io/serial/current/include/serial.h --- a/packages/io/serial/current/include/serial.h +++ b/packages/io/serial/current/include/serial.h @@ -53,6 +53,10 @@ #include #include +#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT +#include +#endif + typedef struct serial_channel serial_channel; typedef struct serial_funs serial_funs; @@ -64,8 +68,7 @@ typedef struct { void (*xmt_char)(serial_channel *chan); // Consume an input character void (*rcv_char)(serial_channel *chan, unsigned char c); - -#ifdef CYGINT_IO_SERIAL_BLOCK_TRANSFER +#if CYGINT_IO_SERIAL_BLOCK_TRANSFER // Request space for input characters bool (*data_rcv_req)(serial_channel *chan, int avail, int* space_avail, unsigned char** space); @@ -76,11 +79,27 @@ typedef struct { int* chars_avail, unsigned char** chars); // Transmit operation completed void (*data_xmt_done)(serial_channel *chan); -#endif // CYGINT_IO_SERIAL_BLOCK_TRANSFER +#endif +#if defined(CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS) + void (*indicate_status)(serial_channel *chan, cyg_serial_line_status_t *s ); +#endif } serial_callbacks_t; -#ifdef CYGINT_IO_SERIAL_BLOCK_TRANSFER -#define SERIAL_CALLBACKS(_l,_init,_xmt_char,_rcv_char, _data_rcv_req, _data_rcv_done, _data_xmt_req, _data_xmt_done) \ +#if CYGINT_IO_SERIAL_BLOCK_TRANSFER +# ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS +# define SERIAL_CALLBACKS(_l,_init,_xmt_char,_rcv_char, _data_rcv_req, _data_rcv_done, _data_xmt_req, _data_xmt_done, _indicate_status) \ +serial_callbacks_t _l = { \ + _init, \ + _xmt_char, \ + _rcv_char, \ + _data_rcv_req, \ + _data_rcv_done, \ + _data_xmt_req, \ + _data_xmt_done \ + _indicate_status \ +}; +# else +# define SERIAL_CALLBACKS(_l,_init,_xmt_char,_rcv_char, _data_rcv_req, _data_rcv_done, _data_xmt_req, _data_xmt_done) \ serial_callbacks_t _l = { \ _init, \ _xmt_char, \ @@ -90,13 +109,24 @@ serial_callbacks_t _l = { _data_xmt_req, \ _data_xmt_done \ }; -#else -#define SERIAL_CALLBACKS(_l,_init,_xmt_char,_rcv_char) \ +# endif +#else +# ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS +# define SERIAL_CALLBACKS(_l,_init,_xmt_char,_rcv_char,_indicate_status) \ +serial_callbacks_t _l = { \ + _init, \ + _xmt_char, \ + _rcv_char, \ + _indicate_status \ +}; +# else +# define SERIAL_CALLBACKS(_l,_init,_xmt_char,_rcv_char) \ serial_callbacks_t _l = { \ _init, \ _xmt_char, \ _rcv_char \ }; +# endif #endif extern serial_callbacks_t cyg_io_serial_callbacks; @@ -106,7 +136,13 @@ typedef struct { volatile int put; volatile int get; int len; - int low_water; // Min space in buffer before restart + int nb; // count of bytes currently in buffer + int low_water; // For tx: min space in buffer before restart + // For rx: max buffer used before flow unthrottled +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + int high_water; // For tx: unused + // For rx: min buffer used before throttle +#endif cyg_drv_cond_t wait; cyg_drv_mutex_t lock; bool waiting; @@ -115,11 +151,23 @@ typedef struct { #endif volatile bool abort; // Set by an outsider to kill processing volatile cyg_int32 pending; // This many bytes waiting to be sent +#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT + struct CYG_SELINFO_TAG selinfo; // select info +#endif } cbuf_t; #define CBUF_INIT(_data, _len) \ {_data, 0, 0, _len} +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL +typedef struct { + cyg_uint32 flags; +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE + cyg_uint8 xchar; +#endif +} flow_desc_t; +#endif + // Private data which describes this channel struct serial_channel { serial_funs *funs; @@ -129,8 +177,19 @@ struct serial_channel { bool init; cbuf_t out_cbuf; cbuf_t in_cbuf; +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + flow_desc_t flow_desc; +#endif +#ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS + cyg_serial_line_status_callback_fn_t status_callback; + CYG_ADDRWORD status_callback_priv; +#endif }; +// Flow descriptor flag values +#define CYG_SERIAL_FLOW_OUT_THROTTLED (1<<0) +#define CYG_SERIAL_FLOW_IN_THROTTLED (1<<1) + // Initialization macro for serial channel #define SERIAL_CHANNEL(_l, \ _funs, \ @@ -166,7 +225,8 @@ struct serial_funs { // Fetch one character from the device unsigned char (*getc)(serial_channel *priv); // Change hardware configuration (baud rate, etc) - bool (*set_config)(serial_channel *priv, cyg_serial_info_t *config); + Cyg_ErrNo (*set_config)(serial_channel *priv, cyg_uint32 key, const void *xbuf, + cyg_uint32 *len); // Enable the transmit channel and turn on transmit interrupts void (*start_xmit)(serial_channel *priv); // Disable the transmit channel and turn transmit interrupts off diff --git a/packages/io/serial/current/include/serialio.h b/packages/io/serial/current/include/serialio.h --- a/packages/io/serial/current/include/serialio.h +++ b/packages/io/serial/current/include/serialio.h @@ -116,6 +116,32 @@ typedef struct { cyg_uint32 flags; } cyg_serial_info_t; +// cyg_serial_info_t flags +#define CYGNUM_SERIAL_FLOW_NONE (0) +// receive flow control, send xon/xoff when necessary: +#define CYGNUM_SERIAL_FLOW_XONXOFF_RX (1<<0) +// transmit flow control, act on received xon/xoff: +#define CYGNUM_SERIAL_FLOW_XONXOFF_TX (1<<1) +// receive flow control, send RTS when necessary: +#define CYGNUM_SERIAL_FLOW_RTSCTS_RX (1<<2) +// transmit flow control, act when not CTS: +#define CYGNUM_SERIAL_FLOW_RTSCTS_TX (1<<3) +// receive flow control, send DTR when necessary: +#define CYGNUM_SERIAL_FLOW_DSRDTR_RX (1<<4) +// transmit flow control, act when not DSR: +#define CYGNUM_SERIAL_FLOW_DSRDTR_TX (1<<5) + +// arguments for CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_FORCE +#define CYGNUM_SERIAL_FLOW_THROTTLE_RX 0 +#define CYGNUM_SERIAL_FLOW_RESTART_RX 1 +#define CYGNUM_SERIAL_FLOW_THROTTLE_TX 2 +#define CYGNUM_SERIAL_FLOW_RESTART_TX 3 + +// arguments for CYG_IO_SET_CONFIG_SERIAL_HW_RX_FLOW_THROTTLE +#define CYGNUM_SERIAL_FLOW_HW_UNTHROTTLE 0 +#define CYGNUM_SERIAL_FLOW_HW_THROTTLE 0 +#define CYGNUM_SERIAL_FLOW_HW_UNTHROTTLE 0 + typedef struct { cyg_int32 rx_bufsize; cyg_int32 rx_count; @@ -123,12 +149,33 @@ typedef struct { cyg_int32 tx_count; } cyg_serial_buf_info_t; - #define CYG_SERIAL_INFO_INIT(_baud,_stop,_parity,_word_length,_flags) \ { _baud, _stop, _parity, _word_length, _flags} -// Control flags -#define CYG_SERIAL_FLAGS_RTSCTS 0x0001 +#ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS + +# define CYGNUM_SERIAL_STATUS_FLOW 0 +# define CYGNUM_SERIAL_STATUS_BREAK 1 +# define CYGNUM_SERIAL_STATUS_FRAMEERR 2 +# define CYGNUM_SERIAL_STATUS_PARITYERR 3 +# define CYGNUM_SERIAL_STATUS_OVERRUNERR 4 +# define CYGNUM_SERIAL_STATUS_CARRIERDETECT 5 +# define CYGNUM_SERIAL_STATUS_RINGINDICATOR 6 + +typedef struct { + cyg_uint32 which; // one of CYGNUM_SERIAL_STATUS_* above + cyg_uint32 value; // and its value +} cyg_serial_line_status_t; + +typedef void (*cyg_serial_line_status_callback_fn_t)( + cyg_serial_line_status_t *s, + CYG_ADDRWORD priv ); +typedef struct { + cyg_serial_line_status_callback_fn_t fn; + CYG_ADDRWORD priv; +} cyg_serial_line_status_callback_t; + +#endif // ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS // Default configuration #define CYG_SERIAL_BAUD_DEFAULT CYGNUM_SERIAL_BAUD_38400 @@ -137,6 +184,16 @@ typedef struct { #define CYG_SERIAL_WORD_LENGTH_DEFAULT CYGNUM_SERIAL_WORD_LENGTH_8 #define CYG_SERIAL_FLAGS_DEFAULT 0 +#ifdef CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_XONXOFF +# define CYG_SERIAL_FLAGS_DEFAULT CYG_SERIAL_FLOW_XONXOFF +#elif defined(CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_RTSCTS) +# define CYG_SERIAL_FLAGS_DEFAULT CYG_SERIAL_FLOW_RTSCTS +#elif defined(CYGDAT_IO_SERIAL_FLOW_CONTROL_DEFAULT_DSRDTR) +# define CYG_SERIAL_FLAGS_DEFAULT CYG_SERIAL_FLOW_DSRDTR +#else +# define CYG_SERIAL_FLAGS_DEFAULT 0 +#endif + #ifdef __cplusplus } #endif diff --git a/packages/io/serial/current/src/common/haldiag.c b/packages/io/serial/current/src/common/haldiag.c --- a/packages/io/serial/current/src/common/haldiag.c +++ b/packages/io/serial/current/src/common/haldiag.c @@ -53,7 +53,8 @@ static bool haldiag_init(struct cyg_devtab_entry *tab); static bool haldiag_putc(serial_channel *chan, unsigned char c); static unsigned char haldiag_getc(serial_channel *chan); -static bool haldiag_set_config(serial_channel *chan, cyg_serial_info_t *config); +static Cyg_ErrNo haldiag_set_config(serial_channel *chan, cyg_uint32 key, + const void *xbuf, cyg_uint32 *len); static SERIAL_FUNS(haldiag_funs, haldiag_putc, @@ -113,10 +114,16 @@ haldiag_getc(serial_channel *chan) return c; } -static bool -haldiag_set_config(serial_channel *chan, cyg_serial_info_t *config) +static Cyg_ErrNo +haldiag_set_config(serial_channel *chan, cyg_uint32 key, const void *xbuf, + cyg_uint32 *len) { - diag_printf("%s\n", __FUNCTION__); - return true; + switch (key) { + case CYG_IO_SET_CONFIG_SERIAL_INFO: + diag_printf("%s\n", __FUNCTION__); + return ENOERR; + default: + return -EINVAL; + } } #endif // CYGPKG_IO_SERIAL_HALDIAG diff --git a/packages/io/serial/current/src/common/serial.c b/packages/io/serial/current/src/common/serial.c --- a/packages/io/serial/current/src/common/serial.c +++ b/packages/io/serial/current/src/common/serial.c @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas, grante +// Contributors: gthomas, grante, jlarmour, jskov // Date: 1999-02-04 // Purpose: Top level serial driver // Description: @@ -51,12 +51,14 @@ static Cyg_ErrNo serial_write(cyg_io_handle_t handle, const void *buf, cyg_uint32 *len); static Cyg_ErrNo serial_read(cyg_io_handle_t handle, void *buf, cyg_uint32 *len); +static Cyg_ErrNo serial_select(cyg_io_handle_t handle, cyg_uint32 which, CYG_ADDRWORD info); static Cyg_ErrNo serial_get_config(cyg_io_handle_t handle, cyg_uint32 key, void *buf, cyg_uint32 *len); static Cyg_ErrNo serial_set_config(cyg_io_handle_t handle, cyg_uint32 key, const void *buf, cyg_uint32 *len); DEVIO_TABLE(cyg_io_serial_devio, serial_write, serial_read, + serial_select, serial_get_config, serial_set_config ); @@ -64,13 +66,29 @@ DEVIO_TABLE(cyg_io_serial_devio, static void serial_init(serial_channel *chan); static void serial_xmt_char(serial_channel *chan); static void serial_rcv_char(serial_channel *chan, unsigned char c); -#ifdef CYGINT_IO_SERIAL_BLOCK_TRANSFER +#ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS +static void serial_indicate_status(serial_channel *chan, + cyg_serial_line_status_t *s); +#endif +#if CYGINT_IO_SERIAL_BLOCK_TRANSFER static bool serial_data_rcv_req(serial_channel *chan, int avail, int* space_avail, unsigned char** space); static void serial_data_rcv_done(serial_channel *chan); static bool serial_data_xmt_req(serial_channel *chan, int space, int* chars_avail, unsigned char** chars); static void serial_data_xmt_done(serial_channel *chan); +# ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_HW +SERIAL_CALLBACKS(cyg_io_serial_callbacks, + serial_init, + serial_xmt_char, + serial_rcv_char, + serial_data_rcv_req, + serial_data_rcv_done, + serial_data_xmt_req, + serial_data_xmt_done, + serial_indicate_status); + +# else SERIAL_CALLBACKS(cyg_io_serial_callbacks, serial_init, serial_xmt_char, @@ -79,13 +97,116 @@ SERIAL_CALLBACKS(cyg_io_serial_callbacks serial_data_rcv_done, serial_data_xmt_req, serial_data_xmt_done); +# endif #else +# ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS +SERIAL_CALLBACKS(cyg_io_serial_callbacks, + serial_init, + serial_xmt_char, + serial_rcv_char, + serial_indicate_status); +# else SERIAL_CALLBACKS(cyg_io_serial_callbacks, serial_init, serial_xmt_char, serial_rcv_char); +# endif #endif +// --------------------------------------------------------------------------- + +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + +static __inline__ void +throttle_tx( serial_channel *chan ) +{ + chan->flow_desc.flags |= CYG_SERIAL_FLOW_OUT_THROTTLED; + // the throttling itself occurs in the serial_xmt_char() callback +} + +static __inline__ void +restart_tx( serial_channel *chan ) +{ + serial_funs *funs = chan->funs; + + chan->flow_desc.flags &= ~CYG_SERIAL_FLOW_OUT_THROTTLED; + +#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT + // See if there is now enough room to say it is available + // for writing + { + cbuf_t *cbuf = &chan->out_cbuf; + int space; + + space = cbuf->len - cbuf->nb; + if (space >= cbuf->low_water) + cyg_selwakeup( &cbuf->selinfo ); + } +#endif + if ( chan->out_cbuf.nb > 0 ) + (funs->start_xmit)(chan); +} + +static __inline__ void +throttle_rx( serial_channel *chan, cyg_bool force ) +{ + serial_funs *funs = chan->funs; + + chan->flow_desc.flags |= CYG_SERIAL_FLOW_IN_THROTTLED; +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE + // send an xoff + if ( force || chan->config.flags & CYGNUM_SERIAL_FLOW_XONXOFF_RX ) { + chan->flow_desc.xchar = CYGDAT_IO_SERIAL_FLOW_CONTROL_XOFF_CHAR; + // Make sure xmit is running so we can send it + (funs->start_xmit)(chan); + } +#endif +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_HW + { + cyg_uint32 i=1; + cyg_uint32 len = sizeof(i); + + // set hardware flow control - don't care if it fails + if ( force || (chan->config.flags & CYGNUM_SERIAL_FLOW_RTSCTS_RX) || + (chan->config.flags & CYGNUM_SERIAL_FLOW_DSRDTR_RX) ) + (funs->set_config)(chan, + CYG_IO_SET_CONFIG_SERIAL_HW_RX_FLOW_THROTTLE, + &i, &len); + } +#endif +} + +static __inline__ void +restart_rx( serial_channel *chan, cyg_bool force ) +{ + serial_funs *funs = chan->funs; + + chan->flow_desc.flags &= ~CYG_SERIAL_FLOW_IN_THROTTLED; +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE + // send an xon + if ( force || chan->config.flags & CYGNUM_SERIAL_FLOW_XONXOFF_RX ) { + chan->flow_desc.xchar = CYGDAT_IO_SERIAL_FLOW_CONTROL_XON_CHAR; + (funs->start_xmit)(chan); // Make sure xmit is running so we can send it + } +#endif +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_HW + { + cyg_uint32 i=0; + cyg_uint32 len = sizeof(i); + + // set hardware flow control - don't care if it fails + if ( force || (chan->config.flags & CYGNUM_SERIAL_FLOW_RTSCTS_RX) || + (chan->config.flags & CYGNUM_SERIAL_FLOW_DSRDTR_RX) ) + (funs->set_config)(chan, + CYG_IO_SET_CONFIG_SERIAL_HW_RX_FLOW_THROTTLE, + &i, &len); + } +#endif +} + +#endif + +// --------------------------------------------------------------------------- static void serial_init(serial_channel *chan) @@ -104,22 +225,57 @@ serial_init(serial_channel *chan) cyg_drv_mutex_init(&chan->out_cbuf.lock); cyg_drv_cond_init(&chan->out_cbuf.wait, &chan->out_cbuf.lock); chan->out_cbuf.low_water = chan->out_cbuf.len / 4; +#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT + cyg_selinit( &chan->out_cbuf.selinfo ); +#endif } if (chan->in_cbuf.len != 0) { + cbuf_t *cbuf = &chan->in_cbuf; + #ifdef CYGDBG_IO_INIT - diag_printf("Set input buffer - buf: %x len: %d\n", chan->in_cbuf.data, chan->in_cbuf.len); + diag_printf("Set input buffer - buf: %x len: %d\n", cbuf->data, cbuf->len); #endif - chan->in_cbuf.waiting = false; - chan->in_cbuf.abort = false; + cbuf->waiting = false; + cbuf->abort = false; #ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING - chan->in_cbuf.blocking = true; + cbuf->blocking = true; +#endif +#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT + cyg_selinit( &cbuf->selinfo ); #endif - cyg_drv_mutex_init(&chan->in_cbuf.lock); - cyg_drv_cond_init(&chan->in_cbuf.wait, &chan->in_cbuf.lock); +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + cbuf->low_water = + (CYGNUM_IO_SERIAL_FLOW_CONTROL_LOW_WATER_PERCENT * cbuf->len) / 100; + cbuf->high_water = + (CYGNUM_IO_SERIAL_FLOW_CONTROL_HIGH_WATER_PERCENT * cbuf->len) / 100; +# ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE + // But make sure it is at least 35 below buffer size, to allow + // for 16 byte fifos, twice, plus some latency before s/w flow + // control can kick in. This doesn't apply to h/w flow control + // as it is near-instaneous + if ( (cbuf->len - cbuf->high_water) < 35 ) + cbuf->high_water = cbuf->len - 35; + // and just in case... + if ( cbuf->high_water <= 0 ) + cbuf->high_water = 1; + if ( cbuf->low_water > cbuf->high_water ) + cbuf->low_water = cbuf->high_water; +# endif +#endif + cyg_drv_mutex_init(&cbuf->lock); + cyg_drv_cond_init(&cbuf->wait, &cbuf->lock); } +#ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS + chan->status_callback = NULL; +#endif + chan->init = true; } +// --------------------------------------------------------------------------- +// FIXME:@@@ Throughout this file there are uses of cyg_drv_cond_signal and +// cyg_drv_cond_broadcast. Does it matter which? -Jifl + static Cyg_ErrNo serial_write(cyg_io_handle_t handle, const void *_buf, cyg_uint32 *len) { @@ -132,13 +288,19 @@ serial_write(cyg_io_handle_t handle, con cbuf_t *cbuf = &chan->out_cbuf; Cyg_ErrNo res = ENOERR; + cyg_drv_mutex_lock(&cbuf->lock); cbuf->abort = false; - cyg_drv_mutex_lock(&cbuf->lock); if (cbuf->len == 0) { // Non interrupt driven (i.e. polled) operation while (size-- > 0) { +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + while ( ( 0 == (chan->flow_desc.flags & CYG_SERIAL_FLOW_OUT_THROTTLED) ) && + ((funs->putc)(chan, *buf) == false) ) + ; // Ignore full, keep trying +#else while ((funs->putc)(chan, *buf) == false) ; // Ignore full, keep trying +#endif buf++; } } else { @@ -146,10 +308,14 @@ serial_write(cyg_io_handle_t handle, con while (size > 0) { next = cbuf->put + 1; if (next == cbuf->len) next = 0; - if (next == cbuf->get) { + if (cbuf->nb == cbuf->len) { cbuf->waiting = true; // Buffer full - wait for space - (funs->start_xmit)(chan); // Make sure xmit is running +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + if ( 0 == (chan->flow_desc.flags & CYG_SERIAL_FLOW_OUT_THROTTLED) ) +#endif + (funs->start_xmit)(chan); // Make sure xmit is running + // Check flag: 'start_xmit' may have obviated the need to wait :-) if (cbuf->waiting) { #ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING @@ -162,7 +328,8 @@ serial_write(cyg_io_handle_t handle, con } #endif // CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING cbuf->pending += size; // Have this much more to send [eventually] - cyg_drv_cond_wait(&cbuf->wait); + if( !cyg_drv_cond_wait(&cbuf->wait) ) + cbuf->abort = true; cbuf->pending -= size; } if (cbuf->abort) { @@ -176,16 +343,23 @@ serial_write(cyg_io_handle_t handle, con } else { cbuf->data[cbuf->put++] = *buf++; cbuf->put = next; + cbuf->nb++; size--; // Only count if actually sent! } } - (funs->start_xmit)(chan); // Start output as necessary +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + if ( 0 == (chan->flow_desc.flags & CYG_SERIAL_FLOW_OUT_THROTTLED) ) +#endif + (funs->start_xmit)(chan); // Start output as necessary cyg_drv_dsr_unlock(); } cyg_drv_mutex_unlock(&cbuf->lock); return res; } + +// --------------------------------------------------------------------------- + static Cyg_ErrNo serial_read(cyg_io_handle_t handle, void *_buf, cyg_uint32 *len) { @@ -203,20 +377,44 @@ serial_read(cyg_io_handle_t handle, void externC cyg_tick_count_t cyg_current_time(void); #endif // CYGDBG_DIAG_BUF + cyg_drv_mutex_lock(&cbuf->lock); cbuf->abort = false; - cyg_drv_mutex_lock(&cbuf->lock); if (cbuf->len == 0) { // Non interrupt driven (i.e. polled) operation while (size++ < *len) { - *buf++ = (funs->getc)(chan); + cyg_uint8 c = (funs->getc)(chan); +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE + // for software flow control, if the driver returns one of the + // characters we act on it and then drop it (the app must not + // see it) + if ( chan->config.flags & CYGNUM_SERIAL_FLOW_XONXOFF_TX ) { + if ( c == CYGDAT_IO_SERIAL_FLOW_CONTROL_XOFF_CHAR ) { + throttle_tx( chan ); + } else if ( c == CYGDAT_IO_SERIAL_FLOW_CONTROL_XON_CHAR ) { + restart_tx( chan ); + } + else + *buf++ = c; + } + else + *buf++ = c; +#else + *buf++ = c; +#endif } } else { cyg_drv_dsr_lock(); // Avoid races while (size < *len) { - if (cbuf->get != cbuf->put) { + if (cbuf->nb > 0) { +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + if ( (cbuf->nb <= cbuf->low_water) && + (chan->flow_desc.flags & CYG_SERIAL_FLOW_IN_THROTTLED) ) + restart_rx( chan, false ); +#endif *buf++ = cbuf->data[cbuf->get]; if (++cbuf->get == cbuf->len) cbuf->get = 0; + cbuf->nb--; size++; } else { #ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING @@ -228,19 +426,20 @@ serial_read(cyg_io_handle_t handle, void #endif // CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING cbuf->waiting = true; #ifdef XX_CYGDBG_DIAG_BUF - enable_diag_uart = 0; - HAL_CLOCK_READ(&_time); - _stime = (int)cyg_current_time(); - diag_printf("READ wait - get: %d, put: %d, time: %x.%x\n", cbuf->get, cbuf->put, _stime, _time); - enable_diag_uart = _enable; + enable_diag_uart = 0; + HAL_CLOCK_READ(&_time); + _stime = (int)cyg_current_time(); + diag_printf("READ wait - get: %d, put: %d, time: %x.%x\n", cbuf->get, cbuf->put, _stime, _time); + enable_diag_uart = _enable; #endif // CYGDBG_DIAG_BUF - cyg_drv_cond_wait(&cbuf->wait); + if( !cyg_drv_cond_wait(&cbuf->wait) ) + cbuf->abort = true; #ifdef XX_CYGDBG_DIAG_BUF - enable_diag_uart = 0; - HAL_CLOCK_READ(&_time); - _stime = (int)cyg_current_time(); - diag_printf("READ continue - get: %d, put: %d, time: %x.%x\n", cbuf->get, cbuf->put, _stime, _time); - enable_diag_uart = _enable; + enable_diag_uart = 0; + HAL_CLOCK_READ(&_time); + _stime = (int)cyg_current_time(); + diag_printf("READ continue - get: %d, put: %d, time: %x.%x\n", cbuf->get, cbuf->put, _stime, _time); + enable_diag_uart = _enable; #endif // CYGDBG_DIAG_BUF if (cbuf->abort) { // Give up! @@ -267,6 +466,66 @@ serial_read(cyg_io_handle_t handle, void return res; } + +// --------------------------------------------------------------------------- + +static cyg_bool +serial_select(cyg_io_handle_t handle, cyg_uint32 which, CYG_ADDRWORD info) +{ +#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT + + cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle; + serial_channel *chan = (serial_channel *)t->priv; + + + switch( which ) + { + case CYG_FREAD: + { + cbuf_t *cbuf = &chan->in_cbuf; + + // Check for data in the input buffer. If there is none, + // register the select operation, otherwise return true. + + if( cbuf->nb == 0 ) + cyg_selrecord( info, &cbuf->selinfo ); + else return true; + } + break; + + case CYG_FWRITE: + { + // Check for space in the output buffer. If there is none, + // register the select operation, otherwise return true. + + cbuf_t *cbuf = &chan->out_cbuf; + int space = cbuf->len - cbuf->nb; +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + if ( (space < cbuf->low_water) || + (chan->flow_desc.flags & CYG_SERIAL_FLOW_OUT_THROTTLED) ) + cyg_selrecord( info, &cbuf->selinfo ); +#else + if (space < cbuf->low_water) + cyg_selrecord( info, &cbuf->selinfo ); +#endif + else return true; + } + break; + + case 0: // exceptions - none supported + break; + } + return false; +#else + + // With no select support, we simply return true. + return true; +#endif +} + + +// --------------------------------------------------------------------------- + static Cyg_ErrNo serial_get_config(cyg_io_handle_t handle, cyg_uint32 key, void *xbuf, cyg_uint32 *len) { @@ -298,20 +557,14 @@ serial_get_config(cyg_io_handle_t handle p = (cyg_serial_buf_info_t *)xbuf; p->rx_bufsize = in_cbuf->len; - if (p->rx_bufsize) { - p->rx_count = in_cbuf->put - in_cbuf->get; - if (p->rx_count < 0) - p->rx_count += p->rx_bufsize; - } + if (p->rx_bufsize) + p->rx_count = in_cbuf->nb; else p->rx_count = 0; p->tx_bufsize = out_cbuf->len; - if (p->tx_bufsize) { - p->tx_count = out_cbuf->put - out_cbuf->get; - if (p->tx_count < 0) - p->tx_count += p->tx_bufsize; - } + if (p->tx_bufsize) + p->tx_count = out_cbuf->nb; else p->tx_count = 0; } @@ -322,9 +575,10 @@ serial_get_config(cyg_io_handle_t handle if (out_cbuf->len == 0) break; // Nothing to do if not buffered cyg_drv_mutex_lock(&out_cbuf->lock); // Stop any further output processing cyg_drv_dsr_lock(); - while (out_cbuf->pending || (out_cbuf->get != out_cbuf->put)) { + while (out_cbuf->pending || (out_cbuf->nb > 0)) { out_cbuf->waiting = true; - cyg_drv_cond_wait(&out_cbuf->wait); + if(!cyg_drv_cond_wait(&out_cbuf->wait) ) + res = -EINTR; } cyg_drv_dsr_unlock(); cyg_drv_mutex_unlock(&out_cbuf->lock); @@ -340,7 +594,7 @@ serial_get_config(cyg_io_handle_t handle cyg_drv_cond_signal(&in_cbuf->wait); in_cbuf->waiting = false; } - in_cbuf->get = in_cbuf->put; // Flush buffered input + in_cbuf->get = in_cbuf->put = in_cbuf->nb = 0; // Flush buffered input cyg_drv_dsr_unlock(); cyg_drv_mutex_unlock(&in_cbuf->lock); break; @@ -363,8 +617,8 @@ serial_get_config(cyg_io_handle_t handle if (out_cbuf->len == 0) break; // Nothing to do if not buffered cyg_drv_mutex_lock(&out_cbuf->lock); // Stop any further output processing cyg_drv_dsr_lock(); - if (out_cbuf->get != out_cbuf->put) { - out_cbuf->get = out_cbuf->put; // Empties queue! + if (out_cbuf->nb > 0) { + out_cbuf->get = out_cbuf->put = out_cbuf->nb = 0; // Empties queue! (funs->stop_xmit)(chan); // Done with transmit } if (out_cbuf->waiting) { @@ -377,14 +631,14 @@ serial_get_config(cyg_io_handle_t handle break; #ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING - case CYG_IO_GET_CONFIG_SERIAL_READ_BLOCKING: + case CYG_IO_GET_CONFIG_READ_BLOCKING: if (*len < sizeof(cyg_uint32)) { return -EINVAL; } *(cyg_uint32*)xbuf = (in_cbuf->blocking) ? 1 : 0; break; - case CYG_IO_GET_CONFIG_SERIAL_WRITE_BLOCKING: + case CYG_IO_GET_CONFIG_WRITE_BLOCKING: if (*len < sizeof(cyg_uint32)) { return -EINVAL; } @@ -398,6 +652,9 @@ serial_get_config(cyg_io_handle_t handle return res; } + +// --------------------------------------------------------------------------- + static Cyg_ErrNo serial_set_config(cyg_io_handle_t handle, cyg_uint32 key, const void *xbuf, cyg_uint32 *len) { @@ -409,38 +666,127 @@ serial_set_config(cyg_io_handle_t handle cbuf_t *in_cbuf = &chan->in_cbuf; #endif serial_funs *funs = chan->funs; - cyg_serial_info_t *buf = (cyg_serial_info_t *)xbuf; switch (key) { - case CYG_IO_SET_CONFIG_SERIAL_INFO: - if (*len != sizeof(cyg_serial_info_t)) { - return -EINVAL; - } - if ((funs->set_config)(chan, buf) != true) { - // Device is not happy with paramters or they cannot be set - res = -EINVAL; - } - break; #ifdef CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING - case CYG_IO_SET_CONFIG_SERIAL_READ_BLOCKING: + case CYG_IO_SET_CONFIG_READ_BLOCKING: if (*len < sizeof(cyg_uint32) || 0 == in_cbuf->len) { return -EINVAL; } in_cbuf->blocking = (1 == *(cyg_uint32*)xbuf) ? true : false; break; - case CYG_IO_SET_CONFIG_SERIAL_WRITE_BLOCKING: + case CYG_IO_SET_CONFIG_WRITE_BLOCKING: if (*len < sizeof(cyg_uint32) || 0 == out_cbuf->len) { return -EINVAL; } out_cbuf->blocking = (1 == *(cyg_uint32*)xbuf) ? true : false; break; #endif // CYGOPT_IO_SERIAL_SUPPORT_NONBLOCKING + +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + case CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_METHOD: + { + cyg_uint32 *f = (cyg_uint32 *)xbuf; + + if (*len < sizeof(*f)) + return -EINVAL; + + cyg_drv_dsr_lock(); + + chan->config.flags &= ~(CYGNUM_SERIAL_FLOW_XONXOFF_RX| + CYGNUM_SERIAL_FLOW_XONXOFF_TX| + CYGNUM_SERIAL_FLOW_RTSCTS_RX| + CYGNUM_SERIAL_FLOW_RTSCTS_TX| + CYGNUM_SERIAL_FLOW_DSRDTR_RX| + CYGNUM_SERIAL_FLOW_DSRDTR_TX); + chan->config.flags |= (*f & ( +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE + CYGNUM_SERIAL_FLOW_XONXOFF_RX| + CYGNUM_SERIAL_FLOW_XONXOFF_TX| +#endif +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_HW + CYGNUM_SERIAL_FLOW_RTSCTS_RX| + CYGNUM_SERIAL_FLOW_RTSCTS_TX| + CYGNUM_SERIAL_FLOW_DSRDTR_RX| + CYGNUM_SERIAL_FLOW_DSRDTR_TX| +#endif + 0)); +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_HW + // up to hardware driver to clear flags if rejected + res = (funs->set_config)(chan, + CYG_IO_SET_CONFIG_SERIAL_HW_FLOW_CONFIG, + NULL, NULL); +#endif + cyg_drv_dsr_unlock(); + } + break; + + case CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_FORCE: + { + cyg_uint32 *f = (cyg_uint32 *)xbuf; + + if (*len < sizeof(*f)) + return -EINVAL; + + cyg_drv_dsr_lock(); + switch (*f) { + case CYGNUM_SERIAL_FLOW_THROTTLE_RX: + throttle_rx( chan, true ); + break; + case CYGNUM_SERIAL_FLOW_RESTART_RX: + restart_rx( chan, true ); + break; + case CYGNUM_SERIAL_FLOW_THROTTLE_TX: + throttle_tx( chan ); + break; + case CYGNUM_SERIAL_FLOW_RESTART_TX: + restart_tx( chan ); + break; + default: + res = -EINVAL; + break; + } + cyg_drv_dsr_unlock(); + } + break; +#endif // CYGPKG_IO_SERIAL_FLOW_CONTROL + +#ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS + case CYG_IO_SET_CONFIG_SERIAL_STATUS_CALLBACK: + { + cyg_serial_line_status_callback_fn_t newfn; + CYG_ADDRWORD newpriv; + cyg_serial_line_status_callback_t *tmp = + (cyg_serial_line_status_callback_t *)xbuf; + + if ( *len < sizeof(*tmp) ) + return -EINVAL; + + newfn = tmp->fn; + newpriv = tmp->priv; + + // prevent callbacks while we do this + cyg_drv_dsr_lock(); + // store old callbacks in same structure + tmp->fn = chan->status_callback; + tmp->priv = chan->status_callback_priv; + chan->status_callback = newfn; + chan->status_callback_priv = newpriv; + cyg_drv_dsr_unlock(); + *len = sizeof(*tmp); + } + break; +#endif + default: - res = -EINVAL; + // pass down to lower layers + return (funs->set_config)(chan, key, xbuf, len); } return res; } +// --------------------------------------------------------------------------- + static void serial_xmt_char(serial_channel *chan) { @@ -449,47 +795,105 @@ serial_xmt_char(serial_channel *chan) unsigned char c; int space; - while (cbuf->get != cbuf->put) { +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE + // if we are required to send an XON/XOFF char, send it before anything else + // FIXME: what if XON gets corrupted in transit to the other end? + // Should we resend XON even though the other end may not be wanting + // to send us stuff at this point? + if ( chan->config.flags & CYGNUM_SERIAL_FLOW_XONXOFF_RX ) { + if ( chan->flow_desc.xchar ) { + if ( (funs->putc)(chan, chan->flow_desc.xchar) ) { + chan->flow_desc.xchar = '\0'; + } else { // otherwise there's no space and we have to wait + return; + } + } + } +#endif +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + // if we're meant to be throttled, just stop and leave + if ( chan->flow_desc.flags & CYG_SERIAL_FLOW_OUT_THROTTLED ) { + (funs->stop_xmit)(chan); // Stop transmitting for now + return; + } +#endif + while (cbuf->nb > 0) { c = cbuf->data[cbuf->get]; if ((funs->putc)(chan, c)) { cbuf->get++; if (cbuf->get == cbuf->len) cbuf->get = 0; - if (cbuf->waiting) { - // See if there is now enough room to restart writer - space = (cbuf->len + cbuf->get) - cbuf->put; - if (space > cbuf->len) space -= cbuf->len; - if (space >= cbuf->low_water) { + cbuf->nb--; + } else { + // See if there is now enough room to restart writer + space = cbuf->len - cbuf->nb; + if (space >= cbuf->low_water) { + if (cbuf->waiting) { cbuf->waiting = false; cyg_drv_cond_broadcast(&cbuf->wait); } +#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT + cyg_selwakeup( &cbuf->selinfo ); +#endif } - } else { return; // Need to wait for more space } } (funs->stop_xmit)(chan); // Done with transmit + + // must signal waiters, and wake up selecters for the case when + // this was the last char to be sent and they hadn't been signalled + // before (e.g. because of flow control) if (cbuf->waiting) { cbuf->waiting = false; cyg_drv_cond_signal(&cbuf->wait); } +#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT + cyg_selwakeup( &cbuf->selinfo ); +#endif } +// --------------------------------------------------------------------------- + static void serial_rcv_char(serial_channel *chan, unsigned char c) { cbuf_t *cbuf = &chan->in_cbuf; -#if 0 - // FIXME: add error handling - int space; - // Check for overflow - space = (cbuf->len + cbuf->put - cbuf->get) % cbuf->len; - if (space == (cbuf->len - 1)) - ; // full since put==get means empty +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE + // for software flow control, if the driver returns one of the characters + // we act on it and then drop it (the app must not see it) + if ( chan->config.flags & CYGNUM_SERIAL_FLOW_XONXOFF_TX ) { + if ( c == CYGDAT_IO_SERIAL_FLOW_CONTROL_XOFF_CHAR ) { + throttle_tx( chan ); + return; // it wasn't a "real" character + } else if ( c == CYGDAT_IO_SERIAL_FLOW_CONTROL_XON_CHAR ) { + restart_tx( chan ); + return; // it wasn't a "real" character + } + } +#endif +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + // If we've hit the high water mark, tell the other side to stop + if ( cbuf->nb >= cbuf->high_water ) { + throttle_rx( chan, false ); + } +#endif +#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT + // Wake up any pending selectors if we are about to + // put some data into a previously empty buffer. + if( cbuf->nb == 0 ) + cyg_selwakeup( &cbuf->selinfo ); #endif - cbuf->data[cbuf->put++] = c; - if (cbuf->put == cbuf->len) cbuf->put = 0; + // If the flow control is not enabled/sufficient and the buffer is + // already full, just throw new characters away. + + if( cbuf->nb < cbuf->len ) + { + cbuf->data[cbuf->put++] = c; + if (cbuf->put == cbuf->len) cbuf->put = 0; + cbuf->nb++; + } if (cbuf->waiting) { #ifdef XX_CYGDBG_DIAG_BUF extern int enable_diag_uart; @@ -508,8 +912,28 @@ serial_rcv_char(serial_channel *chan, un } //---------------------------------------------------------------------------- +// Flow control indication callback + +#ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS +static void +serial_indicate_status(serial_channel *chan, cyg_serial_line_status_t *s ) +{ +#ifdef CYGPKG_IO_SERIAL_FLOW_CONTROL + if ( CYGNUM_SERIAL_STATUS_FLOW == s->which ) { + if ( s->value ) + restart_tx( chan ); + else + throttle_tx( chan ); + } +#endif + if ( chan->status_callback ) + (*chan->status_callback)(s, chan->status_callback_priv); +} +#endif // ifdef CYGOPT_IO_SERIAL_SUPPORT_LINE_STATUS + +//---------------------------------------------------------------------------- // Block transfer functions. Not all drivers require these. -#ifdef CYGINT_IO_SERIAL_BLOCK_TRANSFER +#if CYGINT_IO_SERIAL_BLOCK_TRANSFER static bool serial_data_rcv_req(serial_channel *chan, int avail, @@ -519,33 +943,26 @@ serial_data_rcv_req(serial_channel *chan int gap; // Check for space - gap = (cbuf->len + cbuf->put - cbuf->get) % cbuf->len; - if (gap == (cbuf->len - 1)) - return false; // full since put==get means empty + gap = cbuf->nb; + if (gap == cbuf->len) + return false; // full if (0 == gap) { // Buffer is empty. Reset put/get indexes to get max transfer in // one chunk. cbuf->get = 0; cbuf->put = 0; - gap = cbuf->len - 1; + gap = cbuf->len; } else { // Free space (G = get, P = put, x = data, . = empty) // positive: xxxxP.....Gxxx // negative: ..GxxxxxP..... [offer last chunk only] // First try for a gap between put and get locations - gap = cbuf->get - cbuf->put - 1; + gap = cbuf->get - cbuf->put; if (gap < 0) { // If failed, the gap is between put and the end of buffer gap = cbuf->len - cbuf->put; - - // If get is at the beginning of the buffer, we cannot - // fill the last character, since that would make put==get - // implying empty. In this case we must offer last chunk-1 only. - // GxxxxxP....... - if (cbuf->get == 0) - gap--; } } @@ -554,6 +971,7 @@ serial_data_rcv_req(serial_channel *chan *space_avail = gap; *space = &cbuf->data[cbuf->put]; cbuf->put += gap; + cbuf->nb += gap; if (cbuf->put == cbuf->len) cbuf->put = 0; @@ -568,6 +986,11 @@ serial_data_rcv_done(serial_channel *cha cbuf->waiting = false; cyg_drv_cond_signal(&cbuf->wait); } +#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT + // Wake up any pending selectors if we have + // put some data into a previously empty buffer. + cyg_selwakeup( &cbuf->selinfo ); +#endif } static bool @@ -581,11 +1004,12 @@ serial_data_xmt_req(serial_channel *chan // 0: no data // negative: xxxxP.....Gxxx [offer last chunk only] // positive: ..GxxxxxP..... - avail = cbuf->put - cbuf->get; - if (0 == avail) + if (0 == cbuf->nb) return false; - if (avail < 0) { + if (cbuf->get >= cbuf->put) { avail = cbuf->len - cbuf->get; + } else { + avail = cbuf->put - cbuf->get; } if (avail > space) avail = space; // bound by space in hardware @@ -593,6 +1017,7 @@ serial_data_xmt_req(serial_channel *chan *chars_avail = avail; *chars = &cbuf->data[cbuf->get]; cbuf->get += avail; + cbuf->nb -= avail; if (cbuf->get == cbuf->len) cbuf->get = 0; @@ -608,15 +1033,21 @@ serial_data_xmt_done(serial_channel *cha (funs->stop_xmit)(chan); // Done with transmit - if (cbuf->waiting) { - // See if there is now enough room to restart writer - space = (cbuf->len + cbuf->get) - cbuf->put; - if (space > cbuf->len) space -= cbuf->len; - if (space >= cbuf->low_water) { + // See if there is now enough room to restart writer + space = cbuf->len - cbuf->nb; + if (space >= cbuf->low_water) { + if (cbuf->waiting) { cbuf->waiting = false; cyg_drv_cond_broadcast(&cbuf->wait); } +#ifdef CYGPKG_IO_SERIAL_SELECT_SUPPORT + cyg_selwakeup( &cbuf->selinfo ); +#endif } } #endif // CYGINT_IO_SERIAL_BLOCK_TRANSFER + +// --------------------------------------------------------------------------- + +// EOF serial.c diff --git a/packages/io/serial/current/src/common/termios.c b/packages/io/serial/current/src/common/termios.c new file mode 100644 --- /dev/null +++ b/packages/io/serial/current/src/common/termios.c @@ -0,0 +1,393 @@ +/* ==================================================================== +// +// termios.c +// +// POSIX termios API implementation +// +// ==================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +// ==================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-07-22 +// Purpose: POSIX termios API support +// Description: Most of the real work happens in the POSIX termios tty +// drivers +// +//####DESCRIPTIONEND#### +// +// ==================================================================*/ + +// CONFIGURATION + +#include + +#ifdef CYGPKG_IO_SERIAL_TERMIOS + +// INCLUDES + +#include // Header for this file +#include // Common stuff +#include // Assertion support +#include // Tracing support +#include // eCos serial implementation +#include // file operations +#include +#include // errno +#include // isatty() + +// TYPES + +typedef struct { + const struct termios *termios_p; + int optact; +} setattr_struct; + +// FUNCTIONS + +extern speed_t +cfgetospeed( const struct termios *termios_p ) +{ + CYG_REPORT_FUNCTYPE( "returning speed code %d" ); + CYG_CHECK_DATA_PTRC( termios_p ); + CYG_REPORT_FUNCARG1XV( termios_p ); + CYG_REPORT_RETVAL( termios_p->c_ospeed ); + return termios_p->c_ospeed; +} // cfgetospeed() + + +extern int +cfsetospeed( struct termios *termios_p, speed_t speed ) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_CHECK_DATA_PTRC( termios_p ); + CYG_REPORT_FUNCARG2( "termios_p=%08x, speed=%d", termios_p, speed ); + CYG_REPORT_RETVAL( termios_p->c_ospeed ); + if ( speed > B4000000 ) { + errno = EINVAL; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + termios_p->c_ospeed = speed; + CYG_REPORT_RETVAL( 0 ); + return 0; +} // cfsetospeed() + + +extern speed_t +cfgetispeed( const struct termios *termios_p ) +{ + CYG_REPORT_FUNCTYPE( "returning speed code %d" ); + CYG_CHECK_DATA_PTRC( termios_p ); + CYG_REPORT_FUNCARG1XV( termios_p ); + CYG_REPORT_RETVAL( termios_p->c_ispeed ); + return termios_p->c_ispeed; +} // cfgetispeed() + + +extern int +cfsetispeed( struct termios *termios_p, speed_t speed ) +{ + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_CHECK_DATA_PTRC( termios_p ); + CYG_REPORT_FUNCARG2( "termios_p=%08x, speed=%d", termios_p, speed ); + if ( speed > B115200 ) { + errno = EINVAL; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + termios_p->c_ispeed = speed; + CYG_REPORT_RETVAL( 0 ); + return 0; +} // cfsetispeed() + + +__externC cyg_file * +cyg_fp_get( int fd ); + +__externC void +cyg_fp_free( cyg_file *fp ); + +extern int +tcgetattr( int fildes, struct termios *termios_p ) +{ + cyg_file *fp; + int ret; + int len = sizeof( *termios_p ); + + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_REPORT_FUNCARG2( "fildes=%d, termios_p=%08x", fildes, termios_p ); + CYG_CHECK_DATA_PTRC( termios_p ); + + if ( !isatty(fildes) ) { + errno = ENOTTY; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + fp = cyg_fp_get( fildes ); + + if ( NULL == fp ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + ret = fp->f_ops->fo_getinfo( fp, CYG_IO_GET_CONFIG_TERMIOS, termios_p, + len); + cyg_fp_free( fp ); + + if ( ret > 0 ) { + errno = ret; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + CYG_REPORT_RETVAL( 0 ); + return 0; +} // tcgetattr() + + +extern int +tcsetattr( int fildes, int optact, const struct termios *termios_p ) +{ + cyg_file *fp; + int ret; + setattr_struct attr; + int len = sizeof( attr ); + + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_REPORT_FUNCARG3( "fildes=%d, optact=%d, termios_p=%08x", + fildes, optact, termios_p ); + CYG_CHECK_DATA_PTRC( termios_p ); + + if ( !isatty(fildes) ) { + errno = ENOTTY; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + if ( (optact != TCSANOW) && (optact != TCSADRAIN) && + (optact != TCSAFLUSH) ) { + errno = EINVAL; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + fp = cyg_fp_get( fildes ); + + if ( NULL == fp ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + attr.termios_p = termios_p; + attr.optact = optact; + + ret = fp->f_ops->fo_setinfo( fp, CYG_IO_SET_CONFIG_TERMIOS, &attr, + len); + + cyg_fp_free( fp ); + + if ( ret > 0 ) { + errno = ret; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + CYG_REPORT_RETVAL( 0 ); + return 0; +} // tcsetattr() + + +extern int +tcsendbreak( int fildes, int duration ) +{ + // FIXME + return -EINVAL; +} // tcsendbreak() + +extern int +tcdrain( int fildes ) +{ + cyg_file *fp; + int ret; + + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_REPORT_FUNCARG1DV( fildes ); + + if ( !isatty(fildes) ) { + errno = ENOTTY; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + fp = cyg_fp_get( fildes ); + + if ( NULL == fp ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + ret = fp->f_ops->fo_getinfo( fp, + CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN, + NULL, 0 ); + cyg_fp_free( fp ); + + if ( ret > 0 ) { + errno = ret; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + CYG_REPORT_RETVAL( 0 ); + return 0; +} // tcdrain() + +extern int +tcflush( int fildes, int queue_sel ) +{ + cyg_file *fp; + int ret; + + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_REPORT_FUNCARG2DV( fildes, queue_sel ); + + if ( !isatty(fildes) ) { + errno = ENOTTY; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + fp = cyg_fp_get( fildes ); + + if ( NULL == fp ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + switch( queue_sel ) { + case TCIOFLUSH: + ret = fp->f_ops->fo_getinfo( fp, + CYG_IO_GET_CONFIG_SERIAL_OUTPUT_FLUSH, + NULL, 0 ); + // fallthrough + case TCIFLUSH: + ret = fp->f_ops->fo_getinfo( fp, + CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH, + NULL, 0 ); + break; + case TCOFLUSH: + ret = fp->f_ops->fo_getinfo( fp, + CYG_IO_GET_CONFIG_SERIAL_OUTPUT_FLUSH, + NULL, 0 ); + break; + default: + ret = EINVAL; + break; + } + + cyg_fp_free( fp ); + + if ( ret > 0 ) { + errno = ret; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + CYG_REPORT_RETVAL( 0 ); + return 0; +} // tcflush() + +extern int +tcflow( int fildes, int action ) +{ + cyg_file *fp; + int ret; + cyg_uint32 forcearg; + int len = sizeof(forcearg); + + CYG_REPORT_FUNCTYPE( "returning %d" ); + CYG_REPORT_FUNCARG2DV( fildes, action ); + + if ( !isatty(fildes) ) { + errno = ENOTTY; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + fp = cyg_fp_get( fildes ); + + if ( NULL == fp ) { + errno = EBADF; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + + switch( action ) { + case TCOOFF: + forcearg = CYGNUM_SERIAL_FLOW_THROTTLE_TX; + ret = fp->f_ops->fo_setinfo( fp, + CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_FORCE, + &forcearg, len ); + break; + case TCOON: + forcearg = CYGNUM_SERIAL_FLOW_RESTART_TX; + ret = fp->f_ops->fo_setinfo( fp, + CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_FORCE, + &forcearg, len ); + break; + case TCIOFF: + forcearg = CYGNUM_SERIAL_FLOW_THROTTLE_RX; + ret = fp->f_ops->fo_setinfo( fp, + CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_FORCE, + &forcearg, len ); + break; + case TCION: + forcearg = CYGNUM_SERIAL_FLOW_RESTART_RX; + ret = fp->f_ops->fo_setinfo( fp, + CYG_IO_SET_CONFIG_SERIAL_FLOW_CONTROL_FORCE, + &forcearg, len ); + break; + default: + ret = EINVAL; + break; + } + + cyg_fp_free( fp ); + + if ( ret > 0 ) { + errno = ret; + CYG_REPORT_RETVAL( -1 ); + return -1; + } + CYG_REPORT_RETVAL( 0 ); + return 0; +} // tcflow() + +#endif // ifdef CYGPKG_IO_SERIAL_TERMIOS + +// EOF termios.c diff --git a/packages/io/serial/current/src/common/termiostty.c b/packages/io/serial/current/src/common/termiostty.c new file mode 100644 --- /dev/null +++ b/packages/io/serial/current/src/common/termiostty.c @@ -0,0 +1,896 @@ +//========================================================================== +// +// termiostty.c +// +// POSIX Termios compatible TTY I/O driver +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: gthomas +// Date: 2000-07-22 +// Purpose: Device driver for termios emulation tty I/O, layered on +// top of serial I/O +// Description: TODO: Add OPOST support for 80x25 (configurable) windows +// TODO: Support _POSIX_VDISABLE +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +// CONFIGURATION + +#include + +#ifdef CYGPKG_IO_SERIAL_TERMIOS + +// INCLUDES + +#include // Common types +#include // Assertion support +#include // Tracing support +#include +#include +#include // public serial API +#include // Termios header +#include +#include // malloc +#include +#ifdef CYGSEM_IO_SERIAL_TERMIOS_USE_SIGNALS +# include +#endif + +//========================================================================== +// FUNCTION PROTOTYPES + +static bool +termios_init(struct cyg_devtab_entry *tab); + +static Cyg_ErrNo +termios_lookup(struct cyg_devtab_entry **tab, + struct cyg_devtab_entry *sub_tab, + const char *name); +static Cyg_ErrNo +termios_write(cyg_io_handle_t handle, const void *buf, cyg_uint32 *len); +static Cyg_ErrNo +termios_read(cyg_io_handle_t handle, void *buf, cyg_uint32 *len); +static Cyg_ErrNo +termios_select(cyg_io_handle_t handle, cyg_uint32 which, CYG_ADDRWORD info); +static Cyg_ErrNo +termios_get_config(cyg_io_handle_t handle, cyg_uint32 key, void *buf, + cyg_uint32 *len); +static Cyg_ErrNo +termios_set_config(cyg_io_handle_t handle, cyg_uint32 key, const void *buf, + cyg_uint32 *len); + +//========================================================================== +// TYPE DEFINITIONS + +struct termios_private_info { + struct termios termios; + cyg_io_handle_t dev_handle; + cyg_drv_mutex_t lock; + cyg_bool init; + cyg_uint8 *errbuf; + cyg_uint8 *errbufpos; + cyg_uint32 errbufsize; +}; + +typedef struct { + struct termios *termios_p; + int optact; +} setattr_struct; + + +//========================================================================== +// STATIC OBJECTS + +static DEVIO_TABLE(termios_devio, + termios_write, + termios_read, + termios_select, + termios_get_config, + termios_set_config); + +#ifdef CYGPKG_IO_SERIAL_TERMIOS_TERMIOS0 +static struct termios_private_info termios_private_info0; +DEVTAB_ENTRY(termios_io0, + "/dev/termios0", + CYGDAT_IO_SERIAL_TERMIOS_TERMIOS0_DEV, + &termios_devio, + termios_init, + termios_lookup, + &termios_private_info0); +#endif + +#ifdef CYGPKG_IO_SERIAL_TERMIOS_TERMIOS1 +static struct termios_private_info termios_private_info1; +DEVTAB_ENTRY(termios_io1, + "/dev/termios1", + CYGDAT_IO_SERIAL_TERMIOS_TERMIOS1_DEV, + &termios_devio, + termios_init, + termios_lookup, + &termios_private_info1); +#endif + +#ifdef CYGPKG_IO_SERIAL_TERMIOS_TERMIOS2 +static struct termios_private_info termios_private_info2; +DEVTAB_ENTRY(termios_io2, + "/dev/termios2", + CYGDAT_IO_SERIAL_TERMIOS_TERMIOS2_DEV, + &termios_devio, + termios_init, + termios_lookup, + &termios_private_info2); +#endif + +static const cc_t c_cc_init[ NCCS ] = { + 0x04, /* EOF == ^D */ + 0, /* EOL */ + 0x08, /* ERASE = BS ; NB DEL=0x7f */ + 0x03, /* INTR = ^C */ + 0x15, /* KILL = ^U */ + 0, /* MIN = 0 */ + 0x1c, /* QUIT = ^\ */ + 0x1a, /* SUSP = ^Z ; NB ignored in this impl - no job control */ + 0, /* TIME = 0 */ +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE + CYGDAT_IO_SERIAL_FLOW_CONTROL_XON_CHAR, + CYGDAT_IO_SERIAL_FLOW_CONTROL_XOFF_CHAR, +#else + 17, + 19, +#endif +}; + +// map eCos bitrates to POSIX bitrates. +static speed_t ecosbaud2posixbaud[] = { + 0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B2400, B3600, + B4800, B7200, B9600, B14400, B19200, B38400, B57600, B115200, B230400 }; + +// map POSIX bitrates to eCos bitrates. +static cyg_serial_baud_rate_t posixbaud2ecosbaud[] = { + 0, CYGNUM_SERIAL_BAUD_50, CYGNUM_SERIAL_BAUD_75, CYGNUM_SERIAL_BAUD_110, + CYGNUM_SERIAL_BAUD_134_5, CYGNUM_SERIAL_BAUD_150, CYGNUM_SERIAL_BAUD_200, + CYGNUM_SERIAL_BAUD_300, CYGNUM_SERIAL_BAUD_600, CYGNUM_SERIAL_BAUD_1200, + CYGNUM_SERIAL_BAUD_1800, CYGNUM_SERIAL_BAUD_2400, CYGNUM_SERIAL_BAUD_3600, + CYGNUM_SERIAL_BAUD_4800, CYGNUM_SERIAL_BAUD_7200, CYGNUM_SERIAL_BAUD_9600, + CYGNUM_SERIAL_BAUD_14400, CYGNUM_SERIAL_BAUD_19200, + CYGNUM_SERIAL_BAUD_38400, CYGNUM_SERIAL_BAUD_57600, + CYGNUM_SERIAL_BAUD_115200, CYGNUM_SERIAL_BAUD_230400 }; + + +//========================================================================== +// FUNCTIONS + +static __inline__ speed_t +map_ecosbaud_to_posixbaud( cyg_serial_baud_rate_t ebaud ) +{ + if ( ebaud > (sizeof(ecosbaud2posixbaud) / sizeof(speed_t)) ) + return 0; + return ecosbaud2posixbaud[ ebaud ]; +} + +static __inline__ cyg_serial_baud_rate_t +map_posixbaud_to_ecosbaud( speed_t pbaud ) +{ + if ( pbaud > (sizeof(posixbaud2ecosbaud)/sizeof(cyg_serial_baud_rate_t)) ) + return 0; + return posixbaud2ecosbaud[ pbaud ]; +} + +//========================================================================== +// real_termios_init is used to initialize the termios structure. This is +// called at lookup time, and not from termios_init() because it needs +// to query the serial device which may not be set up yet at that point +// in termios_init() + +#ifdef CYGSEM_IO_SERIAL_TERMIOS_USE_SIGNALS +# define C_IFLAG_INIT (ICRNL|IGNBRK|BRKINT) +#else +# define C_IFLAG_INIT (ICRNL|IGNBRK) +#endif +#define C_OFLAG_INIT (ONLCR) +#define C_CFLAG_INIT (CREAD) +#define C_LFLAG_INIT (ECHO|ECHOE|ECHOK|ICANON) + +static Cyg_ErrNo +real_termios_init( struct termios_private_info *priv ) +{ + Cyg_ErrNo res; + struct termios *t; + cyg_serial_info_t dev_conf; + cyg_serial_buf_info_t dev_buf_conf; + cyg_uint32 len = sizeof( dev_conf ); + + CYG_REPORT_FUNCTYPE("returning %d"); + CYG_REPORT_FUNCARG1XV( priv ); + CYG_CHECK_DATA_PTRC( priv ); + + t = &priv->termios; + + // Get info from driver + res = cyg_io_get_config( priv->dev_handle, CYG_IO_GET_CONFIG_SERIAL_INFO, + &dev_conf, &len ); + if ( ENOERR == res ) { + len = sizeof( dev_buf_conf ); + res = cyg_io_get_config( priv->dev_handle, + CYG_IO_GET_CONFIG_SERIAL_BUFFER_INFO, + &dev_buf_conf, &len ); + } + + priv->errbuf = (cyg_uint8 *)malloc( dev_buf_conf.rx_bufsize ); + if ( NULL == priv->errbuf ) + res = ENOMEM; // FIXME: Are we allowed to do this? + priv->errbufpos = priv->errbuf; + priv->errbufsize = dev_buf_conf.rx_bufsize; + + if ( ENOERR != res ) { + CYG_REPORT_RETVAL( res ); + return res; + } + + // we only support symmetric baud rates + t->c_ispeed = t->c_ospeed = map_ecosbaud_to_posixbaud( dev_conf.baud ); + t->c_iflag = C_IFLAG_INIT; + t->c_oflag = C_OFLAG_INIT; + t->c_cflag = C_CFLAG_INIT; + t->c_lflag = C_LFLAG_INIT; + memcpy( t->c_cc, c_cc_init, sizeof( t->c_cc ) ); + + switch ( dev_conf.parity ) { + case CYGNUM_SERIAL_PARITY_NONE: + t->c_iflag |= IGNPAR; + break; + case CYGNUM_SERIAL_PARITY_ODD: + t->c_cflag |= PARODD; + // DROPTHROUGH + case CYGNUM_SERIAL_PARITY_EVEN: + t->c_iflag |= PARENB; + break; + default: + CYG_FAIL( "Unsupported default parity" ); + break; + } + + switch( dev_conf.word_length ) { + case CYGNUM_SERIAL_WORD_LENGTH_5: + t->c_cflag |= CS5; + break; + case CYGNUM_SERIAL_WORD_LENGTH_6: + t->c_cflag |= CS6; + break; + case CYGNUM_SERIAL_WORD_LENGTH_7: + t->c_cflag |= CS7; + break; + case CYGNUM_SERIAL_WORD_LENGTH_8: + t->c_cflag |= CS8; + break; + default: + CYG_FAIL( "Unsupported word length" ); + break; + } + + switch ( dev_conf.stop ) { + case CYGNUM_SERIAL_STOP_1: + // Don't need to do anything + break; + case CYGNUM_SERIAL_STOP_2: + t->c_cflag |= CSTOPB; + break; + default: + CYG_FAIL( "Unsupported number of stop bits" ); + break; + } + + switch ( dev_conf.flags ) { + case CYGNUM_SERIAL_FLOW_RTSCTS_RX: + t->c_cflag |= CRTSCTS; + // drop through + case CYGNUM_SERIAL_FLOW_XONXOFF_RX: + t->c_iflag |= IXOFF; + break; + case CYGNUM_SERIAL_FLOW_RTSCTS_TX: + t->c_cflag |= CRTSCTS; + // drop through + case CYGNUM_SERIAL_FLOW_XONXOFF_TX: + t->c_iflag |= IXON; + break; + default: + // Ignore flags we don't grok + break; + } + + return ENOERR; +} // real_termios_init() + +//========================================================================== +// set_attr() actually enacts the termios config. We come in here with +// the mutex in priv locked +// +// Possible deviation from standard: POSIX says we should enact which ever +// bits we can and only return EINVAL when none of them can be performed +// Rather than tracking whether *none* of them worked, instead we just +// always claim success. At the very least, setting c_cc is never to +// fail so I'm not sure if this is really non-standard or not! + +static Cyg_ErrNo +set_attr( struct termios *t, struct termios_private_info *priv ) +{ + Cyg_ErrNo res = ENOERR; + cyg_serial_info_t dev_conf, new_dev_conf; + cyg_uint32 len = sizeof( dev_conf ); + cc_t *tempcc = &priv->termios.c_cc[0]; + struct termios *ptermios = &priv->termios; + + // Get info from driver + res = cyg_io_get_config( priv->dev_handle, CYG_IO_GET_CONFIG_SERIAL_INFO, + &dev_conf, &len ); + + if ( ENOERR != res ) + return res; + + // We need to set up each facet of config to change one by one because + // POSIX says we should try and change as much of the config as possible + // This is tedious and has to be done by steam :-( + + if ( t->c_ospeed != ptermios->c_ospeed ) { + new_dev_conf = dev_conf; + new_dev_conf.baud = map_posixbaud_to_ecosbaud( t->c_ospeed ); + if ( 0 != new_dev_conf.baud ) { + len = sizeof( new_dev_conf ); + res = cyg_io_set_config( priv->dev_handle, + CYG_IO_SET_CONFIG_SERIAL_INFO, + &new_dev_conf, &len ); + if ( ENOERR == res ) { + // It worked, so update dev_conf to reflect the new state + dev_conf.baud = new_dev_conf.baud; + // and termios + ptermios->c_ispeed = t->c_ospeed; + ptermios->c_ospeed = t->c_ospeed; + } + } + } + + if ( (t->c_cflag & CSTOPB) != (ptermios->c_cflag & CSTOPB) ) { + new_dev_conf = dev_conf; + if ( t->c_cflag & CSTOPB ) + new_dev_conf.stop = CYGNUM_SERIAL_STOP_2; + else + new_dev_conf.stop = CYGNUM_SERIAL_STOP_1; + + len = sizeof( new_dev_conf ); + res = cyg_io_set_config( priv->dev_handle, + CYG_IO_SET_CONFIG_SERIAL_INFO, + &new_dev_conf, &len ); + if ( ENOERR == res ) { + // It worked, so update dev_conf to reflect the new state + dev_conf.stop = new_dev_conf.stop; + // and termios + ptermios->c_cflag &= ~CSTOPB; + ptermios->c_cflag |= t->c_cflag & CSTOPB; + } + } + + if ( ((t->c_cflag & PARENB) != (ptermios->c_cflag & PARENB)) || + ((t->c_cflag & PARODD) != (ptermios->c_cflag & PARODD)) ) { + new_dev_conf = dev_conf; + if ( t->c_cflag & PARENB ) + if ( t->c_cflag & PARODD ) + new_dev_conf.parity = CYGNUM_SERIAL_PARITY_ODD; + else + new_dev_conf.parity = CYGNUM_SERIAL_PARITY_EVEN; + else + new_dev_conf.parity = CYGNUM_SERIAL_PARITY_NONE; + + len = sizeof( new_dev_conf ); + res = cyg_io_set_config( priv->dev_handle, + CYG_IO_SET_CONFIG_SERIAL_INFO, + &new_dev_conf, &len ); + if ( ENOERR == res ) { + // It worked, so update dev_conf to reflect the new state + dev_conf.parity = new_dev_conf.parity; + // and termios + ptermios->c_cflag &= ~(PARENB|PARODD); + ptermios->c_cflag |= t->c_cflag & (PARENB|PARODD); + } + } + + if ( (t->c_cflag & CSIZE) != (ptermios->c_cflag & CSIZE) ) { + new_dev_conf = dev_conf; + switch ( t->c_cflag & CSIZE ) { + case CS5: + new_dev_conf.word_length = CYGNUM_SERIAL_WORD_LENGTH_5; + break; + case CS6: + new_dev_conf.word_length = CYGNUM_SERIAL_WORD_LENGTH_6; + break; + case CS7: + new_dev_conf.word_length = CYGNUM_SERIAL_WORD_LENGTH_7; + break; + case CS8: + new_dev_conf.word_length = CYGNUM_SERIAL_WORD_LENGTH_8; + break; + } + + len = sizeof( new_dev_conf ); + res = cyg_io_set_config( priv->dev_handle, + CYG_IO_SET_CONFIG_SERIAL_INFO, + &new_dev_conf, &len ); + if ( ENOERR == res ) { + // It worked, so update dev_conf to reflect the new state + dev_conf.word_length = new_dev_conf.word_length; + // and termios + ptermios->c_cflag &= ~CSIZE; + ptermios->c_cflag |= t->c_cflag & CSIZE; + } + } + + if ( (t->c_cflag & IXOFF) != (ptermios->c_cflag & IXOFF) ) { + new_dev_conf = dev_conf; + new_dev_conf.flags &= + ~(CYGNUM_SERIAL_FLOW_XONXOFF_RX|CYGNUM_SERIAL_FLOW_RTSCTS_RX); + if ( t->c_cflag & IXOFF ) + if ( t->c_cflag & CRTSCTS) + new_dev_conf.flags |= CYGNUM_SERIAL_FLOW_RTSCTS_RX; + else + new_dev_conf.flags |= CYGNUM_SERIAL_FLOW_XONXOFF_RX; + else + new_dev_conf.flags |= CYGNUM_SERIAL_FLOW_NONE; + + len = sizeof( new_dev_conf ); + res = cyg_io_set_config( priv->dev_handle, + CYG_IO_SET_CONFIG_SERIAL_INFO, + &new_dev_conf, &len ); + if ( ENOERR == res ) { + // It worked, so update dev_conf to reflect the new state + dev_conf.flags = new_dev_conf.flags; + // and termios + ptermios->c_cflag &= ~(IXOFF|CRTSCTS); + ptermios->c_cflag |= t->c_cflag & (IXOFF|CRTSCTS); + } + } + + if ( (t->c_cflag & IXON) != (ptermios->c_cflag & IXON) ) { + new_dev_conf = dev_conf; + new_dev_conf.flags &= + ~(CYGNUM_SERIAL_FLOW_XONXOFF_TX|CYGNUM_SERIAL_FLOW_RTSCTS_TX); + if ( t->c_cflag & IXON ) + if ( t->c_cflag & CRTSCTS) + new_dev_conf.flags |= CYGNUM_SERIAL_FLOW_RTSCTS_TX; + else + new_dev_conf.flags |= CYGNUM_SERIAL_FLOW_XONXOFF_TX; + else + new_dev_conf.flags |= CYGNUM_SERIAL_FLOW_NONE; + + len = sizeof( new_dev_conf ); + res = cyg_io_set_config( priv->dev_handle, + CYG_IO_SET_CONFIG_SERIAL_INFO, + &new_dev_conf, &len ); + if ( ENOERR == res ) { + // It worked, so update dev_conf to reflect the new state + dev_conf.flags = new_dev_conf.flags; + // and termios + ptermios->c_cflag &= ~(IXON|CRTSCTS); + ptermios->c_cflag |= t->c_cflag & (IXON|CRTSCTS); + } + } + + // Input/Output processing flags can just be set as we grok them all + // with few exceptions (see lflags below) + ptermios->c_iflag &= ~(BRKINT|ICRNL|IGNBRK|IGNCR|IGNPAR|INLCR|INPCK| + ISTRIP|PARMRK); + ptermios->c_iflag |= t->c_iflag & ( +#ifdef CYGSEM_IO_SERIAL_TERMIOS_USE_SIGNALS + BRKINT| +#endif + ICRNL|IGNBRK|IGNCR|IGNPAR| + INLCR|INPCK|ISTRIP|PARMRK ); + + ptermios->c_oflag &= ~(OPOST|ONLCR); + ptermios->c_oflag |= t->c_oflag & ONLCR; +#ifdef NOTYET + ptermios->c_oflag |= t->c_oflag & OPOST; +#endif + + ptermios->c_cflag &= ~(CLOCAL|CREAD|HUPCL); + ptermios->c_cflag |= t->c_cflag & (CLOCAL|CREAD|HUPCL); + + ptermios->c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON| + IEXTEN|ISIG|NOFLSH|TOSTOP); + // Note we don't support IEXTEN nor TOSTOP so we don't set them + ptermios->c_lflag |= t->c_lflag & (ECHO|ECHOE|ECHOK|ECHONL|ICANON| +#ifdef CYGSEM_IO_SERIAL_TERMIOS_USE_SIGNALS + ISIG| +#endif + NOFLSH); + + // control characters. We don't support changing of VSTART, VSTOP, + // VTIME or VSUSP though + tempcc[VEOF] = t->c_cc[VEOF]; + tempcc[VEOL] = t->c_cc[VEOL]; + tempcc[VERASE] = t->c_cc[VERASE]; + tempcc[VINTR] = t->c_cc[VINTR]; + tempcc[VKILL] = t->c_cc[VKILL]; + tempcc[VMIN] = t->c_cc[VMIN]; + tempcc[VQUIT] = t->c_cc[VQUIT]; + + return res; +} + +//========================================================================== + +static bool +termios_init(struct cyg_devtab_entry *tab) +{ + // can't initialize the termios structure because we can't + // query the serial driver yet. Wait until lookup time. + + return true; +} // termios_init() + +//========================================================================== + +static Cyg_ErrNo +termios_lookup(struct cyg_devtab_entry **tab, + struct cyg_devtab_entry *sub_tab, + const char *name) +{ + cyg_io_handle_t chan = (cyg_io_handle_t)sub_tab; + struct termios_private_info *priv = + (struct termios_private_info *)(*tab)->priv; + Cyg_ErrNo err = ENOERR; + + if ( !priv->init ) { + cyg_drv_mutex_lock( &priv->lock ); + if ( !priv->init ) { // retest as we may have been pre-empted + priv->dev_handle = chan; + err = real_termios_init( priv ); + } + cyg_drv_mutex_unlock( &priv->lock ); + } + return err; +} + +//========================================================================== + +#define WRITE_BUFSIZE 100 // FIXME: ->CDL +// #define MAX_CANON 64 FIXME: relevance? + + +static Cyg_ErrNo +termios_write(cyg_io_handle_t handle, const void *_buf, cyg_uint32 *len) +{ + cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle; + struct termios_private_info *priv = (struct termios_private_info *)t->priv; + cyg_io_handle_t chan = (cyg_io_handle_t)priv->dev_handle; + cyg_int32 size, bytes_successful, actually_written; + cyg_uint8 xbuf[WRITE_BUFSIZE]; + cyg_uint8 *buf = (cyg_uint8 *)_buf; + Cyg_ErrNo res; + + size = 0; + bytes_successful = 0; + actually_written = 0; + while (bytes_successful++ < *len) { + xbuf[size] = *buf++; + if ( (xbuf[size] == '\n') && (priv->termios.c_oflag & ONLCR) ) { + xbuf[size] = '\r'; + } + size++; + if ((size == (WRITE_BUFSIZE-1)) || + (bytes_successful == *len)) { + res = cyg_io_write(chan, xbuf, &size); + if (res != ENOERR) { + *len = actually_written; + return res; + } + actually_written += size; + size = 0; + } + } + *len = actually_written; + return ENOERR; +} + + +//========================================================================== + +static Cyg_ErrNo +termios_read(cyg_io_handle_t handle, void *_buf, cyg_uint32 *len) +{ + cyg_devtab_entry_t *dt = (cyg_devtab_entry_t *)handle; + struct termios_private_info *priv = (struct termios_private_info *)dt->priv; + cyg_io_handle_t chan = (cyg_io_handle_t)priv->dev_handle; + struct termios *t = &priv->termios; + cyg_uint32 clen; + cyg_uint32 size; + Cyg_ErrNo res; + cyg_uint8 c; + cyg_uint8 *buf = (cyg_uint8 *)_buf; + cyg_bool discardc; // should c be discarded (not read, not printed) + cyg_bool returnnow = false; // return back to user after this char + + // if receiver off + if (0 == (t->c_cflag & CREAD) ) { + *len = 0; + return -EINVAL; + } + + size = 0; + if ( 0 == (t->c_lflag & ICANON) ) { + // In non-canonical mode we return the min of *len and the + // number of bytes available + // So we query the driver for how many bytes are available - this + // guarantees we won't block + cyg_serial_buf_info_t dev_buf_conf; + cyg_uint32 dbc_len = sizeof( dev_buf_conf ); + res = cyg_io_get_config( chan, + CYG_IO_GET_CONFIG_SERIAL_BUFFER_INFO, + &dev_buf_conf, &dbc_len ); + CYG_ASSERT( res == ENOERR, "Query buffer status failed!" ); + *len = *len < dev_buf_conf.rx_count ? *len : dev_buf_conf.rx_count; + } // if + + while (!returnnow && size < *len) { + clen = 1; + discardc = false; + res = cyg_io_read(chan, &c, &clen); + if (res != ENOERR) { + *len = size; + return res; + } + + // lock to prevent termios getting corrupted while we read from it + cyg_drv_mutex_lock( &priv->lock ); + + if ( t->c_iflag & ISTRIP ) + c &= 0x7f; + + // canonical mode: erase, kill, and newline processing + if ( t->c_lflag & ICANON ) { + if ( t->c_cc[ VERASE ] == c ) { + discardc = true; + // erase on display? + if ( (t->c_lflag & ECHO) && (t->c_lflag & ECHOE) ) { + cyg_uint8 erasebuf[3]; + erasebuf[0] = erasebuf[2] = t->c_cc[ VERASE ]; + erasebuf[1] = ' '; + clen = sizeof(erasebuf); + // FIXME: what about error or non-blocking? + cyg_io_write(chan, erasebuf, &clen); + } + if ( size ) + size--; + } // if + else if ( t->c_cc[ VKILL ] == c ) { + // kill line on display? + if ( (t->c_lflag & ECHO) && (t->c_lflag & ECHOK) ) { + + // we could try and be more efficient here and + // output a stream of erases, and then a stream + // of spaces and then more erases. But this is poor + // because on a slow terminal the user will see characters + // delete from the middle forward in chunks! + // But at least we try and chunk up sets of writes + cyg_uint8 erasebuf[30]; + cyg_uint8 erasechunks; + cyg_uint8 i; + + erasechunks = size < (sizeof(erasebuf)/3) ? + size : (sizeof(erasebuf)/3); + + for (i=0; ic_cc[ VERASE ]; + erasebuf[i*3+1] = ' '; + } + + while( size ) { + cyg_uint8 j; + + j = size < (sizeof(erasebuf)/3) ? + size : (sizeof(erasebuf)/3); + clen = (j*3); + // FIXME: what about error or non-blocking? + cyg_io_write( chan, erasebuf, &clen ); + size -= j; + } + } else + size = 0; + discardc = true; + } // else if + // CR + else if ( '\r' == c ) { + if ( t->c_iflag & IGNCR ) + discardc = true; + else if ( t->c_iflag & ICRNL ) + c = '\n'; + } + // newlines or similar. + // Note: not an else if to catch CRNL conversion + if ( (t->c_cc[ VEOF ] == c) || (t->c_cc[ VEOL ] == c) || + ('\n' == c) ) { + if ( t->c_cc[ VEOF ] == c ) + discardc = true; + if ( t->c_lflag & ECHONL ) { // don't check ECHO in this case + clen = 1; + // FIXME: what about error or non-blocking? + // FIXME: what if INLCR is set? + cyg_io_write( chan, "\n", &clen ); + } + if ( t->c_iflag & INLCR ) + c = '\r'; + returnnow = true; // FIXME: true even for INLCR? + } // else if + } else { // non-canonical mode + if ( size+1 >= t->c_cc[ VMIN ] ) + returnnow = true; + } // else + +#ifdef CYGSEM_IO_SERIAL_TERMIOS_USE_SIGNALS + if ( (t->c_lflag & ISIG) && (t->c_cc[ VINTR ] == c) ) { + discardc = true; + if ( 0 == (t->c_lflag & NOFLSH) ) + size = 0; + // raise could be a non-local jump - we should unlock mutex + cyg_drv_mutex_unlock( &priv->lock ); + + // FIXME: what if raise returns != 0? + raise( SIGINT ); + cyg_drv_mutex_lock( &priv->lock ); + } + + if ( (t->c_lflag & ISIG) && (t->c_cc[ VQUIT ] == c) ) { + discardc = true; + if ( 0 == (t->c_lflag & NOFLSH) ) + size = 0; + // raise could be a non-local jump - we should unlock mutex + cyg_drv_mutex_unlock( &priv->lock ); + + // FIXME: what if raise returns != 0? + raise( SIGQUIT ); + cyg_drv_mutex_lock( &priv->lock ); + } +#endif + if (!discardc) { + buf[size++] = c; + if ( t->c_lflag & ECHO ) { + clen = 1; + // FIXME: what about error or non-blocking? + cyg_io_write( chan, &c, &clen ); + } + } + cyg_drv_mutex_unlock( &priv->lock ); + } // while + + *len = size; + return ENOERR; +} + + +//========================================================================== + +static cyg_bool +termios_select(cyg_io_handle_t handle, cyg_uint32 which, CYG_ADDRWORD info) +{ + cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle; + struct termios_private_info *priv = (struct termios_private_info *)t->priv; + cyg_io_handle_t chan = (cyg_io_handle_t)priv->dev_handle; + + // Just pass it on to next driver level + return cyg_io_select( chan, which, info ); +} + + +//========================================================================== + +static Cyg_ErrNo +termios_get_config(cyg_io_handle_t handle, cyg_uint32 key, void *buf, + cyg_uint32 *len) +{ + cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle; + struct termios_private_info *priv = (struct termios_private_info *)t->priv; + cyg_io_handle_t chan = (cyg_io_handle_t)priv->dev_handle; + Cyg_ErrNo res = ENOERR; + + switch (key) { + case CYG_IO_GET_CONFIG_TERMIOS: + { + if ( *len < sizeof(struct termios) ) { + return -EINVAL; + } + cyg_drv_mutex_lock( &priv->lock ); + *(struct termios *)buf = priv->termios; + cyg_drv_mutex_unlock( &priv->lock ); + *len = sizeof(struct termios); + } + break; + default: // Assume this is a 'serial' driver control + res = cyg_io_get_config(chan, key, buf, len); + } // switch + return res; +} + + +//========================================================================== + + +static Cyg_ErrNo +termios_set_config(cyg_io_handle_t handle, cyg_uint32 key, const void *buf, cyg_uint32 *len) +{ + cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle; + struct termios_private_info *priv = (struct termios_private_info *)t->priv; + cyg_io_handle_t chan = (cyg_io_handle_t)priv->dev_handle; + Cyg_ErrNo res = ENOERR; + + switch (key) { + case CYG_IO_SET_CONFIG_TERMIOS: + { + setattr_struct *attr = (setattr_struct *)buf; + int optact = attr->optact; + + if ( *len != sizeof( *attr ) ) { + return -EINVAL; + } + + CYG_ASSERT( (optact == TCSAFLUSH) || (optact == TCSADRAIN) || + (optact == TCSANOW), "Invalid optact" ); + + cyg_drv_mutex_lock( &priv->lock ); + + if ( ( TCSAFLUSH == optact ) || + ( TCSADRAIN == optact ) ) { + res = cyg_io_get_config( chan, + CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN, + NULL, NULL ); + CYG_ASSERT( ENOERR == res, "Drain request failed" ); + } + if ( TCSAFLUSH == optact ) { + res = cyg_io_get_config( chan, + CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH, + NULL, NULL ); + CYG_ASSERT( ENOERR == res, "Flush request failed" ); + } + + res = set_attr( attr->termios_p, priv ); + cyg_drv_mutex_unlock( &priv->lock ); + return res; + } + default: // Pass on to serial driver + res = cyg_io_set_config(chan, key, buf, len); + } + return res; +} + + +//========================================================================== + +#endif // ifdef CYGPKG_IO_SERIAL_TERMIOS + +// EOF termiostty.c diff --git a/packages/io/serial/current/src/common/tty.c b/packages/io/serial/current/src/common/tty.c --- a/packages/io/serial/current/src/common/tty.c +++ b/packages/io/serial/current/src/common/tty.c @@ -55,6 +55,7 @@ static Cyg_ErrNo tty_lookup(struct cyg_d const char *name); static Cyg_ErrNo tty_write(cyg_io_handle_t handle, const void *buf, cyg_uint32 *len); static Cyg_ErrNo tty_read(cyg_io_handle_t handle, void *buf, cyg_uint32 *len); +static Cyg_ErrNo tty_select(cyg_io_handle_t handle, cyg_uint32 which, CYG_ADDRWORD info); static Cyg_ErrNo tty_get_config(cyg_io_handle_t handle, cyg_uint32 key, void *buf, cyg_uint32 *len); static Cyg_ErrNo tty_set_config(cyg_io_handle_t handle, cyg_uint32 key, const void *buf, cyg_uint32 *len); @@ -66,6 +67,7 @@ struct tty_private_info { static DEVIO_TABLE(tty_devio, tty_write, tty_read, + tty_select, tty_get_config, tty_set_config ); @@ -256,6 +258,17 @@ tty_read(cyg_io_handle_t handle, void *_ return ENOERR; } +static cyg_bool +tty_select(cyg_io_handle_t handle, cyg_uint32 which, CYG_ADDRWORD info) +{ + cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle; + struct tty_private_info *priv = (struct tty_private_info *)t->priv; + cyg_io_handle_t chan = (cyg_io_handle_t)priv->dev_handle; + + // Just pass it on to next driver level + return cyg_io_select( chan, which, info ); +} + static Cyg_ErrNo tty_get_config(cyg_io_handle_t handle, cyg_uint32 key, void *buf, cyg_uint32 *len) { diff --git a/packages/io/serial/current/tests/flow1.c b/packages/io/serial/current/tests/flow1.c new file mode 100644 --- /dev/null +++ b/packages/io/serial/current/tests/flow1.c @@ -0,0 +1,193 @@ +//========================================================================== +// +// flow1.c +// +// Test data half-duplex receive and send with flow control. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov,jlarmour +// Contributors: +// Date: 2000-07-27 +// Description: Test the half-duplex receive and send capabilities of +// the serial driver with flow control. +// Requirements: This test requires the ser_filter on the host side. +// +//####DESCRIPTIONEND#### + +#include + +#include // test macros +#include // assertion macros + +#ifdef CYGPKG_KERNEL +# include +#endif +#ifdef CYGPKG_IO_SERIAL +# include +#endif + +// Package requirements +#ifndef CYGPKG_IO_SERIAL +# define NA_MSG "Requires I/O serial package" +#elif !defined(CYGFUN_KERNEL_API_C) +# define NA_MSG "Requires kernel C API" +#elif !defined(CYGPKG_IO_SERIAL_FLOW_CONTROL) +# define NA_MSG "Requires serial flow control" +#endif + +#ifdef NA_MSG +void +cyg_start( void ) +{ + CYG_TEST_INIT(); + CYG_TEST_NA( NA_MSG); +} +#else + +#include // CYGNUM_HAL_STACK_SIZE_TYPICAL +#include +unsigned char stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; +cyg_thread thread_data; +cyg_handle_t thread_handle; + +// redefine buffer size for large transfer tests +#ifndef CYGPKG_HAL_ARM_AEB +# define IN_BUFFER_SIZE 65536 +#endif + +#include "ser_test_protocol.inl" + + +//--------------------------------------------------------------------------- +// run the tests + +static void +run_tests( cyg_io_handle_t ser_handle ) +{ + + + // Start slowly, then go for max size. + { + test_binary(ser_handle, 16, MODE_EOP_ECHO); + test_binary(ser_handle, 128, MODE_EOP_ECHO); + test_binary(ser_handle, 256, MODE_EOP_ECHO); + test_binary(ser_handle, IN_BUFFER_SIZE, MODE_EOP_ECHO); + } + + // Write some varying length packets. + { + int i; + for(i = 0; i < 8; i++) { + // No echo. + test_binary(ser_handle, 256 + 42*i, MODE_NO_ECHO); + test_binary(ser_handle, 64 + 7*i, MODE_NO_ECHO); + // Echo. + test_binary(ser_handle, 256 + 42*i, MODE_EOP_ECHO); + test_binary(ser_handle, 64 + 7*i, MODE_EOP_ECHO); + } + } + + // End with some long packets. + { + test_binary(ser_handle, 2048, MODE_NO_ECHO); + test_binary(ser_handle, 16384, MODE_NO_ECHO); + test_binary(ser_handle, 65536, MODE_NO_ECHO); + } +} + +//--------------------------------------------------------------------------- +// Serial test main function. + +void +serial_test( void ) +{ + cyg_io_handle_t ser_handle; + cyg_ser_cfg_t *cfg=&test_configs[0]; + cyg_ser_cfg_t new_cfg; + int count = sizeof(test_configs) / sizeof(cyg_ser_cfg_t); + int i; + + test_open_ser(&ser_handle); + + // We need the filter for this test. + test_ping(ser_handle); + + // Choose the configuration with the fastest baud rate, to be most + // provocative. Start at 1 coz cfg already points at 0 + for (i=1; ibaud_rate < test_configs[i].baud_rate) + cfg=&test_configs[i]; + } + + // Set flow control from configuration + // Choose software first + +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE + CYG_TEST_INFO("Setting software flow control"); + + new_cfg = *cfg; + new_cfg.flags |= CYGNUM_SERIAL_FLOW_XONXOFF_RX | + CYGNUM_SERIAL_FLOW_XONXOFF_TX; + if (ENOERR == change_config(ser_handle, &new_cfg)) + run_tests( ser_handle ); +#endif + + // hardware flow control +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_HW + CYG_TEST_INFO("Setting hardware flow control"); + + new_cfg = *cfg; + new_cfg.flags |= CYGNUM_SERIAL_FLOW_RTSCTS_RX|CYGNUM_SERIAL_FLOW_RTSCTS_TX; + if (ENOERR == change_config(ser_handle, &new_cfg)) + run_tests( ser_handle ); +#endif + + CYG_TEST_PASS_FINISH("flow1 test OK"); +} + +void +cyg_start(void) +{ + CYG_TEST_INIT(); + cyg_thread_create(10, // Priority - just a number + (cyg_thread_entry_t*)serial_test, // entry + 0, // + "serial_thread", // Name + &stack[0], // Stack + CYGNUM_HAL_STACK_SIZE_TYPICAL, // Size + &thread_handle, // Handle + &thread_data // Thread data structure + ); + cyg_thread_resume(thread_handle); + cyg_scheduler_start(); +} + +#endif // ifndef NA_MSG + +// EOF flow1.c diff --git a/packages/io/serial/current/tests/flow2.c b/packages/io/serial/current/tests/flow2.c new file mode 100644 --- /dev/null +++ b/packages/io/serial/current/tests/flow2.c @@ -0,0 +1,166 @@ +//========================================================================== +// +// flow2.c +// +// Test duplex receive and send with flow control. +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov,jlarmour +// Contributors: +// Date: 2000-07-27 +// Description: Test the duplex receive and send capabilities of +// the serial driver with flow control. +// Requirements: This test requires the ser_filter on the host side. +// +//####DESCRIPTIONEND#### + +#include + +#include // test macros +#include // assertion macros + +#ifdef CYGPKG_KERNEL +# include +#endif +#ifdef CYGPKG_IO_SERIAL +# include +#endif + +// Package requirements +#ifndef CYGPKG_IO_SERIAL +# define NA_MSG "Requires I/O serial package" +#elif !defined(CYGFUN_KERNEL_API_C) +# define NA_MSG "Requires kernel C API" +#elif !defined(CYGPKG_IO_SERIAL_FLOW_CONTROL) +# define NA_MSG "Requires serial flow control" +#endif + +#ifdef NA_MSG +void +cyg_start( void ) +{ + CYG_TEST_INIT(); + CYG_TEST_NA( NA_MSG); +} +#else + +#include // CYGNUM_HAL_STACK_SIZE_TYPICAL +#include +unsigned char stack[CYGNUM_HAL_STACK_SIZE_TYPICAL]; +cyg_thread thread_data; +cyg_handle_t thread_handle; + +#include "ser_test_protocol.inl" + + +//--------------------------------------------------------------------------- +// run the tests + +static void +run_tests( cyg_io_handle_t ser_handle ) +{ + // Start slowly, then go for max size. + { + test_binary(ser_handle, 16, MODE_DUPLEX_ECHO); + test_binary(ser_handle, 128, MODE_DUPLEX_ECHO); + test_binary(ser_handle, 256, MODE_DUPLEX_ECHO); + test_binary(ser_handle, 1024, MODE_DUPLEX_ECHO); + } +} + +//--------------------------------------------------------------------------- +// Serial test main function. + +void +serial_test( void ) +{ + cyg_io_handle_t ser_handle; + cyg_ser_cfg_t *cfg=&test_configs[0]; + cyg_ser_cfg_t new_cfg; + int count = sizeof(test_configs) / sizeof(cyg_ser_cfg_t); + int i; + + test_open_ser(&ser_handle); + + // We need the filter for this test. + test_ping(ser_handle); + + // Choose the configuration with the fastest baud rate, to be most + // provocative. Start at 1 coz cfg already points at 0 + for (i=1; ibaud_rate < test_configs[i].baud_rate) + cfg=&test_configs[i]; + } + + // Set flow control from configuration + // Choose software first + +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE + CYG_TEST_INFO("Setting software flow control"); + + new_cfg = *cfg; + new_cfg.flags |= CYGNUM_SERIAL_FLOW_XONXOFF_RX | + CYGNUM_SERIAL_FLOW_XONXOFF_TX; + if (ENOERR == change_config(ser_handle, &new_cfg)) + run_tests( ser_handle ); +#endif + + // hardware flow control +#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_HW + CYG_TEST_INFO("Setting hardware flow control"); + + new_cfg = *cfg; + new_cfg.flags |= CYGNUM_SERIAL_FLOW_RTSCTS_RX|CYGNUM_SERIAL_FLOW_RTSCTS_TX; + if (ENOERR == change_config(ser_handle, &new_cfg)) + run_tests( ser_handle ); +#endif + + CYG_TEST_PASS_FINISH("flow2 test OK"); +} + +void +cyg_start(void) +{ + CYG_TEST_INIT(); + cyg_thread_create(10, // Priority - just a number + (cyg_thread_entry_t*)serial_test, // entry + 0, // + "serial_thread", // Name + &stack[0], // Stack + CYGNUM_HAL_STACK_SIZE_TYPICAL, // Size + &thread_handle, // Handle + &thread_data // Thread data structure + ); + cyg_thread_resume(thread_handle); + cyg_scheduler_start(); +} + +#endif // ifndef NA_MSG + +// EOF flow2.c diff --git a/packages/io/serial/current/tests/ser_test_protocol.inl b/packages/io/serial/current/tests/ser_test_protocol.inl --- a/packages/io/serial/current/tests/ser_test_protocol.inl +++ b/packages/io/serial/current/tests/ser_test_protocol.inl @@ -232,6 +232,14 @@ # define TEST_TTY_DEV CYGDAT_IO_SERIAL_TTY_TTY0_DEV # endif #endif +#if defined(CYGPKG_IO_SERIAL_LOOP) \ + && defined(CYGPKG_IO_SERIAL_LOOP_SERIAL0) +# define TEST_CRASH_ID "loop" +# define TEST_SER_DEV CYGDAT_IO_SERIAL_LOOP_SERIAL0_NAME +# if defined(CYGPKG_IO_SERIAL_TTY_TTY0) +# define TEST_TTY_DEV CYGDAT_IO_SERIAL_TTY_TTY0_DEV +# endif +#endif // We can't rely on haldiag for ser_filter detection - it may not define // a working character reading function. @@ -303,7 +311,9 @@ //---------------------------------------------------------------------------- // The data in buffer and the cmd buffer -#define IN_BUFFER_SIZE 1024 +#ifndef IN_BUFFER_SIZE +# define IN_BUFFER_SIZE 1024 +#endif cyg_uint8 in_buffer[IN_BUFFER_SIZE]; cyg_int8 cmd_buffer[128]; @@ -322,10 +332,11 @@ typedef enum { } cyg_test_return_t; typedef struct ser_cfg { - cyg_serial_baud_rate_t baud_rate; - cyg_serial_word_length_t data_bits; - cyg_serial_stop_bits_t stop_bits; - cyg_serial_parity_t parity; + cyg_serial_baud_rate_t baud_rate; + cyg_serial_word_length_t data_bits; + cyg_serial_stop_bits_t stop_bits; + cyg_serial_parity_t parity; + cyg_uint32 flags; // etc... } cyg_ser_cfg_t; @@ -376,32 +387,35 @@ typedef enum { cyg_ser_cfg_t test_configs[] = { #if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904) && !defined(CYGPKG_HAL_ARM_PID) { CYGNUM_SERIAL_BAUD_9600, CYGNUM_SERIAL_WORD_LENGTH_8, - CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE }, + CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE, + CYGNUM_SERIAL_FLOW_NONE }, #endif #if !defined(CYGPKG_HAL_MN10300_AM31) && \ - !defined(CYGPKG_HAL_MN10300_AM33) && \ - 1 + !defined(CYGPKG_HAL_MN10300_AM33) { CYGNUM_SERIAL_BAUD_14400, CYGNUM_SERIAL_WORD_LENGTH_8, - CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE }, + CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE, + CYGNUM_SERIAL_FLOW_NONE }, #endif { CYGNUM_SERIAL_BAUD_19200, CYGNUM_SERIAL_WORD_LENGTH_8, - CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE }, + CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE, + CYGNUM_SERIAL_FLOW_NONE }, #if !defined(CYGPKG_HAL_SPARCLITE_SLEB) && \ !defined(CYGPKG_HAL_ARM_AEB) { CYGNUM_SERIAL_BAUD_38400, CYGNUM_SERIAL_WORD_LENGTH_8, - CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE }, + CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE, + CYGNUM_SERIAL_FLOW_NONE }, #endif #if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904) && \ !defined(CYGPKG_HAL_ARM_AEB) && \ !defined(CYGPKG_HAL_SPARCLITE_SLEB) && \ - !defined(CYGPKG_HAL_MN10300_AM33) && \ - 1 + !defined(CYGPKG_HAL_MN10300_AM33) { CYGNUM_SERIAL_BAUD_57600, CYGNUM_SERIAL_WORD_LENGTH_8, - CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE }, + CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE, + CYGNUM_SERIAL_FLOW_NONE }, #endif #if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904) && \ @@ -412,7 +426,8 @@ cyg_ser_cfg_t test_configs[] = { !defined(CYGPKG_HAL_ARM_EDB7XXX) && \ !defined(CYGPKG_HAL_SPARCLITE_SLEB) { CYGNUM_SERIAL_BAUD_115200, CYGNUM_SERIAL_WORD_LENGTH_8, - CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE }, + CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE, + CYGNUM_SERIAL_FLOW_NONE }, #endif #if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904) && \ @@ -420,7 +435,8 @@ cyg_ser_cfg_t test_configs[] = { !defined(CYGPKG_HAL_ARM_PID) // One stop bit, even parity { CYGNUM_SERIAL_BAUD_19200, CYGNUM_SERIAL_WORD_LENGTH_8, - CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_EVEN }, + CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_EVEN, + CYGNUM_SERIAL_FLOW_NONE }, #endif #if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904) && \ @@ -428,13 +444,15 @@ cyg_ser_cfg_t test_configs[] = { !defined(CYGPKG_HAL_ARM_PID) // Two stop bits, even parity { CYGNUM_SERIAL_BAUD_19200, CYGNUM_SERIAL_WORD_LENGTH_8, - CYGNUM_SERIAL_STOP_2, CYGNUM_SERIAL_PARITY_EVEN }, + CYGNUM_SERIAL_STOP_2, CYGNUM_SERIAL_PARITY_EVEN, + CYGNUM_SERIAL_FLOW_NONE }, #endif #if !defined(CYGPKG_HAL_MIPS_TX39_JMR3904) // Two stop bits, no parity { CYGNUM_SERIAL_BAUD_19200, CYGNUM_SERIAL_WORD_LENGTH_8, - CYGNUM_SERIAL_STOP_2, CYGNUM_SERIAL_PARITY_NONE }, + CYGNUM_SERIAL_STOP_2, CYGNUM_SERIAL_PARITY_NONE, + CYGNUM_SERIAL_FLOW_NONE }, #endif }; @@ -588,7 +606,7 @@ hang(void) // // Then query the host for its capability to use the config: // Format out: -// "@CONFIG::<#data bits>:<#stop bits>:!" +// "@CONFIG::<#data bits>:<#stop bits>::!" // Format in: // OK/ER // @@ -634,6 +652,8 @@ change_config(cyg_io_handle_t handle, cy p1 = itoa(p1, cfg->stop_bits); *p1++ = ':'; p1 = itoa(p1, cfg->parity); + *p1++ = ':'; + p1 = itoa(p1, cfg->flags); *p1++ = '!'; *p1 = 0; // note: we may append to this later @@ -656,6 +676,7 @@ change_config(cyg_io_handle_t handle, cy new_cfg.word_length = cfg->data_bits; new_cfg.stop = cfg->stop_bits; new_cfg.parity = cfg->parity; + new_cfg.flags = cfg->flags; res = cyg_io_set_config(handle, CYG_IO_SET_CONFIG_SERIAL_INFO, &new_cfg, &len); @@ -851,6 +872,7 @@ read_host_crc(cyg_io_handle_t handle) // The current implementation is simple and may not stress the // driver enough. Also, it's command packet format doesn't match // that of the other modes. + cyg_test_return_t test_binary(cyg_io_handle_t handle, int size, cyg_mode_t mode) { @@ -921,7 +943,7 @@ test_binary(cyg_io_handle_t handle, int for (i = 0; i < tx_len; i++) { ADD_CRC_BYTE(xcrc, in_buffer[i]); } - + // Echo data back. chunk_len = size; Tcyg_io_write(handle, &in_buffer[0], &chunk_len); diff --git a/packages/io/serial/current/tests/serial3.c b/packages/io/serial/current/tests/serial3.c --- a/packages/io/serial/current/tests/serial3.c +++ b/packages/io/serial/current/tests/serial3.c @@ -79,13 +79,14 @@ serial_test( void ) // at the default 38400 baud when doing this test. cyg_ser_cfg_t arm_aeb_cfg = { CYGNUM_SERIAL_BAUD_14400, CYGNUM_SERIAL_WORD_LENGTH_8, - CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE }; + CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE, + CYGNUM_SERIAL_FLOW_NONE }; change_config(ser_handle, &arm_aeb_cfg); } #endif - // Start slowly, the go for max size. + // Start slowly, then go for max size. { test_binary(ser_handle, 16, MODE_EOP_ECHO); test_binary(ser_handle, 128, MODE_EOP_ECHO); diff --git a/packages/io/serial/current/tests/serial5.c b/packages/io/serial/current/tests/serial5.c --- a/packages/io/serial/current/tests/serial5.c +++ b/packages/io/serial/current/tests/serial5.c @@ -82,7 +82,8 @@ serial_test( void ) // at the default 38400 baud when doing this test. cyg_ser_cfg_t cfg = { CYGNUM_SERIAL_BAUD_9600, CYGNUM_SERIAL_WORD_LENGTH_8, - CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE }; + CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE, + CYGNUM_SERIAL_FLOW_NONE }; change_config(ser_handle, &cfg); } diff --git a/packages/io/wallclock/current/ChangeLog b/packages/io/wallclock/current/ChangeLog --- a/packages/io/wallclock/current/ChangeLog +++ b/packages/io/wallclock/current/ChangeLog @@ -1,3 +1,7 @@ +2000-07-24 Jonathan Larmour + + * tests/wallclock2.cxx: Depend on CYGPKG_LIBC_TIME not CYGPKG_LIBC + 2000-05-30 Jesper Skov * include/wallclock/wallclock.inl (_simple_mktime): Replaced diff --git a/packages/io/wallclock/current/tests/wallclock2.cxx b/packages/io/wallclock/current/tests/wallclock2.cxx --- a/packages/io/wallclock/current/tests/wallclock2.cxx +++ b/packages/io/wallclock/current/tests/wallclock2.cxx @@ -45,8 +45,8 @@ #include #include #include -#ifdef CYGPKG_LIBC -#include +#ifdef CYGPKG_LIBC_TIME +#include #endif #if defined(CYGSEM_LIBC_TIME_CLOCK_WORKING) diff --git a/packages/isoinfra/current/ChangeLog b/packages/isoinfra/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/ChangeLog @@ -0,0 +1,196 @@ +2000-08-08 Jonathan Larmour + + * include/limits.h: Add SSIZE_MAX + +2000-08-03 Jonathan Larmour + + * include/sys/types.h: Make fd_mask unsigned int, not cyg_uint32 so + as to avoid including cyg_type.h + +2000-08-01 Jonathan Larmour + + * cdl/isoinfra.cdl: Support termios + * include/termios.h: Added + +2000-07-21 Jonathan Larmour + + * cdl/isoinfra.cdl: CYGNUM_ISO_MQUEUE_OPEN_MAX and + CYGNUM_ISO_MQUEUE_PRIO_MAX should only be active if CYGINT_ISO_MQUEUE + rather than them requiring it + +2000-07-20 Nick Garnett + + * cdl/isoinfra.cdl: Added configury for sys/utsname.h. + + * include/unistd.h: Added _POSIX_VERSION constant. + Changed return type of sysconf() to long. + + * include/sys/utsname.h: Added this file. + +2000-07-13 Nick Garnett + + * include/unistd.h: Added fsync() prototype. + +2000-07-13 Jonathan Larmour + + * cdl/isoinfra.cdl: Add CYGINT_ISO_MALLINFO and + CYGBLD_ISO_MALLINFO_HEADER to support mallinfo() + + * include/stdlib.h: Support mallinfo() + +2000-06-28 Nick Garnett + + * include/sys/stat.h: Added prototypes for stat(), fstat() and + mkdir(). + + * include/dirent.h: Added this file to provide directory reading + support. + + * cdl/isoinfra.cdl: Added dirent support. + +2000-06-21 Jonathan Larmour + + * cdl/isoinfra.cdl: Put in below requires line, but change to allow + 0 or 1 implementations + +2000-06-19 Nick Garnett + + * cdl/isoinfra.cdl: Commented out requires line in + CYGINT_POSIX_REALTIME_SIGNALS interface. This causes configuration + errors when the POSIX package is absent. + + * include/sys/types.h: Reimplemented FD_COPY() and FD_ZERO() as + inline copy loops rather than calls to memcpy() and memset(). + +2000-06-09 Jonathan Larmour + + * include/time.h: Following the below change, simply define struct + timeval, while allowing it to be overridden if necessary + * cdl/isoinfra.cdl (CYGBLD_ISO_STRUCTTIMEVAL_HEADER): define for this + purpose + +2000-06-09 Nick Garnett + + * include/time.h: Added definition of struct timeval. This is a + temporary home for this while we work out where definitions like + this should really live. Like the fd_set stuff in sys/types.h, + this is needed by two packages, both of which can operate + independently but which also need to co-operate when they are both + present. + +2000-06-07 Nick Garnett + + * include/sys/types.h: Added definitions for file descriptor sets + and inclusion of BSD specific types. + + * include/stdlib.h: Added extern for environ variable in non-POSIX + builds. + + * include/fcntl.h (O_WRONLY): Moved this to bit 1, leaving bit 2 + for future expansion. + + * cdl/isoinfra.cdl: Added CYGPKG_ISO_EXTRA_TYPES to control + inclusion of types into that are not specified by + POSIX. Mostly needed by the socket and BSD code. + +2000-06-02 Nick Garnett + + * include/unistd.h: Added this initial version of this file. Jifl + will probably want to rewrite it at some point. + + * include/fcntl.h: Changed O_RDWR to (O_RDONLY|O_WRONLY). + +2000-05-31 Nick Garnett + + * include/fcntl.h: Fixed ifdefs around extern declaration of + fcntl(). + +2000-05-20 Jonathan Larmour + + * include/fcntl.h: new file + * include/mqueue.h: new file + * include/sys/stat.h: new file + + * cdl/isoinfra.cdl: No need for memcpy and memset interfaces - they're + always present + (CYGINT_ISO_POSIX_TIMERS): define _POSIX_TIMERS if enabled + (CYGINT_POSIX_REALTIME_SIGNALS): add + (CYGPKG_ISO_POSIX_FCNTL): Add a number of hooks for things that need + to control fcntl.h + (CYGPKG_ISO_MQUEUE): Add a number of hooks for things that need + to control mqueue.h + (CYGBLD_ISO_STAT_DEFS_HEADER): Add to override default sys/stat.h + contents + + Fix some typos throughout, and a few other minor tidies + + * include/limits.h: Move _POSIX_* macros here from POSIX package since + they are implementation independent + + * include/time.h: Keep CLOCKS_PER_SEC at 1000000 + + * include/sys/types.h: Bring some of the types more in line with Linux + + * include/ctype.h, include/errno.h, include/limits.h, include/locale.h, + include/pthread.h, include/sched.h, include/semaphore.h, + include/setjmp.h, include/signal.h, include/stdio.h, include/stdlib.h, + include/string.h, include/time.h, include/sys/types.h: + Don't need to explicitly check interface values > 0 + +2000-05-02 Jonathan Larmour + + * include/time.h: Provide default definitions of time_t, clock_t and + CLOCKS_PER_SEC + + * cdl/isoinfra.cdl: Remove CYGINT_ISO_TIME_T and CYGINT_ISO_CLOCK_T - + not really needed with a default definition + + * New package isoinfra with the following files: + include/errno.h + include/sys/types.h + include/assert.h + include/stddef.h + include/string.h + include/setjmp.h + include/ctype.h + include/float.h + include/sched.h + include/stdarg.h + include/semaphore.h + include/time.h + include/signal.h + include/locale.h + include/pthread.h + include/stdio.h + include/stdlib.h + include/limits.h + cdl/isoinfra.cdl + + This package manages the ISO standard (C and POSIX) top-level header + files + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/isoinfra/current/cdl/isoinfra.cdl b/packages/isoinfra/current/cdl/isoinfra.cdl new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/cdl/isoinfra.cdl @@ -0,0 +1,996 @@ +# ==================================================================== +# +# isoinfra.cdl +# +# ISO C and POSIX standards infrastructure package configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jlarmour +# Contributors: +# Date: 2000-04-07 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_ISOINFRA { + display "ISO C and POSIX infrastructure" + description " + eCos supports implementations of ISO C libraries and POSIX + implementations. This package provides infrastructure used by + all such implementations." + + +# ==================================================================== + + cdl_component CYGPKG_ISO_STARTUP { + display "Startup and termination" + flavor none + no_define + + cdl_interface CYGINT_ISO_MAIN_STARTUP { + display "main() startup implementations" + description " + Implementations of this interface arrange for a user-supplied + main() to be called in an ISO compatible environment." + requires { 1 >= CYGINT_ISO_MAIN_STARTUP } + } + + cdl_interface CYGINT_ISO_ENVIRON { + display "environ implementations" + description " + Implementations of this interface provide the environ + variable required by POSIX." + requires { 1 >= CYGINT_ISO_ENVIRON } + } + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_CTYPE_H { + display "ctype.h functions" + flavor none + no_define + + cdl_interface CYGINT_ISO_CTYPE { + display "Number of implementations of ctype functions" + requires { 1 >= CYGINT_ISO_CTYPE } + } + + cdl_option CYGBLD_ISO_CTYPE_HEADER { + display "Ctype implementation header" + flavor booldata + default_value 0 + } + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_ERRNO { + display "Error handling" + flavor none + no_define + + cdl_interface CYGINT_ISO_ERRNO_CODES { + display "Number of implementations of error codes" + requires { 1 >= CYGINT_ISO_ERRNO_CODES } + } + + cdl_option CYGBLD_ISO_ERRNO_CODES_HEADER { + display "Error codes implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_ERRNO { + display "Number of implementations of errno variable" + requires { 1 >= CYGINT_ISO_ERRNO } + } + + cdl_option CYGBLD_ISO_ERRNO_HEADER { + display "errno variable implementation header" + flavor booldata + default_value 0 + } + + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_LOCALE { + display "Locale-related functions" + flavor none + no_define + + cdl_interface CYGINT_ISO_LOCALE { + display "Number of implementations of locale functions" + requires { 1 >= CYGINT_ISO_LOCALE } + } + + cdl_option CYGBLD_ISO_LOCALE_HEADER { + display "Locale implementation header" + flavor booldata + default_value 0 + } + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_STDIO { + display "Standard I/O-related functionality" + flavor none + no_define + + cdl_interface CYGINT_ISO_STDIO_FILETYPES { + display "Number of implementations of stdio file types" + requires { 1 >= CYGINT_ISO_STDIO_FILETYPES } + } + + cdl_option CYGBLD_ISO_STDIO_FILETYPES_HEADER { + display "Stdio file types implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STDIO_FILEOPS { + display "Number of implementations of stdio file operations" + requires { 1 >= CYGINT_ISO_STDIO_FILEOPS } + } + + cdl_option CYGBLD_ISO_STDIO_FILEOPS_HEADER { + display "Stdio file operations implementation header" + description " + This header controls the file system operations on a file + such as remove(), rename(), tmpfile(), tmpnam() and associated + constants." + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STDIO_FILEACCESS { + display "Number of implementations of stdio file access \ + functionals" + requires { 1 >= CYGINT_ISO_STDIO_FILEACCESS } + } + + cdl_option CYGBLD_ISO_STDIO_FILEACCESS_HEADER { + display "Stdio file access implementation header" + description " + This header controls the file access operations + such as fclose(), fflush(), fopen(), freopen(), setbuf(), + setvbuf(), and associated constants." + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STDIO_FORMATTED_IO { + display "Number of implementations of stdio formatted I/O" + requires { 1 >= CYGINT_ISO_STDIO_FORMATTED_IO } + } + + cdl_option CYGBLD_ISO_STDIO_FORMATTED_IO_HEADER { + display "Stdio formatted I/O implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STDIO_CHAR_IO { + display "Number of implementations of stdio character I/O" + requires { 1 >= CYGINT_ISO_STDIO_CHAR_IO } + } + + cdl_option CYGBLD_ISO_STDIO_CHAR_IO_HEADER { + display "Stdio character I/O implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STDIO_DIRECT_IO { + display "Number of implementations of stdio direct I/O" + requires { 1 >= CYGINT_ISO_STDIO_DIRECT_IO } + } + + cdl_option CYGBLD_ISO_STDIO_DIRECT_IO_HEADER { + display "Stdio direct I/O implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STDIO_FILEPOS { + display "Number of implementations of stdio file positioning" + requires { 1 >= CYGINT_ISO_STDIO_FILEPOS } + } + + cdl_option CYGBLD_ISO_STDIO_FILEPOS { + display "Stdio file positioning implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STDIO_ERROR { + display "Number of implementations of stdio error handling" + requires { 1 >= CYGINT_ISO_STDIO_ERROR } + } + + cdl_option CYGBLD_ISO_STDIO_ERROR_HEADER { + display "Stdio error handling implementation header" + flavor booldata + default_value 0 + } + + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_STDLIB { + display "Standard general utility functions" + flavor none + no_define + + cdl_interface CYGINT_ISO_STDLIB_STRCONV { + display "String conversion function implementations" + requires { 1 >= CYGINT_ISO_STDLIB_STRCONV } + } + + cdl_option CYGBLD_ISO_STDLIB_STRCONV_HEADER { + display "String conversion function implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STDLIB_STRCONV_FLOAT { + display "String to FP conversion function implementations" + requires { 1 >= CYGINT_ISO_STDLIB_STRCONV_FLOAT } + } + + cdl_option CYGBLD_ISO_STDLIB_STRCONV_FLOAT_HEADER { + display "String to FP conversion function implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_RAND { + display "Random number generator implementations" + requires { 1 >= CYGINT_ISO_RAND } + } + + cdl_option CYGBLD_ISO_RAND_HEADER { + display "Random number generator implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_MALLOC { + display "Malloc implementations" + requires { 1 >= CYGINT_ISO_MALLOC } + } + + cdl_option CYGBLD_ISO_MALLOC_HEADER { + display "Malloc implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_MALLINFO { + display "Mallinfo() implementations" + requires { 1 >= CYGINT_ISO_MALLINFO } + } + + cdl_option CYGBLD_ISO_MALLINFO_HEADER { + display "Mallinfo() implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_EXIT { + display "Program exit functionality implementations" + requires { 1 >= CYGINT_ISO_EXIT } + } + + cdl_option CYGBLD_ISO_EXIT_HEADER { + display "Program exit functionality implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STDLIB_ENVIRON { + display "Program environment implementations" + requires { 1 >= CYGINT_ISO_STDLIB_ENVIRON } + } + + cdl_option CYGBLD_ISO_STDLIB_ENVIRON_HEADER { + display "Program environment implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STDLIB_SYSTEM { + display "system() implementations" + requires { 1 >= CYGINT_ISO_STDLIB_SYSTEM } + } + + cdl_option CYGBLD_ISO_STDLIB_SYSTEM_HEADER { + display "system() implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_BSEARCH { + display "bsearch() implementations" + requires { 1 >= CYGINT_ISO_BSEARCH } + } + + cdl_option CYGBLD_ISO_BSEARCH_HEADER { + display "bsearch() implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_QSORT { + display "qsort() implementations" + requires { 1 >= CYGINT_ISO_STDLIB_QSORT } + } + + cdl_option CYGBLD_ISO_QSORT_HEADER { + display "qsort() implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_ABS { + display "abs()/labs() implementations" + requires { 1 >= CYGINT_ISO_STDLIB_ABS } + } + + cdl_option CYGBLD_ISO_STDLIB_ABS_HEADER { + display "abs()/labs() implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_DIV { + display "div()/ldiv() implementations" + requires { 1 >= CYGINT_ISO_STDLIB_DIV } + } + + cdl_option CYGBLD_ISO_STDLIB_DIV_HEADER { + display "div()/ldiv() implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STDLIB_MULTIBYTE { + display "Multibyte character implementations" + requires { 1 >= CYGINT_ISO_STDLIB_MULTIBYTE } + } + + cdl_option CYGBLD_ISO_STDLIB_MULTIBYTE_HEADER { + display "Multibyte character implementation header" + flavor booldata + default_value 0 + } + + + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_STRING { + display "String functions" + flavor none + no_define + + cdl_interface CYGINT_ISO_STRERROR { + display "Number of implementations of strerror() function" + requires { 1 >= CYGINT_ISO_STRERROR } + } + + cdl_option CYGBLD_ISO_STRERROR_HEADER { + display "strerror() implementation header" + flavor booldata + default_value 0 + } + + cdl_option CYGBLD_ISO_MEMCPY_HEADER { + display "memcpy() implementation header" + flavor booldata + default_value 0 + } + + cdl_option CYGBLD_ISO_MEMSET_HEADER { + display "memset() implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STRTOK_R { + display "Number of implementations of strtok_r() function" + requires { 1 >= CYGINT_ISO_STRTOK_R } + } + + cdl_option CYGBLD_ISO_STRTOK_R_HEADER { + display "strtok_r() implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STRING_LOCALE_FUNCS { + display "Number of implementations of locale-specific string \ + functions" + description " + This covers locale-dependent string functions such as strcoll() + and strxfrm()." + requires { 1 >= CYGINT_ISO_STRING_LOCALE_FUNCS } + } + + cdl_option CYGBLD_ISO_STRING_LOCALE_FUNCS_HEADER { + display "Locale-specific string functions' implementation \ + header" + description " + This covers locale-dependent string functions such as strcoll() + and strxfrm()." + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STRING_BSD_FUNCS { + display "Number of implementations of BSD string functions" + requires { 1 >= CYGINT_ISO_STRING_BSD_FUNCS } + } + + cdl_option CYGBLD_ISO_STRING_BSD_FUNCS_HEADER { + display "BSD string functions' implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STRING_MEMFUNCS { + display "Number of implementations of other mem*() functions" + requires { 1 >= CYGINT_ISO_STRING_MEMFUNCS } + } + + cdl_option CYGBLD_ISO_STRING_MEMFUNCS_HEADER { + display "Other mem*() functions' implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_STRING_STRFUNCS { + display "Number of implementations of other ISO C str*() \ + functions" + description " + This covers the other str*() functions defined by ISO C." + requires { 1 >= CYGINT_ISO_STRING_STRFUNCS } + } + + cdl_option CYGBLD_ISO_STRING_STRFUNCS_HEADER { + display "Other ISO C str*() functions' implementation \ + header" + description " + This covers the other str*() functions defined by ISO C." + flavor booldata + default_value 0 + } + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_TIME { + display "Clock and time functionality" + flavor none + no_define + + cdl_option CYGBLD_ISO_TIME_T_HEADER { + display "time_t implementation header" + flavor booldata + default_value 0 + } + + cdl_option CYGBLD_ISO_CLOCK_T_HEADER { + display "clock_t implementation header" + flavor booldata + default_value 0 + } + + cdl_option CYGBLD_ISO_STRUCTTIMEVAL_HEADER { + display "struct timeval implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_POSIX_TIMER_TYPES { + display "Number of implementations of POSIX timer types" + requires { 1 >= CYGINT_ISO_POSIX_TIMER_TYPES } + } + + cdl_option CYGBLD_ISO_POSIX_TIMER_TYPES_HEADER { + display "POSIX timer types implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_C_TIME_TYPES { + display "Number of implementations of ISO C types" + requires { 1 >= CYGINT_ISO_C_TIME_TYPES } + } + + cdl_option CYGBLD_ISO_C_TIME_TYPES_HEADER { + display "ISO C time types implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_POSIX_TIMERS { + display "Number of implementations of POSIX timers" + requires { 1 >= CYGINT_ISO_POSIX_TIMERS } +# FIXME should use this: define _POSIX_TIMERS + define_proc { + puts $::cdl_header "#if CYGINT_ISO_POSIX_TIMERS" + puts $::cdl_header "# define _POSIX_TIMERS 1" + puts $::cdl_header "#endif" + } + } + + cdl_option CYGBLD_ISO_POSIX_TIMERS_HEADER { + display "POSIX timer implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_C_CLOCK_FUNCS { + display "Number of implementations of ISO C clock functions" + requires { 1 >= CYGINT_ISO_C_CLOCK_FUNCS } + } + + cdl_option CYGBLD_ISO_C_CLOCK_FUNCS_HEADER { + display "ISO C clock functions' implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_TZSET { + display "Number of implementations of tzset() function" + requires { 1 >= CYGINT_ISO_TZSET } + } + + cdl_option CYGBLD_ISO_TZSET_HEADER { + display "tzset() implementation header" + flavor booldata + default_value 0 + } + } + + +# ==================================================================== + + cdl_component CYGPKG_ISO_SIGNAL { + display "Signal functionality" + flavor none + no_define + + cdl_interface CYGINT_ISO_SIGNAL_NUMBERS { + display "Number of implementations of signal numbers" + requires { 1 >= CYGINT_ISO_SIGNAL_NUMBERS } + } + + cdl_option CYGBLD_ISO_SIGNAL_NUMBERS_HEADER { + display "Signal numbering implementation header" + description "This header provides the mapping of signal + names (e.g. SIGBUS) to numbers." + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_SIGNAL_IMPL { + display "Number of signal implementations" + requires { 1 >= CYGINT_ISO_SIGNAL_IMPL } + } + + cdl_option CYGBLD_ISO_SIGNAL_IMPL_HEADER { + display "Signals implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_POSIX_REALTIME_SIGNALS { + display "POSIX real time signals feature test macro" + description "This defines the POSIX feature test macro + that indicates that the POSIX real time signals + are present." + requires { 1 >= CYGINT_POSIX_REALTIME_SIGNALS } +# FIXME should use this: define _POSIX_REALTIME_SIGNALS + define_proc { + puts $::cdl_header "#if CYGINT_POSIX_REALTIME_SIGNALS" + puts $::cdl_header "# define _POSIX_REALTIME_SIGNALS 1" + puts $::cdl_header "#endif" + } + } + + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_SETJMP { + display "Non-local jumps functionality" + flavor none + no_define + + cdl_interface CYGINT_ISO_SETJMP { + display "setjmp() / longjmp() implementations" + requires { 1 >= CYGINT_ISO_SETJMP } + } + + cdl_option CYGBLD_ISO_SETJMP_HEADER { + display "setjmp() / longjmp() implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_SIGSETJMP { + display "sigsetjmp() / siglongjmp() implementations" + requires { 1 >= CYGINT_ISO_SIGSETJMP } + } + + cdl_option CYGBLD_ISO_SIGSETJMP_HEADER { + display "sigsetjmp() / siglongjmp() implementation header" + flavor booldata + default_value 0 + } + } + + +# ==================================================================== + + cdl_option CYGBLD_ISO_ASSERT_HEADER { + display "Assertions implementation header" + flavor booldata + default_value 0 + } + + +# ==================================================================== + + cdl_component CYGPKG_ISO_POSIX_FCNTL { + display "POSIX file control" + description "This covers the POSIX file control definitions, + normally found in " + flavor none + no_define + + cdl_option CYGBLD_ISO_OFLAG_HEADER { + display "POSIX open flags implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_FCNTL { + display "POSIX fcntl() implementations" + requires { 1 >= CYGINT_ISO_FCNTL } + } + + cdl_option CYGBLD_ISO_FCNTL_HEADER { + display "POSIX fcntl() implementation header" + flavor booldata + default_value 0 + } + + cdl_interface CYGINT_ISO_OPEN { + display "POSIX file open implementations" + requires { 1 >= CYGINT_ISO_OPEN } + } + + cdl_option CYGBLD_ISO_OPEN_HEADER { + display "POSIX file open implementation header" + flavor booldata + default_value 0 + } + } + +# ==================================================================== + + cdl_option CYGBLD_ISO_STAT_DEFS_HEADER { + display " definitions implementation header" + flavor booldata + default_value 0 + } + + +# ==================================================================== + + cdl_interface CYGINT_ISO_DIRENT { + display "POSIX directory reading implementation" + requires { 1 >= CYGINT_ISO_DIRENT } + } + + cdl_option CYGBLD_ISO_DIRENT_HEADER { + display " definitions implementation header" + flavor booldata + default_value 0 + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_POSIX_TYPES { + display "POSIX contents" + description "This covers the types required by POSIX to be in + " + flavor none + no_define + + cdl_interface CYGINT_ISO_PTHREADTYPES { + display "POSIX thread types implementations" + requires { 1 >= CYGINT_ISO_PTHREADTYPES } + } + + cdl_option CYGBLD_ISO_PTHREADTYPES_HEADER { + display "POSIX thread types implementation header" + flavor booldata + default_value 0 + } + + cdl_option CYGBLD_ISO_SSIZE_T_HEADER { + display "ssize_t implementation header" + flavor booldata + default_value 0 + } + cdl_option CYGBLD_ISO_FSTYPES_HEADER { + display "Filesystem types implementation header" + flavor booldata + default_value 0 + } + cdl_option CYGBLD_ISO_SCHEDTYPES_HEADER { + display "gid_t, pid_t, uid_t implementation header" + flavor booldata + default_value 0 + } + } + + +# ==================================================================== + + cdl_component CYGPKG_ISO_EXTRA_TYPES { + display "Non-POSIX contents" + description "This covers the extra types required by non-POSIX + packages to be in . These would normally + only be visible if _POSIX_SOURCE is not defined." + flavor none + no_define + + cdl_interface CYGINT_ISO_BSDTYPES { + display "BSD compatible types" + requires { 1 >= CYGINT_ISO_BSDTYPES } + } + + cdl_option CYGBLD_ISO_BSDTYPES_HEADER { + display "BSD types header" + flavor booldata + default_value 0 + } + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_UTSNAME { + display "Utsname structure" + flavor none + no_define + + cdl_option CYGBLD_ISO_UTSNAME_HEADER { + display "Utsname header" + flavor booldata + default_value 0 + } + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_SCHED { + display "POSIX scheduler" + flavor none + no_define + + cdl_interface CYGINT_ISO_SCHED_IMPL { + display "POSIX scheduler implementations" + requires { 1 >= CYGINT_ISO_SCHED_IMPL } + } + + cdl_option CYGBLD_ISO_SCHED_IMPL_HEADER { + display "POSIX scheduler implementation header" + flavor booldata + default_value 0 + } + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_SEMAPHORES { + display "POSIX semaphores" + flavor none + no_define + + cdl_interface CYGINT_ISO_SEMAPHORES { + display "POSIX semaphore implementations" + requires { 1 >= CYGINT_ISO_SEMAPHORES } +# FIXME should use this: define _POSIX_SEMAPHORES + define_proc { + puts $::cdl_header "#if CYGINT_ISO_SEMAPHORES" + puts $::cdl_header "# define _POSIX_SEMAPHORES 1" + puts $::cdl_header "#endif" + } + } + + cdl_option CYGBLD_ISO_SEMAPHORES_HEADER { + display "POSIX semaphore implementation header" + flavor booldata + default_value 0 + } + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_MQUEUE { + display "POSIX message queues" + flavor none + no_define + + cdl_interface CYGINT_ISO_MQUEUE { + display "Implementations" + requires { 1 >= CYGINT_ISO_MQUEUE } +# FIXME should use this: define _POSIX_MESSAGE_PASSING + define_proc { + puts $::cdl_header "#if CYGINT_ISO_MQUEUE" + puts $::cdl_header "# define _POSIX_MESSAGE_PASSING 1" + puts $::cdl_header "#endif" + } + } + + cdl_option CYGBLD_ISO_MQUEUE_HEADER { + display "Implementation header" + flavor booldata + default_value 0 + } + + cdl_option CYGNUM_ISO_MQUEUE_OPEN_MAX { + display "Maximum number of open message queues" + flavor booldata + active_if CYGINT_ISO_MQUEUE + define MQ_OPEN_MAX +# FIXME: shouldn't be specific to the implementation, see CR + default_value { CYGNUM_POSIX_MQUEUE_OPEN_MAX > 0 ? CYGNUM_POSIX_MQUEUE_OPEN_MAX : 0 } + } + + cdl_option CYGNUM_ISO_MQUEUE_PRIO_MAX { + display "Maximum number of message priorities" + flavor booldata +# FIXME: again like CYGNUM_ISO_MQUEUE_OPEN_MAX, should be able to be set by +# the implementation + default_value 65535 + active_if CYGINT_ISO_MQUEUE + define MQ_PRIO_MAX + } + + + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_PTHREAD { + display "POSIX threads" + flavor none + no_define + + cdl_interface CYGINT_ISO_PTHREAD_IMPL { + display "POSIX pthread implementations" + requires { 1 >= CYGINT_ISO_PTHREAD_IMPL } + } + + cdl_option CYGBLD_ISO_PTHREAD_IMPL_HEADER { + display "POSIX pthread implementation header" + flavor booldata + default_value 0 + } + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_LIMITS { + display "Limits" + flavor none + no_define + + cdl_interface CYGINT_ISO_POSIX_LIMITS { + display "POSIX pthread limits implementations" + requires { 1 >= CYGINT_ISO_POSIX_LIMITS } + } + + cdl_option CYGBLD_ISO_POSIX_LIMITS_HEADER { + display "POSIX pthread limits implementation header" + flavor booldata + default_value 0 + } + } + +# ==================================================================== + + cdl_component CYGPKG_ISO_TERMIOS { + display "POSIX termios" + flavor none + no_define + + cdl_interface CYGINT_ISO_TERMIOS { + display "POSIX termios implementations" + requires { 1 >= CYGINT_ISO_TERMIOS } + } + + cdl_option CYGBLD_ISO_TERMIOS_HEADER { + display "POSIX termios implementation header" + flavor booldata + default_value 0 + } + } + +# ==================================================================== + + cdl_component CYGPKG_ISOINFRA_OPTIONS { + display "Build options" + flavor none + no_define + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_ISOINFRA_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the ISO C and POSIX infrastructure package. + These flags are used in addition to the set of global flags." + } + + cdl_option CYGPKG_ISOINFRA_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the ISO C and POSIX infrastructure package. + These flags are removed from the set of global flags + if present." + } + } +} + +# ==================================================================== +# End of isoinfra.cdl diff --git a/packages/isoinfra/current/include/assert.h b/packages/isoinfra/current/include/assert.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/assert.h @@ -0,0 +1,112 @@ +#ifndef CYGONCE_ISO_ASSERT_H +#define CYGONCE_ISO_ASSERT_H +/*======================================================================== +// +// assert.h +// +// ISO C assertions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the assert functions required by +// ISO C and POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ +#include /* CYGDBG_USE_ASSERTS */ + +/* INCLUDES */ + +#ifdef CYGBLD_ISO_ASSERT_HEADER +# include CYGBLD_ISO_ASSERT_HEADER +#else + +# ifdef NDEBUG +# define assert( __bool ) ((void)0) +# else /* if NDEBUG is NOT defined */ + +/* First preference is to be standards compliant */ + +#if defined(CYGINT_ISO_STDIO_FORMATTED_IO) && defined(CYGINT_ISO_EXIT) + +# include +# include + +# define assert( __bool ) \ + do { \ + if (0 != (__bool)) { \ + fprintf( stderr, "User assertion failed: \"%s\", at %s:%d\n", \ + #__bool, __FILE__, __LINE__); \ + abort(); \ + } \ + } while(0) + + +/* Second preference is to use the common infra assertion support */ + +#elif defined(CYGDBG_USE_ASSERTS) + +# include + +# define assert( __bool ) \ + CYG_MACRO_START \ + CYG_ASSERT( __bool, "User assertion failed: \"" #__bool "\"" ); \ + CYG_MACRO_END +#else /* Fallback */ + +# include + +# define assert( __bool ) \ + do { \ + if (0 != (__bool)) { \ + diag_printf( "User assertion failed: \"%s\", at %s:%d\n", \ + #__bool, __FILE__, __LINE__); \ + for (;;); \ + } \ + } while(0) + +#endif + +# endif /* NDEBUG not defined */ +#endif + +#endif /* CYGONCE_ISO_ASSERT_H multiple inclusion protection */ + +/* EOF assert.h */ diff --git a/packages/isoinfra/current/include/ctype.h b/packages/isoinfra/current/include/ctype.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/ctype.h @@ -0,0 +1,123 @@ +#ifndef CYGONCE_ISO_CTYPE_H +#define CYGONCE_ISO_CTYPE_H +/*======================================================================== +// +// ctype.h +// +// ISO ctype functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the ctype functions required by +// ISO C 9899:1990 and POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#if CYGINT_ISO_CTYPE +# ifdef CYGBLD_ISO_CTYPE_HEADER +# include CYGBLD_ISO_CTYPE_HEADER +# else + +#ifdef __cplusplus +extern "C" { +#endif + +/* FUNCTION PROTOTYPES */ + +//=========================================================================*/ + +/* 7.3.1 Character testing functions */ + +extern int +isalnum( int ); + +extern int +isalpha( int ); + +extern int +iscntrl( int ); + +extern int +isdigit( int ); + +extern int +isgraph( int ); + +extern int +islower( int ); + +extern int +isprint( int ); + +extern int +ispunct( int ); + +extern int +isspace( int ); + +extern int +isupper( int ); + +extern int +isxdigit( int ); + +/*=========================================================================*/ + +/* 7.3.2 Character case mapping functions */ + +extern int +tolower( int ); + +extern int +toupper( int ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +#endif /* CYGONCE_ISO_CTYPE_H multiple inclusion protection */ + +/* EOF ctype.h */ diff --git a/packages/isoinfra/current/include/dirent.h b/packages/isoinfra/current/include/dirent.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/dirent.h @@ -0,0 +1,86 @@ +#ifndef CYGONCE_ISO_DIRENT_H +#define CYGONCE_ISO_DIRENT_H +/*======================================================================== +// +// dirent.h +// +// POSIX file control functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: +// Date: 2000-06-26 +// Purpose: This file provides the macros, types and functions +// for directory operations required by POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* INCLUDES */ + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if CYGINT_ISO_DIRENT +#ifdef CYGBLD_ISO_DIRENT_HEADER +# include CYGBLD_ISO_DIRENT_HEADER +#endif + +/* PROTOTYPES */ + +extern DIR *opendir( const char *dirname ); + +extern struct dirent *readdir( DIR *dirp ); + +extern int readdir_r( DIR *dirp, struct dirent *entry, struct dirent **result ); + +extern void rewinddir( DIR *dirp ); + +extern int closedir( DIR *dirp ); + +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* CYGONCE_ISO_DIRENT_H multiple inclusion protection */ + +/* EOF dirent.h */ diff --git a/packages/isoinfra/current/include/errno.h b/packages/isoinfra/current/include/errno.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/errno.h @@ -0,0 +1,67 @@ +#ifndef CYGONCE_ISO_ERRNO_H +#define CYGONCE_ISO_ERRNO_H +/*======================================================================== +// +// errno.h +// +// ISO errno variable and constants +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-07 +// Purpose: This file provides the errno variable (or more strictly +// expression) and the E* error codes required by ISO C +// and POSIX 1003.1 +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#if CYGINT_ISO_ERRNO_CODES +# include CYGBLD_ISO_ERRNO_CODES_HEADER +#endif + +#if CYGINT_ISO_ERRNO +# include CYGBLD_ISO_ERRNO_HEADER +#endif + +#endif /* CYGONCE_ISO_ERRNO_H multiple inclusion protection */ + +/* EOF errno.h */ diff --git a/packages/isoinfra/current/include/fcntl.h b/packages/isoinfra/current/include/fcntl.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/fcntl.h @@ -0,0 +1,160 @@ +#ifndef CYGONCE_ISO_FCNTL_H +#define CYGONCE_ISO_FCNTL_H +/*======================================================================== +// +// fcntl.h +// +// POSIX file control functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-05-05 +// Purpose: This file provides the macros, types and functions +// for file control required by POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#ifdef CYGBLD_ISO_OFLAG_HEADER +# include CYGBLD_ISO_OFLAG_HEADER +#else + +/* File access modes used for open() and fnctl() */ +#define O_RDONLY (1<<0) /* Open for reading only */ +#define O_WRONLY (1<<1) /* Open for writing only */ +#define O_RDWR (O_RDONLY|O_WRONLY) /* Open for reading and writing */ + +/* File access mode mask */ +#define O_ACCMODE (O_RDONLY|O_RDWR|O_WRONLY) + +/* open() mode flags */ + +#define O_CREAT (1<<3) /* Create file it it does not exist */ +#define O_EXCL (1<<4) /* Exclusive use */ +#define O_NOCTTY (1<<5) /* Do not assign a controlling terminal */ +#define O_TRUNC (1<<6) /* Truncate */ + +/* File status flags used for open() and fcntl() */ +#define O_APPEND (1<<7) /* Set append mode */ +#define O_DSYNC (1<<8) /* Synchronized I/O data integrity writes */ +#define O_NONBLOCK (1<<9) /* No delay */ +#define O_RSYNC (1<<10) /* Synchronized read I/O */ +#define O_SYNC (1<<11) /* Synchronized I/O file integrity writes */ + +#endif /* ifndef CYGBLD_ISO_OFLAG_HEADER */ + + +#if CYGINT_ISO_FCNTL +# ifdef CYGBLD_ISO_FCNTL_HEADER +# include CYGBLD_ISO_FCNTL_HEADER +# else + +/* fcntl() command values */ + +#define F_DUPFD (1<<0) /* Duplicate file descriptor */ +#define F_GETFD (1<<1) /* Get file descriptor flags */ +#define F_SETFD (1<<2) /* Set file descriptor flags */ +#define F_GETFL (1<<3) /* Get file status flags */ +#define F_SETFL (1<<4) /* Set file status flags */ +#define F_GETLK (1<<5) /* Get record locking information */ +#define F_SETLK (1<<6) /* Set record locking information */ +#define F_SETLKW (1<<7) /* Set record locking info; wait if blocked */ + +/* fd flags */ +#define FD_CLOEXEC (1<<0) /* Close fd on exec */ + +/* Lock types */ + +#define F_RDLCK (1<<0) /* Shared or read lock */ +#define F_UNLCK (1<<1) /* Unlock */ +#define F_WRLCK (1<<2) /* Exclusive or write lock */ + +#include /* off_t, pid_t */ + +struct flock { + short l_type; /* F_RDLCK, F_WRLCK, F_UNLCK */ + short l_whence; /* Flag for starting offset */ + off_t l_start; /* Relative offset in bytes */ + off_t l_len; /* Size; if 0, then until EOF */ + pid_t l_pid; /* Process ID of the process holding the lock, + * returned with F_GETLK. */ +}; + +#ifdef __cplusplus +extern "C" +#else +extern +#endif + +int +fcntl( int /* fildes */, int /* cmd */, ... ); + +# endif /* ifndef CYGBLD_ISO_FCNTL_HEADER */ +#endif /* if CYGINT_ISO_FCNTL */ + + +#if CYGINT_ISO_OPEN +# ifdef CYGBLD_ISO_OPEN_HEADER +# include CYGBLD_ISO_OPEN_HEADER +# else + +#ifdef __cplusplus +extern "C" { +#endif + +#include /* mode_t */ + +extern int +open( const char * /* path */, int /* oflag */, ... ); + +extern int +creat( const char * /* path */, mode_t /* mode */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif /* ifndef CYGBLD_ISO_OPEN_HEADER */ +#endif /* if CYGINT_ISO_OPEN */ + +#endif /* CYGONCE_ISO_FCNTL_H multiple inclusion protection */ + +/* EOF fcntl.h */ diff --git a/packages/isoinfra/current/include/float.h b/packages/isoinfra/current/include/float.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/float.h @@ -0,0 +1,61 @@ +#ifndef CYGONCE_ISO_FLOAT_H +#define CYGONCE_ISO_FLOAT_H +/*======================================================================== +// +// float.h +// +// ISO standard float-point properties +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the floating-point related properties +// required by ISO C +// Description: This file is really provided by the compiler, although in +// due course we may override things here. +// +// The main purpose of this file is as a comment to the FAQ +// about where float.h lives: it is provided by the compiler, +// which for current gcc can be found by looking in the +// include directory in the same place as the specs file +// which you can determine from TARGET-gcc -v, +// e.g. arm-elf-gcc -v +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +#include_next + +#endif /* CYGONCE_ISO_FLOAT_H multiple inclusion protection */ + +/* EOF float.h */ diff --git a/packages/isoinfra/current/include/limits.h b/packages/isoinfra/current/include/limits.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/limits.h @@ -0,0 +1,175 @@ +#ifndef CYGONCE_ISO_LIMITS_H +#define CYGONCE_ISO_LIMITS_H +/*======================================================================== +// +// limits.h +// +// ISO standard limits +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the limits properties +// required by ISO C and POSIX 1003.1 +// Description: The real contents of this file get set from the +// configuration (set by the implementation), as well as +// being partially provided by the compiler. +// +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* DEFINES */ + +/*----------------------------------------------------------------------------- + * Minimum values from POSIX.1 tables 2-3, 2-7 and 2-7a. + + * These are the standard-mandated minimum values. + * These values do not vary with the implementation - they may + * simply be defined + */ + +/* Minimum number of operations in one list I/O call. */ +#define _POSIX_AIO_LISTIO_MAX 2 + +/* Minimal number of outstanding asynchronous I/O operations. */ +#define _POSIX_AIO_MAX 1 + +/* Maximum length of arguments to `execve', including environment. */ +#define _POSIX_ARG_MAX 4096 + +/* Maximum simultaneous processes per real user ID. */ +#define _POSIX_CHILD_MAX 6 + +/* Minimal number of timer expiration overruns. */ +#define _POSIX_DELAYTIMER_MAX 32 + +/* Maximum link count of a file. */ +#define _POSIX_LINK_MAX 8 + +/* Size of storage required for a login name */ +#define _POSIX_LOGIN_NAME_MAX 9 + +/* Number of bytes in a terminal canonical input queue. */ +#define _POSIX_MAX_CANON 255 + +/* Number of bytes for which space will be + available in a terminal input queue. */ +#define _POSIX_MAX_INPUT 255 + +/* Maximum number of message queues open for a process. */ +#define _POSIX_MQ_OPEN_MAX 8 + +/* Maximum number of supported message priorities. */ +#define _POSIX_MQ_PRIO_MAX 32 + +/* Number of bytes in a filename. */ +#define _POSIX_NAME_MAX 14 + +/* Number of simultaneous supplementary group IDs per process. */ +#define _POSIX_NGROUPS_MAX 0 + +/* Number of files one process can have open at once. */ +#define _POSIX_OPEN_MAX 16 + +/* Number of bytes in a pathname. */ +#define _POSIX_PATH_MAX 255 + +/* Number of bytes than can be written atomically to a pipe. */ +#define _POSIX_PIPE_BUF 512 + +/* Minimal number of realtime signals reserved for the application. */ +#define _POSIX_RTSIG_MAX 8 + +/* Number of semaphores a process can have. */ +#define _POSIX_SEM_NSEMS_MAX 256 + +/* Maximal value of a semaphore. */ +#define _POSIX_SEM_VALUE_MAX 32767 + +/* Number of pending realtime signals. */ +#define _POSIX_SIGQUEUE_MAX 32 + +/* Largest value of a `ssize_t'. */ +#define _POSIX_SSIZE_MAX 32767 + +/* Number of streams a process can have open at once. */ +#define _POSIX_STREAM_MAX 8 + +/* Controlling the iterations of destructors for thread-specific data. */ +#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 + +/* The number of data keys per process. */ +#define _POSIX_THREAD_KEYS_MAX 128 + +/* The number of threads per process. */ +#define _POSIX_THREAD_THREADS_MAX 64 + +/* Maximum number of characters in a tty name. */ +#define _POSIX_TTY_NAME_MAX 9 + +/* Number of timer for a process. */ +#define _POSIX_TIMER_MAX 32 + +/* Maximum length of a timezone name (element of `tzname'). */ +#define _POSIX_TZNAME_MAX 3 + +/* Maximum clock resolution in nanoseconds. */ +#define _POSIX_CLOCKRES_MIN 20000000 + + +#ifdef CYGBLD_ISO_SSIZET_HEADER +# include CYGBLD_ISO_SSIZET_HEADER +#else +# ifndef __STRICT_ANSI__ +# define SSIZE_MAX LONG_MAX +# endif +#endif + +/* INCLUDES */ + +#if CYGINT_ISO_POSIX_LIMITS +# ifdef CYGBLD_ISO_POSIX_LIMITS_HEADER +# include CYGBLD_ISO_POSIX_LIMITS_HEADER +# endif +#endif + +#include_next + +#endif /* CYGONCE_ISO_LIMITS_H multiple inclusion protection */ + +/* EOF limits.h */ diff --git a/packages/isoinfra/current/include/locale.h b/packages/isoinfra/current/include/locale.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/locale.h @@ -0,0 +1,139 @@ +#ifndef CYGONCE_ISO_LOCALE_H +#define CYGONCE_ISO_LOCALE_H +/*======================================================================== +// +// locale.h +// +// ISO locale functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the locale functions required by +// ISO C and POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +/* This is the "standard" way to get NULL from stddef.h, + * which is the canonical location of the definitions. + */ +#define __need_NULL +#include + +#if CYGINT_ISO_LOCALE +# ifdef CYGBLD_ISO_LOCALE_HEADER +# include CYGBLD_ISO_LOCALE_HEADER +# else + +/* TYPE DEFINITIONS */ + +/* struct lconv contains information about numeric and monetary numbers + * and is described in the ISO C standard section 7.4 */ + +struct lconv { + + /* the following affect formatted NONMONETARY QUANTITIES only */ + char *decimal_point; /* decimal point */ + char *thousands_sep; /* separates groups of digits before decimal + point */ + char *grouping; /* string whose elements indicate the size */ + /* of each group of digits */ + + /* the following affect formatted MONETARY QUANTITIES only */ + char *int_curr_symbol; /* international curreny symbol */ + char *currency_symbol; /* local currency symbol */ + char *mon_decimal_point; /* decimal point */ + char *mon_thousands_sep; /* separator for groups of digits + before the decimal point */ + char *mon_grouping; /* string whose elements indicate the size + of each group of digits */ + char *positive_sign; /* string to indicate zero or positive value */ + char *negative_sign; /* string to indicate negative value */ + char int_frac_digits; /* number of digits after decimal point for + internationally formatted monetary nums */ + char frac_digits; /* number of digits after decimal point for + formatted monetary nums */ + char p_cs_precedes; /* 1 if currency_symbol precedes non-negative + monetary quantity. 0 if succeeds */ + char p_sep_by_space; /* 1 if currency_symbol separated from value + of non-negative monetary quantity by space. + Otherwise 0. */ + char n_cs_precedes; /* 1 if currency_symbol precedes negative + monetary quantity. 0 if succeeds */ + char n_sep_by_space; /* 1 if currency_symbol separated from value + of negative monetary quantity by space. + Otherwise 0. */ + char p_sign_posn; /* set according to position of positive_sign */ + char n_sign_posn; /* set according to position of negative_sign */ +}; + +/* CONSTANTS */ + +#define LC_COLLATE (1<<0) +#define LC_CTYPE (1<<1) +#define LC_MONETARY (1<<2) +#define LC_NUMERIC (1<<3) +#define LC_TIME (1<<4) +#define LC_ALL (LC_COLLATE|LC_CTYPE|LC_MONETARY|LC_NUMERIC|LC_TIME) + +/* FUNCTION PROTOTYPES */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern char * +setlocale( int /* category */, const char * /* locale */ ); + +extern struct lconv * +localeconv( void ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif /* #elif !defined(CYGBLD_ISO_LOCALE_HEADER) */ +#endif /* CYGINT_ISO_LOCALE */ + +#endif /* CYGONCE_ISO_LOCALE_H multiple inclusion protection */ + +/* EOF locale.h */ diff --git a/packages/isoinfra/current/include/mqueue.h b/packages/isoinfra/current/include/mqueue.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/mqueue.h @@ -0,0 +1,123 @@ +#ifndef CYGONCE_ISO_MQUEUE_H +#define CYGONCE_ISO_MQUEUE_H +/*======================================================================== +// +// mqueue.h +// +// POSIX message queue functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-05-05 +// Purpose: This file provides the macros, types and functions +// for message queues required by POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#ifdef _POSIX_MESSAGE_PASSING +# ifdef CYGBLD_ISO_MQUEUE_HEADER +# include CYGBLD_ISO_MQUEUE_HEADER +# else + +#include /* size_t and ssize_t */ + +/* TYPES */ + +struct mq_attr { + long mq_flags; /* mqueue flags */ + long mq_maxmsg; /* max number of messages */ + long mq_msgsize; /* max message size */ + long mq_curmsgs; /* number of messages currently queued */ +}; + +typedef void *mqd_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/* FUNCTIONS */ + +extern mqd_t +mq_open( const char * /* name */, int /* oflag */, ... ); + +extern int +mq_close( mqd_t /* mqdes */ ); + +extern int +mq_unlink( const char * /* name */ ); + +extern int +mq_send( mqd_t /* mqdes */, const char * /* msg_ptr */, size_t /* msg_len */, + unsigned int /* msg_prio */ ); + +extern ssize_t +mq_receive( mqd_t /* mqdes */, char * /* msg_ptr */, size_t /* msg_len */, + unsigned int * /* msg_prio */ ); + +#ifdef _POSIX_REALTIME_SIGNALS + +struct sigevent; + +extern int +mq_notify( mqd_t /* mqdes */, const struct sigevent * /* notification */ ); +#endif + +extern int +mq_setattr( mqd_t /* mqdes */, const struct mq_attr * /* mqstat */, + struct mq_attr * /* omqstat */ ); + +extern int +mq_getattr( mqd_t /* mqdes */, struct mq_attr * /* mqstat */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +# endif /* ifndef CYGBLD_ISO_MQUEUE_HEADER */ +#endif /* ifdef _POSIX_MESSAGE_PASSING */ + + +#endif /* CYGONCE_ISO_MQUEUE_H multiple inclusion protection */ + +/* EOF mqueue.h */ diff --git a/packages/isoinfra/current/include/pthread.h b/packages/isoinfra/current/include/pthread.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/pthread.h @@ -0,0 +1,65 @@ +#ifndef CYGONCE_ISO_PTHREAD_H +#define CYGONCE_ISO_PTHREAD_H +/*======================================================================== +// +// pthread.h +// +// POSIX pthread functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the macros, types and functions +// for pthreads required by POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#if CYGINT_ISO_PTHREAD_IMPL +# ifdef CYGBLD_ISO_PTHREAD_IMPL_HEADER +# include CYGBLD_ISO_PTHREAD_IMPL_HEADER +# endif +#endif + + +#endif /* CYGONCE_ISO_PTHREAD_H multiple inclusion protection */ + +/* EOF pthread.h */ diff --git a/packages/isoinfra/current/include/sched.h b/packages/isoinfra/current/include/sched.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/sched.h @@ -0,0 +1,116 @@ +#ifndef CYGONCE_ISO_SCHED_H +#define CYGONCE_ISO_SCHED_H +/*======================================================================== +// +// sched.h +// +// POSIX scheduler functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the scheduler macros, types and functions +// required by POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#include + +#if CYGINT_ISO_SCHED_IMPL +# ifdef CYGBLD_ISO_SCHED_IMPL_HEADER +# include CYGBLD_ISO_SCHED_IMPL_HEADER +# else + +//----------------------------------------------------------------------------- +// Scheduling Policys + +#define SCHED_OTHER 1 +#define SCHED_FIFO 2 +#define SCHED_RR 3 + +//----------------------------------------------------------------------------- +//Process scheduling functions. + +#ifdef __cplusplus +extern "C" { +#endif + +// Set scheduling parameters for given process. +extern int sched_setparam (pid_t pid, const struct sched_param *param); + +// Get scheduling parameters for given process. +extern int sched_getparam (pid_t pid, struct sched_param *param); + +// Set scheduling policy and/or parameters for given process. +extern int sched_setscheduler (pid_t pid, + int policy, + const struct sched_param *param); + +// Get scheduling policy for given process. +extern int sched_getscheduler (pid_t pid); + +// Force current thread to relinquish the processor. +extern int sched_yield (void); + +//----------------------------------------------------------------------------- +// Scheduler parameter limits. + +// Get maximum priority value for a policy. +extern int sched_get_priority_max (int policy); + +// Get minimum priority value for a policy. +extern int sched_get_priority_min (int policy); + +// Get the SCHED_RR interval for the given process. +extern int sched_rr_get_interval (pid_t pid, struct timespec *t); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif + +#endif /* if CYGINT_ISO_SCHED_IMPL */ + +#endif /* CYGONCE_ISO_SCHED_H multiple inclusion protection */ + +/* EOF sched.h */ diff --git a/packages/isoinfra/current/include/semaphore.h b/packages/isoinfra/current/include/semaphore.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/semaphore.h @@ -0,0 +1,64 @@ +#ifndef CYGONCE_ISO_SEMAPHORE_H +#define CYGONCE_ISO_SEMAPHORE_H +/*======================================================================== +// +// semaphore.h +// +// POSIX semaphore functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the semaphor macros, types and functions +// required by POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#ifdef _POSIX_SEMAPHORES +# ifdef CYGBLD_ISO_SEMAPHORES_HEADER +# include CYGBLD_ISO_SEMAPHORES_HEADER +# endif +#endif + +#endif /* CYGONCE_ISO_SEMAPHORE_H multiple inclusion protection */ + +/* EOF semaphore.h */ diff --git a/packages/isoinfra/current/include/setjmp.h b/packages/isoinfra/current/include/setjmp.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/setjmp.h @@ -0,0 +1,66 @@ +#ifndef CYGONCE_ISO_SETJMP_H +#define CYGONCE_ISO_SETJMP_H +/*======================================================================== +// +// setjmp.h +// +// ISO non-local jump functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the setjmp macros, types and functions +// required by ISO C and POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#if CYGINT_ISO_SETJMP +# include CYGBLD_ISO_SETJMP_HEADER +#endif + +#if CYGINT_ISO_SIGSETJMP +# include CYGBLD_ISO_SIGSETJMP_HEADER +#endif + +#endif /* CYGONCE_ISO_SETJMP_H multiple inclusion protection */ + +/* EOF setjmp.h */ diff --git a/packages/isoinfra/current/include/signal.h b/packages/isoinfra/current/include/signal.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/signal.h @@ -0,0 +1,67 @@ +#ifndef CYGONCE_ISO_SIGNAL_H +#define CYGONCE_ISO_SIGNAL_H +/*======================================================================== +// +// signal.h +// +// ISO signal functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the signal macros, types and functions +// required by ISO C and POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#if CYGINT_ISO_SIGNAL_NUMBERS +# include CYGBLD_ISO_SIGNAL_NUMBERS_HEADER +#endif + +#if CYGINT_ISO_SIGNAL_IMPL +# include CYGBLD_ISO_SIGNAL_IMPL_HEADER +#endif + + +#endif /* CYGONCE_ISO_SIGNAL_H multiple inclusion protection */ + +/* EOF signal.h */ diff --git a/packages/isoinfra/current/include/stdarg.h b/packages/isoinfra/current/include/stdarg.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/stdarg.h @@ -0,0 +1,61 @@ +#ifndef CYGONCE_ISO_STDARG_H +#define CYGONCE_ISO_STDARG_H +/*======================================================================== +// +// stdarg.h +// +// ISO standard variable argument functionality +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the variable argument macros required +// by ISO C +// Description: This file is really provided by the compiler, although in +// due course we may override things here. +// +// The main purpose of this file is as a comment to the FAQ +// about where stdarg.h lives: it is provided by the compiler, +// which for current gcc can be found by looking in the +// include directory in the same place as the specs file +// which you can determine from TARGET-gcc -v, +// e.g. arm-elf-gcc -v +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +#include_next + +#endif /* CYGONCE_ISO_STDARG_H multiple inclusion protection */ + +/* EOF stdarg.h */ diff --git a/packages/isoinfra/current/include/stddef.h b/packages/isoinfra/current/include/stddef.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/stddef.h @@ -0,0 +1,60 @@ +#ifndef CYGONCE_ISO_STDDEF_H +#define CYGONCE_ISO_STDDEF_H +/*======================================================================== +// +// stddef.h +// +// ISO standard defines +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the standard defines required by ISO C +// Description: This file is really provided by the compiler, although in +// due course we may override things here. +// +// The main purpose of this file is as a comment to the FAQ +// about where stddef.h lives: it is provided by the compiler, +// which for current gcc can be found by looking in the +// include directory in the same place as the specs file +// which you can determine from TARGET-gcc -v, +// e.g. arm-elf-gcc -v +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +#include_next + +#endif /* CYGONCE_ISO_STDDEF_H multiple inclusion protection */ + +/* EOF stddef.h */ diff --git a/packages/isoinfra/current/include/stdio.h b/packages/isoinfra/current/include/stdio.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/stdio.h @@ -0,0 +1,113 @@ +#ifndef CYGONCE_ISO_STDIO_H +#define CYGONCE_ISO_STDIO_H +/*======================================================================== +// +// stdio.h +// +// ISO standard I/O functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the stdio functions required by +// ISO C and POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +/* This is the "standard" way to get NULL and size_t from stddef.h, + * which is the canonical location of the definitions. + */ +#define __need_NULL +#define __need_size_t +#include + +#if CYGINT_ISO_STDIO_FILETYPES +# ifdef CYGBLD_ISO_STDIO_FILETYPES_HEADER +# include CYGBLD_ISO_STDIO_FILETYPES_HEADER +# endif +#endif + +#if CYGINT_ISO_STDIO_FILEOPS +# ifdef CYGBLD_ISO_STDIO_FILEOPS_HEADER +# include CYGBLD_ISO_STDIO_FILEOPS_HEADER +# endif +#endif + +#if CYGINT_ISO_STDIO_FILEACCESS +# ifdef CYGBLD_ISO_STDIO_FILEACCESS_HEADER +# include CYGBLD_ISO_STDIO_FILEACCESS_HEADER +# endif +#endif + +#if CYGINT_ISO_STDIO_FORMATTED_IO +# ifdef CYGBLD_ISO_STDIO_FORMATTED_IO_HEADER +# include CYGBLD_ISO_STDIO_FORMATTED_IO_HEADER +# endif +#endif + +#if CYGINT_ISO_STDIO_CHAR_IO +# ifdef CYGBLD_ISO_STDIO_CHAR_IO_HEADER +# include CYGBLD_ISO_STDIO_CHAR_IO_HEADER +# endif +#endif + +#if CYGINT_ISO_STDIO_DIRECT_IO +# ifdef CYGBLD_ISO_STDIO_DIRECT_IO_HEADER +# include CYGBLD_ISO_STDIO_DIRECT_IO_HEADER +# endif +#endif + +#if CYGINT_ISO_STDIO_FILEPOS +# ifdef CYGBLD_ISO_STDIO_FILEPOS_HEADER +# include CYGBLD_ISO_STDIO_FILEPOS_HEADER +# endif +#endif + +#if CYGINT_ISO_STDIO_ERROR +# ifdef CYGBLD_ISO_STDIO_ERROR_HEADER +# include CYGBLD_ISO_STDIO_ERROR_HEADER +# endif +#endif + +#endif /* CYGONCE_ISO_STDIO_H multiple inclusion protection */ + +/* EOF stdio.h */ diff --git a/packages/isoinfra/current/include/stdlib.h b/packages/isoinfra/current/include/stdlib.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/stdlib.h @@ -0,0 +1,493 @@ +#ifndef CYGONCE_ISO_STDLIB_H +#define CYGONCE_ISO_STDLIB_H +/*======================================================================== +// +// stdlib.h +// +// ISO standard library functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the stdlib functions required by +// ISO C and POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +/* This is the "standard" way to get NULL, wchar_t and size_t from stddef.h, + * which is the canonical location of the definitions. + */ +#define __need_NULL +#define __need_size_t +#define __need_wchar_t +#include + +/*==========================================================================*/ + +#if CYGINT_ISO_STDLIB_STRCONV +# ifdef CYGBLD_ISO_STDLIB_STRCONV_HEADER +# include CYGBLD_ISO_STDLIB_STRCONV_HEADER +# else + +/* ISO C 7.10.1 - String conversion functions */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int +atoi( const char * /* int_str */ ); + +extern long +atol( const char * /* long_str */ ); + +extern long +strtol( const char * /* long_str */, char ** /* endptr */, + int /* base */ ); + +extern unsigned long +strtoul( const char * /* ulong_str */, char ** /* endptr */, + int /* base */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +# endif +#endif + +/*==========================================================================*/ + +#if CYGINT_ISO_STDLIB_STRCONV_FLOAT +# ifdef CYGBLD_ISO_STDLIB_STRCONV_FLOAT_HEADER +# include CYGBLD_ISO_STDLIB_STRCONV_FLOAT_HEADER +# else + +/* ISO C 7.10.1 - String conversion functions */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern double +atof( const char * /* double_str */ ); + +extern double +strtod( const char * /* double_str */, char ** /* endptr */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +# endif +#endif + +/*==========================================================================*/ + +#if CYGINT_ISO_RAND +# ifdef CYGBLD_ISO_RAND_HEADER +# include CYGBLD_ISO_RAND_HEADER +# else + +/* ISO C 7.10.2 - Pseudo-random sequence generation functions */ + +/* Maximum value returned by rand(). */ +#define RAND_MAX 2147483647 + +#ifdef __cplusplus +extern "C" { +#endif + +extern int +rand( void ); + +extern void +srand( unsigned int /* seed */ ); + +/* POSIX 1003.1 section 8.3.8 rand_r() */ +extern int +rand_r( unsigned int * /* seed */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +/*==========================================================================*/ + +#if CYGINT_ISO_MALLOC +# ifdef CYGBLD_ISO_MALLOC_HEADER +# include CYGBLD_ISO_MALLOC_HEADER +# else + +/* ISO C 7.10.3 - Memory management functions */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern void * +calloc( size_t /* num_objects */, size_t /* object_size */ ); + +extern void +free( void * /* ptr */ ); + +extern void * +malloc( size_t /* size */ ); + +extern void * +realloc( void * /* ptr */, size_t /* size */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +/*==========================================================================*/ + +#if CYGINT_ISO_MALLINFO +# ifdef CYGBLD_ISO_MALLINFO_HEADER +# include CYGBLD_ISO_MALLINFO_HEADER +# else + +#ifdef __cplusplus +extern "C" { +#endif + +/* SVID2/XPG mallinfo structure */ + +struct mallinfo { + int arena; /* total size of memory arena */ + int ordblks; /* number of ordinary memory blocks */ + int smblks; /* number of small memory blocks */ + int hblks; /* number of mmapped regions */ + int hblkhd; /* total space in mmapped regions */ + int usmblks; /* space used by small memory blocks */ + int fsmblks; /* space available for small memory blocks */ + int uordblks; /* space used by ordinary memory blocks */ + int fordblks; /* space free for ordinary blocks */ + int keepcost; /* top-most, releasable (via malloc_trim) space */ + int maxfree; /* (NON-STANDARD EXTENSION) size of largest free block */ +}; + +extern struct mallinfo +mallinfo( void ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +/*==========================================================================*/ + +#if CYGINT_ISO_EXIT +# ifdef CYGBLD_ISO_EXIT_HEADER +# include CYGBLD_ISO_EXIT_HEADER +# else + +/* ISO C 7.10.4 - Communication with the environment */ + +/* codes to pass to exit() */ + +/* Successful exit status - must be zero (POSIX 1003.1 8.1) */ +#define EXIT_SUCCESS 0 +/* Failing exit status - must be non-zero (POSIX 1003.1 8.1) */ +#define EXIT_FAILURE 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* Type of function used by atexit() */ +typedef void (*__atexit_fn_t)( void ); + +extern void +abort( void ) __attribute__((__noreturn__)); + +extern int +atexit( __atexit_fn_t /* func_to_register */ ); + +extern void +exit( int /* status */ ) __attribute__((__noreturn__)); + +/* POSIX 1003.1 section 3.2.2 "Terminate a process" */ + +//@@@ FIXME unistd.h +extern void +_exit( int /* status */ ) __attribute__((__noreturn__)); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +/*==========================================================================*/ + +#if CYGINT_ISO_STDLIB_ENVIRON +# ifdef CYGBLD_ISO_STDLIB_ENVIRON_HEADER +# include CYGBLD_ISO_STDLIB_ENVIRON_HEADER +# else + +/* ISO C 7.10.4 - Communication with the environment */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _POSIX_SOURCE + +extern char **environ; /* standard definition of environ */ + +#endif + +extern char * +getenv( const char * /* name */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +/*==========================================================================*/ + +#if CYGINT_ISO_STDLIB_SYSTEM +# ifdef CYGBLD_ISO_STDLIB_SYSTEM_HEADER +# include CYGBLD_ISO_STDLIB_SYSTEM_HEADER +# else + +/* ISO C 7.10.4 - Communication with the environment */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int +system( const char * /* command */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +/*==========================================================================*/ + +#if CYGINT_ISO_BSEARCH +# ifdef CYGBLD_ISO_BSEARCH_HEADER +# include CYGBLD_ISO_BSEARCH_HEADER +# else + +/* ISO C 7.10.5 - Searching and sorting utilities */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int (*__bsearch_comparison_fn_t)(const void * /* object1 */, + const void * /* object2 */); + +extern void * +bsearch( const void * /* search_key */, const void * /* first_object */, + size_t /* num_objects */, size_t /* object_size */, + __bsearch_comparison_fn_t /* comparison_fn */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +/*==========================================================================*/ + +#if CYGINT_ISO_QSORT +# ifdef CYGBLD_ISO_QSORT_HEADER +# include CYGBLD_ISO_QSORT_HEADER +# else + +/* ISO C 7.10.5 - Searching and sorting utilities */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int (*__qsort_comparison_fn_t)(const void * /* object1 */, + const void * /* object2 */); + +extern void +qsort( void * /* first_object */, size_t /* num_objects */, + size_t /* object_size */, __qsort_comparison_fn_t /* comparison_fn */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +/*======================================================================*/ + +#if CYGINT_ISO_ABS +# ifdef CYGBLD_ISO_ABS_HEADER +# include CYGBLD_ISO_ABS_HEADER +# else + +/* TYPE DEFINITIONS */ + +/* ISO C 7.10 and 7.10.6 - Integer Arithmetic Functions */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int +abs( int /* val */ ) __attribute__((__const__)); + +extern long +labs( long /* val */ ) __attribute__((__const__)); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +/*======================================================================*/ + +#if CYGINT_ISO_DIV +# ifdef CYGBLD_ISO_DIV_HEADER +# include CYGBLD_ISO_DIV_HEADER +# else + +/* ISO C 7.10 and 7.10.6 - Integer Arithmetic Functions */ + +/* return type of the div() function */ + +typedef struct { + int quot; /* quotient */ + int rem; /* remainder */ +} div_t; + + +/* return type of the ldiv() function */ + +typedef struct { + long quot; /* quotient */ + long rem; /* remainder */ +} ldiv_t; + +#ifdef __cplusplus +extern "C" { +#endif + +extern div_t +div( int /* numerator */, int /* denominator */ ) __attribute__((__const__)); + +extern ldiv_t +ldiv( long /* numerator */, long /* denominator */ ) __attribute__((__const__)); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +/*==========================================================================*/ + +#if CYGINT_ISO_STDLIB_MULTIBYTE +# ifdef CYGBLD_ISO_STDLIB_MULTIBYTE_HEADER +# include CYGBLD_ISO_STDLIB_MULTIBYTE_HEADER +# else + +/* Maximum number of bytes in a multibyte character for the current locale */ + +#define MB_CUR_MAX 1 + +/* ISO C 7.10.7 - Multibyte character functions */ + + +#ifdef __cplusplus +extern "C" { +#endif + +extern int +mblen( const char * /* s */, size_t /* n */ ); + +extern int +mbtowc( wchar_t * /* pwc */, const char * /* s */, size_t /* n */ ); + +extern int +wctomb( char * /* s */, wchar_t /* wchar */ ); + +extern size_t +mbstowcs( wchar_t * /* pwcs */, const char * /* s */, size_t /* n */ ); + +extern size_t +wcstombs( char * /* s */, const wchar_t * /* pwcs */, size_t /* n */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif +#endif + +/*==========================================================================*/ + +#endif /* CYGONCE_ISO_STDLIB_H multiple inclusion protection */ + +/* EOF stdlib.h */ diff --git a/packages/isoinfra/current/include/string.h b/packages/isoinfra/current/include/string.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/string.h @@ -0,0 +1,121 @@ +#ifndef CYGONCE_ISO_STRING_H +#define CYGONCE_ISO_STRING_H +/*======================================================================== +// +// string.h +// +// ISO string functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the string macros, types and functions +// required by ISO C and POSIX 1003.1. It may also provide +// other compatibility functions like BSD-style string +// functions +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +/* This is the "standard" way to get NULL and size_t from stddef.h, + * which is the canonical location of the definitions. + */ +#define __need_NULL +#define __need_size_t +#include + +#if CYGINT_ISO_STRERROR +# include CYGBLD_ISO_STRERROR_HEADER +#endif + +/* memcpy() and memset() are special as they are used internally by + * the compiler, so they *must* exist. So if no-one claims to implement + * them, prototype them anyway */ + +#ifdef CYGBLD_ISO_MEMCPY_HEADER +# include CYGBLD_ISO_MEMCPY_HEADER +#else + +extern +# ifdef __cplusplus +"C" +# endif +void * +memcpy( void *, const void *, size_t ); + +#endif + +#ifdef CYGBLD_ISO_MEMSET_HEADER +# include CYGBLD_ISO_MEMSET_HEADER +#else + +extern +# ifdef __cplusplus +"C" +# endif +void * +memset( void *, int, size_t ); + +#endif + +#if CYGINT_ISO_STRTOK_R +# include CYGBLD_ISO_STRTOK_R_HEADER +#endif + +#if CYGINT_ISO_STRING_LOCALE_FUNCS +# include CYGBLD_ISO_STRING_LOCALE_FUNCS_HEADER +#endif + +#if CYGINT_ISO_STRING_BSD_FUNCS +# include CYGBLD_ISO_STRING_BSD_FUNCS_HEADER +#endif + +#if CYGINT_ISO_STRING_MEMFUNCS +# include CYGBLD_ISO_STRING_MEMFUNCS_HEADER +#endif + +#if CYGINT_ISO_STRING_STRFUNCS +# include CYGBLD_ISO_STRING_STRFUNCS_HEADER +#endif + +#endif /* CYGONCE_ISO_STRING_H multiple inclusion protection */ + +/* EOF string.h */ diff --git a/packages/isoinfra/current/include/sys/stat.h b/packages/isoinfra/current/include/sys/stat.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/sys/stat.h @@ -0,0 +1,127 @@ +#ifndef CYGONCE_ISO_STAT_H +#define CYGONCE_ISO_STAT_H +/*======================================================================== +// +// stat.h +// +// POSIX file characteristics +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-05-08 +// Purpose: This file provides the macros, types and functions +// for file characteristics required by POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#ifdef CYGBLD_ISO_STAT_DEFS_HEADER +# include CYGBLD_ISO_STAT_DEFS_HEADER +#else + +#include /* ino_t, dev_t, etc. */ +#include /* time_t */ + +#define __stat_mode_DIR (1<<0) +#define __stat_mode_CHR (1<<1) +#define __stat_mode_BLK (1<<2) +#define __stat_mode_REG (1<<3) +#define __stat_mode_FIFO (1<<4) +#define __stat_mode_MQ (1<<5) +#define __stat_mode_SEM (1<<6) +#define __stat_mode_SHM (1<<7) + +#define S_ISDIR(__mode) ((__mode) & __stat_mode_DIR ) +#define S_ISCHR(__mode) ((__mode) & __stat_mode_CHR ) +#define S_ISBLK(__mode) ((__mode) & __stat_mode_BLK ) +#define S_ISREG(__mode) ((__mode) & __stat_mode_REG ) +#define S_ISFIFO(__mode) ((__mode) & __stat_mode_FIFO ) + +#define S_TYPEISMQ(__buf) ((__buf)->st_mode & __stat_mode_MQ ) +#define S_TYPEISSEM(__buf) ((__buf)->st_mode & __stat_mode_SEM ) +#define S_TYPEISSHM(__buf) ((__buf)->st_mode & __stat_mode_SHM ) + + +#define S_IRUSR (1<<8) +#define S_IWUSR (1<<9) +#define S_IXUSR (1<<10) +#define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR) + +#define S_IRGRP (1<<11) +#define S_IWGRP (1<<12) +#define S_IXGRP (1<<13) +#define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP) + +#define S_IROTH (1<<14) +#define S_IWOTH (1<<15) +#define S_IXOTH (1<<16) +#define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH) + +#define S_ISUID (1<<17) +#define S_ISGID (1<<18) + + +struct stat { + mode_t st_mode; /* File mode */ + ino_t st_ino; /* File serial number */ + dev_t st_dev; /* ID of device containing file */ + nlink_t st_nlink; /* Number of hard links */ + uid_t st_uid; /* User ID of the file owner */ + gid_t st_gid; /* Group ID of the file's group */ + off_t st_size; /* File size (regular files only) */ + time_t st_atime; /* Last access time */ + time_t st_mtime; /* Last data modification time */ + time_t st_ctime; /* Last file status change time */ +}; + +#endif /* ifndef CYGBLD_ISO_STAT_DEFS_HEADER */ + +/* PROTOTYPES */ + +__externC int stat( const char *path, struct stat *buf ); + +__externC int fstat( int fd, struct stat *buf ); + +__externC int mkdir(const char *path, mode_t mode); + +#endif /* CYGONCE_ISO_STAT_H multiple inclusion protection */ + +/* EOF stat.h */ diff --git a/packages/isoinfra/current/include/sys/types.h b/packages/isoinfra/current/include/sys/types.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/sys/types.h @@ -0,0 +1,145 @@ +#ifndef CYGONCE_ISO_SYS_TYPES_H +#define CYGONCE_ISO_SYS_TYPES_H +/*======================================================================== +// +// sys/types.h +// +// POSIX types +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides various types required by POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include +#include /* Configuration header */ + +/* INCLUDES */ + +/* This is the "standard" way to get size_t from stddef.h, + * which is the canonical location of the definition. + */ +#define __need_size_t +#include + +#ifdef CYGBLD_ISO_SSIZET_HEADER +# include CYGBLD_ISO_SSIZET_HEADER +#else +typedef long ssize_t; +#endif + +#ifdef CYGBLD_ISO_FSTYPES_HEADER +# include CYGBLD_ISO_FSTYPES_HEADER +#else +typedef short dev_t; +typedef unsigned int ino_t; +typedef unsigned int mode_t; +typedef unsigned short nlink_t; +typedef unsigned long off_t; +#endif + +#ifdef CYGBLD_ISO_SCHEDTYPES_HEADER +# include CYGBLD_ISO_SCHEDTYPES_HEADER +#else +typedef unsigned short gid_t; +typedef unsigned short uid_t; +typedef unsigned int pid_t; +#endif + +#if CYGINT_ISO_PTHREADTYPES +# include CYGBLD_ISO_PTHREADTYPES_HEADER +#endif + +#if !defined(_POSIX_SOURCE) + +#define NBBY 8 /* number of bits in a byte */ + +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). + * FD_SETSIZE may be defined by the user, but the default here should + * be enough for most uses. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE 256 +#endif + +typedef unsigned int fd_mask; +#define __NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ + +#ifndef __howmany +#define __howmany(x, y) (((x) + ((y) - 1)) / (y)) +#endif + +typedef struct fd_set { + fd_mask fds_bits[__howmany(FD_SETSIZE, __NFDBITS)]; +} fd_set; + +#define FD_SET(n, p) ((p)->fds_bits[(n)/__NFDBITS] |= (1 << ((n) % __NFDBITS))) +#define FD_CLR(n, p) ((p)->fds_bits[(n)/__NFDBITS] &= ~(1 << ((n) % __NFDBITS))) +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/__NFDBITS] & (1 << ((n) % __NFDBITS))) + +#define FD_COPY(f, t) \ +{ \ + unsigned int _i; \ + for( _i = 0; _i < __howmany(FD_SETSIZE, __NFDBITS) ; _i++ ) \ + (t)->fds_bits[_i] = (f)->fds_bits[_i]; \ +} + +#define FD_ZERO(p) \ +{ \ + unsigned int _i; \ + for( _i = 0; _i < __howmany(FD_SETSIZE, __NFDBITS) ; _i++ ) \ + (p)->fds_bits[_i] = 0; \ +} + +#define CYG_FD_SET_DEFINED 1 + +#if CYGINT_ISO_BSDTYPES +# ifdef CYGBLD_ISO_BSDTYPES_HEADER +# include CYGBLD_ISO_BSDTYPES_HEADER +# endif +#endif + +#endif // !defined(_POSIX_SOURCE) + +#endif /* CYGONCE_ISO_SYS_TYPES_H multiple inclusion protection */ + +/* EOF sys/types.h */ diff --git a/packages/isoinfra/current/include/sys/utsname.h b/packages/isoinfra/current/include/sys/utsname.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/sys/utsname.h @@ -0,0 +1,60 @@ +#ifndef CYGONCE_ISO_SYS_UTSNAME_H +#define CYGONCE_ISO_SYS_UTSNAME_H +/*======================================================================== +// +// sys/utsname.h +// +// POSIX utsname header +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the utsname struct required by POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include +#include /* Configuration header */ + +#ifdef CYGBLD_ISO_UTSNAME_HEADER +# include CYGBLD_ISO_UTSNAME_HEADER +#endif + +#endif /* CYGONCE_ISO_SYS_UTSNAME_H multiple inclusion protection */ + +/* EOF sys/utsname.h */ diff --git a/packages/isoinfra/current/include/termios.h b/packages/isoinfra/current/include/termios.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/termios.h @@ -0,0 +1,243 @@ +#ifndef CYGONCE_ISO_TERMIOS_H +#define CYGONCE_ISO_TERMIOS_H +/* ==================================================================== +// +// termios.h +// +// POSIX termios +// +// ==================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +// ==================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-07-22 +// Purpose: POSIX termios support +// Description: +// +//####DESCRIPTIONEND#### +// +// ==================================================================*/ + +#include + +#if CYGINT_ISO_TERMIOS +# ifdef CYGBLD_ISO_TERMIOS_HEADER +# include CYGBLD_ISO_TERMIOS_HEADER +# else + +/* TYPES */ + +typedef unsigned int tcflag_t; /* terminal flags type */ +typedef unsigned char cc_t; /* control chars type */ +typedef unsigned int speed_t; /* baud rate type */ + +#define NCCS 16 /* May as well hard-code - ASCII isn't that configurable! */ + +struct termios { + tcflag_t c_iflag; /* Input mode flags */ + tcflag_t c_oflag; /* Output mode flags */ + tcflag_t c_cflag; /* Control mode flags */ + tcflag_t c_lflag; /* Local mode flags */ + cc_t c_cc[NCCS]; /* Control characters */ + speed_t c_ispeed; /* input speed */ + speed_t c_ospeed; /* output speed */ +}; + +/* CONSTANTS */ + +/* Input mode flags */ + +#define BRKINT (1<<0) +#define ICRNL (1<<1) +#define IGNBRK (1<<2) +#define IGNCR (1<<3) +#define IGNPAR (1<<4) +#define INLCR (1<<5) +#define INPCK (1<<6) +#define ISTRIP (1<<7) +#define IXOFF (1<<8) +#define IXON (1<<9) +#define PARMRK (1<<10) + +/* Output mode flags */ + +#define OPOST (1<<0) +#define ONLCR (1<<1) /* Note: This isn't POSIX */ + +/* Control mode flags */ + +#define CLOCAL (1<<0) +#define CREAD (1<<1) +#define CS5 (0) +#define CS6 (1<<2) +#define CS7 (1<<3) +#define CS8 (CS6|CS7) +#define CSIZE (CS8) +#define CSTOPB (1<<4) +#define HUPCL (1<<5) +#define PARENB (1<<6) +#define PARODD (1<<7) +#ifndef _POSIX_SOURCE_ +# define CRTSCTS (1<<8) +#endif + +/* Local mode flags */ + +#define ECHO (1<<0) +#define ECHOE (1<<1) +#define ECHOK (1<<2) +#define ECHONL (1<<3) +#define ICANON (1<<4) +#define IEXTEN (1<<5) +#define ISIG (1<<6) +#define NOFLSH (1<<7) +#define TOSTOP (1<<8) + +/* Special control characters */ + +#define VEOF 0 +#define VEOL 1 +#define VERASE 2 +#define VINTR 3 +#define VKILL 4 +#define VMIN 5 +#define VQUIT 6 +#define VSUSP 7 +#define VTIME 8 +#define VSTART 9 +#define VSTOP 10 + +/* Baud rates */ +/* There may be tables in the implementation that rely on the + * values here, so only append to this table - do not insert values! + */ +#define B0 0 +#define B50 1 +#define B75 2 +#define B110 3 +#define B134 4 +#define B150 5 +#define B200 6 +#define B300 7 +#define B600 8 +#define B1200 9 +#define B1800 10 +#define B2400 11 +#define B3600 12 +#define B4800 13 +#define B7200 14 +#define B9600 15 +#define B14400 16 +#define B19200 17 +#define B38400 18 +#define B57600 19 +#define B115200 20 +#define B230400 21 +#define B460800 22 +#define B500000 23 +#define B576000 24 +#define B921600 25 +#define B1000000 26 +#define B1152000 27 +#define B1500000 28 +#define B2000000 29 +#define B2500000 30 +#define B3000000 31 +#define B3500000 32 +#define B4000000 33 + + +/* Optional actions to tcsetattr() */ + +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +/* Queue selectors for tcflush() */ + +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* Actions for tcflow() */ + +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + + +/* FUNCTIONS */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern speed_t +cfgetospeed( const struct termios *__termios_p ); + +extern int +cfsetospeed( struct termios *__termios_p, speed_t __speed ); + +extern speed_t +cfgetispeed( const struct termios *__termios_p ); + +extern int +cfsetispeed( struct termios *__termios_p, speed_t __speed ); + +extern int +tcgetattr( int __fildes, struct termios *__termios_p ); + +extern int +tcsetattr( int __fildes, int __optact, const struct termios *__termios_p ); + +extern int +tcsendbreak( int __fildes, int __duration ); + +extern int +tcdrain( int __fildes ); + +extern int +tcflush( int __fildes, int __queue_sel ); + +extern int +tcflow( int __fildes, int __action ); + +/* tcgetpgrp() and tcsetpgrp() not included in the absence of job control */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +# endif /* ifndef CYGBLD_ISO_TERMIOS_HEADER */ +#endif /* if CYGINT_ISO_TERMIOS */ + + +#endif /* ifndef CYGONCE_ISO_TERMIOS_H */ + +/* EOF termios.h */ diff --git a/packages/isoinfra/current/include/time.h b/packages/isoinfra/current/include/time.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/time.h @@ -0,0 +1,133 @@ +#ifndef CYGONCE_ISO_TIME_H +#define CYGONCE_ISO_TIME_H +/*======================================================================== +// +// time.h +// +// ISO time functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides the time macros, types and functions +// required by ISO C and POSIX 1003.1. +// Description: The real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +/* This is the "standard" way to get NULL and size_t from stddef.h, + * which is the canonical location of the definitions. + */ +#define __need_NULL +#define __need_size_t +#include + +#ifdef CYGBLD_ISO_TIME_T_HEADER +# include CYGBLD_ISO_TIME_T_HEADER +#else + +/* Define time_t as per ISO C para 7.12.1 + * It is conventionally given the meaning of seconds since the + * Epoch (00:00:00 GMT, 1970-01-01), but don't rely on this - always use + * the type opaquely + */ +typedef int time_t; +# define __time_t_defined + +#endif + +#ifdef CYGBLD_ISO_CLOCK_T_HEADER +# include CYGBLD_ISO_CLOCK_T_HEADER +#else + +/* What to divide clock_t by to get seconds (para 7.12.1) + * According to SUS3, CLOCKS_PER_SEC must be 1 million on all + * XSI-conformant systems. + */ +# define CLOCKS_PER_SEC 1000000 + +/* Define clock_t as per ISO C para 7.12.1 */ + +typedef long clock_t; +# define __clock_t_defined +#endif + +#ifdef CYGBLD_ISO_STRUCTTIMEVAL_HEADER +# include CYGBLD_ISO_STRUCTTIMEVAL_HEADER +#else +# ifndef _POSIX_SOURCE + +/* + * Structure returned by gettimeofday(2), + * and used in other calls such as select(2). + */ +struct timeval { + long tv_sec; /* seconds */ + long tv_usec; /* and microseconds */ +}; + +# endif /* _POSIX_SOURCE */ +#endif + + +#if CYGINT_ISO_POSIX_TIMER_TYPES +# include CYGBLD_ISO_POSIX_TIMER_TYPES_HEADER +#endif + +#if CYGINT_ISO_C_TIME_TYPES +# include CYGBLD_ISO_C_TIME_TYPES_HEADER +#endif + +#if CYGINT_ISO_POSIX_TIMERS +# include CYGBLD_ISO_POSIX_TIMERS_HEADER +#endif + +#if CYGINT_ISO_C_CLOCK_FUNCS +# include CYGBLD_ISO_C_CLOCK_FUNCS_HEADER +#endif + +#if CYGINT_ISO_TZSET +# include CYGBLD_ISO_TZSET_HEADER +#endif + +#endif /* CYGONCE_ISO_TIME_H multiple inclusion protection */ + +/* EOF time.h */ diff --git a/packages/isoinfra/current/include/unistd.h b/packages/isoinfra/current/include/unistd.h new file mode 100644 --- /dev/null +++ b/packages/isoinfra/current/include/unistd.h @@ -0,0 +1,221 @@ +#ifndef CYGONCE_ISO_UNISTD_H +#define CYGONCE_ISO_UNISTD_H +/*======================================================================== +// +// unistd.h +// +// POSIX UNIX standard definitions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: +// Date: 2000-06-01 +// Purpose: This file provides the macros, types and functions +// required by POSIX 1003.1. +// Description: Much of the real contents of this file get set from the +// configuration (set by the implementation) +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#include + +/* This is the "standard" way to get NULL and size_t from stddef.h, + * which is the canonical location of the definitions. + */ +#define __need_NULL +#define __need_size_t +#include + +/* CONSTANTS */ + +/* Configuration constants */ + +#define _POSIX_VERSION 199506L + +/* constants for access() */ +#define R_OK 1 +#define W_OK 2 +#define X_OK 4 +#define F_OK 8 + +/* constants for lseek */ +#ifndef SEEK_SET +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +/* Variable names for sysconf() */ +#define _SC_AIO_LISTIO_MAX 1 +#define _SC_AIO_MAX 2 +#define _SC_AIO_PRIO_DELTA_MAX 3 +#define _SC_ARG_MAX 4 +#define _SC_ASYNCHRONOUS_IO 5 +#define _SC_CHILD_MAX 6 +#define _SC_CLK_TCK 7 +#define _SC_DELAYTIMER_MAX 8 +#define _SC_FSYNC 9 +#define _SC_GETGR_R_SIZE_MAX 10 +#define _SC_GETPW_R_SIZE_MAX 11 +#define _SC_JOB_CONTROL 12 +#define _SC_LOGIN_NAME_MAX 13 +#define _SC_MAPPED_FILES 14 +#define _SC_MEMLOCK 15 +#define _SC_MEMLOCK_RANGE 16 +#define _SC_MEMORY_PROTECTION 17 +#define _SC_MESSAGE_PASSING 18 +#define _SC_MQ_OPEN_MAX 19 +#define _SC_MQ_PRIO_MAX 20 +#define _SC_NGROUPS_MAX 21 +#define _SC_OPEN_MAX 22 +#define _SC_PAGESIZE 23 +#define _SC_PRIORITIZED_IO 24 +#define _SC_PRIORITY_SCHEDULING 25 +#define _SC_REALTIME_SIGNALS 26 +#define _SC_RTSIG_MAX 27 +#define _SC_SAVED_IDS 28 +#define _SC_SEMAPHORES 29 +#define _SC_SEM_NSEMS_MAX 30 +#define _SC_SEM_VALUE_MAX 31 +#define _SC_SHARED_MEMORY_OBJECTS 32 +#define _SC_SIGQUEUE_MAX 33 +#define _SC_STREAM_MAX 34 +#define _SC_SYNCHRONIZED_IO 35 +#define _SC_THREADS 36 +#define _SC_THREAD_ATTR_STACKADDR 37 +#define _SC_THREAD_ATTR_STACKSIZE 38 +#define _SC_THREAD_DESTRUCTOR_ITERATIONS 39 +#define _SC_THREAD_KEYS_MAX 40 +#define _SC_THREAD_PRIO_INHERIT 41 +#define _SC_THREAD_PRIO_PROTECT 42 +#define _SC_THREAD_PRIORITY_SCHEDULING 43 +#define _SC_THREAD_PROCESS_SHARED 44 +#define _SC_THREAD_SAFE_FUNCTIONS 45 +#define _SC_THREAD_STACK_MIN 46 +#define _SC_THREAD_THREADS_MAX 47 +#define _SC_TIMERS 48 +#define _SC_TIMER_MAX 49 +#define _SC_TTY_NAME_MAX 50 +#define _SC_TZNAME_MAX 51 +#define _SC_VERSION 52 + +/* Variable names for pathconf() */ +#define _PC_ASYNC_IO 1 +#define _PC_CHOWN_RESTRICTED 2 +#define _PC_LINK_MAX 3 +#define _PC_MAX_CANON 4 +#define _PC_MAX_INPUT 5 +#define _PC_NAME_MAX 6 +#define _PC_NO_TRUNC 7 +#define _PC_PATH_MAX 8 +#define _PC_PIPE_BUF 9 +#define _PC_PRIO_IO 10 +#define _PC_SYNC_IO 11 +#define _PC_VDISABLE 12 + + +/* Standard function prototypes */ + + +#ifdef __cplusplus +extern "C" { +#endif + + +extern int link(const char *path1, const char *path2); +extern int unlink(const char *path); +extern int rmdir(const char *path); +extern int rename(const char *old_name, const char *new_name); +extern int access(const char *path, int amode); +extern int chown(const char *path, uid_t owner, uid_t group); +extern long pathconf(const char *path, int name); +extern long fpathconf(int fd, int name); +extern int pipe(int fildes[2]); +extern int dup(int fd); +extern int dup2(int fd,int fd2); +extern int close(int fd); +extern ssize_t read(int fd, void *buf, size_t nbyte); +extern ssize_t write(int fd, const void *buf, size_t nbyte); +extern off_t lseek(int fd, off_t offset, int whence); +extern int fsync( int fd ); +extern int ftruncate(int fd, unsigned long length); + +extern int chdir(const char *path); +extern char *getcwd(char *buf, int size); + +extern int getpid(void); +extern int getppid(void); +extern uid_t getuid(void); +extern uid_t geteuid(void); +extern uid_t getgid(void); +extern uid_t getegid(void); +extern int setuid(uid_t uid); +extern int setgid(uid_t uid); +extern int getgroups(int setsize, uid_t *list); +extern char *getlogin(void); +extern char *cuserid(char *s); +extern pid_t getpgrp(void); +extern pid_t setsid(void); +extern int setpgid(pid_t pid, pid_t pgid); +extern char *getenv(const char *name); +extern char *ctermid(char *s); +extern char *ttyname(int fd); +extern int isatty(int fd); +extern long sysconf(int name); + +extern int vfork(void); +extern int execl(char *path,...); +extern int execv(char *path,char **argv); +extern int execle(char *path,...); +extern int execlp(char *file,...); +extern int execvp(char *file, char **argv); +extern int execve(char *name, char **argv, char **envv); +extern void _exit(int code); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* CYGONCE_ISO_UNISTD_H multiple inclusion protection */ + +/* EOF unistd.h */ diff --git a/packages/kernel/current/ChangeLog b/packages/kernel/current/ChangeLog --- a/packages/kernel/current/ChangeLog +++ b/packages/kernel/current/ChangeLog @@ -1,3 +1,49 @@ +2000-08-17 Hugo Tyson + + * src/sched/sched.cxx (unlock_inner): Move an assert to some place + where it's true *all* the time! There was a narrow margin where a + DSR could confuse unlock_inner() by reanimating the current thread + before it had a chance to sleep - hence the call appears to be + pointless. Putting the assert before the DSR calls makes sense. + + * include/mboxt.inl: + * src/sync/bin_sem.cxx: + * src/sync/cnt_sem.cxx: + * src/sync/flag.cxx: + * src/sync/mutex.cxx: + All of these now use Cyg_Scheduler::reschedule() rather than an + unlock/lock pair to yield in their functions which can sleep. + They therefore can be called safely and atomically with the + scheduler already locked. This is a Good Thing[tm]. Since the + network stack synch primitives now use this feature, the asserts + that the scheduler was not locked must disappear: this change. + + +2000-08-07 Jonathan Larmour + + * include/mutex.hxx (class Cyg_Mutex): Add comment explaining + presence of locked. + +2000-08-04 Jonathan Larmour + + * tests/stress_threads.c (STACK_SIZE_HANDLER): Increase stack sizes + otherwise it crashes! + +2000-07-31 Jonathan Larmour + + * include/mempolt2.hxx: As per change of 2000-07-04, also delete - left + behind accidentally + +2000-07-20 Nick Garnett + + * include/mutex.hxx (class Cyg_Mutex): Added get_ceiling() + accessor function. + + * src/sched/mlqueue.cxx: Fixed bug in sorted queue code that + resulted in an infinite loop if the thread being inserted is of + lower priority than all threads in the queue. This case is now + detected early. + 2000-07-17 Gary Thomas * tests/kflag1.c (FIRST_THREAD_WAIT_TIME): Parameterize thread @@ -5,6 +51,32 @@ 2000-07-17 Gary Thomas + + * cdl/kernel.cdl: Remove all configury related to memory allocators, + including tests. Make CYGFUN_KERNEL_API_C require CYGFUN_MEMALLOC_KAPI + + * include/memfixed.hxx, include/mempolt2.inl, include/mempoolt.hxx, + include/mempoolt.inl, include/memvar.hxx, include/mfiximpl.hxx, + include/mfiximpl.inl, include/mvarimpl.hxx, include/mvarimpl.inl, + src/mem/memfixed.cxx, src/mem/memvar.cxx, tests/kmemfix1.c, + tests/kmemvar1.c, tests/memfix1.cxx, tests/memfix2.cxx, + tests/memvar1.cxx, tests/memvar2.cxx: + Move to separate memory allocator package CYGPKG_MEMALLOC + + * include/kapi.h, include/kapidata.h, src/common/kapi.cxx: + Remove memory allocator functionality - now implemented in + CYGPKG_MEMALLOC + + * tests/dhrystone.c: + Update configuration dependencies for new isoinfra design + * tests/stress_threads.c: + Likewise. + Also fix early termination after DEATH_TIME_LIMIT so that + allocated resources are freed, and so more appropriate + statistics are reported + Also update to use mallinfo() interface to memory allocator + 2000-06-23 Hugo Tyson * include/kapi.h (cyg_scheduler_read_lock): New function, to @@ -13,6 +85,17 @@ 2000-06-23 Hugo Tyson + + * src/sched/mlqueue.cxx (Cyg_ThreadQueue_Implementation::enqueue): + Rewrote code to insert threads into priority sorted queue. The + original code could not cope with a queue all of whose members + were lower priority than the new thread - it looped for ever. Also + provided fast paths for common and easily detected cases such as + adding to a single element queue and adding at the front. By + taking these cases out early, we can also simplify the code to + search the queue. + 2000-06-16 Gary Thomas * cdl/kernel.cdl: Remove exception tests for CMA230 - not supported @@ -23,6 +106,35 @@ 2000-06-16 Jesper Skov + + * include/mutex.hxx (class Cyg_Condition_Variable): Added an + inline function, get_queue(), to return a pointer to the + underlying thread queue. To be used mainly for comparing with a + thread's current queue to decide whether it is waiting for a + condition variable. + + * include/kapi.h: + * src/common/kapi.cxx: + Changed return type of cyg_semaphore_wait() to match existing + behaviour of Cyg_Counting_Semaphore::wait(). + Changed return type of cyg_cond_wait() to match new behaviour of + Cyg_Condition_Variable::wait(). + +2000-06-09 Nick Garnett + + * include/mutex.hxx: + * src/sync/mutex.cxx: + Modified non-timeout condition variable wait() API to return + cyg_bool. A true result indicates that the wait() terminated + normally. A false result indicates that the wait() was terminated + as a result of a release() or destroy operation. For most uses + this distinction is irrelevant, but in some situations it is a + useful bit of information to have. + Also modified timeout condition variable wait to reacquire the + mutex under all circumstances. This is the correct and consistent + thing to do. + 2000-06-08 Jesper Skov * src/debug/dbg-thread-demux.c: Use generic HAL feature to allow @@ -33,6 +145,45 @@ 2000-05-30 Gary Thomas + + * cdl/scheduler.cdl (CYGIMP_KERNEL_SCHED_SORTED_QUEUES): Disable by + default + + * src/sched/mlqueue.cxx (enqueue): Add to end of thread queue even + when not priority ordered + +2000-05-20 Jonathan Larmour + + * include/mqueue.hxx, include/mqueue.inl: + Add POSIX-style message queue implementation + + * cdl/kernel.cdl: Add mqueue1 test + * cdl/scheduler.cdl: Add new CYGIMP_KERNEL_SCHED_SORTED_QUEUES option + + * include/sema.hxx: Need thread.inl header, not just thread.hxx + Make Cyg_Counting_Semaphore::peek() const since it is + + * src/sync/cnt_sem.cxx, src/sync/cnt_sem2.cxx, include/sema2.hxx: + Make Cyg_Counting_Semaphore{2}::peek() const since it is + + * include/thread.hxx: don't want Cyg_Thread_queue::empty() to be marked + inline in the class def, otherwise we get warnings elsewhere + + * include/mlqueue.hxx (Cyg_ThreadQueue_Implementation): + Add set_thread_queue private method + Add derived class Cyg_SchedulerThreadQueue_Implementation, and + make scheduler implementation use it instead of + Cyg_ThreadQueue_Implementation + + * src/mlqueue.cxx: Fix typo + Support CYGIMP_KERNEL_SCHED_SORTED_QUEUES, i.e. allow insertion + into thread queue in order of thread priority, with oldest at the + front + (Cyg_ThreadQueue_Implementation::set_thread_queue): Add + (Cyg_SchedulerThreadQueue_Implementation::enqueue): Add, like old + one, except make it FIFO instead of LIFO by inserting at end of queue + 2000-05-15 Jonathan Larmour * cdl/counters.cdl (CYGVAR_KERNEL_COUNTERS_CLOCK_DSR_LATENCY): @@ -51,6 +202,53 @@ 2000-05-02 Gary Thomas + + * cdl/thread.cdl (CYGNUM_KERNEL_THREADS_DATA_LIBC): Don't need libc + slot. Replace with CYGNUM_KERNEL_THREADS_DATA_ERRNO slot instead. + +2000-04-28 Nick Garnett + + * src/sched/sched.cxx (unlock_inner): + A significant change to the behaviour of this function. The + new_lock argument contains the value that the scheduler lock + should have after this function has completed. If it is zero then + the lock is being released and some extra work (running ASRs, + checking for DSRs) is done before returning. If it is non-zero + then it must equal the current value of the lock, and is used to + indicate that we want to reacquire the scheduler lock before + returning. This latter option only makes any sense if the current + thread is no longer runnable, otherwise this function will do + nothing. + + The result of this is that where we used to "blip" the scheduler + lock to force a sleep, we now call reschedule(), which calls + unlock_inner() with the current sched_lock value. The important + difference is that there is not now the brief window between the + calls where the lock is unclaimed. It also prevents ASRs being run + at inopportune moments. In future this will also allow us to force + threads to sleep even when they are deeply nested in the scheduler + lock. + + * include/mutex.hxx: + Added Cyg_Mutex::get_owner() to return pointer to owning thread. + + * include/sched.hxx: + * include/sched.inl: + Added new_lock argument to unlock_inner(), added reschedule(). + Made set_asr_inhibit() and clear_asr_inhibit() available even when + ASRs are disabled. + + * include/mboxt.inl: + * src/sync/bin_sem.cxx: + * src/sync/cnt_sem.cxx: + * src/sync/flag.cxx: + * src/sync/mutex.cxx: + Converted instances of "blipping" the scheduler lock into calls to + Cyg_Scheduler::reschedule(), which is better behaved. Some calls + to set_asr_inhibit() and clear_asr_inhibit() also added in various + places. + 2000-04-26 Jesper Skov * tests/kcache1.c: Also to flush testing with unified caches. @@ -72,6 +270,32 @@ 2000-04-19 Jesper Skov + + * include/clock.hxx: + * src/common/clock.cxx: + Added Cyg_Alarm::get_times() member function to allow reading of + trigger and interval values from an alarm. + +2000-04-12 Nick Garnett + + * include/sched.hxx: + * src/sched/sched.cxx: + Added ASR support. + + * include/thread.hxx: + Made Cyg_ThreadQueue::empty() an inline in class definition. + + * src/common/thread.cxx: + Added CYG_REPORT_FUNCTION() to Cyg_Thread::exit(). + + * include/kapidata.h: + Brought thread structures up to date with kernel objects. + + * cdl/thread.cdl: + * cdl/scheduler.cdl: + Added ASR configuration, minor tidies. + 2000-04-12 Gary Thomas * src/common/kapi.cxx (cyg_scheduler_safe_lock): @@ -84,6 +308,37 @@ 2000-04-12 Jesper Skov + + * include/sched.hxx: + * include/thread.inl: + * src/sync/mutex.cxx: + * src/sched/sched.cxx: + * src/common/thread.cxx: + General reorganization of priority inversion protocol support, + addition of priority ceiling protocol. + + * include/mlqueue.hxx: + * src/sched/mlqueue.cxx: + Added timeslicing enable support. + + * cdl/thread.cdl: + * cdl/synch.cdl: + Reorganized priority inversion protocol configuration to permit + different protocols and dynamic choice. Added configuration for + condition variables to use a user-specified mutex. + + * cdl/scheduler.cdl: + Added dynamic timeslicing enable option. + + * include/kapidata.h: + Adjusted to match changes in other header files. + + * tests/mutex3.cxx: + * tests/sync3.cxx: + Modified these tests to match new priority inversion protocols + configuration options. + 2000-03-28 John Dallaway * cdl/counters.cdl, diff --git a/packages/kernel/current/cdl/kernel.cdl b/packages/kernel/current/cdl/kernel.cdl --- a/packages/kernel/current/cdl/kernel.cdl +++ b/packages/kernel/current/cdl/kernel.cdl @@ -57,7 +57,6 @@ cdl_package CYGPKG_KERNEL { common/thread.cxx common/except.cxx \ instrmnt/meminst.cxx instrmnt/nullinst.cxx \ intr/intr.cxx \ - mem/memfixed.cxx mem/memvar.cxx \ sched/bitmap.cxx sched/lottery.cxx sched/mlqueue.cxx \ sched/sched.cxx \ sync/bin_sem.cxx sync/cnt_sem.cxx sync/flag.cxx \ @@ -202,27 +201,6 @@ cdl_package CYGPKG_KERNEL { script instrument.cdl } - # --------------------------------------------------------------------- - # There appears to be somewhat of a lack of configuration options here. - cdl_component CYGPKG_KERNEL_MEMORY { - display "Memory allocators" - flavor none - description " - Configuration options related to the kernel memory allocation - support." - - cdl_option CYGSEM_KERNEL_MEMORY_COALESCE { - display "Coalesce memory in the variable-block allocator" - default_value 1 - description " - The variable-block memory allocator can perform coalescing - of memory whenever the application code releases memory back - to the pool. This coalescing reduces the possibility of - memory fragmentation problems, but involves extra code and - processor cycles." - } - } - #=================================================================== # Options related to source-level debugging and diagnostics. cdl_component CYGPKG_KERNEL_DEBUG { @@ -260,6 +238,8 @@ cdl_package CYGPKG_KERNEL { cdl_option CYGFUN_KERNEL_API_C { display "Provide C API" default_value 1 + requires CYGPKG_MEMALLOC + requires CYGFUN_MEMALLOC_KAPI description " The eCos kernel is implemented in C++, but there is an optional C API for use by application code. This C API can be @@ -327,12 +307,12 @@ cdl_package CYGPKG_KERNEL { flavor data no_define calculated { - CYGPKG_HAL_ARM_AEB ? "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/except1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kexcept1 tests/kintr0 tests/kmbox1 tests/kmemfix1 tests/kmemvar1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/memfix1 tests/memfix2 tests/memvar1 tests/memvar2 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone" : \ - CYGPKG_HAL_ARM_EBSA285 ? "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/except1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kexcept1 tests/kintr0 tests/kmbox1 tests/kmemfix1 tests/kmemvar1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/memfix1 tests/memfix2 tests/memvar1 tests/memvar2 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone tests/stress_threads tests/kcache1 tests/kcache2" : \ - CYGPKG_HAL_ARM_EDB7XXX ? "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/except1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kexcept1 tests/kintr0 tests/kmbox1 tests/kmemfix1 tests/kmemvar1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/memfix1 tests/memfix2 tests/memvar1 tests/memvar2 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone tests/stress_threads tests/kcache1 tests/kcache2" : \ - CYGPKG_HAL_ARM_CMA230 ? "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kintr0 tests/kmbox1 tests/kmemfix1 tests/kmemvar1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/memfix1 tests/memfix2 tests/memvar1 tests/memvar2 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone" : \ - CYGPKG_HAL_ARM ? "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/except1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kexcept1 tests/kintr0 tests/kmbox1 tests/kmemfix1 tests/kmemvar1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/memfix1 tests/memfix2 tests/memvar1 tests/memvar2 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone" : \ - "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/except1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kexcept1 tests/kintr0 tests/kmbox1 tests/kmemfix1 tests/kmemvar1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/memfix1 tests/memfix2 tests/memvar1 tests/memvar2 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone tests/stress_threads tests/kcache1 tests/kcache2" + CYGPKG_HAL_ARM_AEB ? "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/except1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kexcept1 tests/kintr0 tests/kmbox1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/mqueue1 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone" : \ + CYGPKG_HAL_ARM_EBSA285 ? "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/except1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kexcept1 tests/kintr0 tests/kmbox1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/mqueue1 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone tests/stress_threads tests/kcache1 tests/kcache2" : \ + CYGPKG_HAL_ARM_EDB7XXX ? "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/except1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kexcept1 tests/kintr0 tests/kmbox1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/mqueue1 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone tests/stress_threads tests/kcache1 tests/kcache2" : \ + CYGPKG_HAL_ARM_CMA230 ? "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kintr0 tests/kmbox1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/mqueue1 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone" : \ + CYGPKG_HAL_ARM ? "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/except1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kexcept1 tests/kintr0 tests/kmbox1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/mqueue1 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone" : \ + "tests/bin_sem0 tests/bin_sem1 tests/bin_sem2 tests/clock0 tests/clock1 tests/clockcnv tests/cnt_sem0 tests/cnt_sem1 tests/except1 tests/flag0 tests/flag1 tests/intr0 tests/kclock0 tests/kclock1 tests/kexcept1 tests/kintr0 tests/kmbox1 tests/kmutex0 tests/kmutex1 tests/ksched1 tests/ksem0 tests/ksem1 tests/kflag0 tests/kflag1 tests/kthread0 tests/kthread1 tests/mbox1 tests/mqueue1 tests/mutex0 tests/mutex1 tests/mutex2 tests/mutex3 tests/sched1 tests/sync2 tests/sync3 tests/thread0 tests/thread1 tests/thread2 tests/release tests/kill tests/thread_gdb tests/tm_basic tests/dhrystone tests/stress_threads tests/kcache1 tests/kcache2" } description " This option specifies the set of tests for the eCos kernel." diff --git a/packages/kernel/current/cdl/scheduler.cdl b/packages/kernel/current/cdl/scheduler.cdl --- a/packages/kernel/current/cdl/scheduler.cdl +++ b/packages/kernel/current/cdl/scheduler.cdl @@ -122,8 +122,25 @@ cdl_component CYGNUM_KERNEL_SCHED_PRIORI This option automatically defines the size of bitmap used to track occupied priority levels." } + + + cdl_option CYGIMP_KERNEL_SCHED_SORTED_QUEUES { + display "Dequeue oldest threads first" + flavor bool + default_value 0 + description " + With this option enabled, threads queued in a thread queue + will be dequeued in priority order, rather than last in, + first out (LIFO). Threads of equal priority are dequeued + oldest first. The only exception is the scheduler run + queues where order is less important as each is already + sorted by priority. Note that this makes the thread queueing + less deterministic." + } } +# --------------------------------------------------------------------- +# Timeslice options # NOTE: this option only makes sense for some of the schedulers. # Timeslicing is irrelevant for bitmap schedulers. @@ -155,4 +172,53 @@ cdl_component CYGSEM_KERNEL_SCHED_TIMESL takes place, so increasing the value reduces the frequency of timeslices." } + + cdl_option CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE { + display "Support runtime enable of timeslice per-thread" + flavor bool + default_value false + description "This option makes timslicing a per-thread runtime + option. When enabled, threads may have timeslicing + turned on or off dynamically. This is generally used + by higher level APIs (such as POSIX) to implement + differing scheduling policies." + + } } + +# --------------------------------------------------------------------- +# ASR support options + +cdl_component CYGSEM_KERNEL_SCHED_ASR_SUPPORT { + display "Enable ASR support" + flavor bool + default_value false + description " + This component controls support for Asynchronous Service + Routines (ASRs). This is a function that may be called + from the scheduler when it has just exited the scheduler + lock. This is primarily for use by API compatibility layers." + + cdl_option CYGSEM_KERNEL_SCHED_ASR_GLOBAL { + display "Make ASR function global" + flavor bool + default_value true + description " + This option controls whether the ASR function is shared by + all threads, or whether each thread may have its own ASR + function." + } + + cdl_option CYGSEM_KERNEL_SCHED_ASR_DATA_GLOBAL { + display "Make ASR data global" + flavor bool + default_value true + description " + This option controls whether the ASR data is shared by + all threads, or whether each thread may have its own ASR + data. This is independent of the previous option because + it may be useful to pass per-thread data to a shared ASR + function." + } +} + diff --git a/packages/kernel/current/cdl/synch.cdl b/packages/kernel/current/cdl/synch.cdl --- a/packages/kernel/current/cdl/synch.cdl +++ b/packages/kernel/current/cdl/synch.cdl @@ -40,33 +40,94 @@ # # ==================================================================== -# NOTE: the requires statement is only valid for the current kernel. -# Priority inheritance is possible in other schedulers as well -# but is not yet implemented. -cdl_option CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE { - display "Simple mutex priority inheritance" - requires CYGSEM_KERNEL_SCHED_MLQUEUE - default_value 1 - description " - This option enables a relatively simple implementation of - mutex priority inheritance. The implementation will only work - in the mlqueue scheduler, and it does not handle the rare - case of nested mutexes completely correctly. However it is - both fast and deterministic. Mutex priority inheritance can - be disabled if the application does not require it, which - will reduce both code size and data space." -} + +cdl_component CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL { + display "Priority inversion protection protocols" + flavor booldata + legal_values { "SIMPLE" } + default_value { "SIMPLE" } + active_if { CYGSEM_KERNEL_SCHED_MLQUEUE } + description " + This component controls the protocols used to protect mutexes against + priority inversion. If this option is enabled it defines which + algorithm is used to implement this protection. At present only + one such algorithm is defined: \"SIMPLE\". The implementation + will only work in the mlqueue scheduler, and it does not handle the + rare case of nested mutexes completely correctly. However it is + both fast and deterministic." + + cdl_option CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT { + display "Enable priority inheritance protocol" + default_value 1 + implements CYGINT_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_COUNT + description " + This option enables priority inheritance protocol. This protocol + causes the owner of a mutex to be executed at the highest priority + of the threads waiting for access to the mutex." + } + + cdl_option CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING { + display "Enable priority ceiling protocol" + default_value 1 + implements CYGINT_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_COUNT + description " + This option enables priority ceiling protocol. This protocol + causes the owner of a mutex to be executed at a priority + associated with the mutex." + } -cdl_option CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE_RELAY { - display "Relay enhancement to simple mutex priority inheritance" - active_if CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE - default_value 1 - description " - This option enables an extension to the simple implementation of - mutex priority inheritance whereby a thread releasing a mutex to a - waiting thread relays its own priority to the new owner if there - are still further threads waiting. This can be viewed as a - discovered priority ceiling." + cdl_option CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_NONE { + display "No priority inversion protocol" + default_value 1 + implements CYGINT_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_COUNT + description " + This option enables the ability to have no priority inversion protocol. + It is equivalent to disabling the priority inversion protocol at + the top level, but is necessary for the runtime and default + selection options." + } + + cdl_option CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT { + display "Default priority inversion protocol" + flavor data + legal_values { "INHERIT" "CEILING" "NONE" } + default_value { CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT ? + "INHERIT" : + CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING ? + "CEILING" : "NONE" } + description " + This option defines the default inversion protocol used for mutexes that + are created without an explicit protocol being specified. The protocol + chosen by default is to use priority inheritance if it is present otherwise + priority ceiling, or none if neither is present." + } + + cdl_option CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY { + display "Default priority ceiling" + flavor data + legal_values 0 to { CYGNUM_KERNEL_SCHED_PRIORITIES - 1 } + default_value 0 + active_if { CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT == "CEILING" } + description " + This option defines the default priority ceiling to be + used if the chosen default priority inversion protocol is + priority ceiling protocol. The default value for this is zero, + making all such mutexes boost threads to the maximum priority." + } + + cdl_option CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC { + display "Specify mutex priority inversion protocol at runtime" + default_value 1 + active_if { CYGINT_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_COUNT > 1 } + description " + This option controls whether the priority inversion protocol used by + a mutex can be specified when that mutex is created." + } + + cdl_interface CYGINT_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_COUNT { + display "Number of protocols selected" + } + } cdl_option CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT { @@ -109,3 +170,15 @@ cdl_option CYGMFN_KERNEL_SYNCH_CONDVAR_T This option enables the condition variable timed wait facility." } + +cdl_option CYGMFN_KERNEL_SYNCH_CONDVAR_WAIT_MUTEX { + display "Condition variable explicit mutex wait support" + default_value 1 + description " + This option enables the condition variable explicit mutex wait + facility. By default condition variables in eCos are created with + a statically associated mutex. This option permits wait (and timed wait + if CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT is enabled) to provide a + different mutex as an argument. This makes no difference to the semantics + the wait operation except that a different mutex will be used during it." +} diff --git a/packages/kernel/current/cdl/thread.cdl b/packages/kernel/current/cdl/thread.cdl --- a/packages/kernel/current/cdl/thread.cdl +++ b/packages/kernel/current/cdl/thread.cdl @@ -139,15 +139,13 @@ cdl_component CYGVAR_KERNEL_THREADS_DATA the uITRON compatibility layer for private use." } - cdl_option CYGNUM_KERNEL_THREADS_DATA_LIBC { - display "Slot 2 preallocated for libc" + cdl_option CYGNUM_KERNEL_THREADS_DATA_ERRNO { + display "Slot 2 preallocated for errno" flavor data calculated 2 description " This option defines the index of a per-thread data - slot which is reserved by - the C library (libc) - for private use." + slot which is reserved for use by an errno variable." } cdl_option CYGNUM_KERNEL_THREADS_DATA_POSIX { display "Slot 3 preallocated for POSIX" @@ -182,6 +180,7 @@ cdl_option CYGNUM_KERNEL_THREADS_IDLE_ST # --------------------------------------------------------------------- # Thread-related miscellania. + cdl_option CYGNUM_KERNEL_MAX_SUSPEND_COUNT_ASSERT { display "Maximal suspend count" flavor data @@ -224,15 +223,3 @@ cdl_option CYGIMP_IDLE_THREAD_YIELD { If the scheduler configuration only has a single priority level, then the idle thread must yield each time around its loop." } - - -# --------------------------------------------------------------------- -# Synchronization primitives miscellania. -cdl_option CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE { - display "Priority inheritance" - calculated 1 - active_if CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE - description " - This option is automatically enabled when any implementation - of priority inheritance is selected." -} diff --git a/packages/kernel/current/include/clock.hxx b/packages/kernel/current/include/clock.hxx --- a/packages/kernel/current/include/clock.hxx +++ b/packages/kernel/current/include/clock.hxx @@ -238,7 +238,10 @@ public: void disable(); // Ensure alarm disabled - + void get_times( + cyg_tick_count *trigger, // Next trigger time + cyg_tick_count *interval // Current interval + ); }; // ------------------------------------------------------------------------- diff --git a/packages/kernel/current/include/kapi.h b/packages/kernel/current/include/kapi.h --- a/packages/kernel/current/include/kapi.h +++ b/packages/kernel/current/include/kapi.h @@ -98,12 +98,6 @@ typedef struct cyg_alarm cyg_alarm; struct cyg_mbox; typedef struct cyg_mbox cyg_mbox; -struct cyg_mempool_var; -typedef struct cyg_mempool_var cyg_mempool_var; - -struct cyg_mempool_fix; -typedef struct cyg_mempool_fix cyg_mempool_fix; - struct cyg_sem_t; typedef struct cyg_sem_t cyg_sem_t; @@ -428,96 +422,10 @@ cyg_bool_t cyg_mbox_waiting_to_put(cyg_h /*-----------------------------------------------------------------------*/ /* Memory pools */ -/* There are two sorts of memory pools. A variable size memory pool - is for allocating blocks of any size. A fixed size memory pool, has - the block size specified when the pool is created, and only provides - blocks of that size. */ - -/* Create a variable size memory pool */ -void cyg_mempool_var_create( - void *base, /* base of memory to use for pool */ - cyg_int32 size, /* size of memory in bytes */ - cyg_handle_t *handle, /* returned handle of memory pool */ - cyg_mempool_var *var /* space to put pool structure in */ - ); - -/* Delete variable size memory pool */ -void cyg_mempool_var_delete(cyg_handle_t varpool); - -/* Allocates a block of length size. This waits if the memory is not - currently available. */ -void *cyg_mempool_var_alloc(cyg_handle_t varpool, cyg_int32 size); - -/* Allocates a block of length size. This waits until abstime, - if the memory is not already available. NULL is returned if - no memory is available. */ -void *cyg_mempool_var_timed_alloc( - cyg_handle_t varpool, - cyg_int32 size, - cyg_tick_count_t abstime); - -/* Allocates a block of length size. NULL is returned if no memory is - available. */ -void *cyg_mempool_var_try_alloc( - cyg_handle_t varpool, - cyg_int32 size); - -/* Frees memory back into variable size pool. */ -void cyg_mempool_var_free(cyg_handle_t varpool, void *p); - -/* Returns true if there are any threads waiting for memory in the - given memory pool. */ -cyg_bool_t cyg_mempool_var_waiting(cyg_handle_t varpool); +/* These definitions are found in the "memalloc" package as this is */ +/* where the implementation lives. */ -typedef struct { - cyg_int32 totalmem; - cyg_int32 freemem; - void *base; - cyg_int32 size; - cyg_int32 blocksize; - cyg_int32 maxfree; // The largest free block -} cyg_mempool_info; - -/* Puts information about a variable memory pool into the structure - provided. */ -void cyg_mempool_var_get_info(cyg_handle_t varpool, cyg_mempool_info *info); - -/* Create a fixed size memory pool */ -void cyg_mempool_fix_create( - void *base, // base of memory to use for pool - cyg_int32 size, // size of memory in byte - cyg_int32 blocksize, // size of allocation in bytes - cyg_handle_t *handle, // handle of memory pool - cyg_mempool_fix *fix // space to put pool structure in - ); - -/* Delete fixed size memory pool */ -void cyg_mempool_fix_delete(cyg_handle_t fixpool); - -/* Allocates a block. This waits if the memory is not - currently available. */ -void *cyg_mempool_fix_alloc(cyg_handle_t fixpool); - -/* Allocates a block. This waits until abstime, if the memory - is not already available. NULL is returned if no memory is - available. */ -void *cyg_mempool_fix_timed_alloc( - cyg_handle_t fixpool, - cyg_tick_count_t abstime); - -/* Allocates a block. NULL is returned if no memory is available. */ -void *cyg_mempool_fix_try_alloc(cyg_handle_t fixpool); - -/* Frees memory back into fixed size pool. */ -void cyg_mempool_fix_free(cyg_handle_t fixpool, void *p); - -/* Returns true if there are any threads waiting for memory in the - given memory pool. */ -cyg_bool_t cyg_mempool_fix_waiting(cyg_handle_t fixpool); - -/* Puts information about a variable memory pool into the structure - provided. */ -void cyg_mempool_fix_get_info(cyg_handle_t fixpool, cyg_mempool_info *info); +#include /*---------------------------------------------------------------------------*/ /* Semaphores */ @@ -529,7 +437,7 @@ void cyg_semaphore_init( void cyg_semaphore_destroy( cyg_sem_t *sem ); -void cyg_semaphore_wait( cyg_sem_t *sem ); +cyg_bool_t cyg_semaphore_wait( cyg_sem_t *sem ); #ifdef CYGFUN_KERNEL_THREADS_TIMER cyg_bool_t cyg_semaphore_timed_wait( @@ -619,7 +527,7 @@ void cyg_cond_init( void cyg_cond_destroy( cyg_cond_t *cond ); -void cyg_cond_wait( cyg_cond_t *cond ); +cyg_bool_t cyg_cond_wait( cyg_cond_t *cond ); void cyg_cond_signal( cyg_cond_t *cond ); diff --git a/packages/kernel/current/include/kapidata.h b/packages/kernel/current/include/kapidata.h --- a/packages/kernel/current/include/kapidata.h +++ b/packages/kernel/current/include/kapidata.h @@ -210,7 +210,10 @@ typedef struct cyg_thread *prev; cyg_priority_t priority; /* current thread priority */ - + +#ifdef CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE + cyg_bool timeslice_enabled; /* per-thread timeslice enable */ +#endif #elif defined(CYGSEM_KERNEL_SCHED_LOTTERY) cyg_thread *next; @@ -228,9 +231,19 @@ typedef struct cyg_threadqueue *queue; -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef CYGSEM_KERNEL_SCHED_ASR_SUPPORT + volatile cyg_bool asr_inhibit; // If true, blocks calls to ASRs + volatile cyg_bool asr_pending; // If true, this thread's ASR should be called. +#ifndef CYGSEM_KERNEL_SCHED_ASR_GLOBAL + void (*asr)(CYG_ADDRWORD); // ASR function +#endif +#ifndef CYGSEM_KERNEL_SCHED_ASR_DATA_GLOBAL + CYG_ADDRWORD asr_data; // ASR data pointer +#endif +#endif +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL cyg_count32 mutex_count; -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE cyg_priority_t original_priority; cyg_bool priority_inherited; #endif @@ -328,6 +341,13 @@ struct cyg_mutex_t cyg_bool locked; /* true if locked */ cyg_thread *owner; /* Current locking thread */ cyg_threadqueue queue; /* Queue of waiting threads */ + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC + cyg_uint32 protocol; /* this mutex's protocol */ +#endif +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + cyg_priority_t ceiling; /* mutex priority ceiling */ +#endif }; @@ -339,45 +359,12 @@ struct cyg_cond_t cyg_threadqueue queue; /* Queue of waiting threads */ }; -/*---------------------------------------------------------------------------*/ - -/* This corresponds to the extra fields provided by the mempoolt template - not the actual size of the template in any given instance. */ -typedef struct cyg_mempoolt { - cyg_threadqueue queue; -} cyg_mempoolt; - - -struct cyg_mempool_var_memdq { - struct cyg_mempool_var_memdq *prev, *next; - cyg_int32 size; -}; +/*------------------------------------------------------------------------*/ -struct cyg_mempool_var { - struct cyg_mempool_var_memdq head; - cyg_uint8 *obase; - cyg_int32 osize; - cyg_int32 oalign; - cyg_uint8 *bottom; - cyg_uint8 *top; - cyg_int32 alignment; - cyg_int32 freemem; - cyg_mempoolt mempoolt; -}; +/* Memory allocator types now come from the "memalloc" package which is */ +/* where the implementation lives. */ -struct cyg_mempool_fix { - cyg_uint32 *bitmap; - cyg_int32 maptop; - cyg_uint8 *mempool; - cyg_int32 numblocks; - cyg_int32 freeblocks; - cyg_int32 blocksize; - cyg_int32 firstfree; - cyg_uint8 *top; - cyg_mempoolt mempoolt; -}; - -/*------------------------------------------------------------------------*/ +#include #ifdef __cplusplus } diff --git a/packages/kernel/current/include/mboxt.inl b/packages/kernel/current/include/mboxt.inl --- a/packages/kernel/current/include/mboxt.inl +++ b/packages/kernel/current/include/mboxt.inl @@ -213,12 +213,9 @@ Cyg_Mboxt::get( T &ritem ) get_threadq.enqueue( self ); CYG_INSTRUMENT_MBOXT(WAIT, this, count); - CYG_ASSERT( 1 == Cyg_Scheduler::get_sched_lock(), - "Called with non-zero scheduler lock"); - // Unlock scheduler and allow other threads to run - Cyg_Scheduler::unlock(); - Cyg_Scheduler::lock(); + // Allow other threads to run + Cyg_Scheduler::reschedule(); CYG_ASSERTCLASS( this, "Bad this pointer"); @@ -303,12 +300,9 @@ Cyg_Mboxt::get( T &ritem, get_threadq.enqueue( self ); CYG_INSTRUMENT_MBOXT(WAIT, this, count); - CYG_ASSERT( 1 == Cyg_Scheduler::get_sched_lock(), - "Called with non-zero scheduler lock"); - // Unlock scheduler and allow other threads to run - Cyg_Scheduler::unlock(); - Cyg_Scheduler::lock(); + // Allow other threads to run + Cyg_Scheduler::reschedule(); CYG_ASSERTCLASS( this, "Bad this pointer"); @@ -448,11 +442,9 @@ Cyg_Mboxt::put( const T it put_threadq.enqueue( self ); CYG_INSTRUMENT_MBOXT(WAIT, this, count); - CYG_ASSERT( 1 == Cyg_Scheduler::get_sched_lock(), - "Called with non-zero scheduler lock"); - - Cyg_Scheduler::unlock(); // unlock, maybe switch threads - Cyg_Scheduler::lock(); + + // Allow other threads to run + Cyg_Scheduler::reschedule(); CYG_ASSERTCLASS( this, "Bad this pointer"); @@ -534,12 +526,9 @@ Cyg_Mboxt::put( const T it put_threadq.enqueue( self ); CYG_INSTRUMENT_MBOXT(WAIT, this, count); - CYG_ASSERT( 1 == Cyg_Scheduler::get_sched_lock(), - "Called with non-zero scheduler lock"); - // Unlock scheduler and allow other threads to run - Cyg_Scheduler::unlock(); - Cyg_Scheduler::lock(); + // Allow other threads to run + Cyg_Scheduler::reschedule(); CYG_ASSERTCLASS( this, "Bad this pointer"); diff --git a/packages/kernel/current/include/mlqueue.hxx b/packages/kernel/current/include/mlqueue.hxx --- a/packages/kernel/current/include/mlqueue.hxx +++ b/packages/kernel/current/include/mlqueue.hxx @@ -34,17 +34,17 @@ //========================================================================== //#####DESCRIPTIONBEGIN#### // -// Author(s): nickg -// Contributors: nickg -// Date: 1997-09-10 -// Purpose: Define multilevel queue scheduler implementation -// Description: The classes defined here are used as base classes -// by the common classes that define schedulers and thread -// things. The MLQ scheduler in various configurations -// provides standard FIFO, round-robin and single priority -// schedulers. -// Usage: Included according to configuration by -// +// Author(s): nickg +// Contributors: jlarmour +// Date: 1997-09-10 +// Purpose: Define multilevel queue scheduler implementation +// Description: The classes defined here are used as base classes +// by the common classes that define schedulers and thread +// things. The MLQ scheduler in various configurations +// provides standard FIFO, round-robin and single priority +// schedulers. +// Usage: Included according to configuration by +// // //####DESCRIPTIONEND#### // @@ -99,7 +99,11 @@ class Cyg_ThreadQueue_Implementation { friend class Cyg_Scheduler_Implementation; friend class Cyg_SchedThread_Implementation; - + friend class Cyg_SchedulerThreadQueue_Implementation; + + void set_thread_queue(Cyg_Thread *thread, + Cyg_ThreadQueue *tq ); + Cyg_Thread *queue; protected: @@ -117,7 +121,7 @@ protected: // remove first thread on queue Cyg_Thread *dequeue(); - // remove specified thread from queue + // remove specified thread from queue void remove(Cyg_Thread *thread); // test if queue is empty @@ -134,6 +138,14 @@ inline cyg_bool Cyg_ThreadQueue_Implemen return queue == NULL; } +// thread queue used exclusively by the scheduler, with simpler enqueueing + +class Cyg_SchedulerThreadQueue_Implementation + : public Cyg_ThreadQueue_Implementation +{ + void enqueue(Cyg_Thread *thread); // Add thread to queue +}; + // ------------------------------------------------------------------------- // This class contains the implementation details of the scheduler, and // provides a standard API for accessing it. @@ -150,7 +162,7 @@ class Cyg_Scheduler_Implementation // Each run queue is a double linked circular list of threads. // These pointers point to the head element of each list. - Cyg_ThreadQueue_Implementation run_queue[CYGNUM_KERNEL_SCHED_PRIORITIES]; + Cyg_SchedulerThreadQueue_Implementation run_queue[CYGNUM_KERNEL_SCHED_PRIORITIES]; protected: @@ -163,9 +175,9 @@ protected: static cyg_ucount32 timeslice_count; static void reset_timeslice_count(); - + #endif - + Cyg_Scheduler_Implementation(); // Constructor // The following functions provide the scheduler implementation @@ -197,7 +209,7 @@ protected: // called from the RTC DSR. public: void timeslice(); - + #endif }; @@ -223,6 +235,7 @@ class Cyg_SchedThread_Implementation { friend class Cyg_Scheduler_Implementation; friend class Cyg_ThreadQueue_Implementation; + friend class Cyg_SchedulerThreadQueue_Implementation; Cyg_Thread *next; // next thread in queue Cyg_Thread *prev; // previous thread in queue @@ -245,8 +258,42 @@ protected: void to_queue_head( void ); // Move this thread to the head // of its queue (not necessarily // a scheduler queue) + +#ifdef CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE + + // This defines whether this thread is subject to timeslicing. + // If false, timeslice expiry has no effect on the thread. + + cyg_bool timeslice_enabled; + +public: + + void timeslice_enable(); + + void timeslice_disable(); + +#endif + }; // ------------------------------------------------------------------------- +// Cyg_SchedThread_Implementation inlines. + +#ifdef CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE + +inline void Cyg_SchedThread_Implementation::timeslice_enable() +{ + timeslice_enabled = true; +} + +inline void Cyg_SchedThread_Implementation::timeslice_disable() +{ + timeslice_enabled = false; +} + +#endif + + +// ------------------------------------------------------------------------- #endif // ifndef CYGONCE_KERNEL_MLQUEUE_HXX // EOF mlqueue.hxx diff --git a/packages/kernel/current/include/mqueue.hxx b/packages/kernel/current/include/mqueue.hxx new file mode 100644 --- /dev/null +++ b/packages/kernel/current/include/mqueue.hxx @@ -0,0 +1,142 @@ +#ifndef CYGONCE_KERNEL_MQUEUE_HXX +#define CYGONCE_KERNEL_MQUEUE_HXX +/*======================================================================== +// +// mqueue.hxx +// +// Message queues +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-05-09 +// Purpose: This file provides the interface for eCos message queues +// Description: This differs from the message boxes also supported by +// eCos primarily because the requirements of message +// queues are driven by POSIX semantics. POSIX semantics are +// more dynamic and therefore heavyweight than Mboxes, +// including prioritization, and variable sized queues and +// message lengths +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#include /* size_t */ +#include /* Types */ +#include /* CYGDBG_DEFINE_CHECK_THIS, + CYGDBG_USE_ASSERTS */ +#include /* Cyg_Counting_Semaphore */ + +/* CLASSES */ + +class Cyg_Mqueue { +public: + typedef void (*callback_fn_t)(Cyg_Mqueue &q, CYG_ADDRWORD data); + typedef void * (*qalloc_fn_t)(size_t len); + typedef void (*qfree_fn_t)(void *ptr, size_t len); + + typedef enum { + OK=0, + NOMEM, + WOULDBLOCK, + INTR + } qerr_t; + +protected: + struct qentry { + struct qentry *next; + unsigned int priority; + size_t buflen; + volatile bool busy; + // data buffer follows here + char *buf() const { return (char *)this + sizeof(*this); } + }; + + Cyg_Counting_Semaphore putsem, getsem; + + struct qentry *q; // q entries in use + struct qentry *freelist; // q entries not in use + void *queuespace; // placeholder for the dynamically allocated + // area + + size_t queuespacesize; + + qfree_fn_t free_fn; // how to free queuespace when we destruct + + callback_fn_t callback; + CYG_ADDRWORD callback_data; + + CYGDBG_DEFINE_CHECK_THIS + +#ifdef CYGDBG_USE_ASSERTS + long qlen; + size_t msgsize; +#endif + +public: + + Cyg_Mqueue( long maxmsgs, long maxmsgsize, + qalloc_fn_t qalloc, qfree_fn_t qfree, qerr_t *err ); + ~Cyg_Mqueue(); + + // put() copies len bytes of *buf into the queue at priority prio + qerr_t put( const char *buf, size_t len, unsigned int prio, + bool block=true); + + // get() returns the oldest highest priority message in the queue in *buf + // and sets *prio to the priority (if prio is non-NULL) and *len to the + // actual message size + qerr_t get( char *buf, size_t *len, unsigned int *prio, bool block=true ); + + // count() returns the number of messages in the queue + long count(); + + // Supply a callback function to call (with the supplied data argument) + // when the queue goes from empty to non-empty (unless someone's already + // doing a get()). This returns the old callback_fn, and if olddata is + // non-NULL sets it to the old data (yes, really!) + callback_fn_t setnotify( callback_fn_t callback_fn, CYG_ADDRWORD data, + CYG_ADDRWORD *olddata=NULL); + +}; /* class Cyg_Mqueue */ + +#include + +#endif /* CYGONCE_KERNEL_MQUEUE_HXX multiple inclusion protection */ + +/* EOF mqueue.hxx */ diff --git a/packages/kernel/current/include/mqueue.inl b/packages/kernel/current/include/mqueue.inl new file mode 100644 --- /dev/null +++ b/packages/kernel/current/include/mqueue.inl @@ -0,0 +1,503 @@ +#ifndef CYGONCE_KERNEL_MQUEUE_INL +#define CYGONCE_KERNEL_MQUEUE_INL +/*======================================================================== +// +// mqueue.inl +// +// Message queues implementation +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-05-09 +// Purpose: This file provides the implementation for eCos message +// queues +// Description: This differs from the message boxes also supported +// by eCos primarily because the requirements of message +// queues are driven by POSIX semantics. POSIX semantics are +// more dynamic and therefore heavyweight than Mboxes, +// including prioritization, and variable sized queues and +// message lengths +// Usage: Do not include this file directly - instead +// #include +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include +#include // Configuration header + +/* INCLUDES */ + +#include // size_t, NULL +#include // Types +#include // Header for this file, just in case +#include // Assertion support +#include // Tracing support +#include // scheduler +#include // scheduler inlines +#include // Cyg_Counting_Semaphore + +#ifdef CYGPKG_ISOINFRA +# include // memcpy +#else +externC void * memcpy( void *, const void *, size_t ); +#endif + +// NOTE: +// An alternative implementation based on mutexes and condition variables +// rather than semaphores/scheduler locking was considered. But it was +// not thought quite as good because it isn't driver safe. You would +// also have to manage explicitly what counting semaphores do for you +// intrinsically. Also with the mutex approach, the message queue would +// be locked the whole time a new entry was being filled in, or copied out +// +// It also makes the non-blocking case properly non-blocking rather than +// still being able to block while waiting for a mutex protecting +// the message queue internal structures + +/* INLINE FUNCTIONS */ + +//------------------------------------------------------------------------ + +inline cyg_bool +Cyg_Mqueue::check_this( cyg_assert_class_zeal zeal ) const +{ + if (zeal != cyg_none) { + CYG_CHECK_DATA_PTRC(this); // extreme paranoia + +#ifdef CYGDBG_USE_ASSERTS + if ( qlen <= 0 || msgsize <= 0 ) + return false; +#endif + + if ( queuespacesize < sizeof(struct qentry)+1 ) + return false; + + CYG_CHECK_DATA_PTRC(queuespace); + CYG_CHECK_FUNC_PTRC(free_fn); + + // prevent pre-emption through this. Not so bad since + // this is only a diagnostic function + Cyg_Scheduler::lock(); + + if (NULL != q) + CYG_CHECK_DATA_PTRC(q); + if (NULL != freelist) + CYG_CHECK_DATA_PTRC(freelist); + if (NULL != callback) + CYG_CHECK_FUNC_PTRC(callback); + + // check each queue entry + long msgs=0, busymsgs=0; + unsigned int oldprio=0; + struct qentry *qtmp; + + if ( NULL != q ) + oldprio = q->priority; + for ( qtmp=q; NULL != qtmp; qtmp=qtmp->next ) { + if ( NULL != qtmp->next ) + CYG_CHECK_DATA_PTRC( qtmp->next ); + + // queue should be priority ordered + if ( qtmp->priority > oldprio ) + goto fail; + oldprio = qtmp->priority; + +#ifdef CYGDBG_USE_ASSERTS + // valid length + if ( !qtmp->busy ) + if ( qtmp->buflen > msgsize ) + goto fail; +#endif + if ( qtmp->busy ) + busymsgs++; + else + msgs++; + } // for + + long freemsgs=0; + + // check that number of used and unused messages == q length + for ( qtmp=freelist; NULL != qtmp; qtmp=qtmp->next ) { + if ( NULL != qtmp->next ) + CYG_CHECK_DATA_PTRC( qtmp->next ); + if ( qtmp->busy ) + busymsgs++; + else + freemsgs++; + } + +#ifdef CYGDBG_USE_ASSERTS + // and sum of all messages should be the total q length + if ( qlen != (msgs+freemsgs+busymsgs) ) + goto fail; +#endif + + Cyg_Scheduler::unlock(); + + } + return true; // object OK + fail: + Cyg_Scheduler::unlock(); + return false; // object fubar'd +} + +//------------------------------------------------------------------------ + +inline +Cyg_Mqueue::Cyg_Mqueue( long maxmsgs, long maxmsgsize, + qalloc_fn_t qalloc, qfree_fn_t qfree, qerr_t *err ) + : putsem(maxmsgs), getsem(0) +{ + CYG_REPORT_FUNCTION(); + CYG_REPORT_FUNCARG5( "maxmsgs=%ld, maxmsgsize=%ld, qalloc=%08x, " + "qfree=%08x, &err=%08x", maxmsgs, maxmsgsize, + qalloc, qfree, err); + CYG_PRECONDITIONC( (maxmsgs > 0) && (maxmsgsize > 0) ); + CYG_CHECK_DATA_PTRC( err ); + CYG_CHECK_FUNC_PTRC( qalloc ); + CYG_CHECK_FUNC_PTRC( qfree ); + + // mem to allocate for entire queue size. Also wants to be rounded + // up so that the structs are aligned. + const long addralign = sizeof(void *) - 1; + long entrysize = (sizeof(struct qentry) + maxmsgsize + addralign) + & ~addralign; + + queuespacesize = entrysize * maxmsgs; + queuespace = qalloc( queuespacesize ); + + if (NULL == queuespace) { + *err=NOMEM; + CYG_REPORT_RETURN(); + return; + } + + // link up freelist + long i; + struct qentry *qtmp; + for ( i=0, qtmp=(struct qentry *)queuespace; + inext ) { + qtmp->busy = false; + qtmp->next = (struct qentry *)((char *)qtmp + entrysize); + } // for + + freelist = (struct qentry *)queuespace; + + // set the last entry in the chain to the start to make the list circular + qtmp->next = NULL; + callback = NULL; + q = NULL; + free_fn = qfree; +#ifdef CYGDBG_USE_ASSERTS + qlen = maxmsgs; + msgsize = maxmsgsize; +#endif + + *err = OK; + + // object should be valid now + CYG_ASSERT_THISC(); + + CYG_REPORT_RETURN(); +} + +//------------------------------------------------------------------------ + +inline +Cyg_Mqueue::~Cyg_Mqueue() +{ + CYG_REPORT_FUNCTION(); + + if ( NULL != queuespace ) { + // object should be valid if queuespace was successfully allocated + CYG_ASSERT_THISC(); + free_fn( queuespace, queuespacesize ); + } + +#ifdef CYGDBG_USE_ASSERTS + qlen = msgsize = 0; // deliberately make it fail check_this() if used +#endif + + CYG_REPORT_RETURN(); +} + +//------------------------------------------------------------------------ + +// put() copies len bytes of *buf into the queue at priority prio +inline Cyg_Mqueue::qerr_t +Cyg_Mqueue::put( const char *buf, size_t len, unsigned int prio, bool block ) +{ + CYG_REPORT_FUNCTYPE( "err=%d"); + CYG_REPORT_FUNCARG4( "buf=%08x, len=%ld, prio=%ud, block=%d", + buf, len, prio, block==true ); + CYG_CHECK_DATA_PTRC( buf ); + CYG_ASSERT_THISC(); + CYG_PRECONDITIONC( len <= (size_t)msgsize ); + + qerr_t err; + struct qentry *qtmp, *qent; + + // wait till a freelist entry is available + if ( true == block ) { + if ( false == putsem.wait() ) { + err = INTR; + goto exit; + } + } else { + if ( false == putsem.trywait() ) { + err = WOULDBLOCK; + goto exit; + } + } + + // prevent preemption when fiddling with important members + Cyg_Scheduler::lock(); + + CYG_ASSERT_THISC(); + + // get a queue entry from the freelist + // don't need to check the freelist - the semaphore tells us there's + // definitely a usable non-busy one there. It's just a question of + // locating it. + + if (!freelist->busy) { // fast-track common case + qent = freelist; + freelist = freelist->next; + } else { + for ( qtmp=freelist; !qtmp->next->busy; qtmp=qtmp->next ) + CYG_EMPTY_STATEMENT; // skip through + qent = qtmp->next; + qtmp->next = qent->next; + } + + // now put it in place in q + + if ( NULL == q ) { + q = qent; + q->next = NULL; + } else { + struct qentry **qentp; + + // insert into queue according to prio + for ( qentp=&q; NULL != *qentp; qentp = &((*qentp)->next) ) { + if ((*qentp)->priority < prio) + break; + } // for + + qent->next = *qentp; + *qentp = qent; + } // else + + qent->priority = prio; // have to set this now so when the sched is + // unlocked, other qent's can be added in the + // right place + qent->busy = true; // let things know this entry should be ignored until + // it's finished having its data copied + + // unlock the scheduler, and potentially switch threads, but + // that's okay now. We don't want it locked for the expensive memcpy + Cyg_Scheduler::unlock(); + + qent->buflen = len; + memcpy( qent->buf(), buf, len ); + + // make available now - setting non-atomically is alright if you think + // about it - the only thing that matters is that it's completed before + // the post() + qent->busy = false; + + // if we have to notify someone, we only do it if no-one's already + // sitting waiting for a message to appear, AND if it's a transition + // from empty to non-empty + + if ( callback != NULL && !getsem.waiting() && (0 == getsem.peek()) ) { + getsem.post(); + callback( *this, callback_data ); + } else + getsem.post(); + + err = OK; + + exit: + CYG_ASSERT_THISC(); + CYG_REPORT_RETVAL(err); + return err; +} // Cyg_Mqueue::put() + +//------------------------------------------------------------------------ + + +// get() returns the oldest highest priority message in the queue in *buf +// and sets *prio to the priority (if prio is non-NULL) and *len to the +// actual message size + +inline Cyg_Mqueue::qerr_t +Cyg_Mqueue::get( char *buf, size_t *len, unsigned int *prio, bool block ) +{ + CYG_REPORT_FUNCTYPE( "err=%d"); + CYG_REPORT_FUNCARG4( "buf=%08x, len=%08x, prio=%08x, block=%d", + buf, len, prio, block==true ); + CYG_CHECK_DATA_PTRC( buf ); + CYG_CHECK_DATA_PTRC( len ); + if ( NULL != prio ) + CYG_CHECK_DATA_PTRC( prio ); + CYG_ASSERT_THISC(); + + qerr_t err; + struct qentry *qent; + + // wait till a q entry is available + if ( true == block ) { + if ( false == getsem.wait() ) { + err = INTR; + goto exit; + } + } else { + if ( false == getsem.trywait() ) { + err = WOULDBLOCK; + goto exit; + } + } + + // prevent preemption when fiddling with important members + + Cyg_Scheduler::lock(); + + // don't need to check the q - the semaphore tells us there's + // definitely a usable non-busy one there. It's just a question of + // locating it. + + if ( !q->busy ) { // fast-track the common case + qent = q; + q = qent->next; + } else { + struct qentry *qtmp; + + for ( qtmp=q; !qtmp->next->busy; qtmp=qtmp->next ) + CYG_EMPTY_STATEMENT; // skip through + + qent = qtmp->next; + qtmp->next = qent->next; + } // else + + // now stick at front of freelist, but marked busy + qent->next = freelist; + freelist = qent; + + qent->busy = true; // don't let it truly be part of the freelist just yet + // till the data is copied out + + // unlock the scheduler, and potentially switch threads, but + // that's okay now. We don't want it locked for the expensive memcpy + Cyg_Scheduler::unlock(); + + *len = qent->buflen; + if ( NULL != prio ) + *prio = qent->priority; + memcpy( buf, qent->buf(), *len ); + + // make available now - setting non-atomically is alright if you think + // about it - the only thing that matters is that it's completed before + // the post() + qent->busy = false; + + putsem.post(); + + err = OK; + + exit: + CYG_ASSERT_THISC(); + CYG_REPORT_RETVAL(err); + return err; + +} // Cyg_Mqueue::get() + +//------------------------------------------------------------------------ + +// count() returns the number of messages in the queue +inline long +Cyg_Mqueue::count() +{ + CYG_REPORT_FUNCTYPE("curmsgs=%d"); + + long curmsgs = (long)getsem.peek(); + + CYG_REPORT_RETVAL(curmsgs); + return curmsgs; +} // Cyg_Mqueue::count() + +//------------------------------------------------------------------------ + + +// Supply a callback function to call (with the supplied data argument) +// when the queue goes from empty to non-empty (unless someone's already +// doing a get()). This returns the old callback_fn, and if olddata is +// non-NULL sets it to the old data (yes, really!) +inline Cyg_Mqueue::callback_fn_t +Cyg_Mqueue::setnotify( callback_fn_t callback_fn, CYG_ADDRWORD data, + CYG_ADDRWORD *olddata) +{ + CYG_REPORT_FUNCTYPE("old callback=%08x"); + CYG_REPORT_FUNCARG3XV( callback_fn, data, olddata ); + if ( NULL != callback_fn ) + CYG_CHECK_FUNC_PTRC( callback_fn ); + if (NULL != olddata) + CYG_CHECK_DATA_PTRC( olddata ); + + callback_fn_t oldfn; + + // Need to prevent preemption for accessing common structures + // Just locking the scheduler has the least overhead + Cyg_Scheduler::lock(); + + oldfn = callback; + if (NULL != olddata) + *olddata = callback_data; + + callback_data = data; + callback = callback_fn; + + Cyg_Scheduler::unlock(); + + CYG_REPORT_RETVAL(oldfn); + return oldfn; +} + +//------------------------------------------------------------------------ + +#endif /* CYGONCE_KERNEL_MQUEUE_INL multiple inclusion protection */ + +/* EOF mqueue.inl */ diff --git a/packages/kernel/current/include/mutex.hxx b/packages/kernel/current/include/mutex.hxx --- a/packages/kernel/current/include/mutex.hxx +++ b/packages/kernel/current/include/mutex.hxx @@ -59,11 +59,36 @@ class Cyg_Mutex { friend class Cyg_Condition_Variable; - cyg_atomic locked; // true if locked + cyg_atomic locked; // true if locked. This may seem + // redundant due to "owner" below, + // but is intentionally present for + // future SMP support. Cyg_Thread *owner; // Current locking thread Cyg_ThreadQueue queue; // Queue of waiting threads + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC + +public: + enum cyg_protcol + { + NONE = 0, // no inversion protocol + INHERIT, // priority inheritance protocol + CEILING // priority ceiling protocol + }; + +private: + cyg_protcol protocol; // this mutex's protocol + +#endif + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + +private: + cyg_priority ceiling; // mutex priority ceiling + +#endif public: @@ -71,6 +96,12 @@ public: Cyg_Mutex(); // Create in unlocked state +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC + + Cyg_Mutex( cyg_protcol protocol ); // Create with defined protocol + +#endif + ~Cyg_Mutex(); // Destructor cyg_bool lock(); // lock and/or wait @@ -80,6 +111,18 @@ public: void unlock(); // unlock void release(); // release all waiting threads + + // Get the current owning thread + inline Cyg_Thread *get_owner() { return owner; } + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + + // set ceiling priority for priority ceiling protocol + void set_ceiling( cyg_priority priority ); + + cyg_priority get_ceiling(void) { return ceiling; }; + +#endif }; @@ -91,10 +134,22 @@ class Cyg_Condition_Variable Cyg_Mutex *mutex; // Associated mutex Cyg_ThreadQueue queue; // Queue of waiting threads + + // Private internal implementation function for wait operations + cyg_bool wait_inner( Cyg_Mutex *mutex ); + +#ifdef CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT + + // Private internal implementation function for timed wait operations + cyg_bool wait_inner( Cyg_Mutex *mutex, cyg_tick_count timeout ); + +#endif public: CYGDBG_DEFINE_CHECK_THIS + + Cyg_Condition_Variable(); // simple constructor Cyg_Condition_Variable( Cyg_Mutex &mutex // linked mutex @@ -102,18 +157,41 @@ public: ~Cyg_Condition_Variable(); // Destructor - void wait(); // Wait for condition to be true void signal(); // Set cond true, wake one thread void broadcast(); // Set cond true, wake all threads + // Wait for condition to be true + inline cyg_bool wait() { return wait_inner( mutex ); } + #ifdef CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT // Wait until a signal or timeout expiry - cyg_bool wait( cyg_tick_count timeout ); + inline cyg_bool wait( cyg_tick_count timeout ) + { return wait_inner( mutex, timeout ); } #endif + +#ifdef CYGMFN_KERNEL_SYNCH_CONDVAR_WAIT_MUTEX + + // Wait for condition to be true using the supplied mutex + inline cyg_bool wait( Cyg_Mutex &mx ) { return wait_inner( &mx ); } + + +#ifdef CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT + + // Wait until a signal or timeout expiry, using the supplied mutex + inline cyg_bool wait( Cyg_Mutex &mx, cyg_tick_count timeout ) + { return wait_inner( &mx, timeout ); } + +#endif +#endif + + // Return a pointer to this variables thread queue. Used mainly + // for testing whether a thread is on the queue for a particular + // cv. + inline Cyg_ThreadQueue *get_queue() { return &queue; }; }; diff --git a/packages/kernel/current/include/sched.hxx b/packages/kernel/current/include/sched.hxx --- a/packages/kernel/current/include/sched.hxx +++ b/packages/kernel/current/include/sched.hxx @@ -49,6 +49,16 @@ #include #include // assertion macros + +// ------------------------------------------------------------------------- +// Miscellaneous types + +#ifdef CYGSEM_KERNEL_SCHED_ASR_SUPPORT + +typedef void Cyg_ASR( CYG_ADDRWORD data ); // ASR type signature + +#endif + // ------------------------------------------------------------------------- // Scheduler base class. This defines stuff that is needed by the // specific scheduler implementation. Each scheduler comprises three @@ -81,12 +91,12 @@ protected: // Do some checking that we have a consistent universe. -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL # ifndef CYGIMP_THREAD_PRIORITY -# error Priority inheritance will not work without priorities!!! +# error Priority inversion protocols will not work without priorities!!! # endif # if CYG_SCHED_UNIQUE_PRIORITIES -# error Priority inheritance needs non-unique priorities!!! +# error Priority inversion protocols need non-unique priorities!!! # endif #endif @@ -103,7 +113,7 @@ class Cyg_Scheduler // function. The unlock() later is an inline shell that deals // with the common case. - static void unlock_inner(); + static void unlock_inner(cyg_uint32 new_lock = 0); public: @@ -118,6 +128,9 @@ public: // release the preemption lock and possibly reschedule static void unlock(); + // release and reclaim the lock atomically + static void reschedule(); + // release the preemption lock without rescheduling static void unlock_simple(); @@ -149,6 +162,7 @@ class Cyg_SchedThread { friend class Cyg_ThreadQueue_Implementation; friend class Cyg_Scheduler_Implementation; + friend class Cyg_Scheduler; Cyg_ThreadQueue *queue; @@ -164,34 +178,111 @@ public: // Remove this thread from current queue void remove(); -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef CYGSEM_KERNEL_SCHED_ASR_SUPPORT + + // ASR support. + // An ASR is an Asynchronous Service Routine. When set pending it + // is called when the thread exits the scheduler. ASRs are mainly + // used by compatibility subsystems, such as POSIX, to implement + // such things as thread cancellation and signal delivery. private: - // For all priority inheritance mechanisms we need to keep track of how + volatile cyg_bool asr_inhibit; // If true, blocks calls to ASRs + + volatile cyg_bool asr_pending; // If true, this thread's ASR should be called. + +#ifdef CYGSEM_KERNEL_SCHED_ASR_GLOBAL + static +#endif + Cyg_ASR *asr; // ASR function +#ifdef CYGSEM_KERNEL_SCHED_ASR_DATA_GLOBAL + static +#endif + CYG_ADDRWORD asr_data; // ASR data pointer + + // Default ASR function + static void asr_default(CYG_ADDRWORD data); + +public: + + // Public interface to ASR mechanism + + // Set, clear and get inhibit flag. + inline void set_asr_inhibit() { asr_inhibit = true; } + inline void clear_asr_inhibit() { asr_inhibit = false; } + inline cyg_bool get_asr_inhibit() { return asr_inhibit; } + + // Set and get pending flag. The flag is only cleared when the + // ASR is called. + inline void set_asr_pending() { asr_pending = true; } + inline cyg_bool get_asr_pending() { return asr_pending; } + + // Set a new ASR, returning the old one. + void set_asr( Cyg_ASR *new_asr, CYG_ADDRWORD new_data, + Cyg_ASR **old_asr, CYG_ADDRWORD *old_data); + + // Clear the ASR function back to the default. + void clear_asr(); + +#else + +public: + + // Even when we do not have ASRs enabled, we keep these functions + // available. This avoids excessive ifdefs in the rest of the + // kernel code. + inline void set_asr_inhibit() { } + inline void clear_asr_inhibit() { } + +#endif + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL + +private: + + // For all priority inversion protocols we need to keep track of how // many mutexes we have locked, including one which we are waiting to // lock, because we can inherit priority while sleeping just prior to // wakeup. + cyg_count32 mutex_count; +protected: + // These are implementation functions that are common to all protocols. + + // Inherit the given priority. If thread is non-NULL the priority is + // being inherited from it, otherwise it has come from the mutex. + void set_inherited_priority( cyg_priority pri, Cyg_Thread *thread = 0 ); + + // Relay the priority of the ex-owner thread or from the queue if it + // has a higher priority than ours. + void relay_inherited_priority( Cyg_Thread *ex_owner, Cyg_ThreadQueue *pqueue); + + // Lose priority inheritance + void clear_inherited_priority(); + public: // Count and uncount the number of mutexes held by // this thread. void count_mutex() { mutex_count++; }; void uncount_mutex() { mutex_count--; }; + +#if defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE) protected: -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE - // The simple priority inheritance mechanism simply needs + // The simple priority inversion protocols simply needs // somewhere to store the base priority of the current thread. cyg_priority original_priority; // our original priority cyg_bool priority_inherited; // have we inherited? - + #endif +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT + public: // Inherit the priority of the provided thread if it @@ -206,6 +297,20 @@ public: void disinherit_priority(); #endif + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + +public: + + // Set the priority of this thread to the given ceiling. + void set_priority_ceiling( cyg_priority pri ); + + // Clear the ceiling, if necessary. + void clear_priority_ceiling(); + +#endif + +#endif }; diff --git a/packages/kernel/current/include/sched.inl b/packages/kernel/current/include/sched.inl --- a/packages/kernel/current/include/sched.inl +++ b/packages/kernel/current/include/sched.inl @@ -89,12 +89,24 @@ inline void Cyg_Scheduler::unlock() cyg_ucount32 __lock = sched_lock - 1; - if( __lock == 0 ) unlock_inner(); + if( __lock == 0 ) unlock_inner(0); else sched_lock = __lock; HAL_REORDER_BARRIER(); } +inline void Cyg_Scheduler::reschedule() +{ + // This function performs the equivalent of calling unlock() and + // lock() is succession. Unlike that pair, however, it does not + // leave a brief window between the calls when the lock is unclaimed + // by the current thread. + + CYG_INSTRUMENT_SCHED(RESCHEDULE,sched_lock,0); + + unlock_inner( sched_lock ); +} + inline void Cyg_Scheduler::unlock_simple() { // This function decrements the lock, but does not call unlock_inner(). diff --git a/packages/kernel/current/include/sema.hxx b/packages/kernel/current/include/sema.hxx --- a/packages/kernel/current/include/sema.hxx +++ b/packages/kernel/current/include/sema.hxx @@ -49,7 +49,7 @@ #include #include // assertion macros -#include +#include // thread inlines // ------------------------------------------------------------------------- // Binary semaphore. This has only two states: posted and not-posted. @@ -109,7 +109,7 @@ public: void post(); // Increment count - cyg_count32 peek(); // Get current count value + cyg_count32 peek() const; // Get current count value inline cyg_bool waiting() // Is anyone waiting? diff --git a/packages/kernel/current/include/sema2.hxx b/packages/kernel/current/include/sema2.hxx --- a/packages/kernel/current/include/sema2.hxx +++ b/packages/kernel/current/include/sema2.hxx @@ -113,7 +113,7 @@ public: void post(); // Increment count - cyg_count32 peek(); // Get current count value + cyg_count32 peek() const; // Get current count value inline cyg_bool waiting() // Is anyone waiting? diff --git a/packages/kernel/current/include/thread.inl b/packages/kernel/current/include/thread.inl --- a/packages/kernel/current/include/thread.inl +++ b/packages/kernel/current/include/thread.inl @@ -254,7 +254,7 @@ Cyg_Thread::to_queue_head( void ) inline cyg_priority Cyg_Thread::get_priority() { -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE // If we have an inherited priority, return our original // priority rather than the current one. diff --git a/packages/kernel/current/src/common/clock.cxx b/packages/kernel/current/src/common/clock.cxx --- a/packages/kernel/current/src/common/clock.cxx +++ b/packages/kernel/current/src/common/clock.cxx @@ -785,6 +785,24 @@ void Cyg_Alarm::enable() } } +// ------------------------------------------------------------------------- +// Get the current time values from the alarm + +void Cyg_Alarm::get_times( + cyg_tick_count *t, // Next trigger time + cyg_tick_count *i // Current interval + ) +{ + // Lock the scheduler while we do this to avoid + // race conditions. + Cyg_Scheduler::lock(); + + if( t != NULL ) *t = trigger; + if( i != NULL ) *i = interval; + + Cyg_Scheduler::unlock(); +} + //========================================================================== // System clock object diff --git a/packages/kernel/current/src/common/kapi.cxx b/packages/kernel/current/src/common/kapi.cxx --- a/packages/kernel/current/src/common/kapi.cxx +++ b/packages/kernel/current/src/common/kapi.cxx @@ -58,9 +58,6 @@ #include #include -#include -#include - #include #include #include @@ -706,188 +703,6 @@ externC cyg_bool_t cyg_mbox_waiting_to_p } -/*-----------------------------------------------------------------------*/ -/* Memory pools */ - -/* Create a variable size memory pool */ -externC void cyg_mempool_var_create( - void *base, /* base of memory to use for pool */ - cyg_int32 size, /* size of memory in bytes */ - cyg_handle_t *handle, /* returned handle of memory pool */ - cyg_mempool_var *var /* space to put pool structure in */ - ) -{ - CYG_ASSERT_SIZES( cyg_mempool_var, Cyg_Mempool_Variable ); - - Cyg_Mempool_Variable *t = new((void *)var) Cyg_Mempool_Variable ( - (cyg_uint8 *)base, - size - ); - t=t; - - CYG_CHECK_DATA_PTR( handle, "Bad handle pointer" ); - *handle = (cyg_handle_t)var; -} - -/* Delete variable size memory pool */ -externC void cyg_mempool_var_delete(cyg_handle_t varpool) -{ - ((Cyg_Mempool_Variable *)varpool)->~Cyg_Mempool_Variable(); -} - -/* Allocates a block of length size. This waits if the memory is not - currently available. */ -externC void *cyg_mempool_var_alloc(cyg_handle_t varpool, cyg_int32 size) -{ - return ((Cyg_Mempool_Variable *)varpool)->alloc(size); -} - -#ifdef CYGFUN_KERNEL_THREADS_TIMER - -/* Allocates a block of length size. This waits for up to delay - ticks, if the memory is not already available. NULL is returned if - no memory is available. */ -externC void *cyg_mempool_var_timed_alloc( - cyg_handle_t varpool, - cyg_int32 size, - cyg_tick_count_t abstime) -{ - return ((Cyg_Mempool_Variable *)varpool)->alloc(size, abstime); -} - -#endif - -/* Allocates a block of length size. NULL is returned if no memory is - available. */ -externC void *cyg_mempool_var_try_alloc( - cyg_handle_t varpool, - cyg_int32 size) -{ - return ((Cyg_Mempool_Variable *)varpool)->try_alloc(size); -} - -/* Frees memory back into variable size pool. */ -externC void cyg_mempool_var_free(cyg_handle_t varpool, void *p) -{ - cyg_bool b; - b = ((Cyg_Mempool_Variable *)varpool)->free((cyg_uint8 *)p, 0); - CYG_ASSERT( b, "Bad free"); -} - - -/* Returns true if there are any threads waiting for memory in the - given memory pool. */ -externC cyg_bool_t cyg_mempool_var_waiting(cyg_handle_t varpool) -{ - return ((Cyg_Mempool_Variable *)varpool)->waiting(); -} - -/* Puts information about a variable memory pool into the structure - provided. */ -externC void cyg_mempool_var_get_info( - cyg_handle_t varpool, - cyg_mempool_info *info) -{ - Cyg_Mempool_Variable *v = (Cyg_Mempool_Variable *)varpool; - cyg_uint8 *base; - CYG_ADDRWORD maxfree; - - info->totalmem = v->get_totalmem(); - info->freemem = v->get_freemem(); - v->get_arena(base, info->size, maxfree); - info->base = (void *)base; - info->blocksize = -1; - info->maxfree = maxfree; -} - - -/* Create a fixed size memory pool */ -externC void cyg_mempool_fix_create( - void *base, // base of memory to use for pool - cyg_int32 size, // size of memory in byte - cyg_int32 blocksize, // size of allocation in bytes - cyg_handle_t *handle, // handle of memory pool - cyg_mempool_fix *fix // space to put pool structure in - ) -{ - CYG_ASSERT_SIZES( cyg_mempool_fix, Cyg_Mempool_Fixed ); - - Cyg_Mempool_Fixed *t = new((void *)fix) Cyg_Mempool_Fixed ( - (cyg_uint8 *)base, - size, - blocksize - ); - t=t; - - CYG_CHECK_DATA_PTR( handle, "Bad handle pointer" ); - *handle = (cyg_handle_t)fix; -} - -/* Delete fixed size memory pool */ -externC void cyg_mempool_fix_delete(cyg_handle_t fixpool) -{ - ((Cyg_Mempool_Fixed *)fixpool)->~Cyg_Mempool_Fixed(); -} - -/* Allocates a block. This waits if the memory is not - currently available. */ -externC void *cyg_mempool_fix_alloc(cyg_handle_t fixpool) -{ - return ((Cyg_Mempool_Fixed *)fixpool)->alloc(); -} - -#ifdef CYGFUN_KERNEL_THREADS_TIMER - -/* Allocates a block. This waits for up to delay ticks, if the memory - is not already available. NULL is returned if no memory is - available. */ -externC void *cyg_mempool_fix_timed_alloc( - cyg_handle_t fixpool, - cyg_tick_count_t abstime) -{ - return ((Cyg_Mempool_Fixed *)fixpool)->alloc(abstime); -} - -#endif - -/* Allocates a block. NULL is returned if no memory is available. */ -externC void *cyg_mempool_fix_try_alloc(cyg_handle_t fixpool) -{ - return ((Cyg_Mempool_Fixed *)fixpool)->try_alloc(); -} - -/* Frees memory back into fixed size pool. */ -externC void cyg_mempool_fix_free(cyg_handle_t fixpool, void *p) -{ - cyg_bool b; - b = ((Cyg_Mempool_Fixed *)fixpool)->free((cyg_uint8 *)p); - CYG_ASSERT( b, "Bad free"); -} - -/* Returns true if there are any threads waiting for memory in the - given memory pool. */ -externC cyg_bool_t cyg_mempool_fix_waiting(cyg_handle_t fixpool) -{ - return ((Cyg_Mempool_Fixed *)fixpool)->waiting(); -} - -/* Puts information about a variable memory pool into the structure - provided. */ -externC void cyg_mempool_fix_get_info( - cyg_handle_t fixpool, - cyg_mempool_info *info) -{ - Cyg_Mempool_Fixed *f = (Cyg_Mempool_Fixed *)fixpool; - cyg_uint8 *base; - cyg_addrword_t blocksize; - - info->totalmem = f->get_totalmem(); - info->freemem = f->get_freemem(); - f->get_arena(base, info->size, blocksize); - info->base = (void *)base; - info->maxfree = info->blocksize = (cyg_int32)blocksize; -} - /*---------------------------------------------------------------------------*/ /* Semaphores */ @@ -907,9 +722,9 @@ externC void cyg_semaphore_destroy( cyg_ ((Cyg_Counting_Semaphore *)sem)->~Cyg_Counting_Semaphore(); } -externC void cyg_semaphore_wait( cyg_sem_t *sem ) +externC cyg_bool_t cyg_semaphore_wait( cyg_sem_t *sem ) { - ((Cyg_Counting_Semaphore *)sem)->wait(); + return ((Cyg_Counting_Semaphore *)sem)->wait(); } #ifdef CYGFUN_KERNEL_THREADS_TIMER @@ -1076,9 +891,9 @@ externC void cyg_cond_destroy( cyg_cond_ ((Cyg_Condition_Variable *)cond)->~Cyg_Condition_Variable(); } -externC void cyg_cond_wait( cyg_cond_t *cond ) +externC cyg_bool_t cyg_cond_wait( cyg_cond_t *cond ) { - ((Cyg_Condition_Variable *)cond)->wait(); + return ((Cyg_Condition_Variable *)cond)->wait(); } externC void cyg_cond_signal( cyg_cond_t *cond ) @@ -1140,8 +955,6 @@ Cyg_Check_Structure_Sizes::Cyg_Check_Str CYG_CHECK_SIZES( cyg_clock, Cyg_Clock ); CYG_CHECK_SIZES( cyg_alarm, Cyg_Alarm ); CYG_CHECK_SIZES( cyg_mbox, Cyg_Mbox ); - CYG_CHECK_SIZES( cyg_mempool_var, Cyg_Mempool_Variable ); - CYG_CHECK_SIZES( cyg_mempool_fix, Cyg_Mempool_Fixed ); CYG_CHECK_SIZES( cyg_sem_t, Cyg_Counting_Semaphore ); CYG_CHECK_SIZES( cyg_flag_t, Cyg_Flag ); CYG_CHECK_SIZES( cyg_mutex_t, Cyg_Mutex ); @@ -1150,7 +963,7 @@ Cyg_Check_Structure_Sizes::Cyg_Check_Str CYG_ASSERT( !fail, "Size checks failed"); } -Cyg_Check_Structure_Sizes check_structure_sizes(1); +static Cyg_Check_Structure_Sizes cyg_kapi_check_structure_sizes(1); #endif diff --git a/packages/kernel/current/src/common/thread.cxx b/packages/kernel/current/src/common/thread.cxx --- a/packages/kernel/current/src/common/thread.cxx +++ b/packages/kernel/current/src/common/thread.cxx @@ -716,6 +716,8 @@ Cyg_Thread::release() void Cyg_Thread::exit() { + CYG_REPORT_FUNCTION(); + // The thread should never return from this function. Cyg_Thread *self = Cyg_Thread::self(); @@ -855,7 +857,7 @@ Cyg_Thread::set_priority( cyg_priority n #else // !CYG_SCHED_UNIQUE_PRIORITIES -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE // When we have priority inheritance, we must update the original // priority and not the inherited one. If the new priority is diff --git a/packages/kernel/current/src/sched/mlqueue.cxx b/packages/kernel/current/src/sched/mlqueue.cxx --- a/packages/kernel/current/src/sched/mlqueue.cxx +++ b/packages/kernel/current/src/sched/mlqueue.cxx @@ -32,7 +32,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): nickg -// Contributors: nickg, jlarmour +// Contributors: jlarmour // Date: 1999-02-17 // Purpose: Multilevel queue scheduler class implementation // Description: This file contains the implementations of @@ -261,8 +261,12 @@ Cyg_Scheduler_Implementation::timeslice( #endif CYG_ASSERT( queue_map != 0, "Run queue empty"); CYG_ASSERT( queue_map & (1<timeslice_enabled && --timeslice_count == 0 ) +#else if( --timeslice_count == 0 ) +#endif { CYG_INSTRUMENT_SCHED(TIMESLICE,0,0); #ifdef CYGDBG_KERNEL_TRACE_TIMESLICE @@ -272,6 +276,7 @@ Cyg_Scheduler_Implementation::timeslice( current_thread->yield(); } + CYG_ASSERT( queue_map & (1<insert(thread); + else { +#ifdef CYGIMP_KERNEL_SCHED_SORTED_QUEUES + + // Insert the thread into the queue in priority order. + + if( queue == queue->next ) + { + // There is only one other thread in the queue, join it + // and adjust the queue pointer to point to the highest + // priority of the two. If they are the same priority, + // leave the pointer pointing to the oldest. + + queue->insert( thread ); + + if( thread->priority < queue->priority ) + queue = thread; + } + else + { + // There is more than one thread in the queue. First check + // whether we are of higher priority than the head and if + // so just jump in at the front. Also check whether we are + // lower priority than the tail and jump onto the end. + // Otherwise we really have to search the queue to find + // our place. + + if( thread->priority < queue->priority ) + { + queue->insert( thread ); + queue = thread; + } + else if( thread->priority > queue->prev->priority ) + { + // We are lower priority than any thread in the queue, + // go in at the end. + + queue->prev->insert( thread ); + } + else + { + // Search the queue. We do this backwards so that we + // always add new threads after any that have the same + // priority. + + // Because of the previous tests we know that this + // search will terminate before we hit the head of the + // queue, hence we do not need to check for that + // condition. + + Cyg_Thread *qtmp = queue->prev; + + // Scan the queue until we find a higher or equal + // priority thread. + + while( thread->priority > qtmp->priority ) + qtmp = qtmp->prev; + + // Insert ourself after the node pointed to by qtmp. + // We do this by inserting before the next node since + // that is the operation we have. + + qtmp->next->insert( thread ); + } + + } +#else + queue->prev->insert(thread); +#endif + } thread->queue = CYG_CLASSFROMBASE(Cyg_ThreadQueue, Cyg_ThreadQueue_Implementation, @@ -523,7 +601,7 @@ Cyg_ThreadQueue_Implementation::remove(C CYG_REPORT_FUNCTION(); CYG_REPORT_FUNCARG1("thread=%08x", thread); - // If the thread we want it the at the head + // If the thread we want is the at the head // of the list, and is on its own, clear the // list and return. Otherwise advance to the // next thread and remove ours. If the thread @@ -575,6 +653,33 @@ Cyg_ThreadQueue_Implementation::to_head( // ------------------------------------------------------------------------- +inline void +Cyg_ThreadQueue_Implementation::set_thread_queue(Cyg_Thread *thread, + Cyg_ThreadQueue *tq ) + +{ + thread->queue = tq; +} + +// ------------------------------------------------------------------------- + +void +Cyg_SchedulerThreadQueue_Implementation::enqueue(Cyg_Thread *thread) +{ + CYG_REPORT_FUNCTION(); + CYG_REPORT_FUNCARG1("thread=%08x", thread); + + if( queue == NULL ) queue = thread; + else queue->prev->insert(thread); + + set_thread_queue( thread, CYG_CLASSFROMBASE(Cyg_ThreadQueue, + Cyg_SchedulerThreadQueue_Implementation, + this)); + CYG_REPORT_RETURN(); +} + +// ------------------------------------------------------------------------- + #endif // ------------------------------------------------------------------------- diff --git a/packages/kernel/current/src/sched/sched.cxx b/packages/kernel/current/src/sched/sched.cxx --- a/packages/kernel/current/src/sched/sched.cxx +++ b/packages/kernel/current/src/sched/sched.cxx @@ -58,6 +58,7 @@ #include // Architecture specific definitions #include // thread inlines +#include // scheduler inlines //------------------------------------------------------------------------- // Some local tracing control - a default. @@ -91,19 +92,37 @@ cyg_ucount32 Cyg_Scheduler_Base // ------------------------------------------------------------------------- // Scheduler unlock function. -// This is only called when the lock is to be decremented to zero and there -// is the potential for real work to be done. Other cases are handled in -// Cyg_Scheduler::unlock() which is an inline. -void Cyg_Scheduler::unlock_inner() +// This is only called when the lock is to be zeroed and there is the +// potential for real work to be done. Other cases are handled in +// Cyg_Scheduler::unlock() which is an inline. The new_lock argument +// contains the value that the scheduler lock should have after this +// function has completed. If it is zero then the lock is being +// released and some extra work (running ASRs, checking for DSRs) is +// done before returning. If it is non-zero then it must equal the +// current value of the lock, and is used to indicate that we want to +// reacquire the scheduler lock before returning. This latter option +// only makes any sense if the current thread is no longer runnable, +// otherwise this function will do nothing. + +void Cyg_Scheduler::unlock_inner( cyg_ucount32 new_lock ) { #ifdef CYGDBG_KERNEL_TRACE_UNLOCK_INNER CYG_REPORT_FUNCTION(); #endif + // This assert must be outside the loop because running DSRs can make + // it fail if the current thread that was about to sleep is awoken by + // the DSR! Going round the loop to run new DSRs does the same. + CYG_ASSERT( (new_lock == 0) || + (current_thread->state != Cyg_Thread::RUNNING || + need_reschedule) , + "Unnecessary call to unlock_inner()" ); + do { - CYG_PRECONDITION( sched_lock == 1 , "sched_lock not 1" ); + CYG_PRECONDITION( new_lock==0 ? sched_lock == 1 : sched_lock == new_lock, + "sched_lock not at expected value" ); #ifdef CYGIMP_KERNEL_INTERRUPTS_DSRS @@ -113,7 +132,7 @@ void Cyg_Scheduler::unlock_inner() if( Cyg_Interrupt::DSRs_pending() ) Cyg_Interrupt::call_pending_DSRs(); #endif - + Cyg_Thread *current = current_thread; CYG_ASSERTCLASS( current, "Bad current thread" ); @@ -172,29 +191,72 @@ void Cyg_Scheduler::unlock_inner() need_reschedule = false; // finished rescheduling } - - HAL_REORDER_BARRIER(); // Make sure everything above has happened - // by this point - sched_lock = 0; // Clear the lock - HAL_REORDER_BARRIER(); + + if( new_lock == 0 ) + { + +#ifdef CYGSEM_KERNEL_SCHED_ASR_SUPPORT + + // Check whether the ASR is pending and not inhibited. If + // we can call it, then transfer this info to a local + // variable (call_asr) and clear the pending flag. Note + // that we only do this if the scheduler lock is about to + // be zeroed. In any other circumstance we are not + // unlocking. + + cyg_bool call_asr = false; + + if( !current->asr_inhibit && current->asr_pending ) + { + call_asr = true; + current->asr_pending = false; + } +#endif + + HAL_REORDER_BARRIER(); // Make sure everything above has happened + // by this point + sched_lock = 0; // Clear the lock + HAL_REORDER_BARRIER(); #ifdef CYGIMP_KERNEL_INTERRUPTS_DSRS - // Now check whether any DSRs got posted during the thread - // switch and if so, go around again. Making this test after - // the lock has been zeroed avoids a race condition in which - // a DSR could have been posted during a reschedule, but would - // not be run until the _next_ time we release the sched lock. + // Now check whether any DSRs got posted during the thread + // switch and if so, go around again. Making this test after + // the lock has been zeroed avoids a race condition in which + // a DSR could have been posted during a reschedule, but would + // not be run until the _next_ time we release the sched lock. - if( Cyg_Interrupt::DSRs_pending() ) { - sched_lock = 1; // reclaim the lock - continue; // go back to head of loop - } + if( Cyg_Interrupt::DSRs_pending() ) { + sched_lock = 1; // reclaim the lock + continue; // go back to head of loop + } #endif - // Otherwise the lock is zero, we can return. + // Otherwise the lock is zero, we can return. + + CYG_POSTCONDITION( sched_lock == 0, "sched_lock not zero" ); + +#ifdef CYGSEM_KERNEL_SCHED_ASR_SUPPORT + // If the test within the sched_lock indicating that the ASR + // be called was true, call it here. Calling the ASR must be + // the very last thing we do here, since it must run as close + // to "user" state as possible. + + if( call_asr ) current->asr(current->asr_data); +#endif - CYG_POSTCONDITION( sched_lock == 0, "sched_lock not zero" ); + } + else + { + // If new_lock is non-zero then we restore the sched_lock to + // the value given. + + HAL_REORDER_BARRIER(); + + sched_lock = new_lock; + + HAL_REORDER_BARRIER(); + } #ifdef CYGDBG_KERNEL_TRACE_UNLOCK_INNER CYG_REPORT_RETURN(); @@ -270,6 +332,21 @@ cyg_bool Cyg_Scheduler::check_this( cyg_ // SchedThread members // ------------------------------------------------------------------------- +// Static data members + +#ifdef CYGSEM_KERNEL_SCHED_ASR_SUPPORT + +# ifdef CYGSEM_KERNEL_SCHED_ASR_GLOBAL +Cyg_ASR *Cyg_SchedThread::asr = &Cyg_SchedThread::asr_default; +# endif + +# ifdef CYGSEM_KERNEL_SCHED_ASR_DATA_GLOBAL +CYG_ADDRWORD Cyg_SchedThread::asr_data = 0; +# endif + +#endif // CYGSEM_KERNEL_SCHED_ASR_SUPPORT + +// ------------------------------------------------------------------------- // Constructor Cyg_SchedThread::Cyg_SchedThread(Cyg_Thread *thread, CYG_ADDRWORD sched_info) @@ -282,42 +359,116 @@ Cyg_SchedThread::Cyg_SchedThread(Cyg_Thr if( Cyg_Scheduler::current_thread == NULL ) Cyg_Scheduler::current_thread = thread; -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL mutex_count = 0; + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE + priority_inherited = false; #endif +#endif + +#ifdef CYGSEM_KERNEL_SCHED_ASR_SUPPORT + + asr_inhibit = false; + asr_pending = false; + +#ifndef CYGSEM_KERNEL_SCHED_ASR_GLOBAL + asr = asr_default; +#endif +#ifdef CYGSEM_KERNEL_SCHED_ASR_DATA_GLOBAL + asr_data = NULL +#endif +#endif } // ------------------------------------------------------------------------- -// Priority inheritance support. +// ASR support functions + +#ifdef CYGSEM_KERNEL_SCHED_ASR_SUPPORT + +// ------------------------------------------------------------------------- +// Set ASR +// Install a new ASR, returning the old one. + +void Cyg_SchedThread::set_asr( Cyg_ASR *new_asr, CYG_ADDRWORD new_data, + Cyg_ASR **old_asr, CYG_ADDRWORD *old_data) +{ + CYG_REPORT_FUNCTION(); -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE + // Do this with the scheduler locked... + Cyg_Scheduler::lock(); + + if( old_asr != NULL ) *old_asr = asr; + if( old_data != NULL ) *old_data = asr_data; + + // If new_asr is NULL, do not change the ASR, + // but only change the data. + if( new_asr != NULL ) asr = new_asr; + asr_data = new_data; + + Cyg_Scheduler::unlock(); +} // ------------------------------------------------------------------------- -// Inherit the priority of the provided thread if it -// has a higher priority than ours. +// Clear ASR + +void Cyg_SchedThread::clear_asr() +{ + CYG_REPORT_FUNCTION(); + + // Do this with the scheduler locked... + Cyg_Scheduler::lock(); -void Cyg_SchedThread::inherit_priority( Cyg_Thread *thread) + // Reset ASR to default. + asr = asr_default; + asr_data = 0; + + Cyg_Scheduler::unlock(); +} + +// ------------------------------------------------------------------------- +// Default ASR function. +// having this avoids our having to worry about ever seeing a NULL +// pointer as the ASR function. + +void Cyg_SchedThread::asr_default(CYG_ADDRWORD data) { -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE + CYG_REPORT_FUNCTION(); + + data=data; + return; +} + +#endif + +// ------------------------------------------------------------------------- +// Generic priority protocol support - // A simple implementation of priority inheritance. If the other - // thread is of higher priority, reset our priority to his. The - // first time we do this, save our original priority. +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL + +void Cyg_SchedThread::set_inherited_priority( cyg_priority pri, Cyg_Thread *thread ) +{ + CYG_REPORT_FUNCTION(); +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE + + // This is the comon code for priority inheritance and ceiling + // protocols. This implementation provides a simplified version of + // the protocol. + Cyg_Thread *self = CYG_CLASSFROMBASE(Cyg_Thread, Cyg_SchedThread, this); CYG_ASSERT( mutex_count > 0, "Non-positive mutex count"); - CYG_ASSERT( self != thread, "Trying to inherit from self!"); // Compare with *current* priority in case thread has already // inherited - for relay case below. - if( thread->get_current_priority() < priority ) + if( pri < priority ) { cyg_priority mypri = priority; cyg_bool already_inherited = priority_inherited; @@ -329,7 +480,7 @@ void Cyg_SchedThread::inherit_priority( priority_inherited = false; // so that set_prio DTRT - self->set_priority( thread->get_current_priority() ); + self->set_priority( pri ); if( !already_inherited ) original_priority = mypri; @@ -341,19 +492,15 @@ void Cyg_SchedThread::inherit_priority( #endif } -// ------------------------------------------------------------------------- -// Inherit the priority of the ex-owner thread or from the queue if it -// has a higher priority than ours. +void Cyg_SchedThread::relay_inherited_priority( Cyg_Thread *ex_owner, Cyg_ThreadQueue *pqueue) +{ + CYG_REPORT_FUNCTION(); -void Cyg_SchedThread::relay_priority( Cyg_Thread *ex_owner, Cyg_ThreadQueue *pqueue) -{ -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE // A simple implementation of priority inheritance. // At its simplest, this member does nothing. -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE_RELAY - // If there is anyone else waiting, then the *new* owner inherits from // the current one, since that is a maxima of the others waiting. // (It's worth not doing if there's nobody waiting to prevent @@ -361,37 +508,29 @@ void Cyg_SchedThread::relay_priority( Cy // priority ceiling. if ( !pqueue->empty() ) - inherit_priority( ex_owner ); + set_inherited_priority( ex_owner->get_current_priority(), ex_owner ); #endif -#endif } -// ------------------------------------------------------------------------- -// Lose a priority inheritance +void Cyg_SchedThread::clear_inherited_priority() +{ + CYG_REPORT_FUNCTION(); -void Cyg_SchedThread::disinherit_priority() -{ -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE - // A simple implementation of priority inheritance. The - // simplification in this algorithm is that we do not reduce our - // priority until we have freed all mutexes claimed. Hence we can - // continue to run at an artificially high priority even when we - // should not. However, since nested mutexes are rare, the thread - // we have inherited from is likely to be locking the same mutexes - // we are, and mutex claim periods should be very short, the - // performance difference between this and a more complex algorithm - // should be negligible. The most important advantage of this - // algorithm is that it is fast and deterministic. + // A simple implementation of priority inheritance/ceiling + // protocols. The simplification in this algorithm is that we do + // not reduce our priority until we have freed all mutexes + // claimed. Hence we can continue to run at an artificially high + // priority even when we should not. However, since nested + // mutexes are rare, the thread we have inherited from is likely + // to be locking the same mutexes we are, and mutex claim periods + // should be very short, the performance difference between this + // and a more complex algorithm should be negligible. The most + // important advantage of this algorithm is that it is fast and + // deterministic. - // The simplest algorithm also does not cause a 2nd owner (who waited) - // of a mutex to inherit from 3rd, 4th &c threads that are queueing up - // when it is awoken. That limitation is avoided when - // CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE_RELAY is also - // enabled, see above, which passes the raised priority from one thread - // to the next along with the mutex, like a relay baton. - Cyg_Thread *self = CYG_CLASSFROMBASE(Cyg_Thread, Cyg_SchedThread, this); @@ -408,10 +547,85 @@ void Cyg_SchedThread::disinherit_priorit } -#endif +#endif +} + +#endif // CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL + +// ------------------------------------------------------------------------- +// Priority inheritance support. + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT + +// ------------------------------------------------------------------------- +// Inherit the priority of the provided thread if it +// has a higher priority than ours. + +void Cyg_SchedThread::inherit_priority( Cyg_Thread *thread) +{ + CYG_REPORT_FUNCTION(); + + Cyg_Thread *self = CYG_CLASSFROMBASE(Cyg_Thread, + Cyg_SchedThread, + this); + + CYG_ASSERT( mutex_count > 0, "Non-positive mutex count"); + CYG_ASSERT( self != thread, "Trying to inherit from self!"); + + self->set_inherited_priority( thread->get_current_priority(), thread ); + +} + +// ------------------------------------------------------------------------- +// Inherit the priority of the ex-owner thread or from the queue if it +// has a higher priority than ours. + +void Cyg_SchedThread::relay_priority( Cyg_Thread *ex_owner, Cyg_ThreadQueue *pqueue) +{ + CYG_REPORT_FUNCTION(); + + relay_inherited_priority( ex_owner, pqueue ); } -#endif // CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE of any kind +// ------------------------------------------------------------------------- +// Lose a priority inheritance + +void Cyg_SchedThread::disinherit_priority() +{ + CYG_REPORT_FUNCTION(); + + CYG_ASSERT( mutex_count >= 0, "Non-positive mutex count"); + + clear_inherited_priority(); +} + +#endif // CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT + +// ------------------------------------------------------------------------- +// Priority ceiling support + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + +void Cyg_SchedThread::set_priority_ceiling( cyg_priority pri ) +{ + CYG_REPORT_FUNCTION(); + + CYG_ASSERT( mutex_count > 0, "Non-positive mutex count"); + + set_inherited_priority( pri ); + +} + +void Cyg_SchedThread::clear_priority_ceiling( ) +{ + CYG_REPORT_FUNCTION(); + + CYG_ASSERT( mutex_count >= 0, "Non-positive mutex count"); + + clear_inherited_priority(); +} + +#endif // CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING // ------------------------------------------------------------------------- // EOF sched/sched.cxx diff --git a/packages/kernel/current/src/sync/bin_sem.cxx b/packages/kernel/current/src/sync/bin_sem.cxx --- a/packages/kernel/current/src/sync/bin_sem.cxx +++ b/packages/kernel/current/src/sync/bin_sem.cxx @@ -92,10 +92,8 @@ cyg_bool Cyg_Binary_Semaphore::wait() CYG_INSTRUMENT_BINSEM( WAIT, this, 0 ); - CYG_ASSERT( Cyg_Scheduler::get_sched_lock() == 1, "Called with non-zero scheduler lock"); - - Cyg_Scheduler::unlock(); - Cyg_Scheduler::lock(); + // Allow other threads to run + Cyg_Scheduler::reschedule(); CYG_INSTRUMENT_BINSEM( WOKE, this, state ); diff --git a/packages/kernel/current/src/sync/cnt_sem.cxx b/packages/kernel/current/src/sync/cnt_sem.cxx --- a/packages/kernel/current/src/sync/cnt_sem.cxx +++ b/packages/kernel/current/src/sync/cnt_sem.cxx @@ -97,10 +97,8 @@ cyg_bool Cyg_Counting_Semaphore::wait() CYG_INSTRUMENT_CNTSEM( WAIT, this, 0 ); - CYG_ASSERT( Cyg_Scheduler::get_sched_lock() == 1, "Called with non-zero scheduler lock"); - - Cyg_Scheduler::unlock(); - Cyg_Scheduler::lock(); + // Allow other threads to run + Cyg_Scheduler::reschedule(); CYG_INSTRUMENT_CNTSEM( WOKE, this, count ); @@ -166,11 +164,8 @@ Cyg_Counting_Semaphore::wait( cyg_tick_c CYG_INSTRUMENT_CNTSEM( WAIT, this, 0 ); - CYG_ASSERT( Cyg_Scheduler::get_sched_lock() == 1, - "Called with non-zero scheduler lock"); - - Cyg_Scheduler::unlock(); - Cyg_Scheduler::lock(); + // Allow other threads to run + Cyg_Scheduler::reschedule(); CYG_INSTRUMENT_CNTSEM( WOKE, this, count ); @@ -264,7 +259,7 @@ void Cyg_Counting_Semaphore::post() // ------------------------------------------------------------------------- // Get current count value -cyg_count32 Cyg_Counting_Semaphore::peek() +cyg_count32 Cyg_Counting_Semaphore::peek() const { // This is a single read of the value of count. // This is already atomic, hence there is no need diff --git a/packages/kernel/current/src/sync/cnt_sem2.cxx b/packages/kernel/current/src/sync/cnt_sem2.cxx --- a/packages/kernel/current/src/sync/cnt_sem2.cxx +++ b/packages/kernel/current/src/sync/cnt_sem2.cxx @@ -278,7 +278,7 @@ void Cyg_Counting_Semaphore2::post() // ------------------------------------------------------------------------- // Get current count value -cyg_count32 Cyg_Counting_Semaphore2::peek() +cyg_count32 Cyg_Counting_Semaphore2::peek() const { // This is a single read of the value of count. // This is already atomic, hence there is no need diff --git a/packages/kernel/current/src/sync/flag.cxx b/packages/kernel/current/src/sync/flag.cxx --- a/packages/kernel/current/src/sync/flag.cxx +++ b/packages/kernel/current/src/sync/flag.cxx @@ -242,12 +242,8 @@ Cyg_Flag::wait( Cyg_FlagValue pattern, W // keep track of myself on the queue of waiting threads queue.enqueue( self ); - CYG_ASSERT( 1 == Cyg_Scheduler::get_sched_lock(), - "Called with non-zero scheduler lock"); - - // Unlock scheduler and allow other threads to run - Cyg_Scheduler::unlock(); - Cyg_Scheduler::lock(); + // Allow other threads to run + Cyg_Scheduler::reschedule(); CYG_ASSERT( ((CYG_ADDRWORD)&saveme) == Cyg_Thread::self()->get_wait_info(), @@ -333,12 +329,8 @@ Cyg_Flag::wait( Cyg_FlagValue pattern, W // keep track of myself on the queue of waiting threads queue.enqueue( self ); - CYG_ASSERT( 1 == Cyg_Scheduler::get_sched_lock(), - "Called with non-zero scheduler lock"); - - // Unlock scheduler and allow other threads to run - Cyg_Scheduler::unlock(); - Cyg_Scheduler::lock(); + // Allow other threads to run + Cyg_Scheduler::reschedule(); CYG_ASSERT( ((CYG_ADDRWORD)&saveme) == Cyg_Thread::self()->get_wait_info(), diff --git a/packages/kernel/current/src/sync/mutex.cxx b/packages/kernel/current/src/sync/mutex.cxx --- a/packages/kernel/current/src/sync/mutex.cxx +++ b/packages/kernel/current/src/sync/mutex.cxx @@ -55,6 +55,23 @@ #include // scheduler inlines #include // clock inlines +// ------------------------------------------------------------------------- +// Mutex protocol test macros. +// If the dynamic protocol option is enabled, then these generate appropriate +// tests on the protocol field. If there is no dynamic choice then they simply +// result in empty statements. + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC + +#define IF_PROTOCOL_INHERIT if( protocol == INHERIT ) +#define IF_PROTOCOL_CEILING if( protocol == CEILING ) + +#else + +#define IF_PROTOCOL_INHERIT +#define IF_PROTOCOL_CEILING + +#endif // ------------------------------------------------------------------------- // Constructor @@ -66,10 +83,60 @@ Cyg_Mutex::Cyg_Mutex() locked = false; owner = NULL; +#if defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT) && \ + defined(CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC) + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_INHERIT + protocol = INHERIT; +#endif +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_CEILING + protocol = CEILING; + ceiling = CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY; +#endif +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_NONE + protocol = NONE; +#endif + +#endif + CYG_REPORT_RETURN(); } // ------------------------------------------------------------------------- +// Construct with defined protocol + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC + +Cyg_Mutex::Cyg_Mutex( cyg_protcol protocol_arg ) +{ + CYG_REPORT_FUNCTION(); + + locked = false; + owner = NULL; + + protocol = protocol_arg; + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY + + // if there is a default priority ceiling defined, use that to initialize + // the ceiling. + ceiling = CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_PRIORITY; + +#else + + // Otherwise set it to zero. + ceiling = 0; + +#endif +#endif + + CYG_REPORT_RETURN(); +} + +#endif + +// ------------------------------------------------------------------------- // Destructor Cyg_Mutex::~Cyg_Mutex() @@ -135,7 +202,7 @@ Cyg_Mutex::lock(void) // thread grabbing the mutex between the wakeup in unlock() and // this thread actually starting. -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL self->count_mutex(); @@ -151,21 +218,18 @@ Cyg_Mutex::lock(void) queue.enqueue( self ); -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT - owner->inherit_priority(self); + IF_PROTOCOL_INHERIT + owner->inherit_priority(self); #endif CYG_INSTRUMENT_MUTEX(WAIT, this, 0); - CYG_ASSERT( Cyg_Scheduler::get_sched_lock() == 1, "Called with non-zero scheduler lock"); + // Allow other threads to run + Cyg_Scheduler::reschedule(); - // Unlock scheduler and allow other threads - // to run - Cyg_Scheduler::unlock(); - Cyg_Scheduler::lock(); - CYG_ASSERTCLASS( this, "Bad this pointer"); switch( self->get_wake_reason() ) @@ -190,13 +254,23 @@ Cyg_Mutex::lock(void) locked = true; owner = self; +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + + IF_PROTOCOL_CEILING + self->set_priority_ceiling(ceiling); + +#endif + CYG_INSTRUMENT_MUTEX(LOCKED, this, 0); } -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT else { - self->uncount_mutex(); - self->disinherit_priority(); + IF_PROTOCOL_INHERIT + { + self->uncount_mutex(); + self->disinherit_priority(); + } } #endif @@ -234,11 +308,18 @@ Cyg_Mutex::trylock(void) locked = true; owner = self; -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL self->count_mutex(); #endif +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + + IF_PROTOCOL_CEILING + self->set_priority_ceiling(ceiling); + +#endif + } else result = false; @@ -277,12 +358,13 @@ Cyg_Mutex::unlock(void) CYG_ASSERTCLASS( thread, "Bad thread pointer"); -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT // Give the owner-to-be a chance to inherit from the remaining // queue or the relinquishing thread: - thread->relay_priority(owner, &queue); + IF_PROTOCOL_INHERIT + thread->relay_priority(owner, &queue); #endif @@ -294,12 +376,23 @@ Cyg_Mutex::unlock(void) } -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL owner->uncount_mutex(); - owner->disinherit_priority(); + +#endif +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT + + IF_PROTOCOL_INHERIT + owner->disinherit_priority(); #endif +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + + IF_PROTOCOL_CEILING + owner->clear_priority_ceiling(); + +#endif locked = false; owner = NULL; @@ -349,6 +442,31 @@ void Cyg_Mutex::release() CYG_REPORT_RETURN(); } +// ------------------------------------------------------------------------- +// Set ceiling priority for priority ceiling protocol + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING + +void Cyg_Mutex::set_ceiling( cyg_priority priority ) +{ + CYG_REPORT_FUNCTION(); + +// CYG_ASSERT( priority >= CYG_THREAD_MAX_PRIORITY, "Priority out of range"); +// CYG_ASSERT( priority <= CYG_THREAD_MIN_PRIORITY, "Priority out of range"); + + // Prevent preemption + Cyg_Scheduler::lock(); + + ceiling = priority; + + // Unlock the scheduler + Cyg_Scheduler::unlock(); + + CYG_REPORT_RETURN(); +} + +#endif + //========================================================================== // Condition variables @@ -365,6 +483,15 @@ Cyg_Condition_Variable::Cyg_Condition_Va CYG_REPORT_RETURN(); } +Cyg_Condition_Variable::Cyg_Condition_Variable() +{ + CYG_REPORT_FUNCTION(); + + mutex = NULL; + + CYG_REPORT_RETURN(); +} + // ------------------------------------------------------------------------- // Destructor @@ -399,7 +526,7 @@ Cyg_Condition_Variable::check_this( cyg_ case cyg_system_test: case cyg_extreme: case cyg_thorough: - if( !mutex->check_this(zeal) ) + if( mutex != NULL && !mutex->check_this(zeal) ) result = false; case cyg_quick: case cyg_trivial: @@ -422,11 +549,12 @@ Cyg_Condition_Variable::check_this( cyg_ // in this case, exit with the scheduler locked, which allows this function // to be used in a totally thread-safe manner. -void -Cyg_Condition_Variable::wait(void) +cyg_bool +Cyg_Condition_Variable::wait_inner( Cyg_Mutex *mx ) { CYG_REPORT_FUNCTION(); - + + cyg_bool result = true; Cyg_Thread *self = Cyg_Thread::self(); cyg_int32 current_lock = Cyg_Scheduler::get_sched_lock(); @@ -436,12 +564,12 @@ Cyg_Condition_Variable::wait(void) Cyg_Scheduler::lock(); CYG_ASSERTCLASS( this, "Bad this pointer"); - CYG_ASSERTCLASS( mutex, "Corrupt mutex"); + CYG_ASSERTCLASS( mx, "Corrupt mutex"); CYG_ASSERTCLASS( self, "Bad self thread"); CYG_INSTRUMENT_CONDVAR(WAIT, this, 0); - mutex->unlock(); + mx->unlock(); self->set_sleep_reason( Cyg_Thread::WAIT ); @@ -450,17 +578,28 @@ Cyg_Condition_Variable::wait(void) queue.enqueue( self ); CYG_ASSERT( Cyg_Scheduler::get_sched_lock() == 1, "Called with non-zero scheduler lock"); + + // Avoid calling ASRs during the following unlock. + self->set_asr_inhibit(); // Unlock the scheduler and switch threads Cyg_Scheduler::unlock(); + // Allow ASRs again + self->clear_asr_inhibit(); + CYG_INSTRUMENT_CONDVAR(WOKE, this, self->get_wake_reason()); - + CYG_ASSERTCLASS( this, "Bad this pointer"); - CYG_ASSERTCLASS( mutex, "Corrupt mutex"); + CYG_ASSERTCLASS( mx, "Corrupt mutex"); switch( self->get_wake_reason() ) { + case Cyg_Thread::DESTRUCT: // which, the cv or the mutex? + case Cyg_Thread::BREAK: + result = false; + break; + case Cyg_Thread::EXIT: self->exit(); break; @@ -469,7 +608,6 @@ Cyg_Condition_Variable::wait(void) break; } - // When we awake, we must re-acquire the mutex. Note that while // it is essential to release the mutex and queue on the CV // atomically relative to other threads, to avoid races, it is not @@ -478,19 +616,21 @@ Cyg_Condition_Variable::wait(void) // We need to loop here in case the thread is released while waiting // for the mutex. It is essential that we exit this function with the // mutex claimed. - - while ( !mutex->lock() ) + + while ( !mx->lock() ) continue; CYG_ASSERTCLASS( this, "Bad this pointer"); - CYG_ASSERTCLASS( mutex, "Corrupt mutex"); - CYG_ASSERT( mutex->owner == self, "Not mutex owner"); + CYG_ASSERTCLASS( mx, "Corrupt mutex"); + CYG_ASSERT( mx->owner == self, "Not mutex owner"); CYG_REPORT_RETURN(); if (current_lock) // Reacquire the DSR pseudo lock Cyg_Scheduler::lock(); + + return result; } // ------------------------------------------------------------------------- @@ -502,7 +642,6 @@ Cyg_Condition_Variable::signal(void) CYG_REPORT_FUNCTION(); CYG_ASSERTCLASS( this, "Bad this pointer"); - CYG_ASSERTCLASS( mutex, "Corrupt mutex"); // Prevent preemption Cyg_Scheduler::lock(); @@ -527,7 +666,6 @@ Cyg_Condition_Variable::signal(void) } CYG_ASSERTCLASS( this, "Bad this pointer"); - CYG_ASSERTCLASS( mutex, "Corrupt mutex"); // Unlock the scheduler and maybe switch threads Cyg_Scheduler::unlock(); @@ -544,7 +682,6 @@ Cyg_Condition_Variable::broadcast(void) CYG_REPORT_FUNCTION(); CYG_ASSERTCLASS( this, "Bad this pointer"); - CYG_ASSERTCLASS( mutex, "Corrupt mutex"); // Prevent preemption Cyg_Scheduler::lock(); @@ -568,7 +705,6 @@ Cyg_Condition_Variable::broadcast(void) } CYG_ASSERTCLASS( this, "Bad this pointer"); - CYG_ASSERTCLASS( mutex, "Corrupt mutex"); // Unlock the scheduler and maybe switch threads Cyg_Scheduler::unlock(); @@ -582,13 +718,13 @@ Cyg_Condition_Variable::broadcast(void) #if defined(CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT) cyg_bool -Cyg_Condition_Variable::wait( cyg_tick_count timeout ) +Cyg_Condition_Variable::wait_inner( Cyg_Mutex *mx, cyg_tick_count timeout ) { CYG_REPORT_FUNCTYPE("returning %d"); CYG_REPORT_FUNCARG1("timeout = %d", timeout); CYG_ASSERTCLASS( this, "Bad this pointer"); - CYG_ASSERTCLASS( mutex, "Corrupt mutex"); + CYG_ASSERTCLASS( mx, "Corrupt mutex"); cyg_bool result = true; @@ -601,7 +737,7 @@ Cyg_Condition_Variable::wait( cyg_tick_c CYG_INSTRUMENT_CONDVAR(TIMED_WAIT, this, 0 ); - mutex->unlock(); + mx->unlock(); // The ordering of sleep() and set_timer() here are // important. If the timeout is in the past, the thread @@ -617,12 +753,18 @@ Cyg_Condition_Variable::wait( cyg_tick_c queue.enqueue( self ); CYG_ASSERT( Cyg_Scheduler::get_sched_lock() == 1, "Called with non-zero scheduler lock"); - + + // Avoid calling ASRs during the following unlock. + self->set_asr_inhibit(); + // Unlock the scheduler and switch threads Cyg_Scheduler::unlock(); + // Allow ASRs again + self->clear_asr_inhibit(); + CYG_ASSERTCLASS( this, "Bad this pointer"); - CYG_ASSERTCLASS( mutex, "Corrupt mutex"); + CYG_ASSERTCLASS( mx, "Corrupt mutex"); self->clear_timer(); @@ -651,13 +793,11 @@ Cyg_Condition_Variable::wait( cyg_tick_c // necessary for us to re-acquire the mutex in the same atomic // action. Hence we can do it after unlocking the scheduler. - // FIXME: what if we woke up above due to TIMEOUT/DESTRUCT/BREAK? - // In that situation is it correct to not lock the mutex? - if (false != result) - result = mutex->lock(); - + while ( !mx->lock() ) + continue; + CYG_ASSERTCLASS( this, "Bad this pointer"); - CYG_ASSERTCLASS( mutex, "Corrupt mutex"); + CYG_ASSERTCLASS( mx, "Corrupt mutex"); CYG_REPORT_RETVAL(result); diff --git a/packages/kernel/current/tests/dhrystone.c b/packages/kernel/current/tests/dhrystone.c --- a/packages/kernel/current/tests/dhrystone.c +++ b/packages/kernel/current/tests/dhrystone.c @@ -29,28 +29,38 @@ //============================================================================= #include +#include +#include #include #include -#if defined(CYGPKG_KERNEL) && defined(CYGPKG_LIBC) +#if !defined(CYGPKG_ISOINFRA) +# define NA_MSG "Requires CYGPKG_ISOINFRA" +#else +# include -#include -#include -#include +# if !defined(CYGFUN_KERNEL_API_C) \ + || CYGINT_ISO_STDIO_FORMATTED_IO == 0 \ + || CYGINT_ISO_MALLOC == 0 \ + || CYGINT_ISO_STRING_STRFUNCS == 0 -#if defined(CYGFUN_KERNEL_API_C) \ - && defined(CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT) \ - && defined(CYGPKG_LIBC_MALLOC) +# define NA_MSG "Requires CYGFUN_KERNEL_API_C && CYGINT_ISO_STDIO_FORMATTED_IO && CYGINT_ISO_MALLOC && CYGINT_ISO_STRING_STRFUNCS" -#if defined(__OPTIMIZE__) \ - && !defined(CYGPKG_INFRA_DEBUG) \ - && !defined(CYGPKG_KERNEL_INSTRUMENT) +# elif !defined(__OPTIMIZE__) \ + || defined(CYGPKG_INFRA_DEBUG) \ + || defined(CYGPKG_KERNEL_INSTRUMENT) +# define NA_MSG "Only runs with optimized code, no tracing and no asserts" +# elif defined(CYGDBG_INFRA_DIAG_USE_DEVICE) +# define NA_MSG "Must use HAL diag output to avoid background DSR activity" +# endif +#endif -#if !defined(CYGDBG_INFRA_DIAG_USE_DEVICE) +#ifndef NA_MSG #include #include #include +#include // Time in seconds. double @@ -1165,23 +1175,8 @@ Enumeration Enum_Par_Val; return (false); } /* Func_3 */ -#else -#define NA_MSG "Must use HAL diag output to avoid background DSR activity" -#endif // CYGDBG_INFRA_DIAG_USE_DEVICE - -#else -#define NA_MSG "Only runs with optimized code, no tracing and no asserts" -#endif // __OPTIMIZE__ && !CYGPKG_INFRA_DEBUG && !CYGPKG_KERNEL_INSTRUMENT +#else /* ifndef NA_MSG */ -#else -#define NA_MSG "Requires CYGFUN_KERNEL_API_C && CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT && CYGPKG_LIBC_MALLOC" -#endif // CYGFUN_KERNEL_API_C && CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT - // CYGPKG_LIBC_MALLOC -#else -#define NA_MSG "Requires CYGPKG_KERNEL && CYGPKG_LIBC" -#endif // CYGPKG_KERNEL && CYGPKG_LIBC - -#ifdef NA_MSG externC void cyg_start( void ) { diff --git a/packages/kernel/current/tests/mqueue1.cxx b/packages/kernel/current/tests/mqueue1.cxx new file mode 100644 --- /dev/null +++ b/packages/kernel/current/tests/mqueue1.cxx @@ -0,0 +1,396 @@ +/*======================================================================== +// +// mqueue1.cxx +// +// Message queues tests +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-05-12 +// Purpose: This file provides tests for eCos mqueues +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//====================================================================== +*/ + +/* CONFIGURATION */ + +#include + +/* INCLUDES */ + +#include // common types and externC +#include // Cyg_Thread +#include +#include // Mqueue Header +#include // semaphores +#include // test API + +// use the common kernel test magic to define 2 threads +#define NTHREADS 2 +#include "testaux.hxx" + +/* GLOBALS */ + +static char mempool[500]; +static size_t storedmempoollen; +Cyg_Mqueue *mq; +static Cyg_Binary_Semaphore t0sem, t1sem; +static int calledback; + + +/* FUNCTIONS */ + +static int +my_memcmp(const void *m1, const void *m2, size_t n) +{ + char *s1 = (char *)m1; + char *s2 = (char *)m2; + + while (n--) { + if (*s1 != *s2) + return *s1 - *s2; + s1++; + s2++; + } + return 0; +} // my_memcmp() + +static void * +my_alloc( size_t len ) +{ + if ( len > sizeof(mempool) ) + return NULL; + + storedmempoollen = len; + return &mempool[0]; +} + +static void +my_free( void *ptr, size_t len ) +{ + CYG_TEST_PASS_FAIL( (ptr == &mempool[0]) && (len == storedmempoollen), + "Freed pool correctly"); + mq = NULL; // invalidate +} + +static void +callback(Cyg_Mqueue &mq, CYG_ADDRWORD data) +{ + calledback += (int)data; +} + +//************************************************************************ +//************************************************************************ + +static void +t0( CYG_ADDRWORD data ) +{ + Cyg_Mqueue::qerr_t err; + char buf[35]; + size_t len; + unsigned int prio; + bool b; + + Cyg_Mqueue the_mq(4, 32, &my_alloc, &my_free, &err ); + CYG_TEST_PASS_FAIL( Cyg_Mqueue::OK == err, + "Create queue" ); + mq = &the_mq; + +//------------------------------------------------------------------------ + + err = mq->put( "Peter piper picked", sizeof("Peter piper picked"), + 5, true ); + CYG_TEST_PASS_FAIL( Cyg_Mqueue::OK == err, "Simple (put)"); + + t1sem.post(); + +//------------------------------------------------------------------------ + + t0sem.wait(); + + err = mq->get( buf, &len, &prio, true ); + b = (err == Cyg_Mqueue::OK); + if (b) + b = (len == sizeof("a peck of")); + if (b) + b = (prio == 100); + if (b) + b = (0 == + my_memcmp(buf, "a peck of", sizeof("a peck of")) + ); + CYG_TEST_PASS_FAIL( b, "Blocking get"); + +//------------------------------------------------------------------------ + + t0sem.wait(); + + CYG_TEST_PASS_FAIL( 4 == mq->count(), "mq count" ); + err = mq->get( buf, &len, &prio, false ); + b = (err == Cyg_Mqueue::OK); + if (b) + b = (len == sizeof("pickled peppers")); + if (b) + b = (prio == 300); + if (b) + b = (0 == + my_memcmp(buf, "pickled peppers", sizeof("pickled peppers")) + ); + if (b) + b = (3 == mq->count()); + CYG_TEST_PASS_FAIL( b, "Prioritized (get 1)"); + + err = mq->get( buf, &len, &prio, false ); + b = (err == Cyg_Mqueue::OK); + if (b) + b = (len == sizeof(".")); + if (b) + b = (prio == 250); + if (b) + b = (0 == + my_memcmp(buf, ".", sizeof(".")) + ); + if (b) + b = (2 == mq->count()); + CYG_TEST_PASS_FAIL( b, "Prioritized (get 2)"); + + err = mq->get( buf, &len, &prio, false ); + b = (err == Cyg_Mqueue::OK); + if (b) + b = (len == 1); + if (b) + b = (prio == 225); + if (b) + b = (0 == + my_memcmp(buf, "", 1) + ); + if (b) + b = (1 == mq->count()); + CYG_TEST_PASS_FAIL( b, "Prioritized (get 3)"); + + err = mq->get( buf, &len, &prio, false ); + b = (err == Cyg_Mqueue::OK); + if (b) + b = (len == sizeof("If Peter")); + if (b) + b = (prio == 200); + if (b) + b = (0 == + my_memcmp(buf, "If Peter", sizeof("If Peter")) + ); + if (b) + b = (0 == mq->count()); + CYG_TEST_PASS_FAIL( b, "Prioritized (get 4)"); + +//------------------------------------------------------------------------ + + err = mq->get( buf, &len, &prio, false ); + + CYG_TEST_PASS_FAIL( Cyg_Mqueue::WOULDBLOCK == err, + "Non-blocking get of empty queue" ); + +//------------------------------------------------------------------------ + + Cyg_Mqueue::callback_fn_t oldcallback; + + oldcallback = mq->setnotify( &callback, (CYG_ADDRWORD) 42 ); + + err = mq->put( "If Peter", sizeof("If Peter"), + 200, false ); + CYG_TEST_PASS_FAIL( Cyg_Mqueue::OK == err, + "Prioritized (put in empty queue)"); + CYG_TEST_PASS_FAIL( 42 == calledback, "callback" ); + CYG_TEST_PASS_FAIL( NULL == oldcallback, "oldcallback" ); + + err = mq->get( buf, &len, &prio, false ); + b = (err == Cyg_Mqueue::OK); + if (b) + b = (len == sizeof("If Peter")); + if (b) + b = (prio == 200); + if (b) + b = (0 == + my_memcmp(buf, "If Peter", sizeof("If Peter")) + ); + CYG_TEST_PASS_FAIL( b, "Prioritized (get 2)"); + + t1sem.post(); + + err = mq->get( buf, &len, &prio, true ); + b = (err == Cyg_Mqueue::OK); + if (b) + b = (len == 32); + if (b) + b = (42 == calledback); + if (b) + b = (prio == 250); + if (b) + b = (0 == + my_memcmp(buf, "12345678901234567890123456789012", 32) + ); + CYG_TEST_PASS_FAIL( b, "callback (blocked wait)"); + +//------------------------------------------------------------------------ + + t1sem.post(); + t0sem.wait(); + +} // t0() + + +//************************************************************************ +//************************************************************************ + + +static void +t1( CYG_ADDRWORD data ) +{ + Cyg_Mqueue::qerr_t err; + char buf[35]; + size_t len; + unsigned int prio; + bool b; + +//------------------------------------------------------------------------ + + // wait till t0 says we can go + t1sem.wait(); + + err = mq->get( buf, &len, &prio, true ); + b = (err == Cyg_Mqueue::OK); + if (b) + b = (len == sizeof("Peter piper picked")); + if (b) + b = (prio == 5); + if (b) + b = (0 == + my_memcmp(buf, "Peter piper picked", sizeof("Peter piper picked")) + ); + + CYG_TEST_PASS_FAIL( b, "Simple"); + +//------------------------------------------------------------------------ + + t0sem.post(); // t0 should run straight away + Cyg_Thread::yield(); // but just in case we have a funny sched + + // by now t0 is blocked in mq->get + + err = mq->put( "a peck of", sizeof("a peck of"), + 100, false ); + CYG_TEST_PASS_FAIL( Cyg_Mqueue::OK == err, "Block (put in empty queue)"); + +//------------------------------------------------------------------------ + + err = mq->put( "If Peter", sizeof("If Peter"), + 200, false ); + CYG_TEST_PASS_FAIL( Cyg_Mqueue::OK == err, + "Prioritized (put in empty queue)"); + + err = mq->put( "pickled peppers", sizeof("pickled peppers"), + 300, false ); + CYG_TEST_PASS_FAIL( Cyg_Mqueue::OK == err, + "Prioritized (put in queue w/1)"); + + err = mq->put( ".", sizeof("."), 250, false ); + CYG_TEST_PASS_FAIL( Cyg_Mqueue::OK == err, + "Prioritized (put in queue w/2)"); + + err = mq->put( "", 1, 225, false ); + CYG_TEST_PASS_FAIL( Cyg_Mqueue::OK == err, + "Prioritized (put in queue w/3)"); + + err = mq->put( "foobar", 6, 1, false ); + CYG_TEST_PASS_FAIL( Cyg_Mqueue::WOULDBLOCK == err, + "Prioritized (full queue)"); + + t0sem.post(); + +//------------------------------------------------------------------------ + + t1sem.wait(); + Cyg_Thread::yield(); // but just in case we have a funny sched + + err = mq->put( "12345678901234567890123456789012xxxx", 32, + 250, false ); + CYG_TEST_PASS_FAIL( Cyg_Mqueue::OK == err, + "callback (put in queue)"); + +//------------------------------------------------------------------------ + + t1sem.wait(); + + // Create an oversized queue + { + Cyg_Mqueue huge_mq(99999, 99999, &my_alloc, &my_free, &err ); + CYG_TEST_PASS_FAIL( Cyg_Mqueue::NOMEM == err, + "Oversized queue rejected" ); + // and it now gets destructed - but that shouldn't call free + // to be called + } + +//------------------------------------------------------------------------ + + t0sem.post(); // t0 should run straight away + Cyg_Thread::yield(); // but just in case we have a funny sched + + // check that mq was destroyed when t0 dropped off the end + CYG_TEST_PASS_FAIL( NULL == mq, "queue destroyed correctly" ); + + CYG_TEST_EXIT("kernel mqueue test 1"); + +} // t1() + + +//************************************************************************ +//************************************************************************ + +externC void +cyg_user_start(void) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO( "Starting kernel mqueue test 1" ); + new_thread( t0, 0); + new_thread( t1, 1); + +#ifdef CYGIMP_THREAD_PRIORITY + thread[0]->set_priority( 4 ); + thread[1]->set_priority( 5 ); // make sure the threads execute as intended +#endif +} // cyg_user_start() + +//------------------------------------------------------------------------ + + +/* EOF mqueue1.cxx */ diff --git a/packages/kernel/current/tests/mutex3.cxx b/packages/kernel/current/tests/mutex3.cxx --- a/packages/kernel/current/tests/mutex3.cxx +++ b/packages/kernel/current/tests/mutex3.cxx @@ -61,6 +61,29 @@ (CYGNUM_KERNEL_SCHED_PRIORITIES > 20) // ------------------------------------------------------------------------ +// Manufacture a simpler feature test macro for priority inheritance than +// the configuration gives us. We have priority inheritance if it is configured +// as the only protocol, or if it is the default protocol for dynamic protocol +// choice. +// FIXME: If we have dynamic protocol choice, we can also set priority inheritance +// as the protocol to be used on the mutexes we are interested in. At present we +// do not do this. + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT +# ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC +# ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_INHERIT +# define PRIORITY_INHERITANCE +# else +# undef PRIORITY_INHERITANCE +# endif +# else +# define PRIORITY_INHERITANCE +# endif +#else +# undef PRIORITY_INHERITANCE +#endif + +// ------------------------------------------------------------------------ // Management functions // // Stolen from testaux.hxx and copied in here because I want to be able to @@ -250,12 +273,12 @@ static void t2( CYG_ADDRWORD data ) // Wait longer than the delay in t3 waiting on go_flag } while ( now < (then + 3) ); -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE - CYG_TEST_INFO( "Checking for MUTEX_PRIORITY_INHERITANCE" ); +#ifdef PRIORITY_INHERITANCE + CYG_TEST_INFO( "Checking for mutex priority inheritance" ); CYG_TEST_CHECK( 1 == t3ran, "Thread 3 did not run" ); CYG_TEST_CHECK( 1 == got_it, "Thread 1 did not get the mutex" ); #else - CYG_TEST_INFO( "Checking for NO mutex_priority_inheritance" ); + CYG_TEST_INFO( "Checking for NO mutex priority inheritance" ); CYG_TEST_CHECK( 0 == t3ran, "Thread 3 DID run" ); CYG_TEST_CHECK( 0 == got_it, "Thread 1 DID get the mutex" ); #endif @@ -336,19 +359,11 @@ static void control_thread( CYG_ADDRWORD if ( cyg_test_is_simulator && (0 != i && 13 != i && 26 != i) ) continue; // 13 is 111 base 3, 26 is 222 base 3 -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef PRIORITY_INHERITANCE // If the simple scheme plus relay enhancement, or any other // *complete* scheme, we can run all three ancillary threads no // problem, so no special action here. -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE -#ifndef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE_RELAY - // If the simple scheme but no relay enhancement: - if ( k ) // Cannot run thread 2a nor 3a - break; // if no priority relay. -#endif -#endif - #else // If no priority inheritance at all, running threads 1a and 2a is // OK, but not thread 3a; it blocks the world. diff --git a/packages/kernel/current/tests/stress_threads.c b/packages/kernel/current/tests/stress_threads.c --- a/packages/kernel/current/tests/stress_threads.c +++ b/packages/kernel/current/tests/stress_threads.c @@ -52,17 +52,17 @@ #include -#if defined(CYGPKG_KERNEL) && defined(CYGPKG_IO) && defined(CYGPKG_LIBC) +#if defined(CYGPKG_KERNEL) && defined(CYGPKG_IO) && defined(CYGPKG_ISOINFRA) #include -#include +#include #include CYGHWR_MEMORY_LAYOUT_H #if defined(CYGFUN_KERNEL_API_C) #include -#ifdef CYGPKG_LIBC_STDIO +#if CYGINT_ISO_STDIO_FORMATTED_IO #include #include @@ -75,7 +75,7 @@ #include #if defined(CYGFUN_KERNEL_THREADS_TIMER) -#if defined(CYGPKG_LIBC_MALLOC) +#if CYGINT_ISO_MALLOC /* if TIME_LIMIT is defined, it represents the number of seconds this test should last; if it is undefined the test will go forever */ @@ -85,7 +85,7 @@ // STACK_SIZE is typical +2kB for printf family calls which use big // auto variables. Add more for handler which calls perform_stressful_tasks() #define STACK_SIZE (2*1024 + CYGNUM_HAL_STACK_SIZE_TYPICAL) -#define STACK_SIZE_HANDLER (4*1024 + CYGNUM_HAL_STACK_SIZE_TYPICAL) +#define STACK_SIZE_HANDLER (STACK_SIZE + 30*CYGNUM_HAL_STACK_FRAME_SIZE) #define N_MAIN 1 @@ -100,7 +100,7 @@ #undef STACK_SIZE #undef STACK_SIZE_HANDLER #define STACK_SIZE (1024 + CYGNUM_HAL_STACK_SIZE_TYPICAL) -#define STACK_SIZE_HANDLER (1024 + CYGNUM_HAL_STACK_SIZE_TYPICAL) +#define STACK_SIZE_HANDLER (STACK_SIZE + 10*CYGNUM_HAL_STACK_FRAME_SIZE) #endif //----------------------------------------------------------------------- @@ -388,11 +388,20 @@ void main_program(cyg_addrword_t data) } #ifdef DEATH_TIME_LIMIT - // Stop test if time. We don't care about resource state here - // since we've only run for a limited time anyway. + // Stop test if time. if (is_dead) { - print_statistics(1); - CYG_TEST_PASS_FINISH("Kernel thread stress test OK"); + // Pause clients + cyg_mutex_lock(&client_request_lock); { + clients_paused = 1; + } cyg_mutex_unlock(&client_request_lock); + + // When all handlers have stopped, we can print statistics + // knowing that all (handler allocated) resources should have + // been freed. That is, we should be able to determine leaks. + if (0 == handler_thread_in_use_count) { + print_statistics(1); + CYG_TEST_PASS_FINISH("Kernel thread stress test OK"); + } } #endif /* DEATH_TIME_LIMIT */ @@ -693,7 +702,6 @@ cyg_addrword_t sc_thread_create( #define MINS_HOUR (60) #define MINS_DAY (60*24) -externC void *cyg_libc_get_malloc_pool( void ); void print_statistics(int print_full) { @@ -760,16 +768,18 @@ void print_statistics(int print_full) } } cyg_mutex_unlock(&statistics_print_lock); +#if CYGINT_ISO_MALLINFO //-------------------------------- // System information { - cyg_mempool_info mem_info; - - cyg_mempool_var_get_info((cyg_handle_t) cyg_libc_get_malloc_pool(), - &mem_info); + struct mallinfo mem_info; + + mem_info = mallinfo(); + printf(" Memory system: Total=0x%08x Free=0x%08x Max=0x%08x\n", - mem_info.totalmem, mem_info.freemem, mem_info.maxfree); + mem_info.arena, mem_info.fordblks, mem_info.maxfree); } +#endif // Dump stack status printf(" Stack usage:\n"); @@ -798,9 +808,9 @@ void print_statistics(int print_full) #endif /* (CYGNUM_KERNEL_SCHED_PRIORITIES >= */ /* (N_MAIN+N_CLIENTS+N_LISTENERS+MAX_HANDLERS)) */ -#else /* CYGSEM_LIBC_MALLOC */ +#else /* CYGINT_ISO_MALLOC */ # define N_A_MSG "this test needs malloc" -#endif /* CYGSEM_LIBC_MALLOC */ +#endif /* CYGINT_ISO_MALLOC */ #else /* CYGFUN_KERNEL_THREADS_TIMER */ # define N_A_MSG "this test needs kernel threads timer" @@ -810,16 +820,16 @@ void print_statistics(int print_full) # define N_A_MSG "this test needs libm" #endif /* CYGPKG_LIBM */ -#else /* CYGSEM_LIBC_STDIO */ -# define N_A_MSG "this test needs stdio" -#endif /* CYGSEM_LIBC_STDIO */ +#else /* CYGINT_ISO_STDIO_FORMATTED_IO */ +# define N_A_MSG "this test needs stdio formatted I/O" +#endif /* CYGINT_ISO_STDIO_FORMATTED_IO */ #else // def CYGFUN_KERNEL_API_C # define N_A_MSG "this test needs Kernel C API" #endif -#else // def CYGPKG_KERNEL && CYGPKG_IO && CYGPKG_LIBC -# define N_A_MSG "this tests needs Kernel, libc and IO" +#else // def CYGPKG_KERNEL && CYGPKG_IO && CYGPKG_ISOINFRA +# define N_A_MSG "this tests needs Kernel, isoinfra and IO" #endif #ifdef N_A_MSG diff --git a/packages/kernel/current/tests/sync3.cxx b/packages/kernel/current/tests/sync3.cxx --- a/packages/kernel/current/tests/sync3.cxx +++ b/packages/kernel/current/tests/sync3.cxx @@ -48,8 +48,8 @@ // // Options: // CYGIMP_THREAD_PRIORITY -// CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE -// CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE +// CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT +// CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_SIMPLE //####DESCRIPTIONEND#### #include @@ -68,6 +68,31 @@ #error "Thread priorities disabled" #endif +// ------------------------------------------------------------------------ +// Manufacture a simpler feature test macro for priority inheritance than +// the configuration gives us. We have priority inheritance if it is configured +// as the only protocol, or if it is the default protocol for dynamic protocol +// choice. +// FIXME: If we have dynamic protocol choice, we can also set priority inheritance +// as the protocol to be used on the mutexes we are interested in. At present we +// do not do this. + +#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_INHERIT +# ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC +# ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DEFAULT_INHERIT +# define PRIORITY_INHERITANCE +# else +# undef PRIORITY_INHERITANCE +# endif +# else +# define PRIORITY_INHERITANCE +# endif +#else +# undef PRIORITY_INHERITANCE +#endif + +// ------------------------------------------------------------------------ + #define NTHREADS 3 #include "testaux.hxx" @@ -88,7 +113,7 @@ static void check_priorities_inherited() { CHECK( 5 == thread[0]->get_priority()); CHECK( 6 == thread[1]->get_priority()); -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef PRIORITY_INHERITANCE CHECK( 5 == thread[2]->get_current_priority()); #endif CHECK( 7 == thread[2]->get_priority()); @@ -105,7 +130,7 @@ static void entry0( CYG_ADDRWORD data ) m0d = 0; } m0.unlock(); check_priorities_normal(); -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef PRIORITY_INHERITANCE CYG_TEST_PASS_FINISH("Sync 3 OK -- priority inheritance worked"); #else CYG_TEST_FAIL_FINISH("Sync 3: thread not starved"); @@ -122,7 +147,7 @@ static void entry1( CYG_ADDRWORD data ) for ( volatile cyg_ucount32 i=0; i < 100000; i++ ) ; // math is hard -#ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE +#ifdef PRIORITY_INHERITANCE // thread0 should have stopped by this point CYG_TEST_FAIL_FINISH("Sync 3: priority inheritance mechanism failed"); #else diff --git a/packages/language/c/libc/common/current/ChangeLog b/packages/language/c/libc/common/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/common/current/ChangeLog @@ -0,0 +1,33 @@ +2000-05-02 Jonathan Larmour + + * New package + Separated original libc out into separate packages on functional + boundaries. + Header files are now managed by isoinfra package + Plenty of cleanups done, but no major functionality changes + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/common/current/ChangeLog.libc b/packages/language/c/libc/common/current/ChangeLog.libc new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/common/current/ChangeLog.libc @@ -0,0 +1,2727 @@ +This ChangeLog file is now obsolete. This is the original ChangeLog from when +libc was one large package, before being separated. It is included for +historical reasons. + +2000-04-05 Jesper Skov + + * src/time/settime.cxx: + * src/time/time.cxx: + Wallclock moved to io/. + +2000-03-28 John Dallaway + + * cdl/string.cdl, + cdl/stdlib.cdl, + cdl/stdio.cdl, + cdl/libc.cdl: + + Adjust documentation URLs. + +2000-03-27 Jesper Skov + + * src/clibincl/stream.inl (check_this): Use cyb_bool instead of bool. + +2000-03-06 Jesper Skov + + * tests/time/strftime.c (test): Adjust test to match below change. + +2000-03-02 Jonathan Larmour + + * src/time/strftime.cxx (do_format): Make sure %m counts from + 1..12 rather than 0..11. Fix for case 103300 + +2000-02-29 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: Correctly use 'n' parameter to + restrict length. Credit due to Andrew Lunn here as well. + Resolves 103057-CR-1 + + * tests/stdio/sprintf2.c (test): + Add snprintf tests to verify the correct behaviour of restricting + output length + +2000-02-10 Jesper Skov + + * tests/signal/signal2.c (main): + Also reclaim DATA_TLB_MISS vector if available. + +2000-01-31 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-28 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-19 Hugo Tyson + + * cdl/*.cdl: Add descriptions to a number of options &c which were + lacking same, also tidied up other typos as noticed en passant. + +1999-11-11 Bart Veer + + * cdl/string.cdl: + Switch to a single boolean configuration option for code size vs. + speed optimization. + +1999-11-03 John Dallaway + + * cdl/libc.cdl: Define tests. + +1999-10-19 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: We can now remove Berkeley + advertising clause + * src/stdlib/div.cxx: ditto + * src/stdlib/ldiv.cxx: ditto + * src/stdlib/strtol.cxx: ditto + * src/stdlib/strtoul.cxx: ditto + * src/string/strtok.cxx: ditto + +1999-10-19 John Dallaway + + * cdl/libc.cdl: + + Define CDL options for package-specific CFLAGS. + +1999-10-08 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_THREAD_PRIORITY): Change + default to 10 to keep test farm happy + * cdl/startup.cdl: Likewise + +1999-10-07 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Specify radio buttons using CDL interfaces. + +1999-10-06 Jonathan Larmour + + * cdl/stdio.cdl: Change default to /dev/ttydiag as per 1999-10-01 + change below + * cdl/startup.cdl: Add new form CDL for the startup changes as + per 1999-10-05 + +1999-10-05 Jonathan Larmour + + * include/libc.h: Add CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM to allow + the user to supply their own stack. + Rename CYGNUM_LIBC_MAIN_STACK_SIZE to + CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE and reparent under + CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + Add CYGNUM_LIBC_MAIN_THREAD_PRIORITY to provide main() thread + priority + + * src/support/mainthread.cxx: Add support for user-supplied stack + Allow user to specify thread priority + + These changes fix CR 101069 + +1999-10-01 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE): Change + default to /dev/ttydiag to get correct console-like behaviour + Also don't preclude use if haldiag package isn't included + (case 102065) + +1999-09-15 Jesper Skov + + * tests/signal/signal2.c (cause_fpe): Try both float and integer + division by zero. + +1999-09-10 Jesper Skov + + * src/stdlib/malloc.cxx (cyg_libc_get_malloc_pool): Added for + stress_threads test. + +1999-09-07 Jesper Skov + PRs 20243, 20433 + * tests/signal/signal2.c: Disabled test3 on ARM. + +1999-09-02 Hugo Tyson + + * include/assert.h: Make the sense of NDEBUG correct; it is "set" + when NOT debugging. Fix for CR 101983-CR-1 + See Stroustrup, "The C++ Programming Language." + +1999-08-18 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): Set buffer size 0 when not + buffering + Fix for case 101868 + +1999-08-17 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Implement radio buttons using "FIXME radio" hack in + description field for now. + +1999-08-12 John Dallaway + + * cdl/stdlib.cdl: + Take advantage of MACRONAME_ENUMVAL macros output by CDL. + +1999-08-06 Jonathan Larmour + + * tests/stdio/sprintf2.c (test): Don't rely on 2.345 being exactly + representable in binary as a difference of 1 ulp will make it round + the wrong way. + +1999-07-16 Jonathan Larmour + + * src/stdio/input/fgetc.cxx: + Include outline versions of getc() (actually just a symbol alias for + fgetc() ) and getchar() + Some minor clean-ups + Add tracing/assertions + + * src/stdio/input/fputc.cxx: + Likewise (except applied to putc() and putchar()) + + * src/stdio/common/stdioinlines.cxx (_puts): + Call fputc() not _fputc() + + * src/clibincl/stdiosupp.hxx: + Remove now obsolete prototypes for _fgetc() and _fputc() + + * include/stdio.h: + Don't bother with getc()/putc() macros any more, just call + them as functions + Include protos for getc(), putc(), getchar() and putchar() functions + +1999-06-21 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for SH EDK7708. + +1999-06-11 Jonathan Larmour + + * include/stdio.h: Make FILEs array types so they won't be + given $gp relocations on MIPS targets + +1999-05-27 Jesper Skov + + * tests/time/ctime.c: Fixed compiler warning. + +1999-05-25 Jonathan Larmour + + * tests/signal/signal2.c (main): + Update CYGPKG_HAL_TX39 -> CYGPKG_HAL_MIPS_TX39 due to recent MIPS + HAL changes + Fix for PR 20116 + +1999-04-30 Jesper Skov + PR 19945/19946 workaround + * tests/signal/signal2.c: Disabled test 3 for PowerPC sim. + +1999-04-19 Jonathan Larmour + + * include/time.inl: + Ensure all calls to cyg_libc_time_year_is_leap() are with the full + year, and not the direct contents of a struct tm, which are (year-1900) + +1999-04-19 Jesper Skov + PR 19308, 19410, 19528 + * tests/time/clock.c (test): Also disable data cache which may + affect timing when tracing/assertions are enabled. + +1999-04-15 Jonathan Larmour + + * src/clibincl/stdiosupp.hxx: + Add prototype for new cyg_libc_stdio_flush_all_but() function + + * src/clibincl/stream.hxx: + Don't include stdiosupp.hxx any more to prevent circular dependency, + therefore manually provide _setvbuf prototype + Make sure pkgconf/kernel.h is included before mutex.hxx + + * src/clibincl/stream.inl (Cyg_StdioStream::set_error()): + Add missing unlock_me() + + * src/stdio/common/fflush.cxx: + Separate most of code for fflush(NULL) into separate + cyg_libc_stdio_flush_all_but() function, which has the extra + capability of omitting one stream + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Add missing clibincl/stdiosupp.hxx include + + * src/stdio/common/stream.cxx (Cyg_StdioStream::read()): + When reading, ensure we flush all output streams + + * src/stdio/common/stream.cxx (Cyg_StdioStream::flush_output_unlocked): + Flush the device as well + +1999-04-15 Jonathan Larmour + + * src/stdio/common/streambuf.cxx (set_buffer): + * src/stdio/common/stdioinlines.cxx (_setbuf): + * src/clibincl/streambuf.inl: + * src/clibincl/streambuf.hxx: + * src/clibincl/stream.hxx (class Cyg_StdioStream): + * include/pkgconf/libc.h: + * include/stdio.inl (setbuf): + Fix dumb typo: BUFSIZE -> BUFSIZ + This fixes PR19837 + +1999-04-15 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx (_setbuf): + * include/stdio.inl (setbuf): + Use _IONBF when buf==NULL, and _IOLBF otherwise. + Fix for PR 19836 + +1999-04-15 John Dallaway + + * include/pkgconf/libc.h: Tidy display string capitalization. + +1999-04-12 Jonathan Larmour + + * include/pkgconf/libc.h: + Clarify CDL description of CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE + + * tests/signal/signal2.c: Try harder to generate an exception by + accessing a misaligned address + Don't handle SIGTRAP any more + Part of fix for PRs 19731/19607 + +1999-04-07 Jesper Skov + PR 19667 + * src/support/mainthread.cxx: + Changed to use the new Cyg_Thread constructor. + +1999-04-07 Hugo Tyson + + * tests/signal/signal2.c (main): Use new macro + HAL_VSR_SET_TO_ECOS_HANDLER if defined, to wrest control from + CygMon, for example, by reinstalling eCos' default VSRs for + exceptions that we are provoking. + +1999-03-29 Jonathan Larmour + + * src/signal/siginit.cxx: Include stdlib.h for exit() + Fix for PR 19720 + +1999-03-29 Jonathan Larmour + + * tests/time/clock.c (test): Disable instruction cache + Hopefully fixes PR 19308 + +1999-03-29 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for PPC as it cannot + trap division by zero. + +1999-03-26 Jonathan Larmour + + * src/support/main.cxx (main): Invoke cyg_user_start() if no kernel + Only sensible thing to do in our default main in a non-kernel config + +1999-03-25 Jonathan Larmour + + * tests/time/time.c: + Increase MAX_TIMEOUT since the sparclite gets very close to overrunning + it even when working. + Should return -1 iff CYGSEM_LIBC_TIME_TIME_WORKING isn't defined + Cosmetic changes + +1999-03-25 Hugo Tyson + + * tests/time/time.c (test): Take into account setting of + CYGSEM_LIBC_TIME_SETTIME_WORKING ie. does cyg_libc_time_settime() + work? If not, check that it returns an error. + This was exposed by the random combo in PR#19479. + +1999-03-23 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 to + CYGIMP_... + + Add another rand implementation CYGIMP_LIBC_RAND_SIMPLE1 which is + the default + + Part of fix for PR 19562 + + * include/sys/cstartup.h: + Tidy and remove unnecessary dependencies + + * src/stdlib/rand.cxx: + Rename algorithms from CYGSEM_... to CYGIMP_... + Add new "simple1" algorithm + + * tests/ctype/ctype.c: + Tidy + + * tests/stdlib/rand3.c: + Fix so that 0..RAND_MAX is split evenly over buckets, which it wasn't + before + Deal with case of RAND_MAX not being divisible by NUM_BUCKETS + exactly + Increase TEST_LENGTH to 200000 to provide more representative sample + Add CYG_TEST_INFO output to help ensure it doesn't time out + Tidy + + * tests/stdlib/rand4.c: + Only fail if more than _two_ thirds (rather than one third) match. + This is because half would match for a perfectly random distribution + This is the rest of the fix for PR 19562 + Cosmetic changes + +1999-03-22 Hugo Tyson + + * src/support/mainthread.cxx (CYGNUM_LIBC_MAIN_STACK_SIZE): + Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of + CYGNUM_HAL_MINIMUM_STACK_SIZE. + +1999-03-22 Jonathan Larmour + + * tests/PKGconf.mak: Add -Wno-format when building strftime otherwise + it generates warnings for things that we do want to test (null + string, and %y format) + +1999-03-19 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Put brackets back round negative number since sdf says the config + tool is fixed now (PR 19537) + + Add new CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 + options for different rand() algorithms in a so far failed attempt + to fix PR 19562 + + * src/stdlib/rand.cxx: + Add new optional algorithm from Knuth vol.2 + + * tests/stdlib/rand4.c: + Some tidies + Don't run test when using simplest algorithm + + * tests/signal/signal2.c (main): + Don't try to make an FPE on tx39 - its possible to detect but requires + too much HAL work to be sensible + +1999-03-18 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Use HAL_ENABLE_INTERRUPTS() rather than kernel to enable interrupts + +1999-03-18 Mark Galassi + + * tests/PKGconf.mak (TESTS): added rand4 compilation. + + * tests/stdlib/rand4.c: added this test for periodicity in the + least significant bit of rand(). + +1999-03-18 Jonathan Larmour + + * include/pkgconf/libc.h: Remove CYGFUN_LIBC_TIME_POSIX dependency + on CYGPKG_LIBC_STDIO + + * src/stdlib/itoa.cxx: + New file to convert integers to ascii + + * include/stdlib.h: + Add proto for new cyg_libc_itoa() function + + * include/time.inl: + Rework __asctime_r() to use memcpy() and cyg_libc_itoa() rather than + sprintf() + + * src/PKGconf.mak: + Build stdlib/itoa.cxx + + The above changes fix PR 19448 + +1999-03-17 Jonathan Larmour + + * include/time.h: Add #define of __time_t_defined to placate newlib + if it is used by accident. This is just a temporary workaround though. + +1999-03-16 Gary Thomas + + * src/PKGconf.mak: Add compile option to step around ARM compiler bug. + +1999-03-16 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Don't use parentheses for now + + * src/stdio/common/stream.cxx (refill_read_buffer): + Silence bogus compiler warning + +1999-03-16 Jesper Skov + + * tests/signal/signal2.c (main): Enable SIGSEGV test for + i386/Linux. + + +1999-03-15 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Only enable interrupts if they were disabled + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: + Add FIX ME line as a reminder that the workaround there can go away + in future + + * include/pkgconf/libc.h: + Add proper define for CYGSEM_LIBC_EXIT_CALLS_FFLUSH + Put brackets round negative CYGNUM_LIBC_TIME_DST_DEFAULT_STATE define + Fix run time typo + + * include/time.inl (__localtime_r): + Include sys/timeutil.h before this to get + cyg_libc_time_normalize_structtm() + +1999-03-12 Gary Thomas + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: Remove 'const' from char arrays since + this fails [silently] on ARM when -fwritable-strings (PR19440) + +1999-03-12 Jesper Skov + + * tests/signal/signal2.c (main): Compiler warnings fix was + slightly broken. + +1999-03-12 Jesper Skov + PR 19473 + * tests/signal/signal2.c (main): + Disabling SIGTRAP handling on i386/Linux is not a good idea. +1999-03-11 Jesper Skov + PR 19473 + * tests/signal/signal2.c: + Added compiler warnings fix. + Added N/A handling for i386/Linux. + +1999-03-10 Gary Thomas + + * include/pkgconf/libc.h: Force "haldiag" device to be present. + 'asctime' and friends need 'stdio' as well. + + * include/time.inl: Fix syntax error on difftime() declaration. + +1999-03-08 Gary Thomas + + * src/clibincl/stream.hxx: needed for this file. + + * src/stdio/common/vsscanf.cxx (str_read): Fix problem with string + pointer [created by merge with new I/O package]. + +1999-03-05 John Dallaway + + * include/pkgconf/libc.h: + Add legal values for CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET + and CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET. + +1999-03-05 Jonathan Larmour + + * include/time.inl (cyg_libc_time_year_is_leap): + Fix bug with modulo year 400 + Fix typo in asctime_r macro + Fix gmtime_r, and mktime as a result of testing + + * tests/time/asctime.c, tests/time/ctime.c, tests/time/gmtime.c, + tests/time/gmtime.c, tests/time/localtime.c, tests/time/mktime.c, + tests/time/strftime.c, tests/time/time.c: + New tests + + * tests/PKGconf.mak: + Build above new tests + + * include/pkgconf/libc.h: + Add reminder FIX ME about extra config option + + * src/time/strftime.cxx: + Fix %w and %Y parameters as a result of testing + + * src/time/timeutil.cxx: + Fix cyg_libc_time_normalize_structtm() as a result of testing + of mktime() + + * tests/time/clock.c: + Reformat, remove obsolete bits and tidy + + * include/time.h: + Add Cyg_libc_time_dst type and new functions + cyg_libc_time_setzoneoffsets(), cyg_libc_time_setdst(), + cyg_libc_time_getzoneoffsets(), cyg_libc_time_settime() + + * include/time.inl: + Implement the above functions. This allows us to adjust for timezone + diffences and set the time. + Change localtime() to adjust for STD/DST + Change mktime() to adjust for STD/DST + + * include/libc.h: + Add new config options CYGSEM_LIBC_TIME_SETTIME_WORKING + and component CYGPKG_LIBC_TIME_ZONES containing options + CYGNUM_LIBC_TIME_DST_DEFAULT_STATE, + CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET, + CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET + + * src/strftime.cxx: + Adjust handling of %Z to _not_ deal with STD/DST + + * src/time/settime.cxx: + New file to implement cyg_libc_time_settime() + + * src/PKGconf.mak: + Build settime.cxx + + * src/time/timeutil.cxx: + Supply outline versions of cyg_libc_time_setzoneoffsets(), + cyg_libc_time_setdst(), and cyg_libc_time_getzoneoffsets() + Add variables for STD/DST state + Some minor comment changes + + * include/errno.h: + Use CYGBLD_ATTRIB_CONST instead of __attribute__((const)) directly + + * include/signal.h: + Change format of function comment headers + + * include/signal.inl: + Restrict errno.h inclusion to when its actually used + Fix a spelling typo + + * include/stdlib.h: + Add CYGBLD_ATTRIB_CONST to abs, div, labs, ldiv + + * include/stdlib.inl: + Reformat and tidy + Include new versions of div and ldiv which are more portable and + are cleanly rewritten so aren't covered by the BSD licence, which + is now removed + + * src/stdlib/div.cxx, src/stdlib/ldiv.cxx: + Non-inline, non-BSD and portable versions of the new versions of div + and ldiv from stdlib.inl + + * include/time.h: + Much reformatting, tidying and improving comments + Change CLOCKS_PER_SEC from 1000 to 1000000 + Add new functions asctime_r, ctime_r, gmtime_r, localtime_r, clock, + difftime, mktime, time, asctime, ctime, gmtime, localtime, strftime + Include new time.inl file + + * include/pkgconf/libc.h: + Add new options CYGSEM_LIBC_TIME_CLOCK_WORKING, + CYGSEM_LIBC_TIME_TIME_WORKING, CYGFUN_LIBC_TIME_POSIX, + CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL, CYGIMP_LIBC_TIME_ASCTIME_INLINE, + CYGIMP_LIBC_TIME_CTIME_INLINE, CYGIMP_LIBC_TIME_DIFFTIME_INLINE, + CYGIMP_LIBC_TIME_GMTIME_INLINE, CYGIMP_LIBC_TIME_LOCALTIME_INLINE, + CYGIMP_LIBC_TIME_MKTIME_INLINE, CYGIMP_LIBC_TIME_ASCTIME_R_INLINE, + CYGIMP_LIBC_TIME_CTIME_R_INLINE, CYGIMP_LIBC_TIME_GMTIME_R_INLINE, + and CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE + + * time/asctime.cxx, time/asctime_r.cxx, time/clock.cxx, time/ctime.cxx, + time/ctime_r.cxx, time/difftime.cxx, time/gmtime.cxx, + time/gmtime_r.cxx, time/localtime.cxx, time/localtime_r.cxx, + time/mktime.cxx, time/strftime.cxx, time/time.cxx, time/timeutil.cxx, + include/time.inl: + New files to implement the new time functions. Many of them simply + provide the outline definitions, but the real body of the function + comes from time.inl + + * src/PKGconf.mak: + Build new .cxx files + + * src/clibincl/stdlibsupp.hxx: + Remove _div and _ldiv prototypes since they're no longer needed + + * src/clibincl/timesupp.hxx: + Delete as its now obsolete + + * src/time/clock.cxx: + Use new CYGSEM_LIBC_TIME_CLOCK_WORKING option to control whether it + just returns (clock_t)-1 or not. + Much reformatting and tidying + Change real imlpementation from _clock to __clock + Use CYGBLD_ATTRIB_WEAK_ALIAS now + + * tests/stdlib/div.c, tests/stdlib/ldiv.c: + Add some extra tests for handling of negative numbers + Reformat and tidy a bit, including removing the test for CYGPKG_LIBC + since its now always defined if the test is to be compiled + + * tests/time/clock.c: + Remove duplication CYG_TEST_INFO line + Check if unimplemented using "(clock_t)-1" and not just "-1" + +1999-03-04 Jonathan Larmour + + * src/stdlib/system.cxx: + Make sure system() is a weak alias for __system() + + * include/pkgconf/libc.h: Rework CDL description for + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE and change its default to + "/dev/haldiag" + + * src/stdio/common/stream.cxx: + Check that dev is valid when passed to stream constructor + + * src/stdio/common/stdiosupp.cxx: + Tidy + + * src/support/mainthread.cxx: Make this depend on + CYGSEM_LIBC_STARTUP_MAIN_THREAD rather than just CYGPKG_KERNEL + +1999-03-04 Gary Thomas + + Merged in changes from 'ecos-new_devs-19990216-branch' + + (1999-02-24 Jonathan Larmour ) + + * src/stdio/common/stream.cxx: + Add "fix me" comments and remove a couple of commented out lines + + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Revert to using pointer to string for private data, not just string. + This preserves the state across multiple calls + + (1999-02-24 Gary Thomas ) + + * src/stdio/common/vsscanf.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/stream.cxx: + * src/stdio/common/stdiosupp.cxx: + * src/stdio/common/fopen.cxx: + * src/clibincl/stream.inl: + * src/clibincl/stream.hxx: + * src/clibincl/stdiosupp.hxx: + * include/pkgconf/libc.h: Changes for new I/O system. + +1999-03-03 Jonathan Larmour + + * tests/stdlib/atexit.c: Forgot to config atexit test for + CYGFUN_LIBC_ATEXIT option + + * include/pkgconf/libc.h: + Require CYGVAR_KERNEL_THREADS_DATA for CYGSEM_LIBC_PER_THREAD_STRTOK + This fixes PR 19362 + Require CYGPKG_KERNEL for thread safe streams + Also don't need "requires CYGPKG_KERNEL" for per-thread rand and errno + if we already require a finer granularity kernel option + +1999-02-25 Jonathan Larmour + + * include/pkgconf/libc.h: Fix CYGNUM_LIBC_MAIN_STACK_SIZE by changing + CYGPKG_LIBC_STARTUP_MAIN_THREAD -> CYGSEM_LIBC_STARTUP_MAIN_THREAD + Fix for PR 19304 + +1999-02-23 Jonathan Larmour + + * src/stdlib/system.cxx: Add to implement trivial system() call + * include/stdlib.h: Add system() prototype + * src/PKGconf.mak: Build system.cxx + + * tests/ctype/ctype.c, tests/i18n/setlocale.c, tests/setjmp/setjmp.c, + tests/signal/signal1.c, tests/signal/signal2.c, + tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdio/stdiooutput.c, tests/stdlib/atexit.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/getenv.c, tests/stdlib/labs.c, + tests/stdlib/ldiv.c, tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/realloc.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + Use CYG_TEST_NA() macro for non-applicable test configurations + +1999-02-20 Jonathan Larmour + + * include/signal.h: + * include/signal.inl: + * src/signal/raise.cxx: + * src/signal/siginit.cxx: + * src/signal/signal.cxx: + * tests/signal/signal1.c + * tests/signal/signal2.c: + New files to implement ISO standard signals + + * src/PKGconf.mak (TESTS): + * tests/PKGconf.mak (TESTS): + Update to build new files above + + * include/stdlib.h: + * src/clibincl/stdlibsupp.hxx: + Comment and QA changes (including giving better names to some types) + + * include/libc.h: + Add new configuration options for signals + Add new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + Add a note to CYGNUM_LIBC_MAIN_STACK_SIZE option that it may be + overriden by HAL + Add new CYGFUN_LIBC_ATEXIT option and move ...ATEXIT_HANDLERS under + it + Add new CYGSEM_LIBC_EXIT_CALLS_FFLUSH option + Require CYGSEM_LIBC_STARTUP_MAIN_THREAD for "Invoke default static + constructors" option + + * src/stdlib/atexit.cxx: + Support above CYGFUN_LIBC_ATEXIT and QA changes + + * src/stdlib/exit.cxx: + Support for above new libc.h options, and some QA changes + + * src/support/cstartup.cxx: + Add support for new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + + * src/support/mainthread.cxx: + Override main stack size if the HAL has a minimum + + * src/string/strncpy.cxx: + Use improved algorithm for aligned copies - imported from newlib + QA changes + + * src/stdlib/abort.cxx: + Support raise(SIGABRT), and some QA + + * include/errno.h: + Add const attribute + + * tests/stdlib/abs.c: + QA improvements + +1999-02-04 Jesper Skov + + * src/support/cstartup.cxx: Only define cyg_libc_main_thread when + the kernel is around. + +1999-02-01 Jesper Skov + + * tests/time/clock.c: Joined the two test/NOP checks into + one. + Increased tolerance in attempt to fix PRs 18737,18787,18846. + Fixed typo. + +1999-01-28 Jonathan Larmour + + * src/string/strtok.cxx: + * src/stdlib/rand.cxx: + Include if we use kernel header files + +1999-01-25 Jonathan Larmour + + * tests/stdio/sscanf.c (test): + CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT should be + CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + Fix for PR 18786 + + * src/string/strtok.cxx: + * src/stdio/common/stdiofiles.cxx: + * src/errno/errno.cxx: + * src/stdlib/rand.cxx: + Give mutex protection objects a libc constructor priority + + * src/support/invokemain.cxx: + Add prototype for cyg_hal_invoke_constructors() + + * src/support/mainthread.cxx: + Give cyg_libc_dummy_constructor_obj a libc constructor priority, + and make its class have a public constructor + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/stdin.cxx: + Give cyg_libc_stdio_stdin/out/err static objects a libc constructor + priority + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + * src/clibincl/stream.hxx (class Cyg_StdioStream): + Remove private copy constructor. Needed to make prioritised + static constructors work. Fix for PR 18898 + +1999-01-22 Jonathan Larmour + + * src/errno/errno.cxx: + Include pkgconf/kernel.h otherwise it fails with per-thread errno + enabled + + * include/pkgconf/libc.h: + Enable per-thread errno by default since that is what POSIX would + want + + * tests/time/clock.c (test): + Placate compiler by initializing clock_first/second/third anyway, + even though they won't be in practice. This is only a test program + so adding an extra instruction doesn't matter. + + * src/i18n/locale.cxx (_setlocale): + Placate compiler, since it is dumb, by nesting, not serializing, if's + This is an idempotent change, but screws up the formatting :-(. + + * src/string/strpbrk.cxx (_strpbrk): + Change while loop to do loop to placate compiler. It'll even save an + instruction too (wow!) + +1999-01-22 John Dallaway + + * include/pkgconf/libc.h: + Add closing curly brace to CYGPKG_LIBC_STRING_STRTOK definition + +1999-01-21 Jonathan Larmour + + * include/errno.h: + Tidy up and add to header description + Change cyg_get_errno_p() to cyg_libc_get_errno_p() + Remove ifdef CYGPKG_LIBC + + * include/sys/file_if.h: + Remove - move contents to stdio.h + + * include/stdio.h: + Tidy up header description + Move FILE typedef here from sys/file_if.h + SEEK_SET, SEEK_CUR, SEEK_END defined to 0, 1, 2 respectively + for backwards compatibility with old UNIX + Change definitions of stdin/out/err to be addresses of FILE + globals - even though they're actually Cyg_StdioStream it'll work + + * include/pkgconf/libc.h: + Make CYGPRI_LIBC_WEAK et al macros depend on new ones in infra + Reorganise trace options under the individual components they are + associated with. + Reorganise thread-safety options under the individual components + they are associated with. + Add new CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS option + Misc. reformatting + Remove dependency on pkgconf/kernel.h - Configuration Tool will + generate check macros anyway. + Remove CYGPKG_LIBC_TRACE, CYGFUN_LIBC_strtok, CYGPKG_LIBC_RAND + options + Tidy up description header + + * src/clibincl/clibdata.hxx: + * src/clibincl/clibdata.inl: + * src/support/clibdata.cxx: + Remove and instead rely on each component to initialise its own data + + * src/clibincl/stdiofiles.hxx, src/clibincl/stdiofiles.inl: + New files to contain global file list and lock (if applicable). + Implemented as class with member access functions + + * src/errno/errno.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Rename cyg_get_errno_p() to cyg_libc_get_errno_p() + + * src/stdio/common/fclose.cxx: + * src/stdio/common/fflush.cxx: + * src/stdio/common/fopen.cxx: + * src/stdio/common/freopen.cxx: + Remove ifdef CYGPKG_LIBC + Use new global file access method from stdiofiles.hxx + Tidy up description header + Use new CYGBLD_ATTRIB_WEAK_ALIAS + Access errno "normally" rather than clibdata way + + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx + * src/stdio/common/stderr.cxx: + New files. Implement Cyg_StdioStream objects for each stream. In + separate self-contained files so using one doesn't bring in the + others + + * src/stdio/common/stdiofiles.cxx: + New file. Implements global files array and lock + + * src/stdlib/_exit.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Use infra CYGBLD* macros + + * src/stdlib/malloc.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Add pkgconf/kernel.h now that pkgconf/libc.h doesn't have it + Use infra CYGBLD* macros + Make pool visible externally with weak attribute and new name + cyg_libc_malloc_memorypool + + * src/stdlib/rand.cxx: + * src/stdlib/strtok.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Use infra CYGBLD* macros + + * src/support/cstartup.cxx: + Split into smaller files to make selective linking work better, + fix i386 port problem and make GDB happy + + * src/support/environ.cxx: + * src/support/invokemain.cxx: + * src/support/main.cxx: + * src/support/mainthread.cxx: + New files from bits of the old cstartup.cxx + Add support for CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG + + * src/PKGconf.mak: + Update to reflect file additions/deletion + + * tests/stdlib/rand1.c: + * tests/stdlib/rand2.c: + * tests/stdlib/rand3.c: + * tests/stdlib/srand.c: + Make conform to coding standards + Remove ifdef CYGPKG_LIBC_RAND + Tidy up description header + + * tests/string/strtok.c: + Make conform to coding standards + Remove ifdef CYGFUN_LIBC_strtok + Tidy up description header + +1999-01-15 Mark Galassi + + * tests/stdlib/getenv.c (main): added tests for the case in which + the user does not supply environ and in which the user supplies a + NULL environ. + +1999-01-15 Jesper Skov + + * src/support/cstartup.cxx: Added workaround for weak aliasing + problem in i386 gcc. + + +1999-01-15 Gary Thomas + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_STACK_SIZE): + (CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE): Change defaults to be + more reasonable on small systems. + +1999-01-04 Jonathan Larmour + + * src/support/clibdata.cxx: + Minor bug with environ not being initialised correctly by + default + +1998-12-24 Bart Veer + + * src/clibincl/stream.inl (Cyg_StdioStream): + check_this() member functions should now be const + +1998-12-22 Jonathan Larmour + + * src/string/memchr.cxx (_memchr): + treat search value parameter to memchr as an unsigned byte, + not a signed int - copied fix from newlib PR 18471 + +1998-12-21 Jonathan Larmour + + * tests/stdlib/realloc.c: + * tests/stdlib/malloc3.c: + * tests/stdlib/malloc2.c: + Warning cleanup + +1998-12-14 Jonathan Larmour + + * tests/stdlib/malloc2.c, tests/stdlib/malloc3.c, + tests/stdlib/realloc.c: + Only run these tests when we have a coalescing memory allocator + +1998-12-14 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Only check buffer init success if buffering + + * src/stdio/common/streambuf.cxx (set_buffer): + Check for diff of requested size against buffer_size, not + get_buffer_size(), since this may return -1, which won't be + equal to size, and will cause malloc to be called + +1998-12-01 Jesper Skov + + * tests/stdlib/getenv.c (main): Don't declare variables when they + are not used. + +Thu Nov 26 17:59:12 1998 Jonathan Larmour + + * tests/string/strncpy1.c: + Fix off-by-one error since it called my_strcmp() and not + my_strncmp(), which meant in included the trailing NULL when it + shouldn't have. + +1998-11-26 Jesper Skov + + * src/stdlib/qsort.cxx (_qsort): + * src/stdlib/rand.cxx (_srand): + Changed CYG_REPORT_FUNCNAMETYPE to CYG_REPORT_FUNCNAME in void + functions. + +Mon Oct 26 18:49:00 1998 Jonathan Larmour + + * src/support/cstartup.cxx (cyg_libc_dummy_main): + Silence compiler warning with cast of char * to CYG_ADDRWORD + +Wed Oct 28 17:31:21 1998 Jonathan Larmour + + * src/time/clock.cxx (_clock): + Reorder scaling expression as it was both incorrect and risked + overflow. + Fix for PR 18076 + +Mon Oct 19 14:40:06 1998 Jonathan Larmour + + * include/stdio.h (EOF): + Change from -64 to (-1), to allow broken code to work :-/ + Also change other negative defines to be within parentheses + +1998-10-19 Mark Galassi + + * include/pkgconf/libc.h: updated the doc URL + +Thu Oct 15 21:33:44 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Only include kernel thread headers when we're in thread-safe mode + + * src/time/clock.cxx: + Only include kernel clock headers if there's a kernel with the + right functionality available + + * tests/time/clock.c: + Remove unnecessary inclusion of + + Above changes are required for PR 17229 + +Wed Oct 14 16:38:55 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise inclusion of clibincl/stdiosupp.hxx and + clibincl/stream.hxx. Tidying up PR 17502 + +Wed Oct 14 14:08:56 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGPKG_LIBC_STRING_OPTIMISATIONS to + CYGPKG_LIBC_STRING_OPTIMIZATIONS to make it truely merkin. + +Tue Oct 13 19:34:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_ARGUMENTS): + Add a default argv[0] of "" as many programs assume argc>0 + The standard allows argv[0] to be "" if the program name + is not available + +1998-09-26 Bart Veer + + * src/clibincl/stdiosupp.hxx: + PR 17502: this header file now does nothing if the stdio option + is disabled completely. This is the same behaviour is + clibincl/stream.hxx, although arguably the #ifdef protection + should happen wherever the header file is #include'd rather than + in the header file itself. + + * src/clibincl/clibdata.hxx: + PR 17502: this header file still #include's internal stdio-related + header files and references the FILE structure, even if stdio is + disabled. There were some #ifdef's for CYGPKG_LIBC_STDIO already. + One more has been added for _fopen() and _fclose(). + +1998-09-25 Bart Veer + + * src/clibincl/streambuf.inl (Cyg_StdioStreamBuffer): + PR 17487: Reorder the calls to initialize member fields, to + eliminate a compiler warning. + +Fri Sep 25 19:04:29 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/string/strtok.cxx, + src/time/clock.cxx: + Only define tracing variable and tracing level macro when + the relevant tracing level config options are set. Otherwise + keep the tracing level fixed at 0 + Fix for PR 17476 + + * include/pkgconf/libc.h: + Define trace levels only if parent CYGPKG_LIBC_TRACE is defined + for consistency with Configuration Tool + + +Fri Sep 25 17:24:45 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Make definition of vscanf() dependent on CYGFUN_LIBC_STDIO_ungetc + otherwise _vfscanf() won't be compiled. This therefore would + cause a link fail iff selective linking is not enabled. + Fix for PR 17455 + +Fri Sep 25 17:23:17 1998 Jonathan Larmour + + * src/stdlib/rand.cxx: + Make compilation dependent on CYGPKG_LIBC_RAND + Fix for PR 17473 + + * tests/stdlib/srand.c: + Make definition of dummy test pass conditional on CYGPKG_LIBC_RAND + not being defined, as well as CYGPKG_LIBC + Caused compilation failure when testing PR 17473 fix + +Mon Sep 21 17:11:04 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Make sscanf test conditional on CYGFUN_LIBC_STDIO_ungetc since + _vfscanf() only gets compiled if this is defined + Fix for PR 17346 + +1998-09-20 Mark Galassi + + * include/pkgconf/libc.h: updated CDL doc strings. + +Fri Sep 18 22:18:47 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_errno_p): + Rather than this function only being available in thread-safe mode, + instead make what it returns be either the per-thread errno, or + global errno depending on the configuration. + Include (conditionally) to support this change + +Wed Sep 16 11:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove "fix me" comment which I forgot to remove before + +Tue Sep 15 19:27:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Updated descriptions and a few other minor things after review. + Notably though, the NDEBUG config option has been removed + +1998-09-15 Bart Veer + + * include/pkgconf/libc.h: + PR 17201: removed dependency on CYGPKG_KERNEL in the option + CYGNUM_LIBC_MAIN_STACK_SIZE, since the actual dependencies cannot + be expressed sensibly in the current system. + +1998-09-11 Bart Veer + + * include/pkgconf/libc.h: + Sorting out dependencies for error package. + +1998-09-10 Mark Galassi + + * include/pkgconf/libc.h: started adding doc fields to the + cdl_package data, as a pilot for now. + +Wed Sep 9 17:41:23 1998 Hugo Tyson + + * include/pkgconf/libc.h: + Add option CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE to explicitly + control whether the empty delete functions (currently) in + kernel/.../common/delete.cxx are enabled; controls code bloat, see + the comments in delete.cxx. + +Fri Sep 4 16:43:38 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add a default CYG_TEST_PASS() to make sure the test infra doesn't + complain. + Also remove the unused string functionsa + +Fri Sep 4 15:43:48 1998 Hugo Tyson + + * src/stdlib/exit.cxx (__libc_exit): + * src/stdlib/_exit.cxx (__libc__exit): + * src/stdlib/malloc.cxx (_free): + * src/stdlib/abort.cxx (abort): + * src/support/cstartup.cxx (invoke_main): + Tracing system asserted cos it was being called incorrectly; these + are void functions so you shouldn't give a type to the function + reporting call. + +Fri Sep 4 15:03:10 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Fix CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE description to refer to + the table.cxx file, not table.h + +Fri Sep 4 14:38:52 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add description for CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE since + Proven won't be making any changes to the device driver + implementation after all. + Fix for PR 17148 + + * src/clibincl/stream.inl (set_position): + Remove "fix me" line. It is obvious that this will have to change + with a filesystem interface + Fix for PR 17147 + + * src/stdio/common/freopen.cxx: + Remove "fix me" - I know about this issue + Fix for PR 17145 + + * src/stdio/common/stream.cxx (read): + Remove "fix me" and change to use memcpy + Fix for PR 17144 + +Fri Sep 4 14:36:47 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Actually add it this time! + +Fri Sep 4 13:48:13 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add new tests for misc stdio output functions + + * tests/PKGconf.mak: + Build stdiooutput.c test + +Fri Sep 4 12:52:10 1998 Jonathan Larmour + + * src/clibincl/stream.inl (write_byte): + Remove bogus assert + + * tests/stdlib/getenv.c (main): + Check whether str is NULL before doing a strcmp() + + * tests/stdio/sprintf2.c (main): + Reformat to 76 columns + +Fri Sep 4 02:10:54 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/stdio/common/stream.cxx: + Add new peek_byte method to Cyg_StdioStream + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix up buffer access to work with new peek_byte method above + Fix for PR 16954 + +Thu Sep 3 19:40:11 1998 Jonathan Larmour + + * tests/stdlib/rand1.c, tests/stdlib/rand2.c, + tests/stdlib/rand3.c: + Add extra check for CYGPKG_LIBC_RAND to decide whether the test + is applicable or not + + * tests/stdlib/rand2.c (test): + Use CYGNUM_LIBC_RAND_SEED for default seed, not 1 + + * tests/string/strtok.c: + Add extra check for CYGFUN_LIBC_strtok to decide whether the + test is applicable or not + +Wed Sep 2 19:11:40 1998 Jonathan Larmour + + * src/stdio/input/fread.cxx, src/stdio/output/fwrite.cxx: + Add fread() and fwrite() functions + + * src/PKGconf.mak: + Build fread.cxx and fwrite.cxx from above + + * src/stdio/common/stream.cxx: + Reformat to 76 columns + In write(), move initialisation of *bytes_written to start + In read(), move initialisation of *bytes_read to start + + * include/stdio.h: + Reformat to 76 columns + + Replace all references to the ANSI + standard to instead by the ISO C standard + + Add commented argument names for "documentation" + + Add fread() and fwrite() prototypes + + * src/clibincl/stdiosupp.hxx: + Copy the above changes from stdio.h, and add _fread() and _fwrite() + prototypes + + * src/stdio/output/fputs.cxx, src/stdio/input/fgets.cxx: + Reformat to 76 columns + +Wed Sep 2 15:41:15 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Reformat to 76 columns + +Wed Sep 2 14:46:18 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Use trylock_me() instead of lock_me(), and loop to prevent + deadlocks + + * src/clibincl/stream.hxx, src/clibincl/stream.inl: + Add trylock_me() method + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/fflush.cxx: + Reformat to 76 columns + +Wed Sep 2 12:24:27 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change 0x7fff to 0x7fffffff. Oops! + give main stack size option a legal_values field + Undefine tracing by default + Add some more description in the header + +Tue Sep 1 20:02:07 1998 Jonathan Larmour + + * tests/i18n/setlocale.c (cyg_package_start): + Fix typo - extra "x" for no reason at all! :-) + +Tue Sep 1 19:44:58 1998 Jonathan Larmour + + * src/i18n/locale.cxx: + Fix bug in find_locale_data() that miscalculated size of + all_locales + + Make find_locale_data() match the locale "" and add some + other things in _setlocale() to ensure that "C" gets returned + when the default locale "" is passed. + + Only check the locale pointer when it is non-NULL + + * tests/i18n/setlocale.c: + New tests for setlocale() + + * tests/PKGconf.mak: + Update to build setlocale.c test + + * src/support/cstartup.cxx: + Don't actually call system default main() "main" otherwise GDB + gets confused and thinks its the entry point. Instead make a weak + alias and call the real function something different. + +Tue Sep 1 18:31:42 1998 Jonathan Larmour + + * src/i18n/locale.cxx (_setlocale): + Fix tracing macro name and remove "str maybe used before + initialised" warning + + * tests/stdlib/qsort.c: + Correct file description header + +Tue Sep 1 17:04:32 1998 Jonathan Larmour + + * include/locale.h, src/clibincl/i18nsupp.hxx, src/i18n/locale.cxx: + New files to add support for locales as defined by the ISO C + standard. i.e. setlocale() and localeconv() functions and some + other bits + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAX_LOCALE_NAME_SIZE config option for locale + support + + * src/PKGconf.mak: + build locale.cxx + + * include/errno.h, src/clibincl/ctypesupp.hxx: + Tidy up to 76 columns + +Tue Sep 1 00:24:22 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Move environment-related options from stdlib into new + CYGPKG_LIBC_STARTUP component. Also add options for main()'s + arguments (CYGPKG_LIBC_ARGUMENTS), main()'s default stack size + (CYGNUM_LIBC_MAIN_STACK_SIZE), number of atexit handlers + (CYGNUM_LIBC_ATEXIT_HANDLERS), and whether _exit() stops the + system (CYGSEM_LIBC_EXIT_STOPS_SYSTEM). + + * src/clibincl/stdlibsupp.hxx: + Fix a few comment bugs, and add new + cyg_libc_invoke_atexit_handlers() function prototype + + * src/stdlib/_exit.cxx, src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Implement exit(), atexit() and _exit() correctly now. Also + includes cyg_libc_invoke_atexit_handlers() in atexit.cxx. Now + we get the correct behaviour of atexit(), and exit() invokes the + atexit handlers and fflushs all the stdio streams. Add plenty of + tracing of asserts too. + + * src/support/cstartup.cxx: + Make main_thread object an exported global. Allow user-settable + arguments. Add MUCH more tracing and asserts. Improve comments. + Tidy up to 76 columns + + * tests/stdlib/atexit.c: + Add simple test for atexit() and it calling registered functions + + * tests/PKGconf.mak: + Build atexit.c test + +Mon Aug 31 18:54:48 1998 Jonathan Larmour + + * src/stdlib/getenv.cxx, tests/stdlib/getenv.c: + Add support for getenv(), and some tests to ensure it works + + * src/PKGconf.mak, tests/PKGconf.mak: + Update to include getenv.cxx and getenv.c test + + * src/clibincl/clibdata.hxx: + remove prototype for environ - we expect files needing it to + define it themselves + + * src/support/clibdata.cxx: + Tidy up to 76 columns and add definition of char **environ, but + with a configurable initialiser (see libc.h below) + + * tests/stdlib/abs.c (main): + Tidy up to 76 columns + + * src/stdlib/malloc.cxx: + Tidy up to 76 columns and remove warning for undefined _memcpy() + by changing to memcpy(), and casting away signedness + + * include/pkgconf/libc.h: + Add CYGPKG_LIBC_ENVIRONMENT and CYGDAT_LIBC_DEFAULT_ENVIRONMENT + configuration options + + * include/pkgconf/libc.h, src/clibincl/clibdata.hxx: + Tidy up to 76 columns + + * include/stdlib.h: + Add getenv() prototype and tidy up to 76 columns + + * src/clibincl/stdlibsupp.hxx: + Add _getenv() prototype + +Mon Aug 31 13:37:08 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Add realloc() + + * tests/stdlib/realloc.c: + Add this file to test new realloc() functionality + + * tests/PKGconf.mak: + Build realloc test + + * tests/stdlib/malloc3.c (main), tests/stdlib/malloc2.c (main), + tests/stdlib/malloc1.c (main): + Conditionalise local vars to prevent warnings + + * tests/stdlib/malloc3.c (fill_with_data): + Move '{' into "verb" line + + * include/pkgconf/libc.h: + Require infra tracing support to allow tracing + + * include/stdlib.h: + Add realloc() + + * src/clibincl/stdlibsupp.hxx: + Update the commented argument names from stdlib.h, including realloc() + +1998-08-28 Bart Veer + + * include/pkgconf/libc.h: + * src/clibincl/clibdata.hxx, src/time/clock.cxx: + + Updated for new kernel configuration option symbol names + +Fri Aug 28 19:18:25 1998 Hugo Tyson + + Changed the entry below to sat "tx39" instead of "mn10300". + It's been a long week. + +Fri Aug 28 18:59:20 1998 Hugo Tyson + + * src/support/cstartup.cxx: Add a weakly named main to allow the + default configuration to link on the tx39 which has no + scalextric linking yet. The static Cyg_Thread main_thread object + below continues to exist, though unreferenced, so all its + descendants must exist too. + +Fri Aug 28 08:54:29 1998 Jonathan Larmour + + * include/stdlib.h: + Add commented argument names Add exit(), and atexit(). And move + these along with abort() and _exit() to a new section. + + * src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Add trivial versions of atexit() and exit() + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAIN_STACK_SIZE config option + + * include/sys/cstartup.h, src/support/cstartup.cxx, src/PKGconf.mak: + New files to provide a new function cyg_iso_c_support(), which + invokes main "correctly". + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/srand.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcoll2.c, tests/string/strcpy1.c, + tests/string/strcpy2.c, tests/string/strcspn.c, + tests/string/strlen.c, tests/string/strncat1.c, + tests/string/strncat2.c, tests/string/strncpy1.c, + tests/string/strncpy2.c, tests/string/strpbrk.c, + tests/string/strrchr.c, tests/string/strspn.c, + tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, + tests/time/clock.c: + + Modify all tests to use new startup mechanism, and cyg_iso_c_start() + +Fri Aug 28 00:29:38 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Add #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO around all accesses to + flags.last_buffer_op_was_read. Fix for PR 16997 + +Thu Aug 27 01:12:42 1998 Jonathan Larmour + + * include/sys/file_if.h: + Fix comments and remove cyg_get_file_star() + +Wed Aug 26 20:24:32 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove #define CYGPKG_LIBC is that is meant to live in + after all + +Wed Aug 26 19:39:23 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + More fixes to CDL stuff to make it work better, and look better on + the screen + +Tue Aug 25 20:21:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Make some fixes after running the ConfigTool + +Tue Aug 25 16:46:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_STDIO_BUFSIZE): + Fix typo of CYGNUM_LIBC_STDIO_BUFSIZE + +Tue Aug 25 15:10:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Tidy up CDL stuff a bit more, prior to checking it actually works. + +Tue Aug 25 11:38:52 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c (main): + Prevent calls to CYG_TEST_STILL_ALIVE for now + +Tue Aug 25 05:39:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change cosmetic paragraph alignment. + +Tue Aug 25 03:11:34 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Make stderr initialise with buffer size 0. + For PR 16955 + +Mon Aug 24 17:38:46 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + First pass at CDL-ifying the C library configuration. Currently + deliberately disabled as there a few outstanding issues. + +Mon Aug 24 16:14:22 1998 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx (_vfnprintf): + clear up warning for unused argument + + * tests/stdlib/malloc2.c (NUM_ITERATIONS): + Lower to 100 from 50000 so it won't take too long under the simulator + +Thu Aug 20 17:48:43 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Remove now unnecessary inclusion of kernel/ktypes.h + +Wed Aug 19 19:19:14 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, + tests/stdio/sscanf.c, tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, + tests/stdlib/strtoul.c, tests/string/strtok.c, + tests/time/clock.c: + Add parameters to "main()" to silence warnings + +Wed Aug 19 18:52:59 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx (refill_read_buffer): + Put conditional error check into same #ifdef and if as what was being + checked in the first place! + +Wed Aug 19 18:49:19 1998 Jonathan Larmour + + * src/clibincl/stream.inl: + Reorder Cyg_StdioStream::check_this() to be first to silence + warnings + +Tue Aug 18 16:10:03 1998 Jonathan Larmour + + * ecc/language/c/libc/current/src/clibincl/clibdata.hxx, + ecc/language/c/libc/current/src/errno/errno.cxx, + ecc/language/c/libc/current/src/stdio/common/fopen.cxx, + ecc/language/c/libc/current/src/stdlib/rand.cxx, + ecc/language/c/libc/current/src/string/strtok.cxx: + Rename CYGIMP_LIBC_INTERNAL_DATA_PREAMBLE, + CYGIMP_LIBC_INTERNAL_DATA_ALLOC_CHECK_PREAMBLE, + CYGVAR_LIBC_INTERNAL_DATA, and + CYGIMP_LIBC_INTERNAL_DATA_CHECK to all have CYGPRI_ prefix instead + as recommended by the config name rules + + +Tue Aug 18 14:31:19 1998 Jonathan Larmour + + * src/stdio/common/setvbuf.cxx (_setvbuf): + Rename variable names in assert line, otherwise doesn't build + with asserts on! + +Sun Aug 16 18:15:12 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix some bugs, although there are some left to fix still. Unrelated + to the rest of the checkins, so I will check the partial fix in now. + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx: + Add parameters to constructor to allow more things to be done at + construction time. + + Now we have "new", remove separate "construct" method + + Add more documentation on constructor + + As requested by code review, where possible, move boolean flags + into separate packed bitfield structure for space efficiency + + Make readbuf_char be usable all the time rather than when configured + not to be buffering, as it is also needed for non-buffered mode i.e. + _IONBF + + * src/stdio/common/fopen.cxx: + Change to use new method of construction from above, using new + + Use thread-specific data, rather than global. And so change errnos + to access errno entry specifically + + Make process_mode() check for append mode too + + Reformat for coding standards to have { in same line as "verb" + + * src/stdio/common/setvbuf.cxx: + + Change to cope with different way of dealing with buffering policy + flags etc. in Cyg_StdioStream + + * src/stdio/common/vsnprintf.cxx, src/stdio/common/vsscanf.cxx, + src/support/clibdata.cxx: + Change construction of streams to use new parameters added above, + and change to use _IONBF mode for string stdio functions, + otherwise its a waste of memory. And use _IONBF for stderr as the + ISO standard tells us to! + + Reformat for coding standards to have { in same line as "verb" + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Change constructor so that it can be set with default size and + dynamic buffer (if applicable) + + Fix minor bug in destructor - should only call free when allocated + dynamically + + Change get_buffer_size to return -1 if the buffer was not allowed + to be set up + + * src/stdio/common/streambuf.cxx: + Remove unnecessary stdio.h include and add extra comment to whether + to free bit in set_buffer() + + * src/stdio/common/freopen.cxx: + Change @@@ to standard fix me string + + * src/stdio/output/fputc.cxx: + Remove unnecessary "written" variable + +Thu Aug 13 15:37:28 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: + Included use of "fix me" line to ensure this is discussed before + release + + * include/stdlib.h, src/stdlib/abort.cxx, src/PKGconf.mak: + Add abort.cxx to implement abort(), albeit naively + +Thu Jul 30 18:03:09 1998 Jonathan Larmour + + * src/stdio/common/vsscanf.cxx (_vsscanf), + src/stdio/common/vsnprintf.cxx (_vsnprintf): + Fix initialiser of pseudo string device table that didn't get updated + when the table changed (Bad proven, no biscuit). + + * src/clibincl/stream.inl (~Cyg_StdioStream): + Move invalidation of magic_validity_word to after unlock_me(), + otherwise it always fails! + +Tue Jul 28 21:29:53 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Shorten over-long lines + +Tue Jul 28 20:28:23 1998 Jonathan Larmour + + * src/clibincl/stream.hxx (class Cyg_StdioStream), + src/clibincl/stream.inl, src/stdio/common/stream.cxx: + Clarify some comments and get the CYGDBG_DEFINE_CHECK_THIS and + CYG_ASSERTCLASS stuff going + + * src/clibincl/stream.inl: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 15:31:06 1998 Jonathan Larmour + + * src/clibincl/streambuf.inl, src/stdio/common/streambuf.cxx: + Move set_buffer() from streambuf.inl to new file streambuf.cxx + + * src/PKGconf.mak (COMPILE): + Build new file streambuf.cxx + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + Add METHODS comment + + * src/stdio/common/stream.cxx: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 00:26:36 1998 Jonathan Larmour + + * include/stdlib.inl, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/div.cxx, + src/stdlib/ldiv.cxx, src/stdlib/qsort.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/string/strtok.cxx: + + Include proper Berkeley license inline in the file, rather than + referring to an external file + + * doc/COPYING.UCB: + Remove, now that it isn't referred to any more + +Mon Jul 27 23:34:26 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl, include/errno.h, + include/stdio.h, include/stdio.inl, include/stdlib.h, + include/stdlib.inl, include/string.h, include/string.inl, + include/time.h, include/sys/file_if.h, src/PKGconf.mak, + src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/stdiosupp.hxx, + src/clibincl/stream.hxx, src/clibincl/streambuf.hxx, + src/clibincl/streambuf.inl, src/clibincl/stringsupp.hxx, + src/clibincl/timesupp.hxx, src/ctype/isalnum.cxx, + src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, + src/ctype/islower.cxx, src/ctype/isprint.cxx, + src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, + src/ctype/tolower.cxx, src/ctype/toupper.cxx, + src/errno/errno.cxx, src/stdio/common/snprintf.cxx, + src/stdio/common/sprintf.cxx, src/stdio/common/sscanf.cxx, + src/stdio/common/stdioinlines.cxx, src/stdio/common/stream.cxx, + src/stdio/common/ungetc.cxx, src/stdio/common/vsnprintf.cxx, + src/stdio/common/vsscanf.cxx, src/stdio/input/fgetc.cxx, + src/stdio/input/fgets.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/gets.cxx, src/stdio/input/scanf.cxx, + src/stdio/output/fnprintf.cxx, src/stdio/output/fprintf.cxx, + src/stdio/output/fputc.cxx, src/stdio/output/fputs.cxx, + src/stdio/output/printf.cxx, src/stdlib/_exit.cxx, + src/stdlib/abs.cxx, src/stdlib/atof.cxx, src/stdlib/atoi.cxx, + src/stdlib/atol.cxx, src/stdlib/div.cxx, src/stdlib/labs.cxx, + src/stdlib/ldiv.cxx, src/stdlib/rand.cxx, src/stdlib/strtod.cxx, + src/string/memchr.cxx, src/string/memcmp.cxx, + src/string/memmove.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, + src/string/strcoll.cxx, src/string/strcpy.cxx, + src/string/strcspn.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx, src/string/strpbrk.cxx, + src/string/strrchr.cxx, src/string/strspn.cxx, + src/string/strstr.cxx, src/string/strsuppt.cxx, + src/string/strtok.cxx, src/string/strxfrm.cxx, + src/support/clibdata.cxx, src/time/clock.cxx: + Untabify + +Mon Jul 27 23:14:18 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/stdlib/malloc.cxx, src/stdlib/qsort.cxx, + tests/ctype/ctype.c, tests/stdlib/rand3.c, tests/stdlib/malloc3.c: + Remove all mentions of "register" in variable declarations. Also + untabify where needed + + * src/stdlib/bsearch.cxx: + Untabify this too + + +Mon Jul 27 22:18:51 1998 Jonathan Larmour + + * src/stdio/output/fputc.cxx (_fputc): + Replace call to stream write() with call to write_byte() + + * src/clibincl/stream.inl (write_byte): + Add asserts for stream write() returning odd values for how much has + been written + + (bytes_available_to_read): + Remove "register" def for variable declaration + +Mon Jul 27 22:06:22 1998 Jonathan Larmour + + * src/stdio/common/stdiosupp.cxx: + Remove #if 0'd cyg_get_file_star() and unnecessary pseudo string + device definition + +Mon Jul 27 21:57:25 1998 Jonathan Larmour + + * include/pkgconf/libc.h, src/support/clibdata.cxx: + Change CYGXXX_LIBC_STDIO_DEFAULT_CONSOLE to + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE + +Mon Jul 27 21:49:23 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/setjmpsupp.hxx, + src/clibincl/stdiosupp.hxx, src/clibincl/stdlibsupp.hxx, + src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl, + src/clibincl/stringsupp.hxx, src/clibincl/timesupp.hxx: + + Change CYGONCE_LIBC_*_{HXX,INL} to CYGONCE_LIBC_CLIBINCL_*_{HXX,INL} + +Mon Jul 27 21:34:05 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change #define XXXXX 1 to #define XXXXX where applicable as per code + review + + Also remove obsolete CYGIMP_LIBC_THREAD_START_SUSPENDS_SELF + +Mon Jul 27 19:42:27 1998 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): + Use #ifdef, not #if for config options + +Mon Jul 27 15:01:51 BST 1998 Chris Provenzano + + * src/stdio/common/stream.cxx, src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx: + Fixes to compile with the new Cyg_IORB field names. + +Thu Jul 9 03:40:21 1998 Jonathan Larmour + + * tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Adjust starting of tests to possibly start scheduler since + strtol/stroul rely on errno, which may be a per-thread variable + +Thu Jul 9 03:06:25 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx, src/stdio/common/setvbuf.cxx: + Consolidate read and write buffers into single buffer, as it should + have been all along + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Add drain_buffer() method to speed up the case when we want the + buffer completely emptied + +Tue Jul 7 21:26:33 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Add a couple of new tests that check that very long strings work too + +Wed Jul 1 19:52:39 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/streambuf.hxx: + Do not permit copy constructors + + * src/clibincl/stream.inl, src/stdio/common/fclose.cxx: + Make sure we use #ifdef and not #if + + * src/clibincl/streambuf.inl: + Use member initialisation list rather than explicit initialisation to + reduce warnings + +Wed Jul 1 19:17:55 1998 Jonathan Larmour + + * include/pkgconf/libc.h and all files using config options: + Rename configuration defines to make them more standard + +Thu Jun 25 20:09:30 1998 Jonathan Larmour + + * src/string/strcat.cxx: + Add parentheses on check to silence warning + (Verified by proven) + +Thu Jun 25 19:30:01 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Make sure that the malloc pool is initialised before other things + can use it. This is done with the hot new constructor ordering + feature. + +Thu Jun 25 18:27:03 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Remove bogus ifdef if floating point is _not_ wanted + +Thu Jun 25 17:31:42 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Fix argument checking to allow first argument of NULL + +Thu Jun 25 04:18:50 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_strtok_last_p): + Remove bogus assertion + + * src/stdlib/malloc.cxx: + Got sense of alignment check assertion the wrong way round, so negate + it + +Thu Jun 25 03:56:35 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: + Fix argument checking assertions with legitimate nulls here too + +Thu Jun 25 03:46:32 1998 Jonathan Larmour + + * src/stdlib/strtoul.cxx, src/stdlib/strtol.cxx: + Fix argument checking assertions to cope with legitimate nulls + +Wed Jun 24 09:01:45 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Remove extraneous info messages + +Wed Jun 24 05:59:17 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c: + + Change large automatic arrays to static arrays to prevent overuse + of a potentially small stack + +Wed Jun 24 05:45:28 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/string/strtok.c, tests/time/clock.c: + + Increase thread stack size from 4K to 32K as in some cases it was + too small. + + +Tue Jun 23 20:12:31 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Add extra tests, including floating point conversion testing + +Tue Jun 23 17:01:06 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Make sure this is only compiled if CYGFUN_LIBC_strtok is defined + +Tue Jun 23 06:10:13 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + add some comments - that's all + + * src/stdio/common/stream.cxx: + fix case in refill_read_buffer() for what to do when there's nothing + left. Now return EAGAIN + + * src/stdio/common/vsscanf.cxx, src/stdio/input/vfscanf.cxx: + Get sscanf working properly and passing tests. Also make sure it + ignores FP when its not configured + + * src/stdlib/atof.cxx: + Only compile at all if strtod() is present + + +Mon Jun 22 19:13:42 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise strtok_last and rand_seed better + +Mon Jun 22 14:14:12 1998 Jonathan Larmour + + * tests/stdlib/malloc3.c: + Add test for checking that mallocing and freeing repeatedly works + + * tests/PKGconf.mak: + Update to reflect addition of the above + +Mon Jun 22 13:09:33 BST 1998 Chris Provenzano + + * src/stdio/common/fopen.cxx + * src/stdio/common/stream.cxx + * src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx + Include cyg/devs/common/iorb.h instead of iorb.hxx + + * src/stdio/common/stream.cxx + Use read_blocking and write_blocking instead of just read and + write when accessing devices through the virtual device table. + +Sun Jun 21 18:19:13 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Propagate change of return code handling for puts from stdio.inl + into here + + * src/stdio/output/fputc.cxx: + make sure the right type is used for output - byte not int + + * src/support/clibdata.cxx: + Fix #define config mistook. #endif was in wrong place + +Sun Jun 21 16:11:04 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Allow explicit construction to get around a bug when + dynamically allocating per-thread structure + +Sun Jun 21 16:02:51 1998 Jonathan Larmour + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, tests/stdlib/qsort.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + + Update tests to "do the right thing" with all configuration settings + + +Sun Jun 21 04:54:14 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + I have to be careful not to use setjmp() in a way not exactly + defined by the standard, so make sure I do, and add a comment + documenting these ways. + + Also ensure this test does the right thing in all configurations + +Sun Jun 21 04:38:15 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add extra checks for invalid configurations + Also make default for thread safety OFF + + * src/clibincl/clibdata.inl: + Adjust indentation + + * src/stdio/output/vfnprintf.cxx: + Make printf of -0.0 floating point do the right thing + +Sun Jun 21 04:28:00 1998 Jonathan Larmour + + * src/stdio/common/snprintf.cxx, src/stdio/common/sprintf.cxx, + src/stdio/common/sscanf.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/scanf.cxx, src/stdio/output/fnprintf.cxx, + src/stdio/output/fprintf.cxx, src/stdio/output/printf.cxx: + + Had to remove inline functions with varargs. Which means separating + out each function from stdioinlines.cxx into a separate file, as they + no longer belong there. So all the above files were created. + + * include/stdio.inl, src/PKGconf.mak, + src/stdio/common/stdioinlines.cxx: + Changed to take account of the above + + +Sun Jun 21 03:58:42 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c: + Update with floating-point tests. Also make sure they DTRT in all + configurations + +Fri Jun 19 19:33:06 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + accidentally initialised stdin/out/err twice + +Fri Jun 19 19:09:29 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Another typo + +Fri Jun 19 18:59:07 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Missing #endif typo + +Fri Jun 19 18:51:42 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Fix initialisation of static data members. Unsure how it worked at + all before! + +Fri Jun 19 18:01:01 1998 Jonathan Larmour + + * include/stdio.inl: + puts should check whether fputs returns non-negative, rather than + non-zero + +Fri Jun 19 17:22:52 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl: + Make inclusion of get_errno_p conditional on thread-safety + +Wed Jun 17 10:55:32 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Add weak alias of vfscanf() to _vfscanf() + +Wed Jun 17 09:10:41 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Initialise err to silence compiler warning + +Wed Jun 17 08:59:20 1998 Jonathan Larmour + + * Most important is the addition of floating point support in + src/stdio/output/vfnprintf.cxx and src/stdio/input/vfscanf.cxx. This + also required the addition of atof() and strtod() in stdlib which is + definitely no bad thing! Other than that... + + * Fix a whole bunch of stuff I messed up first time round. Also the + sprintf and sscanf tests are included again. + +Tue Jun 16 16:38:02 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Typo with not putting comment character at the beginning. Sigh. + +Tue Jun 16 14:53:09 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Forgot to (temporarily) remove fputs test for now + +Mon Jun 15 20:40:03 1998 Jonathan Larmour + + Everything to do with stdio has almost completely changed, so there's + not much point documenting individual changes. + +Mon Jun 15 18:36:01 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c: + Stop it moaning quite as much when it fails by making it exit sooner + + * tests/time/clock.c : + This isn't a compound testcase + +Thu Jun 11 17:59:13 1998 Jonathan Larmour + + * include/assert.h + Reverse sense of NDEBUG ifdef, that was left in accidentally due + to testing + +Thu Jun 11 04:58:08 1998 Jonathan Larmour + + * include/errno.h, include/string.h, src/clibincl/stringsupp.hxx: + Modify as I've now added an "error" package which defines the error + codes and strerror() + + * src/errno/strerror.cxx: + Moved to new error package and thus deleted + +Wed Jun 10 18:37:37 1998 Jonathan Larmour + + * include/assert.h: + create this header and add assert() function + +Wed Jun 10 16:23:57 1998 Jonathan Larmour + + * include/stdlib.h, src/clibincl/stdlibsupp.hxx, src/stdlib/malloc.cxx: + Add malloc(), calloc() and free() functions + + * include/pkgconf/libc.h: + Add malloc memory pool size option + + * tests/stdlib/malloc1.c, tests/stdlib/malloc2.c: + new tests for malloc + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for new files + +Wed Jun 10 15:06:16 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + Add another test + +Tue Jun 9 18:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add some setjmp config's and a macro for the noreturn attribute + + * include/setjmp.h, include/setjmp.inl, src/clibincl/setjmpsupp.hxx, + src/setjmp/longjmp.cxx, tests/setjmp/setjmp.c: + Added to implement and test setjmp() and longjmp() + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for newly added files + +Thu Jun 4 01:29:18 1998 Jonathan Larmour + + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, src/string/strcpy.cxx, + src/string/strlen.cxx, src/string/strncat.cxx, + src/string/strncmp.cxx, src/string/strncpy.cxx: + Rename CYGIMP_LIBC_PREFER_SMALL_TO_FAST to + CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST + + Also use slower but smaller version when __OPTIMIZE_SIZE__ is + defined (which comes from using gcc -Os) + +Fri May 29 16:15:04 1998 Jonathan Larmour + + * include/ctype.inl, src/ctype/isxdigit.cxx: + Fix bug that numerals aren't considered hex digits + + * include/time.h: + Change clock_t and time_t to be signed so that they can accept -1, as + required by other libc functions + + * src/clibincl/clibdata.hxx: + Fix typo that CYGIMP_LIBC_THREAD_SUPPORT should be ..._SAFETY + Also fix macro to allocate thread-specific data to not set variables + in a different stack-frame + + * tests/ctype/ctype.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/stdlib/qsort.c: + make ctr unsigned to prevent warnings + + * tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/string/strrchr.c: + Fix off by one error + + * tests/string/strspn.c: + Fix case-sensitivity problem, and off-by-one error + + * tests/string/strxfrm1.c: + Remove bogus bit of test that doesn't apply to strxfrm, and fix typo + + +Fri May 22 16:33:04 1998 Jonathan Larmour + + * src/PKGconf.mak + Remove CXXFLAGS line now that its redundant + + * tests/everything! + Do a blitz change of all tests - break some of them down into + different files, add new tests, standardize format, fix bugs, + update for recent header file changes and much more! + +Wed May 20 17:50:04 1998 Jonathan Larmour + + * tests/PKGconf.mak: + interim checkin for different dir structure for Bart + +Fri May 15 20:30:46 1998 Jonathan Larmour + + * Tidy up some loose ends I forgot: rename src/include directory to + src/clibincl. And add clibdata.inl and timesupp.hxx in there. + +Thu May 14 19:56:32 1998 Jonathan Larmour + + * Basically everything has changed in the C library. Files have + been moved, renamed, deleted and reworked. This is a major + revision, and now starts from this new baseline rather than doing + incremental changes. + +Fri Apr 17 18:43:02 1998 Jonathan Larmour + + * src/ECCconf.mak: + added for new build system (actually Bart did this, but didn't + update this ChangeLog) + +Fri Apr 17 15:03:25 1998 Hugo Tyson + + * src/stdio/device/sim.cxx: + Make it build with CYG_EMPTY_STATEMENT; the unadorned one is being + removed. + +Thu Apr 16 00:24:24 1998 Jonathan Larmour + + * All source files: + replace ECCIMP_LIBC_* conditional ifdef with CYGIMP_LIBC_* + + * include/eccconf/libc.h: + improve comments and reorder a bit + +Wed Apr 8 14:35:20 1998 Jonathan Larmour + + * Makefile.am, src/Makefile.am, tests/Makefile.am, configure.in: + many changes to integrate build structure from release tree + + * src/ctype/Makefile.am, src/ctype/Makefile.in, src/errno/Makefile.am, + src/errno/Makefile.in, src/stdio/Makefile.am, src/stdio/Makefile.in, + src/stdio/common/Makefile.am, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.am, src/stdio/device/Makefile.in, + src/stdio/output/Makefile.am, src/stdio/output/Makefile.in, + src/stdio/input/Makefile.am, src/stdio/input/Makefile.in, + src/stdlib/Makefile.am, src/stdlib/Makefile.in, + src/string/Makefile.am, src/string/Makefile.in, + src/support/Makefile.am, src/support/Makefile.in, + src/time/Makefile.am, src/time/Makefile.in: + Remove as they are now redundant with above changes + + * include/Makefile.am: + Add to support above changes + + * include/eccconf/libc.h: + Change include file for configuration from kernel to system + + * src/include/kerndiag.hxx, src/stdio/device/kerndiag.cxx, + src/time/clockfn.cxx: + Change kernel include file to eccconf/kernel.h + + * src/include/strngdev.h: + remove unnecessary kernel include + + * Makefile.in, aclocal.m4, configure, src/Makefile.in, + tests/Makefile.in, include/Makefile.in: + regenerate + +Mon Apr 6 20:55:07 1998 Jonathan Larmour + + * src/stdlib/abs.cxx, src/stdlib/atoi.cxx, src/stdlib/atol.cxx, + src/stdlib/div.cxx, src/stdlib/labs.cxx, src/stdlib/ldiv.cxx: + Separated out functions from stdlib.cxx into separate files + + * src/stdlib/stdlib.cxx: + removed to be replaced by above files + + * Makefile.am, src/stdlib/Makefile.am: + modified to support building above and not building stdlib.cxx + + * src/support/tsd.cxx: + Remove unnecessary header file includes + + * Makefile.in, src/stdlib/Makefile.in: + regenerated + +Mon Apr 6 19:19:42 1998 Jonathan Larmour + + * src/support/tsd.cxx, include/eccconf/libc.h: + remove lame hack for tx39 compiler now that its fixed + + * src/include/sim.hxx: + define constants as static to placate compiler + +Thu Apr 2 21:01:21 1998 Jonathan Larmour + + * src/ctype/ctype.cxx: + deleted and separated out into below files + + * src/ctype/isalnum.cxx, src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, src/ctype/islower.cxx, + src/ctype/isprint.cxx, src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, src/ctype/tolower.cxx, + src/ctype/toupper.cxx: + Separated out individual ctype functions from ctype.cxx into separate + files + + * Makefile.am, src/ctype/Makefile.am: + modified to reflect above deletion/additions + + * Makefile.in, src/ctype/Makefile.in: + regenerated + +Thu Apr 2 19:08:26 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: optimise using prefix increments + +Thu Apr 2 15:18:15 1998 Jonathan Larmour + + * src/string/strchr.cxx: optimise setting of mask a little + +Thu Mar 26 14:07:01 1998 Jonathan Larmour + + * src/support/tsd.cxx: fixed some typos + +Thu Mar 26 11:58:47 1998 Jonathan Larmour + + * include/eccconf/libc.h, src/support/tsd.cxx: + Implement workaround for tx39 compiler bug. + + * src/include/strsuppt.hxx: + remove prototypes for _memcpy() and _memset() as they are now in the + kernel + +Wed Mar 25 18:31:53 1998 Jonathan Larmour + + * Makefile.am, src/string/Makefile.am: memcpy() and memset() are + now in the kernel so remove them from build + * include/string.h: add a comment to say as much + * Makefile.in, src/string/Makefile.in: regenerate + +Wed Mar 25 15:30:42 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx, src/include/file_if.inl: + Change _exit workaround to not cause a compiler optimisation + problem. Now just references _exit rather than calls it. + +Wed Mar 25 14:59:49 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fix bug causing tests to fail completely + for this function + +Wed Mar 25 12:55:53 1998 Jonathan Larmour + + * src/include/sim.hxx: add types to constants (oops!) + * Makefile.am: link src/stdio/device/sim.cxx + * Makefile.in: regenerated + +Wed Mar 25 04:14:30 1998 Jonathan Larmour + + * src/include/file_if.hxx, src/include/file_if.inl, + src/include/kerndiag.hxx, src/include/sim.hxx, + src/include/stdio_if.hxx, src/include/strngdev.hxx, + src/include/tsd.hxx, src/stdio/common/clearerr.cxx, + src/stdio/common/clearerr.cxx, src/stdio/common/feof.cxx, + src/stdio/common/ferror.cxx, src/stdio/common/file_if.cxx, + src/stdio/common/vsprintf.cxx, + src/stdio/device/kerndiag.cxx, src/stdio/device/sim.cxx, + src/stdio/device/strngdev.cxx, src/stdio/output/fputc.cxx, + src/stdio/output/fputs.cxx, src/stdio/output/puts.cxx, + src/stdio/output/vfnprintf.cxx, src/support/tsd.cxx: + Modified to support buffered reads including renaming + _EccInternalFileStruct to __EccStdioStream which is what affects + most of these files + * src/include/file_if.inl, src/stdio/common/file_if.cxx: added for + the above reason + * src/stdio/common/sscanf.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/input/Makefile.am: added to provide sscanf() functionality + * include/ctype.h, include/stdio.h, include/stdlib.h, + include/string.h, include/eccconf/libc.h, src/ctype/ctype.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/stdio/common/stdio.cxx: + rename *_INLINES macros with prefix CYG rather than ECC + * include/errno.h, src/errno/errno.cxx, src/errno/strerror.cxx: + rename ErrNo to _ErrNo and add EAGAIN and EWOULDBLOCK error codes + * configure.in, Makefile.am, src/stdio/Makefile.am, + src/stdio/input/Makefile.am: add support for building + file_if.cxx sscanf.cxx and vfscanf.cxx + * src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/input/Makefile.in, configure, Makefile.in: regenerated + +Tue Mar 24 19:51:40 1998 Jonathan Larmour + + * src/time/clockfn.cxx, src/time/clock.cxx: + Renamed clock.cxx to clockfn.cxx (preserving CVS history) + * Makefile.am, src/time/Makefile.am: updated to reflect name change + * Makefile.in, src/time/Makefile.in: regenerated + +Tue Mar 24 16:28:06 1998 Jonathan Larmour + + * include/ctype.inl: Swap around definitions to get right order so + inlining works + +Tue Mar 24 14:43:05 1998 Jonathan Larmour + + * include/ctype.h, include/stdio.h, include/stdlib.h, include/string.h: + modify to only conditionally include inlines + * src/ctype/ctype.cxx, src/stdio/common/stdio.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/ctype/Makefile.am: Add to provide real linkable alternatives + to inline functions + * Makefile.am, configure.in, src/Makefile.am, + src/stdio/common/Makefile.am, src/stdlib/Makefile.am, + src/string/Makefile.am: modified to support previous additions + * include/eccconf/libc.h: redefine inline macro to add extern inline, + and add conditional defines for inline functions. Also rename + space vs. speed macro to have CYG instead of ECC prefix + * include/stdio.inl: fix comment typo + * src/stdlib/qsort.cxx: fix to define inline functions properly + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/memcpy.cxx, + src/string/memset.cxx, src/string/strcat.cxx, src/string/strchr.cxx, + src/string/strcmp.cxx, src/string/strcpy.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx + * Makefile.in, configure, src/Makefile.in, src/ctype/Makefile.in, + src/stdio/common/Makefile.in, src/stdlib/Makefile.in, + src/string/Makefile.in: regenerate + + +Mon Mar 23 19:19:49 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: added to support temporary _exit + * include/stdlib.h, include/stdlib.inl: added support for _exit and + added abs(), labs(), div() and ldiv() functions + * src/include/file_if.hxx: added support for _exit kludge + * src/stdlib/qsort.cxx: Added Berkeley copyright message + * src/time/clock.cxx: Include correct kernel config header as + CYG_CONFIGURATION rather than + * Makefile.am src/stdlib/Makefile.am: added support for _exit + * Makefile.in, src/stdlib/Makefile.in: regenerated + +Mon Mar 23 14:41:07 1998 Jonathan Larmour + + * Replace ECCPKG_ANSI_LIBC with CYGPKG_ANSI_LIBC in all source files + +Mon Mar 23 14:28:44 1998 Jonathan Larmour + + * include/string.inl: add file to provide strcoll() + * include/string.h: include string.inl + * ctype.h: include ctype.inl (oops!) + * include/stdlib.h: include stdlib.inl (oops!) + +Mon Mar 23 13:30:38 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl: added to provide ANSI ctype + functionality + * include/stdlib.h, include/stdlib.inl, src/include/stdlibbsp.hxx, + src/stdlib/Makefile.am, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/stdlib/srand.cxx, + src/stdlib/strtol.cxx, src/stdlib/strtoul.cxx: Added to provide + many stdlib functions + * src/include/tsd.hxx: modified to support rand() random number + seed, and added some comments + * configure.in, Makefile.am, src/Makefile.am: modified to support + addition of above new sources + * include/eccconf/libc.h: Add extra helpful comments, and #include + kernel config file + * src/time/clock.cxx: #include clock.inl and fix to call + get_resolution() properly now + * Makefile.in, configure, src/Makefile.in, src/errno/Makefile.in, + src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.in, src/stdio/output/Makefile.in, + src/stdlib/Makefile.in, src/strings/Makefile.in, + src/support/Makefile.in, src/time/Makefile.in, + tests/Makefile.in: regenerated + + +Sun Mar 22 21:29:25 1998 Jonathan Larmour + + * include/time.h, src/include/timesupp.hxx, src/time/clock.cxx, + src/time/Makefile.am: added to provide clock() function + * src/Makefile.am: modified to try to build in src/time directory + * include/eccconf/libc.h: added and is now the main configuration + file for this package + * acconfig.h, include/libcconf.h.in, include/stamp-h.in: removed + due to usage of libc.h above instead + * Almost all *.h, *.hxx and *.cxx: replaced LIBC_CONFIG_HEADER + defined include with simple + * configure.in: remove AM_CONFIG_HEADER of libcconf.h and + LIBC_CONFIG_HEADER definition. Also remove usage of builtin + memcpy() etc. from gcc, and generate src/time/Makefile + * Makefile.am: link in src/time/clock.o + * src/include/file_if.hxx, src/include/sim.hxx: use config header + to decide whether C library is to be used + * Makefile.in, aclocal.m4, configure, src/Makefile.in: regenerated + +Fri Mar 20 18:08:10 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fixed bug with ignoring terminating NULL + +1998-03-20 Chris Tarpy + + * configure: - regenerated + * Makefile.am: - Support added for libc testcases + * Makefile.in: regenerated + * configure.in: set c compiler, descend test dir + * tests/Makefile.in: added + * tests/Makefile.am: added + * tests/tcdiag.cxx : added + + +Thu Mar 19 11:41:56 1998 Jonathan Larmour + + * Initial check-in of everything + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/common/current/cdl/libc.cdl b/packages/language/c/libc/common/current/cdl/libc.cdl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/common/current/cdl/libc.cdl @@ -0,0 +1,54 @@ +# ==================================================================== +# +# libc.cdl +# +# C library common package configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jlarmour +# Contributors: +# Date: 2000-04-14 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_LIBC { + display "ISO C library" + description " +The packages under this package enable compatibility with the ISO C +standard - ISO/IEC 9899:1990. This allows the user application to use +well known standard C library functions, and in eCos starts a thread +to invoke the user function main(). This package is a top-level placeholder +to contain the implementations." + doc redirect/the-iso-standard-c-and-math-libraries.html +} + +# ==================================================================== +# EOF libc.cdl diff --git a/packages/language/c/libc/i18n/current/ChangeLog b/packages/language/c/libc/i18n/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/i18n/current/ChangeLog @@ -0,0 +1,33 @@ +2000-05-02 Jonathan Larmour + + * New package + Separated original libc out into separate packages on functional + boundaries. + Header files are now managed by isoinfra package + Plenty of cleanups done, but no major functionality changes + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/i18n/current/ChangeLog.libc b/packages/language/c/libc/i18n/current/ChangeLog.libc new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/i18n/current/ChangeLog.libc @@ -0,0 +1,2727 @@ +This ChangeLog file is now obsolete. This is the original ChangeLog from when +libc was one large package, before being separated. It is included for +historical reasons. + +2000-04-05 Jesper Skov + + * src/time/settime.cxx: + * src/time/time.cxx: + Wallclock moved to io/. + +2000-03-28 John Dallaway + + * cdl/string.cdl, + cdl/stdlib.cdl, + cdl/stdio.cdl, + cdl/libc.cdl: + + Adjust documentation URLs. + +2000-03-27 Jesper Skov + + * src/clibincl/stream.inl (check_this): Use cyb_bool instead of bool. + +2000-03-06 Jesper Skov + + * tests/time/strftime.c (test): Adjust test to match below change. + +2000-03-02 Jonathan Larmour + + * src/time/strftime.cxx (do_format): Make sure %m counts from + 1..12 rather than 0..11. Fix for case 103300 + +2000-02-29 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: Correctly use 'n' parameter to + restrict length. Credit due to Andrew Lunn here as well. + Resolves 103057-CR-1 + + * tests/stdio/sprintf2.c (test): + Add snprintf tests to verify the correct behaviour of restricting + output length + +2000-02-10 Jesper Skov + + * tests/signal/signal2.c (main): + Also reclaim DATA_TLB_MISS vector if available. + +2000-01-31 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-28 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-19 Hugo Tyson + + * cdl/*.cdl: Add descriptions to a number of options &c which were + lacking same, also tidied up other typos as noticed en passant. + +1999-11-11 Bart Veer + + * cdl/string.cdl: + Switch to a single boolean configuration option for code size vs. + speed optimization. + +1999-11-03 John Dallaway + + * cdl/libc.cdl: Define tests. + +1999-10-19 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: We can now remove Berkeley + advertising clause + * src/stdlib/div.cxx: ditto + * src/stdlib/ldiv.cxx: ditto + * src/stdlib/strtol.cxx: ditto + * src/stdlib/strtoul.cxx: ditto + * src/string/strtok.cxx: ditto + +1999-10-19 John Dallaway + + * cdl/libc.cdl: + + Define CDL options for package-specific CFLAGS. + +1999-10-08 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_THREAD_PRIORITY): Change + default to 10 to keep test farm happy + * cdl/startup.cdl: Likewise + +1999-10-07 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Specify radio buttons using CDL interfaces. + +1999-10-06 Jonathan Larmour + + * cdl/stdio.cdl: Change default to /dev/ttydiag as per 1999-10-01 + change below + * cdl/startup.cdl: Add new form CDL for the startup changes as + per 1999-10-05 + +1999-10-05 Jonathan Larmour + + * include/libc.h: Add CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM to allow + the user to supply their own stack. + Rename CYGNUM_LIBC_MAIN_STACK_SIZE to + CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE and reparent under + CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + Add CYGNUM_LIBC_MAIN_THREAD_PRIORITY to provide main() thread + priority + + * src/support/mainthread.cxx: Add support for user-supplied stack + Allow user to specify thread priority + + These changes fix CR 101069 + +1999-10-01 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE): Change + default to /dev/ttydiag to get correct console-like behaviour + Also don't preclude use if haldiag package isn't included + (case 102065) + +1999-09-15 Jesper Skov + + * tests/signal/signal2.c (cause_fpe): Try both float and integer + division by zero. + +1999-09-10 Jesper Skov + + * src/stdlib/malloc.cxx (cyg_libc_get_malloc_pool): Added for + stress_threads test. + +1999-09-07 Jesper Skov + PRs 20243, 20433 + * tests/signal/signal2.c: Disabled test3 on ARM. + +1999-09-02 Hugo Tyson + + * include/assert.h: Make the sense of NDEBUG correct; it is "set" + when NOT debugging. Fix for CR 101983-CR-1 + See Stroustrup, "The C++ Programming Language." + +1999-08-18 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): Set buffer size 0 when not + buffering + Fix for case 101868 + +1999-08-17 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Implement radio buttons using "FIXME radio" hack in + description field for now. + +1999-08-12 John Dallaway + + * cdl/stdlib.cdl: + Take advantage of MACRONAME_ENUMVAL macros output by CDL. + +1999-08-06 Jonathan Larmour + + * tests/stdio/sprintf2.c (test): Don't rely on 2.345 being exactly + representable in binary as a difference of 1 ulp will make it round + the wrong way. + +1999-07-16 Jonathan Larmour + + * src/stdio/input/fgetc.cxx: + Include outline versions of getc() (actually just a symbol alias for + fgetc() ) and getchar() + Some minor clean-ups + Add tracing/assertions + + * src/stdio/input/fputc.cxx: + Likewise (except applied to putc() and putchar()) + + * src/stdio/common/stdioinlines.cxx (_puts): + Call fputc() not _fputc() + + * src/clibincl/stdiosupp.hxx: + Remove now obsolete prototypes for _fgetc() and _fputc() + + * include/stdio.h: + Don't bother with getc()/putc() macros any more, just call + them as functions + Include protos for getc(), putc(), getchar() and putchar() functions + +1999-06-21 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for SH EDK7708. + +1999-06-11 Jonathan Larmour + + * include/stdio.h: Make FILEs array types so they won't be + given $gp relocations on MIPS targets + +1999-05-27 Jesper Skov + + * tests/time/ctime.c: Fixed compiler warning. + +1999-05-25 Jonathan Larmour + + * tests/signal/signal2.c (main): + Update CYGPKG_HAL_TX39 -> CYGPKG_HAL_MIPS_TX39 due to recent MIPS + HAL changes + Fix for PR 20116 + +1999-04-30 Jesper Skov + PR 19945/19946 workaround + * tests/signal/signal2.c: Disabled test 3 for PowerPC sim. + +1999-04-19 Jonathan Larmour + + * include/time.inl: + Ensure all calls to cyg_libc_time_year_is_leap() are with the full + year, and not the direct contents of a struct tm, which are (year-1900) + +1999-04-19 Jesper Skov + PR 19308, 19410, 19528 + * tests/time/clock.c (test): Also disable data cache which may + affect timing when tracing/assertions are enabled. + +1999-04-15 Jonathan Larmour + + * src/clibincl/stdiosupp.hxx: + Add prototype for new cyg_libc_stdio_flush_all_but() function + + * src/clibincl/stream.hxx: + Don't include stdiosupp.hxx any more to prevent circular dependency, + therefore manually provide _setvbuf prototype + Make sure pkgconf/kernel.h is included before mutex.hxx + + * src/clibincl/stream.inl (Cyg_StdioStream::set_error()): + Add missing unlock_me() + + * src/stdio/common/fflush.cxx: + Separate most of code for fflush(NULL) into separate + cyg_libc_stdio_flush_all_but() function, which has the extra + capability of omitting one stream + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Add missing clibincl/stdiosupp.hxx include + + * src/stdio/common/stream.cxx (Cyg_StdioStream::read()): + When reading, ensure we flush all output streams + + * src/stdio/common/stream.cxx (Cyg_StdioStream::flush_output_unlocked): + Flush the device as well + +1999-04-15 Jonathan Larmour + + * src/stdio/common/streambuf.cxx (set_buffer): + * src/stdio/common/stdioinlines.cxx (_setbuf): + * src/clibincl/streambuf.inl: + * src/clibincl/streambuf.hxx: + * src/clibincl/stream.hxx (class Cyg_StdioStream): + * include/pkgconf/libc.h: + * include/stdio.inl (setbuf): + Fix dumb typo: BUFSIZE -> BUFSIZ + This fixes PR19837 + +1999-04-15 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx (_setbuf): + * include/stdio.inl (setbuf): + Use _IONBF when buf==NULL, and _IOLBF otherwise. + Fix for PR 19836 + +1999-04-15 John Dallaway + + * include/pkgconf/libc.h: Tidy display string capitalization. + +1999-04-12 Jonathan Larmour + + * include/pkgconf/libc.h: + Clarify CDL description of CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE + + * tests/signal/signal2.c: Try harder to generate an exception by + accessing a misaligned address + Don't handle SIGTRAP any more + Part of fix for PRs 19731/19607 + +1999-04-07 Jesper Skov + PR 19667 + * src/support/mainthread.cxx: + Changed to use the new Cyg_Thread constructor. + +1999-04-07 Hugo Tyson + + * tests/signal/signal2.c (main): Use new macro + HAL_VSR_SET_TO_ECOS_HANDLER if defined, to wrest control from + CygMon, for example, by reinstalling eCos' default VSRs for + exceptions that we are provoking. + +1999-03-29 Jonathan Larmour + + * src/signal/siginit.cxx: Include stdlib.h for exit() + Fix for PR 19720 + +1999-03-29 Jonathan Larmour + + * tests/time/clock.c (test): Disable instruction cache + Hopefully fixes PR 19308 + +1999-03-29 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for PPC as it cannot + trap division by zero. + +1999-03-26 Jonathan Larmour + + * src/support/main.cxx (main): Invoke cyg_user_start() if no kernel + Only sensible thing to do in our default main in a non-kernel config + +1999-03-25 Jonathan Larmour + + * tests/time/time.c: + Increase MAX_TIMEOUT since the sparclite gets very close to overrunning + it even when working. + Should return -1 iff CYGSEM_LIBC_TIME_TIME_WORKING isn't defined + Cosmetic changes + +1999-03-25 Hugo Tyson + + * tests/time/time.c (test): Take into account setting of + CYGSEM_LIBC_TIME_SETTIME_WORKING ie. does cyg_libc_time_settime() + work? If not, check that it returns an error. + This was exposed by the random combo in PR#19479. + +1999-03-23 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 to + CYGIMP_... + + Add another rand implementation CYGIMP_LIBC_RAND_SIMPLE1 which is + the default + + Part of fix for PR 19562 + + * include/sys/cstartup.h: + Tidy and remove unnecessary dependencies + + * src/stdlib/rand.cxx: + Rename algorithms from CYGSEM_... to CYGIMP_... + Add new "simple1" algorithm + + * tests/ctype/ctype.c: + Tidy + + * tests/stdlib/rand3.c: + Fix so that 0..RAND_MAX is split evenly over buckets, which it wasn't + before + Deal with case of RAND_MAX not being divisible by NUM_BUCKETS + exactly + Increase TEST_LENGTH to 200000 to provide more representative sample + Add CYG_TEST_INFO output to help ensure it doesn't time out + Tidy + + * tests/stdlib/rand4.c: + Only fail if more than _two_ thirds (rather than one third) match. + This is because half would match for a perfectly random distribution + This is the rest of the fix for PR 19562 + Cosmetic changes + +1999-03-22 Hugo Tyson + + * src/support/mainthread.cxx (CYGNUM_LIBC_MAIN_STACK_SIZE): + Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of + CYGNUM_HAL_MINIMUM_STACK_SIZE. + +1999-03-22 Jonathan Larmour + + * tests/PKGconf.mak: Add -Wno-format when building strftime otherwise + it generates warnings for things that we do want to test (null + string, and %y format) + +1999-03-19 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Put brackets back round negative number since sdf says the config + tool is fixed now (PR 19537) + + Add new CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 + options for different rand() algorithms in a so far failed attempt + to fix PR 19562 + + * src/stdlib/rand.cxx: + Add new optional algorithm from Knuth vol.2 + + * tests/stdlib/rand4.c: + Some tidies + Don't run test when using simplest algorithm + + * tests/signal/signal2.c (main): + Don't try to make an FPE on tx39 - its possible to detect but requires + too much HAL work to be sensible + +1999-03-18 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Use HAL_ENABLE_INTERRUPTS() rather than kernel to enable interrupts + +1999-03-18 Mark Galassi + + * tests/PKGconf.mak (TESTS): added rand4 compilation. + + * tests/stdlib/rand4.c: added this test for periodicity in the + least significant bit of rand(). + +1999-03-18 Jonathan Larmour + + * include/pkgconf/libc.h: Remove CYGFUN_LIBC_TIME_POSIX dependency + on CYGPKG_LIBC_STDIO + + * src/stdlib/itoa.cxx: + New file to convert integers to ascii + + * include/stdlib.h: + Add proto for new cyg_libc_itoa() function + + * include/time.inl: + Rework __asctime_r() to use memcpy() and cyg_libc_itoa() rather than + sprintf() + + * src/PKGconf.mak: + Build stdlib/itoa.cxx + + The above changes fix PR 19448 + +1999-03-17 Jonathan Larmour + + * include/time.h: Add #define of __time_t_defined to placate newlib + if it is used by accident. This is just a temporary workaround though. + +1999-03-16 Gary Thomas + + * src/PKGconf.mak: Add compile option to step around ARM compiler bug. + +1999-03-16 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Don't use parentheses for now + + * src/stdio/common/stream.cxx (refill_read_buffer): + Silence bogus compiler warning + +1999-03-16 Jesper Skov + + * tests/signal/signal2.c (main): Enable SIGSEGV test for + i386/Linux. + + +1999-03-15 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Only enable interrupts if they were disabled + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: + Add FIX ME line as a reminder that the workaround there can go away + in future + + * include/pkgconf/libc.h: + Add proper define for CYGSEM_LIBC_EXIT_CALLS_FFLUSH + Put brackets round negative CYGNUM_LIBC_TIME_DST_DEFAULT_STATE define + Fix run time typo + + * include/time.inl (__localtime_r): + Include sys/timeutil.h before this to get + cyg_libc_time_normalize_structtm() + +1999-03-12 Gary Thomas + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: Remove 'const' from char arrays since + this fails [silently] on ARM when -fwritable-strings (PR19440) + +1999-03-12 Jesper Skov + + * tests/signal/signal2.c (main): Compiler warnings fix was + slightly broken. + +1999-03-12 Jesper Skov + PR 19473 + * tests/signal/signal2.c (main): + Disabling SIGTRAP handling on i386/Linux is not a good idea. +1999-03-11 Jesper Skov + PR 19473 + * tests/signal/signal2.c: + Added compiler warnings fix. + Added N/A handling for i386/Linux. + +1999-03-10 Gary Thomas + + * include/pkgconf/libc.h: Force "haldiag" device to be present. + 'asctime' and friends need 'stdio' as well. + + * include/time.inl: Fix syntax error on difftime() declaration. + +1999-03-08 Gary Thomas + + * src/clibincl/stream.hxx: needed for this file. + + * src/stdio/common/vsscanf.cxx (str_read): Fix problem with string + pointer [created by merge with new I/O package]. + +1999-03-05 John Dallaway + + * include/pkgconf/libc.h: + Add legal values for CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET + and CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET. + +1999-03-05 Jonathan Larmour + + * include/time.inl (cyg_libc_time_year_is_leap): + Fix bug with modulo year 400 + Fix typo in asctime_r macro + Fix gmtime_r, and mktime as a result of testing + + * tests/time/asctime.c, tests/time/ctime.c, tests/time/gmtime.c, + tests/time/gmtime.c, tests/time/localtime.c, tests/time/mktime.c, + tests/time/strftime.c, tests/time/time.c: + New tests + + * tests/PKGconf.mak: + Build above new tests + + * include/pkgconf/libc.h: + Add reminder FIX ME about extra config option + + * src/time/strftime.cxx: + Fix %w and %Y parameters as a result of testing + + * src/time/timeutil.cxx: + Fix cyg_libc_time_normalize_structtm() as a result of testing + of mktime() + + * tests/time/clock.c: + Reformat, remove obsolete bits and tidy + + * include/time.h: + Add Cyg_libc_time_dst type and new functions + cyg_libc_time_setzoneoffsets(), cyg_libc_time_setdst(), + cyg_libc_time_getzoneoffsets(), cyg_libc_time_settime() + + * include/time.inl: + Implement the above functions. This allows us to adjust for timezone + diffences and set the time. + Change localtime() to adjust for STD/DST + Change mktime() to adjust for STD/DST + + * include/libc.h: + Add new config options CYGSEM_LIBC_TIME_SETTIME_WORKING + and component CYGPKG_LIBC_TIME_ZONES containing options + CYGNUM_LIBC_TIME_DST_DEFAULT_STATE, + CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET, + CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET + + * src/strftime.cxx: + Adjust handling of %Z to _not_ deal with STD/DST + + * src/time/settime.cxx: + New file to implement cyg_libc_time_settime() + + * src/PKGconf.mak: + Build settime.cxx + + * src/time/timeutil.cxx: + Supply outline versions of cyg_libc_time_setzoneoffsets(), + cyg_libc_time_setdst(), and cyg_libc_time_getzoneoffsets() + Add variables for STD/DST state + Some minor comment changes + + * include/errno.h: + Use CYGBLD_ATTRIB_CONST instead of __attribute__((const)) directly + + * include/signal.h: + Change format of function comment headers + + * include/signal.inl: + Restrict errno.h inclusion to when its actually used + Fix a spelling typo + + * include/stdlib.h: + Add CYGBLD_ATTRIB_CONST to abs, div, labs, ldiv + + * include/stdlib.inl: + Reformat and tidy + Include new versions of div and ldiv which are more portable and + are cleanly rewritten so aren't covered by the BSD licence, which + is now removed + + * src/stdlib/div.cxx, src/stdlib/ldiv.cxx: + Non-inline, non-BSD and portable versions of the new versions of div + and ldiv from stdlib.inl + + * include/time.h: + Much reformatting, tidying and improving comments + Change CLOCKS_PER_SEC from 1000 to 1000000 + Add new functions asctime_r, ctime_r, gmtime_r, localtime_r, clock, + difftime, mktime, time, asctime, ctime, gmtime, localtime, strftime + Include new time.inl file + + * include/pkgconf/libc.h: + Add new options CYGSEM_LIBC_TIME_CLOCK_WORKING, + CYGSEM_LIBC_TIME_TIME_WORKING, CYGFUN_LIBC_TIME_POSIX, + CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL, CYGIMP_LIBC_TIME_ASCTIME_INLINE, + CYGIMP_LIBC_TIME_CTIME_INLINE, CYGIMP_LIBC_TIME_DIFFTIME_INLINE, + CYGIMP_LIBC_TIME_GMTIME_INLINE, CYGIMP_LIBC_TIME_LOCALTIME_INLINE, + CYGIMP_LIBC_TIME_MKTIME_INLINE, CYGIMP_LIBC_TIME_ASCTIME_R_INLINE, + CYGIMP_LIBC_TIME_CTIME_R_INLINE, CYGIMP_LIBC_TIME_GMTIME_R_INLINE, + and CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE + + * time/asctime.cxx, time/asctime_r.cxx, time/clock.cxx, time/ctime.cxx, + time/ctime_r.cxx, time/difftime.cxx, time/gmtime.cxx, + time/gmtime_r.cxx, time/localtime.cxx, time/localtime_r.cxx, + time/mktime.cxx, time/strftime.cxx, time/time.cxx, time/timeutil.cxx, + include/time.inl: + New files to implement the new time functions. Many of them simply + provide the outline definitions, but the real body of the function + comes from time.inl + + * src/PKGconf.mak: + Build new .cxx files + + * src/clibincl/stdlibsupp.hxx: + Remove _div and _ldiv prototypes since they're no longer needed + + * src/clibincl/timesupp.hxx: + Delete as its now obsolete + + * src/time/clock.cxx: + Use new CYGSEM_LIBC_TIME_CLOCK_WORKING option to control whether it + just returns (clock_t)-1 or not. + Much reformatting and tidying + Change real imlpementation from _clock to __clock + Use CYGBLD_ATTRIB_WEAK_ALIAS now + + * tests/stdlib/div.c, tests/stdlib/ldiv.c: + Add some extra tests for handling of negative numbers + Reformat and tidy a bit, including removing the test for CYGPKG_LIBC + since its now always defined if the test is to be compiled + + * tests/time/clock.c: + Remove duplication CYG_TEST_INFO line + Check if unimplemented using "(clock_t)-1" and not just "-1" + +1999-03-04 Jonathan Larmour + + * src/stdlib/system.cxx: + Make sure system() is a weak alias for __system() + + * include/pkgconf/libc.h: Rework CDL description for + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE and change its default to + "/dev/haldiag" + + * src/stdio/common/stream.cxx: + Check that dev is valid when passed to stream constructor + + * src/stdio/common/stdiosupp.cxx: + Tidy + + * src/support/mainthread.cxx: Make this depend on + CYGSEM_LIBC_STARTUP_MAIN_THREAD rather than just CYGPKG_KERNEL + +1999-03-04 Gary Thomas + + Merged in changes from 'ecos-new_devs-19990216-branch' + + (1999-02-24 Jonathan Larmour ) + + * src/stdio/common/stream.cxx: + Add "fix me" comments and remove a couple of commented out lines + + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Revert to using pointer to string for private data, not just string. + This preserves the state across multiple calls + + (1999-02-24 Gary Thomas ) + + * src/stdio/common/vsscanf.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/stream.cxx: + * src/stdio/common/stdiosupp.cxx: + * src/stdio/common/fopen.cxx: + * src/clibincl/stream.inl: + * src/clibincl/stream.hxx: + * src/clibincl/stdiosupp.hxx: + * include/pkgconf/libc.h: Changes for new I/O system. + +1999-03-03 Jonathan Larmour + + * tests/stdlib/atexit.c: Forgot to config atexit test for + CYGFUN_LIBC_ATEXIT option + + * include/pkgconf/libc.h: + Require CYGVAR_KERNEL_THREADS_DATA for CYGSEM_LIBC_PER_THREAD_STRTOK + This fixes PR 19362 + Require CYGPKG_KERNEL for thread safe streams + Also don't need "requires CYGPKG_KERNEL" for per-thread rand and errno + if we already require a finer granularity kernel option + +1999-02-25 Jonathan Larmour + + * include/pkgconf/libc.h: Fix CYGNUM_LIBC_MAIN_STACK_SIZE by changing + CYGPKG_LIBC_STARTUP_MAIN_THREAD -> CYGSEM_LIBC_STARTUP_MAIN_THREAD + Fix for PR 19304 + +1999-02-23 Jonathan Larmour + + * src/stdlib/system.cxx: Add to implement trivial system() call + * include/stdlib.h: Add system() prototype + * src/PKGconf.mak: Build system.cxx + + * tests/ctype/ctype.c, tests/i18n/setlocale.c, tests/setjmp/setjmp.c, + tests/signal/signal1.c, tests/signal/signal2.c, + tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdio/stdiooutput.c, tests/stdlib/atexit.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/getenv.c, tests/stdlib/labs.c, + tests/stdlib/ldiv.c, tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/realloc.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + Use CYG_TEST_NA() macro for non-applicable test configurations + +1999-02-20 Jonathan Larmour + + * include/signal.h: + * include/signal.inl: + * src/signal/raise.cxx: + * src/signal/siginit.cxx: + * src/signal/signal.cxx: + * tests/signal/signal1.c + * tests/signal/signal2.c: + New files to implement ISO standard signals + + * src/PKGconf.mak (TESTS): + * tests/PKGconf.mak (TESTS): + Update to build new files above + + * include/stdlib.h: + * src/clibincl/stdlibsupp.hxx: + Comment and QA changes (including giving better names to some types) + + * include/libc.h: + Add new configuration options for signals + Add new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + Add a note to CYGNUM_LIBC_MAIN_STACK_SIZE option that it may be + overriden by HAL + Add new CYGFUN_LIBC_ATEXIT option and move ...ATEXIT_HANDLERS under + it + Add new CYGSEM_LIBC_EXIT_CALLS_FFLUSH option + Require CYGSEM_LIBC_STARTUP_MAIN_THREAD for "Invoke default static + constructors" option + + * src/stdlib/atexit.cxx: + Support above CYGFUN_LIBC_ATEXIT and QA changes + + * src/stdlib/exit.cxx: + Support for above new libc.h options, and some QA changes + + * src/support/cstartup.cxx: + Add support for new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + + * src/support/mainthread.cxx: + Override main stack size if the HAL has a minimum + + * src/string/strncpy.cxx: + Use improved algorithm for aligned copies - imported from newlib + QA changes + + * src/stdlib/abort.cxx: + Support raise(SIGABRT), and some QA + + * include/errno.h: + Add const attribute + + * tests/stdlib/abs.c: + QA improvements + +1999-02-04 Jesper Skov + + * src/support/cstartup.cxx: Only define cyg_libc_main_thread when + the kernel is around. + +1999-02-01 Jesper Skov + + * tests/time/clock.c: Joined the two test/NOP checks into + one. + Increased tolerance in attempt to fix PRs 18737,18787,18846. + Fixed typo. + +1999-01-28 Jonathan Larmour + + * src/string/strtok.cxx: + * src/stdlib/rand.cxx: + Include if we use kernel header files + +1999-01-25 Jonathan Larmour + + * tests/stdio/sscanf.c (test): + CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT should be + CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + Fix for PR 18786 + + * src/string/strtok.cxx: + * src/stdio/common/stdiofiles.cxx: + * src/errno/errno.cxx: + * src/stdlib/rand.cxx: + Give mutex protection objects a libc constructor priority + + * src/support/invokemain.cxx: + Add prototype for cyg_hal_invoke_constructors() + + * src/support/mainthread.cxx: + Give cyg_libc_dummy_constructor_obj a libc constructor priority, + and make its class have a public constructor + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/stdin.cxx: + Give cyg_libc_stdio_stdin/out/err static objects a libc constructor + priority + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + * src/clibincl/stream.hxx (class Cyg_StdioStream): + Remove private copy constructor. Needed to make prioritised + static constructors work. Fix for PR 18898 + +1999-01-22 Jonathan Larmour + + * src/errno/errno.cxx: + Include pkgconf/kernel.h otherwise it fails with per-thread errno + enabled + + * include/pkgconf/libc.h: + Enable per-thread errno by default since that is what POSIX would + want + + * tests/time/clock.c (test): + Placate compiler by initializing clock_first/second/third anyway, + even though they won't be in practice. This is only a test program + so adding an extra instruction doesn't matter. + + * src/i18n/locale.cxx (_setlocale): + Placate compiler, since it is dumb, by nesting, not serializing, if's + This is an idempotent change, but screws up the formatting :-(. + + * src/string/strpbrk.cxx (_strpbrk): + Change while loop to do loop to placate compiler. It'll even save an + instruction too (wow!) + +1999-01-22 John Dallaway + + * include/pkgconf/libc.h: + Add closing curly brace to CYGPKG_LIBC_STRING_STRTOK definition + +1999-01-21 Jonathan Larmour + + * include/errno.h: + Tidy up and add to header description + Change cyg_get_errno_p() to cyg_libc_get_errno_p() + Remove ifdef CYGPKG_LIBC + + * include/sys/file_if.h: + Remove - move contents to stdio.h + + * include/stdio.h: + Tidy up header description + Move FILE typedef here from sys/file_if.h + SEEK_SET, SEEK_CUR, SEEK_END defined to 0, 1, 2 respectively + for backwards compatibility with old UNIX + Change definitions of stdin/out/err to be addresses of FILE + globals - even though they're actually Cyg_StdioStream it'll work + + * include/pkgconf/libc.h: + Make CYGPRI_LIBC_WEAK et al macros depend on new ones in infra + Reorganise trace options under the individual components they are + associated with. + Reorganise thread-safety options under the individual components + they are associated with. + Add new CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS option + Misc. reformatting + Remove dependency on pkgconf/kernel.h - Configuration Tool will + generate check macros anyway. + Remove CYGPKG_LIBC_TRACE, CYGFUN_LIBC_strtok, CYGPKG_LIBC_RAND + options + Tidy up description header + + * src/clibincl/clibdata.hxx: + * src/clibincl/clibdata.inl: + * src/support/clibdata.cxx: + Remove and instead rely on each component to initialise its own data + + * src/clibincl/stdiofiles.hxx, src/clibincl/stdiofiles.inl: + New files to contain global file list and lock (if applicable). + Implemented as class with member access functions + + * src/errno/errno.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Rename cyg_get_errno_p() to cyg_libc_get_errno_p() + + * src/stdio/common/fclose.cxx: + * src/stdio/common/fflush.cxx: + * src/stdio/common/fopen.cxx: + * src/stdio/common/freopen.cxx: + Remove ifdef CYGPKG_LIBC + Use new global file access method from stdiofiles.hxx + Tidy up description header + Use new CYGBLD_ATTRIB_WEAK_ALIAS + Access errno "normally" rather than clibdata way + + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx + * src/stdio/common/stderr.cxx: + New files. Implement Cyg_StdioStream objects for each stream. In + separate self-contained files so using one doesn't bring in the + others + + * src/stdio/common/stdiofiles.cxx: + New file. Implements global files array and lock + + * src/stdlib/_exit.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Use infra CYGBLD* macros + + * src/stdlib/malloc.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Add pkgconf/kernel.h now that pkgconf/libc.h doesn't have it + Use infra CYGBLD* macros + Make pool visible externally with weak attribute and new name + cyg_libc_malloc_memorypool + + * src/stdlib/rand.cxx: + * src/stdlib/strtok.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Use infra CYGBLD* macros + + * src/support/cstartup.cxx: + Split into smaller files to make selective linking work better, + fix i386 port problem and make GDB happy + + * src/support/environ.cxx: + * src/support/invokemain.cxx: + * src/support/main.cxx: + * src/support/mainthread.cxx: + New files from bits of the old cstartup.cxx + Add support for CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG + + * src/PKGconf.mak: + Update to reflect file additions/deletion + + * tests/stdlib/rand1.c: + * tests/stdlib/rand2.c: + * tests/stdlib/rand3.c: + * tests/stdlib/srand.c: + Make conform to coding standards + Remove ifdef CYGPKG_LIBC_RAND + Tidy up description header + + * tests/string/strtok.c: + Make conform to coding standards + Remove ifdef CYGFUN_LIBC_strtok + Tidy up description header + +1999-01-15 Mark Galassi + + * tests/stdlib/getenv.c (main): added tests for the case in which + the user does not supply environ and in which the user supplies a + NULL environ. + +1999-01-15 Jesper Skov + + * src/support/cstartup.cxx: Added workaround for weak aliasing + problem in i386 gcc. + + +1999-01-15 Gary Thomas + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_STACK_SIZE): + (CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE): Change defaults to be + more reasonable on small systems. + +1999-01-04 Jonathan Larmour + + * src/support/clibdata.cxx: + Minor bug with environ not being initialised correctly by + default + +1998-12-24 Bart Veer + + * src/clibincl/stream.inl (Cyg_StdioStream): + check_this() member functions should now be const + +1998-12-22 Jonathan Larmour + + * src/string/memchr.cxx (_memchr): + treat search value parameter to memchr as an unsigned byte, + not a signed int - copied fix from newlib PR 18471 + +1998-12-21 Jonathan Larmour + + * tests/stdlib/realloc.c: + * tests/stdlib/malloc3.c: + * tests/stdlib/malloc2.c: + Warning cleanup + +1998-12-14 Jonathan Larmour + + * tests/stdlib/malloc2.c, tests/stdlib/malloc3.c, + tests/stdlib/realloc.c: + Only run these tests when we have a coalescing memory allocator + +1998-12-14 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Only check buffer init success if buffering + + * src/stdio/common/streambuf.cxx (set_buffer): + Check for diff of requested size against buffer_size, not + get_buffer_size(), since this may return -1, which won't be + equal to size, and will cause malloc to be called + +1998-12-01 Jesper Skov + + * tests/stdlib/getenv.c (main): Don't declare variables when they + are not used. + +Thu Nov 26 17:59:12 1998 Jonathan Larmour + + * tests/string/strncpy1.c: + Fix off-by-one error since it called my_strcmp() and not + my_strncmp(), which meant in included the trailing NULL when it + shouldn't have. + +1998-11-26 Jesper Skov + + * src/stdlib/qsort.cxx (_qsort): + * src/stdlib/rand.cxx (_srand): + Changed CYG_REPORT_FUNCNAMETYPE to CYG_REPORT_FUNCNAME in void + functions. + +Mon Oct 26 18:49:00 1998 Jonathan Larmour + + * src/support/cstartup.cxx (cyg_libc_dummy_main): + Silence compiler warning with cast of char * to CYG_ADDRWORD + +Wed Oct 28 17:31:21 1998 Jonathan Larmour + + * src/time/clock.cxx (_clock): + Reorder scaling expression as it was both incorrect and risked + overflow. + Fix for PR 18076 + +Mon Oct 19 14:40:06 1998 Jonathan Larmour + + * include/stdio.h (EOF): + Change from -64 to (-1), to allow broken code to work :-/ + Also change other negative defines to be within parentheses + +1998-10-19 Mark Galassi + + * include/pkgconf/libc.h: updated the doc URL + +Thu Oct 15 21:33:44 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Only include kernel thread headers when we're in thread-safe mode + + * src/time/clock.cxx: + Only include kernel clock headers if there's a kernel with the + right functionality available + + * tests/time/clock.c: + Remove unnecessary inclusion of + + Above changes are required for PR 17229 + +Wed Oct 14 16:38:55 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise inclusion of clibincl/stdiosupp.hxx and + clibincl/stream.hxx. Tidying up PR 17502 + +Wed Oct 14 14:08:56 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGPKG_LIBC_STRING_OPTIMISATIONS to + CYGPKG_LIBC_STRING_OPTIMIZATIONS to make it truely merkin. + +Tue Oct 13 19:34:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_ARGUMENTS): + Add a default argv[0] of "" as many programs assume argc>0 + The standard allows argv[0] to be "" if the program name + is not available + +1998-09-26 Bart Veer + + * src/clibincl/stdiosupp.hxx: + PR 17502: this header file now does nothing if the stdio option + is disabled completely. This is the same behaviour is + clibincl/stream.hxx, although arguably the #ifdef protection + should happen wherever the header file is #include'd rather than + in the header file itself. + + * src/clibincl/clibdata.hxx: + PR 17502: this header file still #include's internal stdio-related + header files and references the FILE structure, even if stdio is + disabled. There were some #ifdef's for CYGPKG_LIBC_STDIO already. + One more has been added for _fopen() and _fclose(). + +1998-09-25 Bart Veer + + * src/clibincl/streambuf.inl (Cyg_StdioStreamBuffer): + PR 17487: Reorder the calls to initialize member fields, to + eliminate a compiler warning. + +Fri Sep 25 19:04:29 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/string/strtok.cxx, + src/time/clock.cxx: + Only define tracing variable and tracing level macro when + the relevant tracing level config options are set. Otherwise + keep the tracing level fixed at 0 + Fix for PR 17476 + + * include/pkgconf/libc.h: + Define trace levels only if parent CYGPKG_LIBC_TRACE is defined + for consistency with Configuration Tool + + +Fri Sep 25 17:24:45 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Make definition of vscanf() dependent on CYGFUN_LIBC_STDIO_ungetc + otherwise _vfscanf() won't be compiled. This therefore would + cause a link fail iff selective linking is not enabled. + Fix for PR 17455 + +Fri Sep 25 17:23:17 1998 Jonathan Larmour + + * src/stdlib/rand.cxx: + Make compilation dependent on CYGPKG_LIBC_RAND + Fix for PR 17473 + + * tests/stdlib/srand.c: + Make definition of dummy test pass conditional on CYGPKG_LIBC_RAND + not being defined, as well as CYGPKG_LIBC + Caused compilation failure when testing PR 17473 fix + +Mon Sep 21 17:11:04 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Make sscanf test conditional on CYGFUN_LIBC_STDIO_ungetc since + _vfscanf() only gets compiled if this is defined + Fix for PR 17346 + +1998-09-20 Mark Galassi + + * include/pkgconf/libc.h: updated CDL doc strings. + +Fri Sep 18 22:18:47 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_errno_p): + Rather than this function only being available in thread-safe mode, + instead make what it returns be either the per-thread errno, or + global errno depending on the configuration. + Include (conditionally) to support this change + +Wed Sep 16 11:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove "fix me" comment which I forgot to remove before + +Tue Sep 15 19:27:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Updated descriptions and a few other minor things after review. + Notably though, the NDEBUG config option has been removed + +1998-09-15 Bart Veer + + * include/pkgconf/libc.h: + PR 17201: removed dependency on CYGPKG_KERNEL in the option + CYGNUM_LIBC_MAIN_STACK_SIZE, since the actual dependencies cannot + be expressed sensibly in the current system. + +1998-09-11 Bart Veer + + * include/pkgconf/libc.h: + Sorting out dependencies for error package. + +1998-09-10 Mark Galassi + + * include/pkgconf/libc.h: started adding doc fields to the + cdl_package data, as a pilot for now. + +Wed Sep 9 17:41:23 1998 Hugo Tyson + + * include/pkgconf/libc.h: + Add option CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE to explicitly + control whether the empty delete functions (currently) in + kernel/.../common/delete.cxx are enabled; controls code bloat, see + the comments in delete.cxx. + +Fri Sep 4 16:43:38 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add a default CYG_TEST_PASS() to make sure the test infra doesn't + complain. + Also remove the unused string functionsa + +Fri Sep 4 15:43:48 1998 Hugo Tyson + + * src/stdlib/exit.cxx (__libc_exit): + * src/stdlib/_exit.cxx (__libc__exit): + * src/stdlib/malloc.cxx (_free): + * src/stdlib/abort.cxx (abort): + * src/support/cstartup.cxx (invoke_main): + Tracing system asserted cos it was being called incorrectly; these + are void functions so you shouldn't give a type to the function + reporting call. + +Fri Sep 4 15:03:10 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Fix CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE description to refer to + the table.cxx file, not table.h + +Fri Sep 4 14:38:52 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add description for CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE since + Proven won't be making any changes to the device driver + implementation after all. + Fix for PR 17148 + + * src/clibincl/stream.inl (set_position): + Remove "fix me" line. It is obvious that this will have to change + with a filesystem interface + Fix for PR 17147 + + * src/stdio/common/freopen.cxx: + Remove "fix me" - I know about this issue + Fix for PR 17145 + + * src/stdio/common/stream.cxx (read): + Remove "fix me" and change to use memcpy + Fix for PR 17144 + +Fri Sep 4 14:36:47 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Actually add it this time! + +Fri Sep 4 13:48:13 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add new tests for misc stdio output functions + + * tests/PKGconf.mak: + Build stdiooutput.c test + +Fri Sep 4 12:52:10 1998 Jonathan Larmour + + * src/clibincl/stream.inl (write_byte): + Remove bogus assert + + * tests/stdlib/getenv.c (main): + Check whether str is NULL before doing a strcmp() + + * tests/stdio/sprintf2.c (main): + Reformat to 76 columns + +Fri Sep 4 02:10:54 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/stdio/common/stream.cxx: + Add new peek_byte method to Cyg_StdioStream + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix up buffer access to work with new peek_byte method above + Fix for PR 16954 + +Thu Sep 3 19:40:11 1998 Jonathan Larmour + + * tests/stdlib/rand1.c, tests/stdlib/rand2.c, + tests/stdlib/rand3.c: + Add extra check for CYGPKG_LIBC_RAND to decide whether the test + is applicable or not + + * tests/stdlib/rand2.c (test): + Use CYGNUM_LIBC_RAND_SEED for default seed, not 1 + + * tests/string/strtok.c: + Add extra check for CYGFUN_LIBC_strtok to decide whether the + test is applicable or not + +Wed Sep 2 19:11:40 1998 Jonathan Larmour + + * src/stdio/input/fread.cxx, src/stdio/output/fwrite.cxx: + Add fread() and fwrite() functions + + * src/PKGconf.mak: + Build fread.cxx and fwrite.cxx from above + + * src/stdio/common/stream.cxx: + Reformat to 76 columns + In write(), move initialisation of *bytes_written to start + In read(), move initialisation of *bytes_read to start + + * include/stdio.h: + Reformat to 76 columns + + Replace all references to the ANSI + standard to instead by the ISO C standard + + Add commented argument names for "documentation" + + Add fread() and fwrite() prototypes + + * src/clibincl/stdiosupp.hxx: + Copy the above changes from stdio.h, and add _fread() and _fwrite() + prototypes + + * src/stdio/output/fputs.cxx, src/stdio/input/fgets.cxx: + Reformat to 76 columns + +Wed Sep 2 15:41:15 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Reformat to 76 columns + +Wed Sep 2 14:46:18 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Use trylock_me() instead of lock_me(), and loop to prevent + deadlocks + + * src/clibincl/stream.hxx, src/clibincl/stream.inl: + Add trylock_me() method + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/fflush.cxx: + Reformat to 76 columns + +Wed Sep 2 12:24:27 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change 0x7fff to 0x7fffffff. Oops! + give main stack size option a legal_values field + Undefine tracing by default + Add some more description in the header + +Tue Sep 1 20:02:07 1998 Jonathan Larmour + + * tests/i18n/setlocale.c (cyg_package_start): + Fix typo - extra "x" for no reason at all! :-) + +Tue Sep 1 19:44:58 1998 Jonathan Larmour + + * src/i18n/locale.cxx: + Fix bug in find_locale_data() that miscalculated size of + all_locales + + Make find_locale_data() match the locale "" and add some + other things in _setlocale() to ensure that "C" gets returned + when the default locale "" is passed. + + Only check the locale pointer when it is non-NULL + + * tests/i18n/setlocale.c: + New tests for setlocale() + + * tests/PKGconf.mak: + Update to build setlocale.c test + + * src/support/cstartup.cxx: + Don't actually call system default main() "main" otherwise GDB + gets confused and thinks its the entry point. Instead make a weak + alias and call the real function something different. + +Tue Sep 1 18:31:42 1998 Jonathan Larmour + + * src/i18n/locale.cxx (_setlocale): + Fix tracing macro name and remove "str maybe used before + initialised" warning + + * tests/stdlib/qsort.c: + Correct file description header + +Tue Sep 1 17:04:32 1998 Jonathan Larmour + + * include/locale.h, src/clibincl/i18nsupp.hxx, src/i18n/locale.cxx: + New files to add support for locales as defined by the ISO C + standard. i.e. setlocale() and localeconv() functions and some + other bits + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAX_LOCALE_NAME_SIZE config option for locale + support + + * src/PKGconf.mak: + build locale.cxx + + * include/errno.h, src/clibincl/ctypesupp.hxx: + Tidy up to 76 columns + +Tue Sep 1 00:24:22 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Move environment-related options from stdlib into new + CYGPKG_LIBC_STARTUP component. Also add options for main()'s + arguments (CYGPKG_LIBC_ARGUMENTS), main()'s default stack size + (CYGNUM_LIBC_MAIN_STACK_SIZE), number of atexit handlers + (CYGNUM_LIBC_ATEXIT_HANDLERS), and whether _exit() stops the + system (CYGSEM_LIBC_EXIT_STOPS_SYSTEM). + + * src/clibincl/stdlibsupp.hxx: + Fix a few comment bugs, and add new + cyg_libc_invoke_atexit_handlers() function prototype + + * src/stdlib/_exit.cxx, src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Implement exit(), atexit() and _exit() correctly now. Also + includes cyg_libc_invoke_atexit_handlers() in atexit.cxx. Now + we get the correct behaviour of atexit(), and exit() invokes the + atexit handlers and fflushs all the stdio streams. Add plenty of + tracing of asserts too. + + * src/support/cstartup.cxx: + Make main_thread object an exported global. Allow user-settable + arguments. Add MUCH more tracing and asserts. Improve comments. + Tidy up to 76 columns + + * tests/stdlib/atexit.c: + Add simple test for atexit() and it calling registered functions + + * tests/PKGconf.mak: + Build atexit.c test + +Mon Aug 31 18:54:48 1998 Jonathan Larmour + + * src/stdlib/getenv.cxx, tests/stdlib/getenv.c: + Add support for getenv(), and some tests to ensure it works + + * src/PKGconf.mak, tests/PKGconf.mak: + Update to include getenv.cxx and getenv.c test + + * src/clibincl/clibdata.hxx: + remove prototype for environ - we expect files needing it to + define it themselves + + * src/support/clibdata.cxx: + Tidy up to 76 columns and add definition of char **environ, but + with a configurable initialiser (see libc.h below) + + * tests/stdlib/abs.c (main): + Tidy up to 76 columns + + * src/stdlib/malloc.cxx: + Tidy up to 76 columns and remove warning for undefined _memcpy() + by changing to memcpy(), and casting away signedness + + * include/pkgconf/libc.h: + Add CYGPKG_LIBC_ENVIRONMENT and CYGDAT_LIBC_DEFAULT_ENVIRONMENT + configuration options + + * include/pkgconf/libc.h, src/clibincl/clibdata.hxx: + Tidy up to 76 columns + + * include/stdlib.h: + Add getenv() prototype and tidy up to 76 columns + + * src/clibincl/stdlibsupp.hxx: + Add _getenv() prototype + +Mon Aug 31 13:37:08 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Add realloc() + + * tests/stdlib/realloc.c: + Add this file to test new realloc() functionality + + * tests/PKGconf.mak: + Build realloc test + + * tests/stdlib/malloc3.c (main), tests/stdlib/malloc2.c (main), + tests/stdlib/malloc1.c (main): + Conditionalise local vars to prevent warnings + + * tests/stdlib/malloc3.c (fill_with_data): + Move '{' into "verb" line + + * include/pkgconf/libc.h: + Require infra tracing support to allow tracing + + * include/stdlib.h: + Add realloc() + + * src/clibincl/stdlibsupp.hxx: + Update the commented argument names from stdlib.h, including realloc() + +1998-08-28 Bart Veer + + * include/pkgconf/libc.h: + * src/clibincl/clibdata.hxx, src/time/clock.cxx: + + Updated for new kernel configuration option symbol names + +Fri Aug 28 19:18:25 1998 Hugo Tyson + + Changed the entry below to sat "tx39" instead of "mn10300". + It's been a long week. + +Fri Aug 28 18:59:20 1998 Hugo Tyson + + * src/support/cstartup.cxx: Add a weakly named main to allow the + default configuration to link on the tx39 which has no + scalextric linking yet. The static Cyg_Thread main_thread object + below continues to exist, though unreferenced, so all its + descendants must exist too. + +Fri Aug 28 08:54:29 1998 Jonathan Larmour + + * include/stdlib.h: + Add commented argument names Add exit(), and atexit(). And move + these along with abort() and _exit() to a new section. + + * src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Add trivial versions of atexit() and exit() + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAIN_STACK_SIZE config option + + * include/sys/cstartup.h, src/support/cstartup.cxx, src/PKGconf.mak: + New files to provide a new function cyg_iso_c_support(), which + invokes main "correctly". + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/srand.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcoll2.c, tests/string/strcpy1.c, + tests/string/strcpy2.c, tests/string/strcspn.c, + tests/string/strlen.c, tests/string/strncat1.c, + tests/string/strncat2.c, tests/string/strncpy1.c, + tests/string/strncpy2.c, tests/string/strpbrk.c, + tests/string/strrchr.c, tests/string/strspn.c, + tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, + tests/time/clock.c: + + Modify all tests to use new startup mechanism, and cyg_iso_c_start() + +Fri Aug 28 00:29:38 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Add #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO around all accesses to + flags.last_buffer_op_was_read. Fix for PR 16997 + +Thu Aug 27 01:12:42 1998 Jonathan Larmour + + * include/sys/file_if.h: + Fix comments and remove cyg_get_file_star() + +Wed Aug 26 20:24:32 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove #define CYGPKG_LIBC is that is meant to live in + after all + +Wed Aug 26 19:39:23 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + More fixes to CDL stuff to make it work better, and look better on + the screen + +Tue Aug 25 20:21:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Make some fixes after running the ConfigTool + +Tue Aug 25 16:46:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_STDIO_BUFSIZE): + Fix typo of CYGNUM_LIBC_STDIO_BUFSIZE + +Tue Aug 25 15:10:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Tidy up CDL stuff a bit more, prior to checking it actually works. + +Tue Aug 25 11:38:52 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c (main): + Prevent calls to CYG_TEST_STILL_ALIVE for now + +Tue Aug 25 05:39:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change cosmetic paragraph alignment. + +Tue Aug 25 03:11:34 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Make stderr initialise with buffer size 0. + For PR 16955 + +Mon Aug 24 17:38:46 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + First pass at CDL-ifying the C library configuration. Currently + deliberately disabled as there a few outstanding issues. + +Mon Aug 24 16:14:22 1998 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx (_vfnprintf): + clear up warning for unused argument + + * tests/stdlib/malloc2.c (NUM_ITERATIONS): + Lower to 100 from 50000 so it won't take too long under the simulator + +Thu Aug 20 17:48:43 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Remove now unnecessary inclusion of kernel/ktypes.h + +Wed Aug 19 19:19:14 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, + tests/stdio/sscanf.c, tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, + tests/stdlib/strtoul.c, tests/string/strtok.c, + tests/time/clock.c: + Add parameters to "main()" to silence warnings + +Wed Aug 19 18:52:59 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx (refill_read_buffer): + Put conditional error check into same #ifdef and if as what was being + checked in the first place! + +Wed Aug 19 18:49:19 1998 Jonathan Larmour + + * src/clibincl/stream.inl: + Reorder Cyg_StdioStream::check_this() to be first to silence + warnings + +Tue Aug 18 16:10:03 1998 Jonathan Larmour + + * ecc/language/c/libc/current/src/clibincl/clibdata.hxx, + ecc/language/c/libc/current/src/errno/errno.cxx, + ecc/language/c/libc/current/src/stdio/common/fopen.cxx, + ecc/language/c/libc/current/src/stdlib/rand.cxx, + ecc/language/c/libc/current/src/string/strtok.cxx: + Rename CYGIMP_LIBC_INTERNAL_DATA_PREAMBLE, + CYGIMP_LIBC_INTERNAL_DATA_ALLOC_CHECK_PREAMBLE, + CYGVAR_LIBC_INTERNAL_DATA, and + CYGIMP_LIBC_INTERNAL_DATA_CHECK to all have CYGPRI_ prefix instead + as recommended by the config name rules + + +Tue Aug 18 14:31:19 1998 Jonathan Larmour + + * src/stdio/common/setvbuf.cxx (_setvbuf): + Rename variable names in assert line, otherwise doesn't build + with asserts on! + +Sun Aug 16 18:15:12 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix some bugs, although there are some left to fix still. Unrelated + to the rest of the checkins, so I will check the partial fix in now. + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx: + Add parameters to constructor to allow more things to be done at + construction time. + + Now we have "new", remove separate "construct" method + + Add more documentation on constructor + + As requested by code review, where possible, move boolean flags + into separate packed bitfield structure for space efficiency + + Make readbuf_char be usable all the time rather than when configured + not to be buffering, as it is also needed for non-buffered mode i.e. + _IONBF + + * src/stdio/common/fopen.cxx: + Change to use new method of construction from above, using new + + Use thread-specific data, rather than global. And so change errnos + to access errno entry specifically + + Make process_mode() check for append mode too + + Reformat for coding standards to have { in same line as "verb" + + * src/stdio/common/setvbuf.cxx: + + Change to cope with different way of dealing with buffering policy + flags etc. in Cyg_StdioStream + + * src/stdio/common/vsnprintf.cxx, src/stdio/common/vsscanf.cxx, + src/support/clibdata.cxx: + Change construction of streams to use new parameters added above, + and change to use _IONBF mode for string stdio functions, + otherwise its a waste of memory. And use _IONBF for stderr as the + ISO standard tells us to! + + Reformat for coding standards to have { in same line as "verb" + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Change constructor so that it can be set with default size and + dynamic buffer (if applicable) + + Fix minor bug in destructor - should only call free when allocated + dynamically + + Change get_buffer_size to return -1 if the buffer was not allowed + to be set up + + * src/stdio/common/streambuf.cxx: + Remove unnecessary stdio.h include and add extra comment to whether + to free bit in set_buffer() + + * src/stdio/common/freopen.cxx: + Change @@@ to standard fix me string + + * src/stdio/output/fputc.cxx: + Remove unnecessary "written" variable + +Thu Aug 13 15:37:28 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: + Included use of "fix me" line to ensure this is discussed before + release + + * include/stdlib.h, src/stdlib/abort.cxx, src/PKGconf.mak: + Add abort.cxx to implement abort(), albeit naively + +Thu Jul 30 18:03:09 1998 Jonathan Larmour + + * src/stdio/common/vsscanf.cxx (_vsscanf), + src/stdio/common/vsnprintf.cxx (_vsnprintf): + Fix initialiser of pseudo string device table that didn't get updated + when the table changed (Bad proven, no biscuit). + + * src/clibincl/stream.inl (~Cyg_StdioStream): + Move invalidation of magic_validity_word to after unlock_me(), + otherwise it always fails! + +Tue Jul 28 21:29:53 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Shorten over-long lines + +Tue Jul 28 20:28:23 1998 Jonathan Larmour + + * src/clibincl/stream.hxx (class Cyg_StdioStream), + src/clibincl/stream.inl, src/stdio/common/stream.cxx: + Clarify some comments and get the CYGDBG_DEFINE_CHECK_THIS and + CYG_ASSERTCLASS stuff going + + * src/clibincl/stream.inl: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 15:31:06 1998 Jonathan Larmour + + * src/clibincl/streambuf.inl, src/stdio/common/streambuf.cxx: + Move set_buffer() from streambuf.inl to new file streambuf.cxx + + * src/PKGconf.mak (COMPILE): + Build new file streambuf.cxx + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + Add METHODS comment + + * src/stdio/common/stream.cxx: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 00:26:36 1998 Jonathan Larmour + + * include/stdlib.inl, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/div.cxx, + src/stdlib/ldiv.cxx, src/stdlib/qsort.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/string/strtok.cxx: + + Include proper Berkeley license inline in the file, rather than + referring to an external file + + * doc/COPYING.UCB: + Remove, now that it isn't referred to any more + +Mon Jul 27 23:34:26 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl, include/errno.h, + include/stdio.h, include/stdio.inl, include/stdlib.h, + include/stdlib.inl, include/string.h, include/string.inl, + include/time.h, include/sys/file_if.h, src/PKGconf.mak, + src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/stdiosupp.hxx, + src/clibincl/stream.hxx, src/clibincl/streambuf.hxx, + src/clibincl/streambuf.inl, src/clibincl/stringsupp.hxx, + src/clibincl/timesupp.hxx, src/ctype/isalnum.cxx, + src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, + src/ctype/islower.cxx, src/ctype/isprint.cxx, + src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, + src/ctype/tolower.cxx, src/ctype/toupper.cxx, + src/errno/errno.cxx, src/stdio/common/snprintf.cxx, + src/stdio/common/sprintf.cxx, src/stdio/common/sscanf.cxx, + src/stdio/common/stdioinlines.cxx, src/stdio/common/stream.cxx, + src/stdio/common/ungetc.cxx, src/stdio/common/vsnprintf.cxx, + src/stdio/common/vsscanf.cxx, src/stdio/input/fgetc.cxx, + src/stdio/input/fgets.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/gets.cxx, src/stdio/input/scanf.cxx, + src/stdio/output/fnprintf.cxx, src/stdio/output/fprintf.cxx, + src/stdio/output/fputc.cxx, src/stdio/output/fputs.cxx, + src/stdio/output/printf.cxx, src/stdlib/_exit.cxx, + src/stdlib/abs.cxx, src/stdlib/atof.cxx, src/stdlib/atoi.cxx, + src/stdlib/atol.cxx, src/stdlib/div.cxx, src/stdlib/labs.cxx, + src/stdlib/ldiv.cxx, src/stdlib/rand.cxx, src/stdlib/strtod.cxx, + src/string/memchr.cxx, src/string/memcmp.cxx, + src/string/memmove.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, + src/string/strcoll.cxx, src/string/strcpy.cxx, + src/string/strcspn.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx, src/string/strpbrk.cxx, + src/string/strrchr.cxx, src/string/strspn.cxx, + src/string/strstr.cxx, src/string/strsuppt.cxx, + src/string/strtok.cxx, src/string/strxfrm.cxx, + src/support/clibdata.cxx, src/time/clock.cxx: + Untabify + +Mon Jul 27 23:14:18 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/stdlib/malloc.cxx, src/stdlib/qsort.cxx, + tests/ctype/ctype.c, tests/stdlib/rand3.c, tests/stdlib/malloc3.c: + Remove all mentions of "register" in variable declarations. Also + untabify where needed + + * src/stdlib/bsearch.cxx: + Untabify this too + + +Mon Jul 27 22:18:51 1998 Jonathan Larmour + + * src/stdio/output/fputc.cxx (_fputc): + Replace call to stream write() with call to write_byte() + + * src/clibincl/stream.inl (write_byte): + Add asserts for stream write() returning odd values for how much has + been written + + (bytes_available_to_read): + Remove "register" def for variable declaration + +Mon Jul 27 22:06:22 1998 Jonathan Larmour + + * src/stdio/common/stdiosupp.cxx: + Remove #if 0'd cyg_get_file_star() and unnecessary pseudo string + device definition + +Mon Jul 27 21:57:25 1998 Jonathan Larmour + + * include/pkgconf/libc.h, src/support/clibdata.cxx: + Change CYGXXX_LIBC_STDIO_DEFAULT_CONSOLE to + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE + +Mon Jul 27 21:49:23 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/setjmpsupp.hxx, + src/clibincl/stdiosupp.hxx, src/clibincl/stdlibsupp.hxx, + src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl, + src/clibincl/stringsupp.hxx, src/clibincl/timesupp.hxx: + + Change CYGONCE_LIBC_*_{HXX,INL} to CYGONCE_LIBC_CLIBINCL_*_{HXX,INL} + +Mon Jul 27 21:34:05 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change #define XXXXX 1 to #define XXXXX where applicable as per code + review + + Also remove obsolete CYGIMP_LIBC_THREAD_START_SUSPENDS_SELF + +Mon Jul 27 19:42:27 1998 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): + Use #ifdef, not #if for config options + +Mon Jul 27 15:01:51 BST 1998 Chris Provenzano + + * src/stdio/common/stream.cxx, src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx: + Fixes to compile with the new Cyg_IORB field names. + +Thu Jul 9 03:40:21 1998 Jonathan Larmour + + * tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Adjust starting of tests to possibly start scheduler since + strtol/stroul rely on errno, which may be a per-thread variable + +Thu Jul 9 03:06:25 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx, src/stdio/common/setvbuf.cxx: + Consolidate read and write buffers into single buffer, as it should + have been all along + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Add drain_buffer() method to speed up the case when we want the + buffer completely emptied + +Tue Jul 7 21:26:33 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Add a couple of new tests that check that very long strings work too + +Wed Jul 1 19:52:39 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/streambuf.hxx: + Do not permit copy constructors + + * src/clibincl/stream.inl, src/stdio/common/fclose.cxx: + Make sure we use #ifdef and not #if + + * src/clibincl/streambuf.inl: + Use member initialisation list rather than explicit initialisation to + reduce warnings + +Wed Jul 1 19:17:55 1998 Jonathan Larmour + + * include/pkgconf/libc.h and all files using config options: + Rename configuration defines to make them more standard + +Thu Jun 25 20:09:30 1998 Jonathan Larmour + + * src/string/strcat.cxx: + Add parentheses on check to silence warning + (Verified by proven) + +Thu Jun 25 19:30:01 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Make sure that the malloc pool is initialised before other things + can use it. This is done with the hot new constructor ordering + feature. + +Thu Jun 25 18:27:03 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Remove bogus ifdef if floating point is _not_ wanted + +Thu Jun 25 17:31:42 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Fix argument checking to allow first argument of NULL + +Thu Jun 25 04:18:50 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_strtok_last_p): + Remove bogus assertion + + * src/stdlib/malloc.cxx: + Got sense of alignment check assertion the wrong way round, so negate + it + +Thu Jun 25 03:56:35 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: + Fix argument checking assertions with legitimate nulls here too + +Thu Jun 25 03:46:32 1998 Jonathan Larmour + + * src/stdlib/strtoul.cxx, src/stdlib/strtol.cxx: + Fix argument checking assertions to cope with legitimate nulls + +Wed Jun 24 09:01:45 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Remove extraneous info messages + +Wed Jun 24 05:59:17 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c: + + Change large automatic arrays to static arrays to prevent overuse + of a potentially small stack + +Wed Jun 24 05:45:28 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/string/strtok.c, tests/time/clock.c: + + Increase thread stack size from 4K to 32K as in some cases it was + too small. + + +Tue Jun 23 20:12:31 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Add extra tests, including floating point conversion testing + +Tue Jun 23 17:01:06 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Make sure this is only compiled if CYGFUN_LIBC_strtok is defined + +Tue Jun 23 06:10:13 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + add some comments - that's all + + * src/stdio/common/stream.cxx: + fix case in refill_read_buffer() for what to do when there's nothing + left. Now return EAGAIN + + * src/stdio/common/vsscanf.cxx, src/stdio/input/vfscanf.cxx: + Get sscanf working properly and passing tests. Also make sure it + ignores FP when its not configured + + * src/stdlib/atof.cxx: + Only compile at all if strtod() is present + + +Mon Jun 22 19:13:42 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise strtok_last and rand_seed better + +Mon Jun 22 14:14:12 1998 Jonathan Larmour + + * tests/stdlib/malloc3.c: + Add test for checking that mallocing and freeing repeatedly works + + * tests/PKGconf.mak: + Update to reflect addition of the above + +Mon Jun 22 13:09:33 BST 1998 Chris Provenzano + + * src/stdio/common/fopen.cxx + * src/stdio/common/stream.cxx + * src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx + Include cyg/devs/common/iorb.h instead of iorb.hxx + + * src/stdio/common/stream.cxx + Use read_blocking and write_blocking instead of just read and + write when accessing devices through the virtual device table. + +Sun Jun 21 18:19:13 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Propagate change of return code handling for puts from stdio.inl + into here + + * src/stdio/output/fputc.cxx: + make sure the right type is used for output - byte not int + + * src/support/clibdata.cxx: + Fix #define config mistook. #endif was in wrong place + +Sun Jun 21 16:11:04 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Allow explicit construction to get around a bug when + dynamically allocating per-thread structure + +Sun Jun 21 16:02:51 1998 Jonathan Larmour + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, tests/stdlib/qsort.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + + Update tests to "do the right thing" with all configuration settings + + +Sun Jun 21 04:54:14 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + I have to be careful not to use setjmp() in a way not exactly + defined by the standard, so make sure I do, and add a comment + documenting these ways. + + Also ensure this test does the right thing in all configurations + +Sun Jun 21 04:38:15 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add extra checks for invalid configurations + Also make default for thread safety OFF + + * src/clibincl/clibdata.inl: + Adjust indentation + + * src/stdio/output/vfnprintf.cxx: + Make printf of -0.0 floating point do the right thing + +Sun Jun 21 04:28:00 1998 Jonathan Larmour + + * src/stdio/common/snprintf.cxx, src/stdio/common/sprintf.cxx, + src/stdio/common/sscanf.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/scanf.cxx, src/stdio/output/fnprintf.cxx, + src/stdio/output/fprintf.cxx, src/stdio/output/printf.cxx: + + Had to remove inline functions with varargs. Which means separating + out each function from stdioinlines.cxx into a separate file, as they + no longer belong there. So all the above files were created. + + * include/stdio.inl, src/PKGconf.mak, + src/stdio/common/stdioinlines.cxx: + Changed to take account of the above + + +Sun Jun 21 03:58:42 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c: + Update with floating-point tests. Also make sure they DTRT in all + configurations + +Fri Jun 19 19:33:06 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + accidentally initialised stdin/out/err twice + +Fri Jun 19 19:09:29 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Another typo + +Fri Jun 19 18:59:07 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Missing #endif typo + +Fri Jun 19 18:51:42 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Fix initialisation of static data members. Unsure how it worked at + all before! + +Fri Jun 19 18:01:01 1998 Jonathan Larmour + + * include/stdio.inl: + puts should check whether fputs returns non-negative, rather than + non-zero + +Fri Jun 19 17:22:52 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl: + Make inclusion of get_errno_p conditional on thread-safety + +Wed Jun 17 10:55:32 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Add weak alias of vfscanf() to _vfscanf() + +Wed Jun 17 09:10:41 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Initialise err to silence compiler warning + +Wed Jun 17 08:59:20 1998 Jonathan Larmour + + * Most important is the addition of floating point support in + src/stdio/output/vfnprintf.cxx and src/stdio/input/vfscanf.cxx. This + also required the addition of atof() and strtod() in stdlib which is + definitely no bad thing! Other than that... + + * Fix a whole bunch of stuff I messed up first time round. Also the + sprintf and sscanf tests are included again. + +Tue Jun 16 16:38:02 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Typo with not putting comment character at the beginning. Sigh. + +Tue Jun 16 14:53:09 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Forgot to (temporarily) remove fputs test for now + +Mon Jun 15 20:40:03 1998 Jonathan Larmour + + Everything to do with stdio has almost completely changed, so there's + not much point documenting individual changes. + +Mon Jun 15 18:36:01 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c: + Stop it moaning quite as much when it fails by making it exit sooner + + * tests/time/clock.c : + This isn't a compound testcase + +Thu Jun 11 17:59:13 1998 Jonathan Larmour + + * include/assert.h + Reverse sense of NDEBUG ifdef, that was left in accidentally due + to testing + +Thu Jun 11 04:58:08 1998 Jonathan Larmour + + * include/errno.h, include/string.h, src/clibincl/stringsupp.hxx: + Modify as I've now added an "error" package which defines the error + codes and strerror() + + * src/errno/strerror.cxx: + Moved to new error package and thus deleted + +Wed Jun 10 18:37:37 1998 Jonathan Larmour + + * include/assert.h: + create this header and add assert() function + +Wed Jun 10 16:23:57 1998 Jonathan Larmour + + * include/stdlib.h, src/clibincl/stdlibsupp.hxx, src/stdlib/malloc.cxx: + Add malloc(), calloc() and free() functions + + * include/pkgconf/libc.h: + Add malloc memory pool size option + + * tests/stdlib/malloc1.c, tests/stdlib/malloc2.c: + new tests for malloc + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for new files + +Wed Jun 10 15:06:16 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + Add another test + +Tue Jun 9 18:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add some setjmp config's and a macro for the noreturn attribute + + * include/setjmp.h, include/setjmp.inl, src/clibincl/setjmpsupp.hxx, + src/setjmp/longjmp.cxx, tests/setjmp/setjmp.c: + Added to implement and test setjmp() and longjmp() + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for newly added files + +Thu Jun 4 01:29:18 1998 Jonathan Larmour + + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, src/string/strcpy.cxx, + src/string/strlen.cxx, src/string/strncat.cxx, + src/string/strncmp.cxx, src/string/strncpy.cxx: + Rename CYGIMP_LIBC_PREFER_SMALL_TO_FAST to + CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST + + Also use slower but smaller version when __OPTIMIZE_SIZE__ is + defined (which comes from using gcc -Os) + +Fri May 29 16:15:04 1998 Jonathan Larmour + + * include/ctype.inl, src/ctype/isxdigit.cxx: + Fix bug that numerals aren't considered hex digits + + * include/time.h: + Change clock_t and time_t to be signed so that they can accept -1, as + required by other libc functions + + * src/clibincl/clibdata.hxx: + Fix typo that CYGIMP_LIBC_THREAD_SUPPORT should be ..._SAFETY + Also fix macro to allocate thread-specific data to not set variables + in a different stack-frame + + * tests/ctype/ctype.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/stdlib/qsort.c: + make ctr unsigned to prevent warnings + + * tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/string/strrchr.c: + Fix off by one error + + * tests/string/strspn.c: + Fix case-sensitivity problem, and off-by-one error + + * tests/string/strxfrm1.c: + Remove bogus bit of test that doesn't apply to strxfrm, and fix typo + + +Fri May 22 16:33:04 1998 Jonathan Larmour + + * src/PKGconf.mak + Remove CXXFLAGS line now that its redundant + + * tests/everything! + Do a blitz change of all tests - break some of them down into + different files, add new tests, standardize format, fix bugs, + update for recent header file changes and much more! + +Wed May 20 17:50:04 1998 Jonathan Larmour + + * tests/PKGconf.mak: + interim checkin for different dir structure for Bart + +Fri May 15 20:30:46 1998 Jonathan Larmour + + * Tidy up some loose ends I forgot: rename src/include directory to + src/clibincl. And add clibdata.inl and timesupp.hxx in there. + +Thu May 14 19:56:32 1998 Jonathan Larmour + + * Basically everything has changed in the C library. Files have + been moved, renamed, deleted and reworked. This is a major + revision, and now starts from this new baseline rather than doing + incremental changes. + +Fri Apr 17 18:43:02 1998 Jonathan Larmour + + * src/ECCconf.mak: + added for new build system (actually Bart did this, but didn't + update this ChangeLog) + +Fri Apr 17 15:03:25 1998 Hugo Tyson + + * src/stdio/device/sim.cxx: + Make it build with CYG_EMPTY_STATEMENT; the unadorned one is being + removed. + +Thu Apr 16 00:24:24 1998 Jonathan Larmour + + * All source files: + replace ECCIMP_LIBC_* conditional ifdef with CYGIMP_LIBC_* + + * include/eccconf/libc.h: + improve comments and reorder a bit + +Wed Apr 8 14:35:20 1998 Jonathan Larmour + + * Makefile.am, src/Makefile.am, tests/Makefile.am, configure.in: + many changes to integrate build structure from release tree + + * src/ctype/Makefile.am, src/ctype/Makefile.in, src/errno/Makefile.am, + src/errno/Makefile.in, src/stdio/Makefile.am, src/stdio/Makefile.in, + src/stdio/common/Makefile.am, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.am, src/stdio/device/Makefile.in, + src/stdio/output/Makefile.am, src/stdio/output/Makefile.in, + src/stdio/input/Makefile.am, src/stdio/input/Makefile.in, + src/stdlib/Makefile.am, src/stdlib/Makefile.in, + src/string/Makefile.am, src/string/Makefile.in, + src/support/Makefile.am, src/support/Makefile.in, + src/time/Makefile.am, src/time/Makefile.in: + Remove as they are now redundant with above changes + + * include/Makefile.am: + Add to support above changes + + * include/eccconf/libc.h: + Change include file for configuration from kernel to system + + * src/include/kerndiag.hxx, src/stdio/device/kerndiag.cxx, + src/time/clockfn.cxx: + Change kernel include file to eccconf/kernel.h + + * src/include/strngdev.h: + remove unnecessary kernel include + + * Makefile.in, aclocal.m4, configure, src/Makefile.in, + tests/Makefile.in, include/Makefile.in: + regenerate + +Mon Apr 6 20:55:07 1998 Jonathan Larmour + + * src/stdlib/abs.cxx, src/stdlib/atoi.cxx, src/stdlib/atol.cxx, + src/stdlib/div.cxx, src/stdlib/labs.cxx, src/stdlib/ldiv.cxx: + Separated out functions from stdlib.cxx into separate files + + * src/stdlib/stdlib.cxx: + removed to be replaced by above files + + * Makefile.am, src/stdlib/Makefile.am: + modified to support building above and not building stdlib.cxx + + * src/support/tsd.cxx: + Remove unnecessary header file includes + + * Makefile.in, src/stdlib/Makefile.in: + regenerated + +Mon Apr 6 19:19:42 1998 Jonathan Larmour + + * src/support/tsd.cxx, include/eccconf/libc.h: + remove lame hack for tx39 compiler now that its fixed + + * src/include/sim.hxx: + define constants as static to placate compiler + +Thu Apr 2 21:01:21 1998 Jonathan Larmour + + * src/ctype/ctype.cxx: + deleted and separated out into below files + + * src/ctype/isalnum.cxx, src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, src/ctype/islower.cxx, + src/ctype/isprint.cxx, src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, src/ctype/tolower.cxx, + src/ctype/toupper.cxx: + Separated out individual ctype functions from ctype.cxx into separate + files + + * Makefile.am, src/ctype/Makefile.am: + modified to reflect above deletion/additions + + * Makefile.in, src/ctype/Makefile.in: + regenerated + +Thu Apr 2 19:08:26 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: optimise using prefix increments + +Thu Apr 2 15:18:15 1998 Jonathan Larmour + + * src/string/strchr.cxx: optimise setting of mask a little + +Thu Mar 26 14:07:01 1998 Jonathan Larmour + + * src/support/tsd.cxx: fixed some typos + +Thu Mar 26 11:58:47 1998 Jonathan Larmour + + * include/eccconf/libc.h, src/support/tsd.cxx: + Implement workaround for tx39 compiler bug. + + * src/include/strsuppt.hxx: + remove prototypes for _memcpy() and _memset() as they are now in the + kernel + +Wed Mar 25 18:31:53 1998 Jonathan Larmour + + * Makefile.am, src/string/Makefile.am: memcpy() and memset() are + now in the kernel so remove them from build + * include/string.h: add a comment to say as much + * Makefile.in, src/string/Makefile.in: regenerate + +Wed Mar 25 15:30:42 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx, src/include/file_if.inl: + Change _exit workaround to not cause a compiler optimisation + problem. Now just references _exit rather than calls it. + +Wed Mar 25 14:59:49 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fix bug causing tests to fail completely + for this function + +Wed Mar 25 12:55:53 1998 Jonathan Larmour + + * src/include/sim.hxx: add types to constants (oops!) + * Makefile.am: link src/stdio/device/sim.cxx + * Makefile.in: regenerated + +Wed Mar 25 04:14:30 1998 Jonathan Larmour + + * src/include/file_if.hxx, src/include/file_if.inl, + src/include/kerndiag.hxx, src/include/sim.hxx, + src/include/stdio_if.hxx, src/include/strngdev.hxx, + src/include/tsd.hxx, src/stdio/common/clearerr.cxx, + src/stdio/common/clearerr.cxx, src/stdio/common/feof.cxx, + src/stdio/common/ferror.cxx, src/stdio/common/file_if.cxx, + src/stdio/common/vsprintf.cxx, + src/stdio/device/kerndiag.cxx, src/stdio/device/sim.cxx, + src/stdio/device/strngdev.cxx, src/stdio/output/fputc.cxx, + src/stdio/output/fputs.cxx, src/stdio/output/puts.cxx, + src/stdio/output/vfnprintf.cxx, src/support/tsd.cxx: + Modified to support buffered reads including renaming + _EccInternalFileStruct to __EccStdioStream which is what affects + most of these files + * src/include/file_if.inl, src/stdio/common/file_if.cxx: added for + the above reason + * src/stdio/common/sscanf.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/input/Makefile.am: added to provide sscanf() functionality + * include/ctype.h, include/stdio.h, include/stdlib.h, + include/string.h, include/eccconf/libc.h, src/ctype/ctype.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/stdio/common/stdio.cxx: + rename *_INLINES macros with prefix CYG rather than ECC + * include/errno.h, src/errno/errno.cxx, src/errno/strerror.cxx: + rename ErrNo to _ErrNo and add EAGAIN and EWOULDBLOCK error codes + * configure.in, Makefile.am, src/stdio/Makefile.am, + src/stdio/input/Makefile.am: add support for building + file_if.cxx sscanf.cxx and vfscanf.cxx + * src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/input/Makefile.in, configure, Makefile.in: regenerated + +Tue Mar 24 19:51:40 1998 Jonathan Larmour + + * src/time/clockfn.cxx, src/time/clock.cxx: + Renamed clock.cxx to clockfn.cxx (preserving CVS history) + * Makefile.am, src/time/Makefile.am: updated to reflect name change + * Makefile.in, src/time/Makefile.in: regenerated + +Tue Mar 24 16:28:06 1998 Jonathan Larmour + + * include/ctype.inl: Swap around definitions to get right order so + inlining works + +Tue Mar 24 14:43:05 1998 Jonathan Larmour + + * include/ctype.h, include/stdio.h, include/stdlib.h, include/string.h: + modify to only conditionally include inlines + * src/ctype/ctype.cxx, src/stdio/common/stdio.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/ctype/Makefile.am: Add to provide real linkable alternatives + to inline functions + * Makefile.am, configure.in, src/Makefile.am, + src/stdio/common/Makefile.am, src/stdlib/Makefile.am, + src/string/Makefile.am: modified to support previous additions + * include/eccconf/libc.h: redefine inline macro to add extern inline, + and add conditional defines for inline functions. Also rename + space vs. speed macro to have CYG instead of ECC prefix + * include/stdio.inl: fix comment typo + * src/stdlib/qsort.cxx: fix to define inline functions properly + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/memcpy.cxx, + src/string/memset.cxx, src/string/strcat.cxx, src/string/strchr.cxx, + src/string/strcmp.cxx, src/string/strcpy.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx + * Makefile.in, configure, src/Makefile.in, src/ctype/Makefile.in, + src/stdio/common/Makefile.in, src/stdlib/Makefile.in, + src/string/Makefile.in: regenerate + + +Mon Mar 23 19:19:49 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: added to support temporary _exit + * include/stdlib.h, include/stdlib.inl: added support for _exit and + added abs(), labs(), div() and ldiv() functions + * src/include/file_if.hxx: added support for _exit kludge + * src/stdlib/qsort.cxx: Added Berkeley copyright message + * src/time/clock.cxx: Include correct kernel config header as + CYG_CONFIGURATION rather than + * Makefile.am src/stdlib/Makefile.am: added support for _exit + * Makefile.in, src/stdlib/Makefile.in: regenerated + +Mon Mar 23 14:41:07 1998 Jonathan Larmour + + * Replace ECCPKG_ANSI_LIBC with CYGPKG_ANSI_LIBC in all source files + +Mon Mar 23 14:28:44 1998 Jonathan Larmour + + * include/string.inl: add file to provide strcoll() + * include/string.h: include string.inl + * ctype.h: include ctype.inl (oops!) + * include/stdlib.h: include stdlib.inl (oops!) + +Mon Mar 23 13:30:38 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl: added to provide ANSI ctype + functionality + * include/stdlib.h, include/stdlib.inl, src/include/stdlibbsp.hxx, + src/stdlib/Makefile.am, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/stdlib/srand.cxx, + src/stdlib/strtol.cxx, src/stdlib/strtoul.cxx: Added to provide + many stdlib functions + * src/include/tsd.hxx: modified to support rand() random number + seed, and added some comments + * configure.in, Makefile.am, src/Makefile.am: modified to support + addition of above new sources + * include/eccconf/libc.h: Add extra helpful comments, and #include + kernel config file + * src/time/clock.cxx: #include clock.inl and fix to call + get_resolution() properly now + * Makefile.in, configure, src/Makefile.in, src/errno/Makefile.in, + src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.in, src/stdio/output/Makefile.in, + src/stdlib/Makefile.in, src/strings/Makefile.in, + src/support/Makefile.in, src/time/Makefile.in, + tests/Makefile.in: regenerated + + +Sun Mar 22 21:29:25 1998 Jonathan Larmour + + * include/time.h, src/include/timesupp.hxx, src/time/clock.cxx, + src/time/Makefile.am: added to provide clock() function + * src/Makefile.am: modified to try to build in src/time directory + * include/eccconf/libc.h: added and is now the main configuration + file for this package + * acconfig.h, include/libcconf.h.in, include/stamp-h.in: removed + due to usage of libc.h above instead + * Almost all *.h, *.hxx and *.cxx: replaced LIBC_CONFIG_HEADER + defined include with simple + * configure.in: remove AM_CONFIG_HEADER of libcconf.h and + LIBC_CONFIG_HEADER definition. Also remove usage of builtin + memcpy() etc. from gcc, and generate src/time/Makefile + * Makefile.am: link in src/time/clock.o + * src/include/file_if.hxx, src/include/sim.hxx: use config header + to decide whether C library is to be used + * Makefile.in, aclocal.m4, configure, src/Makefile.in: regenerated + +Fri Mar 20 18:08:10 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fixed bug with ignoring terminating NULL + +1998-03-20 Chris Tarpy + + * configure: - regenerated + * Makefile.am: - Support added for libc testcases + * Makefile.in: regenerated + * configure.in: set c compiler, descend test dir + * tests/Makefile.in: added + * tests/Makefile.am: added + * tests/tcdiag.cxx : added + + +Thu Mar 19 11:41:56 1998 Jonathan Larmour + + * Initial check-in of everything + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/i18n/current/cdl/i18n.cdl b/packages/language/c/libc/i18n/current/cdl/i18n.cdl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/i18n/current/cdl/i18n.cdl @@ -0,0 +1,143 @@ +# ==================================================================== +# +# i18n.cdl +# +# C library internationalization (i18n) related configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jlarmour +# Contributors: +# Date: 2000-04-14 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_LIBC_I18N { + display "ISO C library internationalization functions" + description " + This package provides internationalization functions specified by the + ISO C standard - ISO/IEC 9899:1990. These include locale-related + functionality and functionality." + doc redirect/the-iso-standard-c-and-math-libraries.html + include_dir cyg/libc/i18n + parent CYGPKG_LIBC + implements CYGINT_ISO_LOCALE + implements CYGINT_ISO_CTYPE + requires CYGPKG_ISOINFRA + compile ctype.cxx locale.cxx + +# ==================================================================== + + cdl_option CYGNUM_LIBC_I18N_MAX_LOCALE_NAME_SIZE { + display "Size of locale name strings" + flavor data + legal_values 2 to 0x7fffffff + default_value 2 + description " + This option controls the maximum size of + locale names and is used, among other things + to instantiate a static string used + as a return value from the + setlocale() function. When requesting the + current locale settings with LC_ALL, a string + must be constructed to contain this data, rather + than just returning a constant string. This + string data is stored in the static string. + This depends on the length of locale names, + hence this option. If just the C locale is + present, this option can be set as low as 2." + } + + +# ==================================================================== + + cdl_option CYGIMP_LIBC_I18N_CTYPE_INLINES { + display "Inline versions of functions" + default_value 1 + requires { CYGBLD_ISO_CTYPE_HEADER == \ + "" } + description " + This option chooses whether the simple character + classification and conversion functions (e.g. + isupper(), isalpha(), toupper(), etc.) + from are available as inline + functions. This may improve performance and as + the functions are small, may even improve code + size." + } + +# ==================================================================== + + cdl_component CYGPKG_LIBC_I18N_OPTIONS { + display "C library i18n functions build options" + flavor none + no_define + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_LIBC_I18N_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the C library. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_LIBC_I18N_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the C library. These flags are removed from + the set of global flags if present." + } + + cdl_option CYGPKG_LIBC_I18N_TESTS { + display "C library i18n function tests" + flavor data + no_define + calculated { "tests/ctype tests/setlocale" } + description " + This option specifies the set of tests for the C library + i18n functions." + } + } +} + +# ==================================================================== +# EOF i18n.cdl diff --git a/packages/language/c/libc/i18n/current/include/ctype.inl b/packages/language/c/libc/i18n/current/include/ctype.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/i18n/current/include/ctype.inl @@ -0,0 +1,180 @@ +#ifndef CYGONCE_LIBC_CTYPE_INL +#define CYGONCE_LIBC_CTYPE_INL +/*=========================================================================== +// +// ctype.inl +// +// Inline implementations of ISO standard ctype routines defined in +// section 7.3 of the standard +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: Do not include this file directly - use #include +// +//####DESCRIPTIONEND#### +// +//=========================================================================*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* The outline implementation will override this to prevent inlining */ +#ifndef CYGPRI_LIBC_I18N_CTYPE_INLINE +# define CYGPRI_LIBC_I18N_CTYPE_INLINE extern __inline__ +#endif + +/* FUNCTIONS */ + +#ifdef __cplusplus +extern "C" { +#endif + +/*=========================================================================*/ + +/* 7.3.1 Character testing functions */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +isupper( int c ) +{ + return (('A' <= c) && (c <= 'Z')); +} /* isupper() */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +islower( int c ) +{ + return (('a' <= c) && (c <= 'z')); +} /* islower() */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +isalpha( int c ) +{ + return ( islower(c) || isupper(c) ); +} /* isalpha() */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +isdigit( int c ) +{ + return ( ('0' <= c) && (c <= '9') ); +} /* isdigit() */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +isalnum( int c ) +{ + return ( isalpha(c) || isdigit(c) ); +} /* isalnum() */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +iscntrl( int c ) +{ + /* Simple standard 7-bit ASCII map is assumed */ + return ( ((0 <= c) && (c <= 0x1F)) || + (c == 0x7F) ); +} /* iscntrl() */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +isgraph( int c ) +{ + // Simple standard 7-bit ASCII map is assumed + return ( ('!' <= c) && (c <= '~') ); +} /* isgraph() */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +isprint( int c ) +{ + /* Simple standard 7-bit ASCII map is assumed */ + return ( (' ' <= c) && (c <= '~') ); +} /* isprint() */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +ispunct( int c ) +{ + /* Simple standard 7-bit ASCII map is assumed */ + return ( (('!' <= c) && (c <= '/')) || // ASCII 0x21 - 0x2F + ((':' <= c) && (c <= '@')) || // ASCII 0x3A - 0x40 + (('[' <= c) && (c <= '`')) || // ASCII 0x5B - 0x60 + (('{' <= c) && (c <= '~')) ); // ASCII 0x7B - 0x7E + +} /* ispunct() */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +isspace( int c ) +{ + return ( (c == ' ') || (c == '\f') || (c == '\n') || (c == '\r') || + (c == '\t') || (c == '\v') ); +} /* isspace() */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +isxdigit( int c ) +{ + return ( isdigit(c) || + (('a' <= c) && (c <= 'f')) || + (('A' <= c) && (c <= 'F')) ); +} /* isxdigit() */ + +/*========================================================================*/ + +/* 7.3.2 Character case mapping functions */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +tolower( int c ) +{ + return isupper(c) ? c - 'A' + 'a' : c; +} /* tolower() */ + + +CYGPRI_LIBC_I18N_CTYPE_INLINE int +toupper( int c ) +{ + return islower(c) ? c - 'a' + 'A' : c; +} /* toupper() */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* CYGONCE_LIBC_CTYPE_INL multiple inclusion protection */ + +/* EOF ctype.inl */ diff --git a/packages/language/c/libc/i18n/current/src/ctype.cxx b/packages/language/c/libc/i18n/current/src/ctype.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/i18n/current/src/ctype.cxx @@ -0,0 +1,55 @@ +/*=========================================================================== +// +// ctype.cxx +// +// ISO C standard ctype functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-28 +// Purpose: +// Description: Real alternative for inline implementation of the ISO +// standard ctype functions defined in section 7.3 of +// the standard +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================*/ + +/* We don't want the inline versions of the ctype functions defined here */ + +#define CYGPRI_LIBC_I18N_CTYPE_INLINE + +/* This means that including ctype.inl will make the outline functions */ + +#include + +/* EOF ctype.cxx */ diff --git a/packages/language/c/libc/i18n/current/src/locale.cxx b/packages/language/c/libc/i18n/current/src/locale.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/i18n/current/src/locale.cxx @@ -0,0 +1,363 @@ +//======================================================================== +// +// locale.cxx +// +// Implementation of ISO C internationalisation (i18n) locales +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-18 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // Common tracing support +#include // Common assertion support +#include // struct lconv +#include // several string functions +#include // CHAR_MAX + +// TYPE DEFINITIONS + +// define a type to encapsulate the locale. In time this will get much +// richer and complete + +typedef struct { + + const char *name; + struct lconv numdata; + +} Cyg_libc_locale_t; + + +// CONSTANTS + +// define the "C" locale +static const Cyg_libc_locale_t +C_locale = { "C", + { ".", "", "", "", "", "", "", "", "", "", + CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, + CHAR_MAX, CHAR_MAX + } + }; + +// only one locale now, but leave room for expansion +static const Cyg_libc_locale_t *all_locales[] = { &C_locale }; + +// GLOBALS + +// the current locales. Our default is the C locale +static const Cyg_libc_locale_t *current_collate_locale = &C_locale; +static const Cyg_libc_locale_t *current_ctype_locale = &C_locale; +static const Cyg_libc_locale_t *current_monetary_locale = &C_locale; +static const Cyg_libc_locale_t *current_numeric_locale = &C_locale; +static const Cyg_libc_locale_t *current_time_locale = &C_locale; + +// FUNCTIONS + +static const Cyg_libc_locale_t * +find_locale_data( const char *locale_str, cyg_ucount32 checklen ) +{ + CYG_REPORT_FUNCNAMETYPE( "find_locale_data", "returning %08x" ); + CYG_REPORT_FUNCARG1( "locale_str=%s", locale_str ); + + const Cyg_libc_locale_t *temp_locale, *curr_locale=NULL; + cyg_ucount32 i; + + // is it "" i.e. use the default? + if (*locale_str=='\0') { + curr_locale = &C_locale; + CYG_REPORT_RETVAL( curr_locale ); + return curr_locale; + } // if + + for (i=0; iname, locale_str, checklen) ) + curr_locale = temp_locale; + } // for + + CYG_REPORT_RETVAL( curr_locale ); + return curr_locale; +} // find_locale_data() + + +externC char * +setlocale( int category, const char *locale ) +{ + CYG_REPORT_FUNCNAMETYPE("setlocale", "returning %08x"); + CYG_REPORT_FUNCARG2( "category=%d, locale=%s", category, locale ); + + if (locale != NULL) + CYG_CHECK_DATA_PTR( locale, "locale pointer is invalid!" ); + + const char *str; + + // special case if locale==NULL, return current locale name + if (locale==NULL) { + + CYG_TRACE0( true, "Getting current locale value" ); + + switch (category) { + + case LC_COLLATE: + str = current_collate_locale->name; + break; + case LC_CTYPE: + str = current_ctype_locale->name; + break; + case LC_MONETARY: + str = current_monetary_locale->name; + break; + case LC_NUMERIC: + str = current_numeric_locale->name; + break; + case LC_TIME: + str = current_time_locale->name; + break; + case LC_ALL: + + // create static string to give a constructed string back + // to the user. The size is the number of categories other + // than LC_ALL times the maximum name size, and add a constant + // for the delimiting octothorpes + static char my_str[ CYGNUM_LIBC_I18N_MAX_LOCALE_NAME_SIZE*5+10 ]; + + strcpy( my_str, "#" ); + strcat( my_str, current_collate_locale->name ); + strcat( my_str, "#" ); + strcat( my_str, current_ctype_locale->name ); + strcat( my_str, "#" ); + strcat( my_str, current_monetary_locale->name ); + strcat( my_str, "#" ); + strcat( my_str, current_numeric_locale->name ); + strcat( my_str, "#" ); + strcat( my_str, current_time_locale->name ); + strcat( my_str, "#" ); + + str = &my_str[0]; + break; + default: + str=NULL; + CYG_FAIL("setlocale() passed bad category!" ); + break; + + } // switch + + CYG_REPORT_RETVAL( (char *)str); + return (char *)str; + } // if + + // we only get here if locale is non-NULL, i.e. we want to set it + + const Cyg_libc_locale_t *loc; + cyg_bool default_locale = (*locale=='\0'); + + CYG_TRACE0( true, "Setting current locale value" ); + + switch( category ) { + case LC_COLLATE: + loc = find_locale_data( locale, CYGNUM_LIBC_I18N_MAX_LOCALE_NAME_SIZE ); + if (loc != NULL) // found it + current_collate_locale=loc; + break; + + case LC_CTYPE: + loc = find_locale_data( locale, CYGNUM_LIBC_I18N_MAX_LOCALE_NAME_SIZE ); + if (loc != NULL) // found it + current_ctype_locale=loc; + break; + + case LC_MONETARY: + loc = find_locale_data( locale, CYGNUM_LIBC_I18N_MAX_LOCALE_NAME_SIZE ); + if (loc != NULL) // found it + current_monetary_locale=loc; + break; + + case LC_NUMERIC: + loc = find_locale_data( locale, CYGNUM_LIBC_I18N_MAX_LOCALE_NAME_SIZE ); + if (loc != NULL) // found it + current_numeric_locale=loc; + break; + + case LC_TIME: + loc = find_locale_data( locale, CYGNUM_LIBC_I18N_MAX_LOCALE_NAME_SIZE ); + if (loc != NULL) // found it + current_time_locale=loc; + break; + + case LC_ALL: + // first try and match it exactly + loc = find_locale_data( locale, CYGNUM_LIBC_I18N_MAX_LOCALE_NAME_SIZE ); + if (loc != NULL) { // found it + + CYG_TRACE0(true, "Matched locale string exactly"); + current_collate_locale = current_ctype_locale = loc; + current_monetary_locale = current_numeric_locale = loc; + current_time_locale = loc; + } // if + else { + CYG_TRACE0( true, "Attempting to parse string previously " + "returned from setlocale()" ); + // now try and see if it is a compound string returned + // earlier by setlocale( LC_ALL, NULL ); + + // Note we don't do much checking here. This could be + // much more rigorous (but at the expense of speed/size?) + + const Cyg_libc_locale_t *temp_collate_locale, + *temp_ctype_locale, *temp_monetary_locale, + *temp_numeric_locale, *temp_time_locale; + + cyg_ucount32 token_len; + + str = &locale[0]; + if ( *str=='#' ) { + ++str; + token_len = strcspn( str, "#" ); + loc = find_locale_data( str, token_len ); + + if (loc!=NULL) { + temp_collate_locale=loc; + str += token_len+1; + token_len = strcspn( str, "#" ); + loc = find_locale_data( str, token_len ); + + if (loc!=NULL) { + temp_ctype_locale=loc; + str += token_len+1; + token_len = strcspn( str, "#" ); + loc = find_locale_data( str, token_len ); + + if (loc!=NULL) { + temp_monetary_locale=loc; + str += token_len+1; + token_len = strcspn( str, "#" ); + loc = find_locale_data( str, token_len ); + + if (loc!=NULL) { + temp_numeric_locale=loc; + str += token_len+1; + token_len = strcspn( str, "#" ); + loc = find_locale_data( str, token_len ); + + if (loc!=NULL) { + temp_time_locale=loc; + str += token_len+1; + token_len = strcspn( str, "#" ); + loc = find_locale_data( str, token_len ); + + if (loc!=NULL) { + // if we've got this far and loc still isn't NULL, + // then everything's fine, and we've matched everything + + current_collate_locale = temp_collate_locale; + current_ctype_locale = temp_ctype_locale; + current_monetary_locale = temp_monetary_locale; + current_numeric_locale = temp_numeric_locale; + current_time_locale = temp_time_locale; + + } // if + } // if + } // if + } // if + } // if + } // if + } // if + + } // else + break; // case LC_ALL + + default: + CYG_FAIL("setlocale() passed bad category!" ); + loc=NULL; + break; + } // switch + + if (loc==NULL) { + CYG_REPORT_RETVAL( NULL ); + return NULL; + } // if + else if (default_locale==true) { + CYG_REPORT_RETVAL(C_locale.name); + return (char *)C_locale.name; + } // else if + else { + CYG_REPORT_RETVAL(locale); + return (char *)locale; + } // else +} // setlocale() + +externC struct lconv * +localeconv( void ) +{ + CYG_REPORT_FUNCNAMETYPE( "localeconv", "returning %08x" ); + CYG_REPORT_FUNCARGVOID(); + + static struct lconv static_lconv; + + static_lconv.decimal_point = + current_numeric_locale->numdata.decimal_point; + + static_lconv.thousands_sep = + current_numeric_locale->numdata.thousands_sep; + + static_lconv.grouping = + current_numeric_locale->numdata.grouping; + + // we cheat a bit, but it should be worth it - a lot of these are + // constants which optimise nicely + cyg_ucount32 size_used; + size_used = (char *)&static_lconv.int_curr_symbol - + (char *)&static_lconv; + + memcpy( &(static_lconv.int_curr_symbol), + &(current_monetary_locale->numdata.int_curr_symbol), + sizeof(struct lconv) - size_used ); + + + CYG_REPORT_RETVAL( &static_lconv ); + return &static_lconv; +} // localeconv() + +// EOF locale.cxx diff --git a/packages/language/c/libc/i18n/current/tests/ctype.c b/packages/language/c/libc/i18n/current/tests/ctype.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/i18n/current/tests/ctype.c @@ -0,0 +1,211 @@ +//================================================================= +// +// ctype.c +// +// General testcase for C library ctype functions +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-14 +// Description: Contains general testcode for C library ctype functions +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include +#include + + +// FUNCTIONS + +int +main( int argc, char *argv[] ) +{ + int c; // character we use as a parameter + + CYG_TEST_INIT(); + + CYG_TEST_INFO( "Starting tests from testcase " __FILE__ " for C library " + " functions" ); + + // Check isalnum + c = 't'; + CYG_TEST_PASS_FAIL( isalnum(c), "isalnum('t')"); + c = '2'; + CYG_TEST_PASS_FAIL( isalnum(c), "isalnum('2')"); + c = 2; + CYG_TEST_PASS_FAIL( !isalnum(c), "!isalnum(2)"); + c = 127; + CYG_TEST_PASS_FAIL( !isalnum(c), "!isalnum(127)"); + + // Check isalpha + c = 'A'; + CYG_TEST_PASS_FAIL( isalpha(c), "isalpha('A')"); + c = 'a'; + CYG_TEST_PASS_FAIL( isalpha(c), "isalpha('a')"); + c = '2'; + CYG_TEST_PASS_FAIL( !isalpha(c), "!isalpha('2')"); + c = '\n'; + CYG_TEST_PASS_FAIL( !isalpha(c), "!isalpha('newline')"); + + // Check iscntrl + c = 'a'; + CYG_TEST_PASS_FAIL( !iscntrl(c), "!iscntrl('a')"); + c = 7; + CYG_TEST_PASS_FAIL( iscntrl(c), "iscntrl('7')"); + c = '\n'; + CYG_TEST_PASS_FAIL( iscntrl(c), "iscntrl(newline)"); + c = 0x7F; + CYG_TEST_PASS_FAIL( iscntrl(c), "iscntrl(0x7F)"); + + // Check isdigit + c = '2'; + CYG_TEST_PASS_FAIL( isdigit(c), "isdigit('2')"); + c = '0'; + CYG_TEST_PASS_FAIL( isdigit(c), "isdigit('0')"); + c = 't'; + CYG_TEST_PASS_FAIL( !isdigit(c), "!isdigit('t')"); + + // Check isgraph + c = ')'; + CYG_TEST_PASS_FAIL( isgraph(c), "isgraph(')')"); + c = '~'; + CYG_TEST_PASS_FAIL( isgraph(c), "isgraph('~')"); + c = '9'; + CYG_TEST_PASS_FAIL( isgraph(c), "isgraph('9')"); + c = 9; + CYG_TEST_PASS_FAIL( !isgraph(c), "!isgraph(9)"); + c = ' '; + CYG_TEST_PASS_FAIL( !isgraph(c), "!isgraph(' ')"); + c = '\t'; + CYG_TEST_PASS_FAIL( !isgraph(c), "!isgraph(tab)"); + c = '\n'; + CYG_TEST_PASS_FAIL( !isgraph(c), "!isgraph(newline)"); + c = 0x7F; + CYG_TEST_PASS_FAIL( !isgraph(c), "!isgraph(DEL)"); + c = 200; + CYG_TEST_PASS_FAIL( !isgraph(c), "!isgraph(200)"); + c = '\0'; + CYG_TEST_PASS_FAIL( !isgraph(c), "!isgraph(NUL)"); + + // Check islower + c = 'J'; + CYG_TEST_PASS_FAIL( !islower(c), "islower('J')"); + c = 'j'; + CYG_TEST_PASS_FAIL( islower(c), "islower('j')"); + c = '5'; + CYG_TEST_PASS_FAIL( !islower(c), "!islower(5)"); + + // Check isprint + c = ' '; + CYG_TEST_PASS_FAIL( isprint(c), "isprint(' ')"); + c = 'x'; + CYG_TEST_PASS_FAIL( isprint(c), "isprint('x')"); + c = '\b'; + CYG_TEST_PASS_FAIL( !isprint(c), "!isprint(backspace)"); + + // Check ispunct + c = '.'; + CYG_TEST_PASS_FAIL( ispunct(c), "ispunct('.')"); + c = '#'; + CYG_TEST_PASS_FAIL( ispunct(c), "ispunct('#')"); + c = '@'; + CYG_TEST_PASS_FAIL( ispunct(c), "ispunct('@')"); + c = 'f'; + CYG_TEST_PASS_FAIL( !ispunct(c), "!ispunct('f')"); + c = '7'; + CYG_TEST_PASS_FAIL( !ispunct(c), "!ispunct('7')"); + c = '\n'; + CYG_TEST_PASS_FAIL( !ispunct(c), "!ispunct('newline')"); + + // Check isspace + c = ' '; + CYG_TEST_PASS_FAIL( isspace(c), "isspace(' ')"); + c = '\t'; + CYG_TEST_PASS_FAIL( isspace(c), "isspace(tab)"); + c = '\r'; + CYG_TEST_PASS_FAIL( isspace(c), "isspace(return)"); + c = '\v'; + CYG_TEST_PASS_FAIL( isspace(c), "isspace(vertical tab)"); + c = '\n'; + CYG_TEST_PASS_FAIL( isspace(c), "isspace(newline)"); + c = 'd'; + CYG_TEST_PASS_FAIL( !isspace(c), "!isspace('d')"); + c = ','; + CYG_TEST_PASS_FAIL( !isspace(c), "!isspace(',')"); + + // Check isupper + c = 'A'; + CYG_TEST_PASS_FAIL( isupper(c), "isupper('A')"); + c = 'a'; + CYG_TEST_PASS_FAIL( !isupper(c), "!isupper('a')"); + c = '2'; + CYG_TEST_PASS_FAIL( !isupper(c), "!isupper('2')"); + c = '\b'; + CYG_TEST_PASS_FAIL( !isupper(c), "!isupper(backspace)"); + + // Check isxdigit + c = 'f'; + CYG_TEST_PASS_FAIL( isxdigit(c), "isxdigit('f')"); + c = 'D'; + CYG_TEST_PASS_FAIL( isxdigit(c), "isxdigit('D')"); + c = '1'; + CYG_TEST_PASS_FAIL( isxdigit(c), "isxdigit('1')"); + c = '0'; + CYG_TEST_PASS_FAIL( isxdigit(c), "isxdigit('0')"); + c = 'g'; + CYG_TEST_PASS_FAIL( !isxdigit(c), "!isxdigit('g')"); + c = 'x'; + CYG_TEST_PASS_FAIL( !isxdigit(c), "!isxdigit('x')"); + + // Check tolower + c = 'F'; + CYG_TEST_PASS_FAIL( tolower(c) == 'f', "tolower('F')"); + c = 'g'; + CYG_TEST_PASS_FAIL( tolower(c) == 'g', "tolower('g')"); + c = '3'; + CYG_TEST_PASS_FAIL( tolower(c) == '3', "tolower('3')"); + + // Check toupper + c = 'f'; + CYG_TEST_PASS_FAIL( toupper(c) == 'F', "toupper('f')"); + c = 'G'; + CYG_TEST_PASS_FAIL( toupper(c) == 'G', "toupper('G')"); + c = ','; + CYG_TEST_PASS_FAIL( toupper(c) == ',', "toupper(',')"); + + CYG_TEST_FINISH( "Finished tests from testcase " __FILE__ " for C library " + " functions" ); +} // main() + +// EOF ctype.c diff --git a/packages/language/c/libc/i18n/current/tests/setlocale.c b/packages/language/c/libc/i18n/current/tests/setlocale.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/i18n/current/tests/setlocale.c @@ -0,0 +1,118 @@ +//================================================================= +// +// setlocale.c +// +// Testcase for C library setlocale() function +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-18 +// Description: Contains testcode for C library setlocale() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include // header for functions to test +#include // Testcase API + + +// FUNCTIONS + +static int +my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + +int +main( int argc, char *argv[] ) +{ + char *str; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C " + "library setlocale() function"); + + // Check 1 + str = setlocale(LC_CTYPE, NULL); + CYG_TEST_PASS_FAIL( !my_strcmp(str, "C" ), + "Initial locale for LC_CTYPE is \"C\"" ); + + // Check 2 + str = setlocale(LC_ALL, NULL); + CYG_TEST_PASS_FAIL( !my_strcmp(str, "#C#C#C#C#C#" ), + "Initial locale for LC_ALL is correct" ); + + // Check 3 + str = setlocale(LC_COLLATE, "C"); + CYG_TEST_PASS_FAIL( !my_strcmp(str, "C" ), + "Set locale for LC_COLLATE to \"C\"" ); + + // Check 4 + str = setlocale(LC_MONETARY, ""); + CYG_TEST_PASS_FAIL( !my_strcmp(str, "C" ), + "Set default locale for LC_MONETARY" ); + str = setlocale(LC_MONETARY, NULL); + CYG_TEST_PASS_FAIL( !my_strcmp(str, "C" ), + "Stored default locale for LC_MONETARY" ); + + // Check 5 + str = setlocale(LC_ALL, "C"); + CYG_TEST_PASS_FAIL( !my_strcmp(str, "C" ), + "Set locale for LC_COLLATE to \"C\"" ); + + // Check 6 + str = setlocale(LC_ALL, ""); + CYG_TEST_PASS_FAIL( !my_strcmp(str, "C" ), + "Set locale for LC_COLLATE to default" ); + + // Check 7 + str = setlocale(LC_ALL, NULL); + CYG_TEST_PASS_FAIL( !my_strcmp(str, "#C#C#C#C#C#" ), + "Get locale for LC_ALL" ); + str = setlocale(LC_ALL, str); + CYG_TEST_PASS_FAIL( !my_strcmp(str, "#C#C#C#C#C#" ), + "Set locale for LC_ALL from retrieved locale" ); + + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C " + "library setlocale() function"); +} // main() + +// EOF setlocale.c diff --git a/packages/language/c/libc/setjmp/current/ChangeLog b/packages/language/c/libc/setjmp/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/setjmp/current/ChangeLog @@ -0,0 +1,38 @@ +2000-05-16 Nick Garnett + + * src/longjmp.cxx: Was still including pkgconf/libc.h rather that + pkgconf/libc_setjmp.h. + +2000-05-02 Jonathan Larmour + + * New package + Separated original libc out into separate packages on functional + boundaries. + Header files are now managed by isoinfra package + Plenty of cleanups done, but no major functionality changes + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/setjmp/current/ChangeLog.libc b/packages/language/c/libc/setjmp/current/ChangeLog.libc new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/setjmp/current/ChangeLog.libc @@ -0,0 +1,2727 @@ +This ChangeLog file is now obsolete. This is the original ChangeLog from when +libc was one large package, before being separated. It is included for +historical reasons. + +2000-04-05 Jesper Skov + + * src/time/settime.cxx: + * src/time/time.cxx: + Wallclock moved to io/. + +2000-03-28 John Dallaway + + * cdl/string.cdl, + cdl/stdlib.cdl, + cdl/stdio.cdl, + cdl/libc.cdl: + + Adjust documentation URLs. + +2000-03-27 Jesper Skov + + * src/clibincl/stream.inl (check_this): Use cyb_bool instead of bool. + +2000-03-06 Jesper Skov + + * tests/time/strftime.c (test): Adjust test to match below change. + +2000-03-02 Jonathan Larmour + + * src/time/strftime.cxx (do_format): Make sure %m counts from + 1..12 rather than 0..11. Fix for case 103300 + +2000-02-29 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: Correctly use 'n' parameter to + restrict length. Credit due to Andrew Lunn here as well. + Resolves 103057-CR-1 + + * tests/stdio/sprintf2.c (test): + Add snprintf tests to verify the correct behaviour of restricting + output length + +2000-02-10 Jesper Skov + + * tests/signal/signal2.c (main): + Also reclaim DATA_TLB_MISS vector if available. + +2000-01-31 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-28 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-19 Hugo Tyson + + * cdl/*.cdl: Add descriptions to a number of options &c which were + lacking same, also tidied up other typos as noticed en passant. + +1999-11-11 Bart Veer + + * cdl/string.cdl: + Switch to a single boolean configuration option for code size vs. + speed optimization. + +1999-11-03 John Dallaway + + * cdl/libc.cdl: Define tests. + +1999-10-19 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: We can now remove Berkeley + advertising clause + * src/stdlib/div.cxx: ditto + * src/stdlib/ldiv.cxx: ditto + * src/stdlib/strtol.cxx: ditto + * src/stdlib/strtoul.cxx: ditto + * src/string/strtok.cxx: ditto + +1999-10-19 John Dallaway + + * cdl/libc.cdl: + + Define CDL options for package-specific CFLAGS. + +1999-10-08 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_THREAD_PRIORITY): Change + default to 10 to keep test farm happy + * cdl/startup.cdl: Likewise + +1999-10-07 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Specify radio buttons using CDL interfaces. + +1999-10-06 Jonathan Larmour + + * cdl/stdio.cdl: Change default to /dev/ttydiag as per 1999-10-01 + change below + * cdl/startup.cdl: Add new form CDL for the startup changes as + per 1999-10-05 + +1999-10-05 Jonathan Larmour + + * include/libc.h: Add CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM to allow + the user to supply their own stack. + Rename CYGNUM_LIBC_MAIN_STACK_SIZE to + CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE and reparent under + CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + Add CYGNUM_LIBC_MAIN_THREAD_PRIORITY to provide main() thread + priority + + * src/support/mainthread.cxx: Add support for user-supplied stack + Allow user to specify thread priority + + These changes fix CR 101069 + +1999-10-01 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE): Change + default to /dev/ttydiag to get correct console-like behaviour + Also don't preclude use if haldiag package isn't included + (case 102065) + +1999-09-15 Jesper Skov + + * tests/signal/signal2.c (cause_fpe): Try both float and integer + division by zero. + +1999-09-10 Jesper Skov + + * src/stdlib/malloc.cxx (cyg_libc_get_malloc_pool): Added for + stress_threads test. + +1999-09-07 Jesper Skov + PRs 20243, 20433 + * tests/signal/signal2.c: Disabled test3 on ARM. + +1999-09-02 Hugo Tyson + + * include/assert.h: Make the sense of NDEBUG correct; it is "set" + when NOT debugging. Fix for CR 101983-CR-1 + See Stroustrup, "The C++ Programming Language." + +1999-08-18 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): Set buffer size 0 when not + buffering + Fix for case 101868 + +1999-08-17 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Implement radio buttons using "FIXME radio" hack in + description field for now. + +1999-08-12 John Dallaway + + * cdl/stdlib.cdl: + Take advantage of MACRONAME_ENUMVAL macros output by CDL. + +1999-08-06 Jonathan Larmour + + * tests/stdio/sprintf2.c (test): Don't rely on 2.345 being exactly + representable in binary as a difference of 1 ulp will make it round + the wrong way. + +1999-07-16 Jonathan Larmour + + * src/stdio/input/fgetc.cxx: + Include outline versions of getc() (actually just a symbol alias for + fgetc() ) and getchar() + Some minor clean-ups + Add tracing/assertions + + * src/stdio/input/fputc.cxx: + Likewise (except applied to putc() and putchar()) + + * src/stdio/common/stdioinlines.cxx (_puts): + Call fputc() not _fputc() + + * src/clibincl/stdiosupp.hxx: + Remove now obsolete prototypes for _fgetc() and _fputc() + + * include/stdio.h: + Don't bother with getc()/putc() macros any more, just call + them as functions + Include protos for getc(), putc(), getchar() and putchar() functions + +1999-06-21 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for SH EDK7708. + +1999-06-11 Jonathan Larmour + + * include/stdio.h: Make FILEs array types so they won't be + given $gp relocations on MIPS targets + +1999-05-27 Jesper Skov + + * tests/time/ctime.c: Fixed compiler warning. + +1999-05-25 Jonathan Larmour + + * tests/signal/signal2.c (main): + Update CYGPKG_HAL_TX39 -> CYGPKG_HAL_MIPS_TX39 due to recent MIPS + HAL changes + Fix for PR 20116 + +1999-04-30 Jesper Skov + PR 19945/19946 workaround + * tests/signal/signal2.c: Disabled test 3 for PowerPC sim. + +1999-04-19 Jonathan Larmour + + * include/time.inl: + Ensure all calls to cyg_libc_time_year_is_leap() are with the full + year, and not the direct contents of a struct tm, which are (year-1900) + +1999-04-19 Jesper Skov + PR 19308, 19410, 19528 + * tests/time/clock.c (test): Also disable data cache which may + affect timing when tracing/assertions are enabled. + +1999-04-15 Jonathan Larmour + + * src/clibincl/stdiosupp.hxx: + Add prototype for new cyg_libc_stdio_flush_all_but() function + + * src/clibincl/stream.hxx: + Don't include stdiosupp.hxx any more to prevent circular dependency, + therefore manually provide _setvbuf prototype + Make sure pkgconf/kernel.h is included before mutex.hxx + + * src/clibincl/stream.inl (Cyg_StdioStream::set_error()): + Add missing unlock_me() + + * src/stdio/common/fflush.cxx: + Separate most of code for fflush(NULL) into separate + cyg_libc_stdio_flush_all_but() function, which has the extra + capability of omitting one stream + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Add missing clibincl/stdiosupp.hxx include + + * src/stdio/common/stream.cxx (Cyg_StdioStream::read()): + When reading, ensure we flush all output streams + + * src/stdio/common/stream.cxx (Cyg_StdioStream::flush_output_unlocked): + Flush the device as well + +1999-04-15 Jonathan Larmour + + * src/stdio/common/streambuf.cxx (set_buffer): + * src/stdio/common/stdioinlines.cxx (_setbuf): + * src/clibincl/streambuf.inl: + * src/clibincl/streambuf.hxx: + * src/clibincl/stream.hxx (class Cyg_StdioStream): + * include/pkgconf/libc.h: + * include/stdio.inl (setbuf): + Fix dumb typo: BUFSIZE -> BUFSIZ + This fixes PR19837 + +1999-04-15 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx (_setbuf): + * include/stdio.inl (setbuf): + Use _IONBF when buf==NULL, and _IOLBF otherwise. + Fix for PR 19836 + +1999-04-15 John Dallaway + + * include/pkgconf/libc.h: Tidy display string capitalization. + +1999-04-12 Jonathan Larmour + + * include/pkgconf/libc.h: + Clarify CDL description of CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE + + * tests/signal/signal2.c: Try harder to generate an exception by + accessing a misaligned address + Don't handle SIGTRAP any more + Part of fix for PRs 19731/19607 + +1999-04-07 Jesper Skov + PR 19667 + * src/support/mainthread.cxx: + Changed to use the new Cyg_Thread constructor. + +1999-04-07 Hugo Tyson + + * tests/signal/signal2.c (main): Use new macro + HAL_VSR_SET_TO_ECOS_HANDLER if defined, to wrest control from + CygMon, for example, by reinstalling eCos' default VSRs for + exceptions that we are provoking. + +1999-03-29 Jonathan Larmour + + * src/signal/siginit.cxx: Include stdlib.h for exit() + Fix for PR 19720 + +1999-03-29 Jonathan Larmour + + * tests/time/clock.c (test): Disable instruction cache + Hopefully fixes PR 19308 + +1999-03-29 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for PPC as it cannot + trap division by zero. + +1999-03-26 Jonathan Larmour + + * src/support/main.cxx (main): Invoke cyg_user_start() if no kernel + Only sensible thing to do in our default main in a non-kernel config + +1999-03-25 Jonathan Larmour + + * tests/time/time.c: + Increase MAX_TIMEOUT since the sparclite gets very close to overrunning + it even when working. + Should return -1 iff CYGSEM_LIBC_TIME_TIME_WORKING isn't defined + Cosmetic changes + +1999-03-25 Hugo Tyson + + * tests/time/time.c (test): Take into account setting of + CYGSEM_LIBC_TIME_SETTIME_WORKING ie. does cyg_libc_time_settime() + work? If not, check that it returns an error. + This was exposed by the random combo in PR#19479. + +1999-03-23 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 to + CYGIMP_... + + Add another rand implementation CYGIMP_LIBC_RAND_SIMPLE1 which is + the default + + Part of fix for PR 19562 + + * include/sys/cstartup.h: + Tidy and remove unnecessary dependencies + + * src/stdlib/rand.cxx: + Rename algorithms from CYGSEM_... to CYGIMP_... + Add new "simple1" algorithm + + * tests/ctype/ctype.c: + Tidy + + * tests/stdlib/rand3.c: + Fix so that 0..RAND_MAX is split evenly over buckets, which it wasn't + before + Deal with case of RAND_MAX not being divisible by NUM_BUCKETS + exactly + Increase TEST_LENGTH to 200000 to provide more representative sample + Add CYG_TEST_INFO output to help ensure it doesn't time out + Tidy + + * tests/stdlib/rand4.c: + Only fail if more than _two_ thirds (rather than one third) match. + This is because half would match for a perfectly random distribution + This is the rest of the fix for PR 19562 + Cosmetic changes + +1999-03-22 Hugo Tyson + + * src/support/mainthread.cxx (CYGNUM_LIBC_MAIN_STACK_SIZE): + Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of + CYGNUM_HAL_MINIMUM_STACK_SIZE. + +1999-03-22 Jonathan Larmour + + * tests/PKGconf.mak: Add -Wno-format when building strftime otherwise + it generates warnings for things that we do want to test (null + string, and %y format) + +1999-03-19 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Put brackets back round negative number since sdf says the config + tool is fixed now (PR 19537) + + Add new CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 + options for different rand() algorithms in a so far failed attempt + to fix PR 19562 + + * src/stdlib/rand.cxx: + Add new optional algorithm from Knuth vol.2 + + * tests/stdlib/rand4.c: + Some tidies + Don't run test when using simplest algorithm + + * tests/signal/signal2.c (main): + Don't try to make an FPE on tx39 - its possible to detect but requires + too much HAL work to be sensible + +1999-03-18 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Use HAL_ENABLE_INTERRUPTS() rather than kernel to enable interrupts + +1999-03-18 Mark Galassi + + * tests/PKGconf.mak (TESTS): added rand4 compilation. + + * tests/stdlib/rand4.c: added this test for periodicity in the + least significant bit of rand(). + +1999-03-18 Jonathan Larmour + + * include/pkgconf/libc.h: Remove CYGFUN_LIBC_TIME_POSIX dependency + on CYGPKG_LIBC_STDIO + + * src/stdlib/itoa.cxx: + New file to convert integers to ascii + + * include/stdlib.h: + Add proto for new cyg_libc_itoa() function + + * include/time.inl: + Rework __asctime_r() to use memcpy() and cyg_libc_itoa() rather than + sprintf() + + * src/PKGconf.mak: + Build stdlib/itoa.cxx + + The above changes fix PR 19448 + +1999-03-17 Jonathan Larmour + + * include/time.h: Add #define of __time_t_defined to placate newlib + if it is used by accident. This is just a temporary workaround though. + +1999-03-16 Gary Thomas + + * src/PKGconf.mak: Add compile option to step around ARM compiler bug. + +1999-03-16 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Don't use parentheses for now + + * src/stdio/common/stream.cxx (refill_read_buffer): + Silence bogus compiler warning + +1999-03-16 Jesper Skov + + * tests/signal/signal2.c (main): Enable SIGSEGV test for + i386/Linux. + + +1999-03-15 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Only enable interrupts if they were disabled + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: + Add FIX ME line as a reminder that the workaround there can go away + in future + + * include/pkgconf/libc.h: + Add proper define for CYGSEM_LIBC_EXIT_CALLS_FFLUSH + Put brackets round negative CYGNUM_LIBC_TIME_DST_DEFAULT_STATE define + Fix run time typo + + * include/time.inl (__localtime_r): + Include sys/timeutil.h before this to get + cyg_libc_time_normalize_structtm() + +1999-03-12 Gary Thomas + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: Remove 'const' from char arrays since + this fails [silently] on ARM when -fwritable-strings (PR19440) + +1999-03-12 Jesper Skov + + * tests/signal/signal2.c (main): Compiler warnings fix was + slightly broken. + +1999-03-12 Jesper Skov + PR 19473 + * tests/signal/signal2.c (main): + Disabling SIGTRAP handling on i386/Linux is not a good idea. +1999-03-11 Jesper Skov + PR 19473 + * tests/signal/signal2.c: + Added compiler warnings fix. + Added N/A handling for i386/Linux. + +1999-03-10 Gary Thomas + + * include/pkgconf/libc.h: Force "haldiag" device to be present. + 'asctime' and friends need 'stdio' as well. + + * include/time.inl: Fix syntax error on difftime() declaration. + +1999-03-08 Gary Thomas + + * src/clibincl/stream.hxx: needed for this file. + + * src/stdio/common/vsscanf.cxx (str_read): Fix problem with string + pointer [created by merge with new I/O package]. + +1999-03-05 John Dallaway + + * include/pkgconf/libc.h: + Add legal values for CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET + and CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET. + +1999-03-05 Jonathan Larmour + + * include/time.inl (cyg_libc_time_year_is_leap): + Fix bug with modulo year 400 + Fix typo in asctime_r macro + Fix gmtime_r, and mktime as a result of testing + + * tests/time/asctime.c, tests/time/ctime.c, tests/time/gmtime.c, + tests/time/gmtime.c, tests/time/localtime.c, tests/time/mktime.c, + tests/time/strftime.c, tests/time/time.c: + New tests + + * tests/PKGconf.mak: + Build above new tests + + * include/pkgconf/libc.h: + Add reminder FIX ME about extra config option + + * src/time/strftime.cxx: + Fix %w and %Y parameters as a result of testing + + * src/time/timeutil.cxx: + Fix cyg_libc_time_normalize_structtm() as a result of testing + of mktime() + + * tests/time/clock.c: + Reformat, remove obsolete bits and tidy + + * include/time.h: + Add Cyg_libc_time_dst type and new functions + cyg_libc_time_setzoneoffsets(), cyg_libc_time_setdst(), + cyg_libc_time_getzoneoffsets(), cyg_libc_time_settime() + + * include/time.inl: + Implement the above functions. This allows us to adjust for timezone + diffences and set the time. + Change localtime() to adjust for STD/DST + Change mktime() to adjust for STD/DST + + * include/libc.h: + Add new config options CYGSEM_LIBC_TIME_SETTIME_WORKING + and component CYGPKG_LIBC_TIME_ZONES containing options + CYGNUM_LIBC_TIME_DST_DEFAULT_STATE, + CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET, + CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET + + * src/strftime.cxx: + Adjust handling of %Z to _not_ deal with STD/DST + + * src/time/settime.cxx: + New file to implement cyg_libc_time_settime() + + * src/PKGconf.mak: + Build settime.cxx + + * src/time/timeutil.cxx: + Supply outline versions of cyg_libc_time_setzoneoffsets(), + cyg_libc_time_setdst(), and cyg_libc_time_getzoneoffsets() + Add variables for STD/DST state + Some minor comment changes + + * include/errno.h: + Use CYGBLD_ATTRIB_CONST instead of __attribute__((const)) directly + + * include/signal.h: + Change format of function comment headers + + * include/signal.inl: + Restrict errno.h inclusion to when its actually used + Fix a spelling typo + + * include/stdlib.h: + Add CYGBLD_ATTRIB_CONST to abs, div, labs, ldiv + + * include/stdlib.inl: + Reformat and tidy + Include new versions of div and ldiv which are more portable and + are cleanly rewritten so aren't covered by the BSD licence, which + is now removed + + * src/stdlib/div.cxx, src/stdlib/ldiv.cxx: + Non-inline, non-BSD and portable versions of the new versions of div + and ldiv from stdlib.inl + + * include/time.h: + Much reformatting, tidying and improving comments + Change CLOCKS_PER_SEC from 1000 to 1000000 + Add new functions asctime_r, ctime_r, gmtime_r, localtime_r, clock, + difftime, mktime, time, asctime, ctime, gmtime, localtime, strftime + Include new time.inl file + + * include/pkgconf/libc.h: + Add new options CYGSEM_LIBC_TIME_CLOCK_WORKING, + CYGSEM_LIBC_TIME_TIME_WORKING, CYGFUN_LIBC_TIME_POSIX, + CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL, CYGIMP_LIBC_TIME_ASCTIME_INLINE, + CYGIMP_LIBC_TIME_CTIME_INLINE, CYGIMP_LIBC_TIME_DIFFTIME_INLINE, + CYGIMP_LIBC_TIME_GMTIME_INLINE, CYGIMP_LIBC_TIME_LOCALTIME_INLINE, + CYGIMP_LIBC_TIME_MKTIME_INLINE, CYGIMP_LIBC_TIME_ASCTIME_R_INLINE, + CYGIMP_LIBC_TIME_CTIME_R_INLINE, CYGIMP_LIBC_TIME_GMTIME_R_INLINE, + and CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE + + * time/asctime.cxx, time/asctime_r.cxx, time/clock.cxx, time/ctime.cxx, + time/ctime_r.cxx, time/difftime.cxx, time/gmtime.cxx, + time/gmtime_r.cxx, time/localtime.cxx, time/localtime_r.cxx, + time/mktime.cxx, time/strftime.cxx, time/time.cxx, time/timeutil.cxx, + include/time.inl: + New files to implement the new time functions. Many of them simply + provide the outline definitions, but the real body of the function + comes from time.inl + + * src/PKGconf.mak: + Build new .cxx files + + * src/clibincl/stdlibsupp.hxx: + Remove _div and _ldiv prototypes since they're no longer needed + + * src/clibincl/timesupp.hxx: + Delete as its now obsolete + + * src/time/clock.cxx: + Use new CYGSEM_LIBC_TIME_CLOCK_WORKING option to control whether it + just returns (clock_t)-1 or not. + Much reformatting and tidying + Change real imlpementation from _clock to __clock + Use CYGBLD_ATTRIB_WEAK_ALIAS now + + * tests/stdlib/div.c, tests/stdlib/ldiv.c: + Add some extra tests for handling of negative numbers + Reformat and tidy a bit, including removing the test for CYGPKG_LIBC + since its now always defined if the test is to be compiled + + * tests/time/clock.c: + Remove duplication CYG_TEST_INFO line + Check if unimplemented using "(clock_t)-1" and not just "-1" + +1999-03-04 Jonathan Larmour + + * src/stdlib/system.cxx: + Make sure system() is a weak alias for __system() + + * include/pkgconf/libc.h: Rework CDL description for + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE and change its default to + "/dev/haldiag" + + * src/stdio/common/stream.cxx: + Check that dev is valid when passed to stream constructor + + * src/stdio/common/stdiosupp.cxx: + Tidy + + * src/support/mainthread.cxx: Make this depend on + CYGSEM_LIBC_STARTUP_MAIN_THREAD rather than just CYGPKG_KERNEL + +1999-03-04 Gary Thomas + + Merged in changes from 'ecos-new_devs-19990216-branch' + + (1999-02-24 Jonathan Larmour ) + + * src/stdio/common/stream.cxx: + Add "fix me" comments and remove a couple of commented out lines + + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Revert to using pointer to string for private data, not just string. + This preserves the state across multiple calls + + (1999-02-24 Gary Thomas ) + + * src/stdio/common/vsscanf.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/stream.cxx: + * src/stdio/common/stdiosupp.cxx: + * src/stdio/common/fopen.cxx: + * src/clibincl/stream.inl: + * src/clibincl/stream.hxx: + * src/clibincl/stdiosupp.hxx: + * include/pkgconf/libc.h: Changes for new I/O system. + +1999-03-03 Jonathan Larmour + + * tests/stdlib/atexit.c: Forgot to config atexit test for + CYGFUN_LIBC_ATEXIT option + + * include/pkgconf/libc.h: + Require CYGVAR_KERNEL_THREADS_DATA for CYGSEM_LIBC_PER_THREAD_STRTOK + This fixes PR 19362 + Require CYGPKG_KERNEL for thread safe streams + Also don't need "requires CYGPKG_KERNEL" for per-thread rand and errno + if we already require a finer granularity kernel option + +1999-02-25 Jonathan Larmour + + * include/pkgconf/libc.h: Fix CYGNUM_LIBC_MAIN_STACK_SIZE by changing + CYGPKG_LIBC_STARTUP_MAIN_THREAD -> CYGSEM_LIBC_STARTUP_MAIN_THREAD + Fix for PR 19304 + +1999-02-23 Jonathan Larmour + + * src/stdlib/system.cxx: Add to implement trivial system() call + * include/stdlib.h: Add system() prototype + * src/PKGconf.mak: Build system.cxx + + * tests/ctype/ctype.c, tests/i18n/setlocale.c, tests/setjmp/setjmp.c, + tests/signal/signal1.c, tests/signal/signal2.c, + tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdio/stdiooutput.c, tests/stdlib/atexit.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/getenv.c, tests/stdlib/labs.c, + tests/stdlib/ldiv.c, tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/realloc.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + Use CYG_TEST_NA() macro for non-applicable test configurations + +1999-02-20 Jonathan Larmour + + * include/signal.h: + * include/signal.inl: + * src/signal/raise.cxx: + * src/signal/siginit.cxx: + * src/signal/signal.cxx: + * tests/signal/signal1.c + * tests/signal/signal2.c: + New files to implement ISO standard signals + + * src/PKGconf.mak (TESTS): + * tests/PKGconf.mak (TESTS): + Update to build new files above + + * include/stdlib.h: + * src/clibincl/stdlibsupp.hxx: + Comment and QA changes (including giving better names to some types) + + * include/libc.h: + Add new configuration options for signals + Add new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + Add a note to CYGNUM_LIBC_MAIN_STACK_SIZE option that it may be + overriden by HAL + Add new CYGFUN_LIBC_ATEXIT option and move ...ATEXIT_HANDLERS under + it + Add new CYGSEM_LIBC_EXIT_CALLS_FFLUSH option + Require CYGSEM_LIBC_STARTUP_MAIN_THREAD for "Invoke default static + constructors" option + + * src/stdlib/atexit.cxx: + Support above CYGFUN_LIBC_ATEXIT and QA changes + + * src/stdlib/exit.cxx: + Support for above new libc.h options, and some QA changes + + * src/support/cstartup.cxx: + Add support for new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + + * src/support/mainthread.cxx: + Override main stack size if the HAL has a minimum + + * src/string/strncpy.cxx: + Use improved algorithm for aligned copies - imported from newlib + QA changes + + * src/stdlib/abort.cxx: + Support raise(SIGABRT), and some QA + + * include/errno.h: + Add const attribute + + * tests/stdlib/abs.c: + QA improvements + +1999-02-04 Jesper Skov + + * src/support/cstartup.cxx: Only define cyg_libc_main_thread when + the kernel is around. + +1999-02-01 Jesper Skov + + * tests/time/clock.c: Joined the two test/NOP checks into + one. + Increased tolerance in attempt to fix PRs 18737,18787,18846. + Fixed typo. + +1999-01-28 Jonathan Larmour + + * src/string/strtok.cxx: + * src/stdlib/rand.cxx: + Include if we use kernel header files + +1999-01-25 Jonathan Larmour + + * tests/stdio/sscanf.c (test): + CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT should be + CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + Fix for PR 18786 + + * src/string/strtok.cxx: + * src/stdio/common/stdiofiles.cxx: + * src/errno/errno.cxx: + * src/stdlib/rand.cxx: + Give mutex protection objects a libc constructor priority + + * src/support/invokemain.cxx: + Add prototype for cyg_hal_invoke_constructors() + + * src/support/mainthread.cxx: + Give cyg_libc_dummy_constructor_obj a libc constructor priority, + and make its class have a public constructor + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/stdin.cxx: + Give cyg_libc_stdio_stdin/out/err static objects a libc constructor + priority + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + * src/clibincl/stream.hxx (class Cyg_StdioStream): + Remove private copy constructor. Needed to make prioritised + static constructors work. Fix for PR 18898 + +1999-01-22 Jonathan Larmour + + * src/errno/errno.cxx: + Include pkgconf/kernel.h otherwise it fails with per-thread errno + enabled + + * include/pkgconf/libc.h: + Enable per-thread errno by default since that is what POSIX would + want + + * tests/time/clock.c (test): + Placate compiler by initializing clock_first/second/third anyway, + even though they won't be in practice. This is only a test program + so adding an extra instruction doesn't matter. + + * src/i18n/locale.cxx (_setlocale): + Placate compiler, since it is dumb, by nesting, not serializing, if's + This is an idempotent change, but screws up the formatting :-(. + + * src/string/strpbrk.cxx (_strpbrk): + Change while loop to do loop to placate compiler. It'll even save an + instruction too (wow!) + +1999-01-22 John Dallaway + + * include/pkgconf/libc.h: + Add closing curly brace to CYGPKG_LIBC_STRING_STRTOK definition + +1999-01-21 Jonathan Larmour + + * include/errno.h: + Tidy up and add to header description + Change cyg_get_errno_p() to cyg_libc_get_errno_p() + Remove ifdef CYGPKG_LIBC + + * include/sys/file_if.h: + Remove - move contents to stdio.h + + * include/stdio.h: + Tidy up header description + Move FILE typedef here from sys/file_if.h + SEEK_SET, SEEK_CUR, SEEK_END defined to 0, 1, 2 respectively + for backwards compatibility with old UNIX + Change definitions of stdin/out/err to be addresses of FILE + globals - even though they're actually Cyg_StdioStream it'll work + + * include/pkgconf/libc.h: + Make CYGPRI_LIBC_WEAK et al macros depend on new ones in infra + Reorganise trace options under the individual components they are + associated with. + Reorganise thread-safety options under the individual components + they are associated with. + Add new CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS option + Misc. reformatting + Remove dependency on pkgconf/kernel.h - Configuration Tool will + generate check macros anyway. + Remove CYGPKG_LIBC_TRACE, CYGFUN_LIBC_strtok, CYGPKG_LIBC_RAND + options + Tidy up description header + + * src/clibincl/clibdata.hxx: + * src/clibincl/clibdata.inl: + * src/support/clibdata.cxx: + Remove and instead rely on each component to initialise its own data + + * src/clibincl/stdiofiles.hxx, src/clibincl/stdiofiles.inl: + New files to contain global file list and lock (if applicable). + Implemented as class with member access functions + + * src/errno/errno.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Rename cyg_get_errno_p() to cyg_libc_get_errno_p() + + * src/stdio/common/fclose.cxx: + * src/stdio/common/fflush.cxx: + * src/stdio/common/fopen.cxx: + * src/stdio/common/freopen.cxx: + Remove ifdef CYGPKG_LIBC + Use new global file access method from stdiofiles.hxx + Tidy up description header + Use new CYGBLD_ATTRIB_WEAK_ALIAS + Access errno "normally" rather than clibdata way + + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx + * src/stdio/common/stderr.cxx: + New files. Implement Cyg_StdioStream objects for each stream. In + separate self-contained files so using one doesn't bring in the + others + + * src/stdio/common/stdiofiles.cxx: + New file. Implements global files array and lock + + * src/stdlib/_exit.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Use infra CYGBLD* macros + + * src/stdlib/malloc.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Add pkgconf/kernel.h now that pkgconf/libc.h doesn't have it + Use infra CYGBLD* macros + Make pool visible externally with weak attribute and new name + cyg_libc_malloc_memorypool + + * src/stdlib/rand.cxx: + * src/stdlib/strtok.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Use infra CYGBLD* macros + + * src/support/cstartup.cxx: + Split into smaller files to make selective linking work better, + fix i386 port problem and make GDB happy + + * src/support/environ.cxx: + * src/support/invokemain.cxx: + * src/support/main.cxx: + * src/support/mainthread.cxx: + New files from bits of the old cstartup.cxx + Add support for CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG + + * src/PKGconf.mak: + Update to reflect file additions/deletion + + * tests/stdlib/rand1.c: + * tests/stdlib/rand2.c: + * tests/stdlib/rand3.c: + * tests/stdlib/srand.c: + Make conform to coding standards + Remove ifdef CYGPKG_LIBC_RAND + Tidy up description header + + * tests/string/strtok.c: + Make conform to coding standards + Remove ifdef CYGFUN_LIBC_strtok + Tidy up description header + +1999-01-15 Mark Galassi + + * tests/stdlib/getenv.c (main): added tests for the case in which + the user does not supply environ and in which the user supplies a + NULL environ. + +1999-01-15 Jesper Skov + + * src/support/cstartup.cxx: Added workaround for weak aliasing + problem in i386 gcc. + + +1999-01-15 Gary Thomas + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_STACK_SIZE): + (CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE): Change defaults to be + more reasonable on small systems. + +1999-01-04 Jonathan Larmour + + * src/support/clibdata.cxx: + Minor bug with environ not being initialised correctly by + default + +1998-12-24 Bart Veer + + * src/clibincl/stream.inl (Cyg_StdioStream): + check_this() member functions should now be const + +1998-12-22 Jonathan Larmour + + * src/string/memchr.cxx (_memchr): + treat search value parameter to memchr as an unsigned byte, + not a signed int - copied fix from newlib PR 18471 + +1998-12-21 Jonathan Larmour + + * tests/stdlib/realloc.c: + * tests/stdlib/malloc3.c: + * tests/stdlib/malloc2.c: + Warning cleanup + +1998-12-14 Jonathan Larmour + + * tests/stdlib/malloc2.c, tests/stdlib/malloc3.c, + tests/stdlib/realloc.c: + Only run these tests when we have a coalescing memory allocator + +1998-12-14 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Only check buffer init success if buffering + + * src/stdio/common/streambuf.cxx (set_buffer): + Check for diff of requested size against buffer_size, not + get_buffer_size(), since this may return -1, which won't be + equal to size, and will cause malloc to be called + +1998-12-01 Jesper Skov + + * tests/stdlib/getenv.c (main): Don't declare variables when they + are not used. + +Thu Nov 26 17:59:12 1998 Jonathan Larmour + + * tests/string/strncpy1.c: + Fix off-by-one error since it called my_strcmp() and not + my_strncmp(), which meant in included the trailing NULL when it + shouldn't have. + +1998-11-26 Jesper Skov + + * src/stdlib/qsort.cxx (_qsort): + * src/stdlib/rand.cxx (_srand): + Changed CYG_REPORT_FUNCNAMETYPE to CYG_REPORT_FUNCNAME in void + functions. + +Mon Oct 26 18:49:00 1998 Jonathan Larmour + + * src/support/cstartup.cxx (cyg_libc_dummy_main): + Silence compiler warning with cast of char * to CYG_ADDRWORD + +Wed Oct 28 17:31:21 1998 Jonathan Larmour + + * src/time/clock.cxx (_clock): + Reorder scaling expression as it was both incorrect and risked + overflow. + Fix for PR 18076 + +Mon Oct 19 14:40:06 1998 Jonathan Larmour + + * include/stdio.h (EOF): + Change from -64 to (-1), to allow broken code to work :-/ + Also change other negative defines to be within parentheses + +1998-10-19 Mark Galassi + + * include/pkgconf/libc.h: updated the doc URL + +Thu Oct 15 21:33:44 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Only include kernel thread headers when we're in thread-safe mode + + * src/time/clock.cxx: + Only include kernel clock headers if there's a kernel with the + right functionality available + + * tests/time/clock.c: + Remove unnecessary inclusion of + + Above changes are required for PR 17229 + +Wed Oct 14 16:38:55 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise inclusion of clibincl/stdiosupp.hxx and + clibincl/stream.hxx. Tidying up PR 17502 + +Wed Oct 14 14:08:56 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGPKG_LIBC_STRING_OPTIMISATIONS to + CYGPKG_LIBC_STRING_OPTIMIZATIONS to make it truely merkin. + +Tue Oct 13 19:34:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_ARGUMENTS): + Add a default argv[0] of "" as many programs assume argc>0 + The standard allows argv[0] to be "" if the program name + is not available + +1998-09-26 Bart Veer + + * src/clibincl/stdiosupp.hxx: + PR 17502: this header file now does nothing if the stdio option + is disabled completely. This is the same behaviour is + clibincl/stream.hxx, although arguably the #ifdef protection + should happen wherever the header file is #include'd rather than + in the header file itself. + + * src/clibincl/clibdata.hxx: + PR 17502: this header file still #include's internal stdio-related + header files and references the FILE structure, even if stdio is + disabled. There were some #ifdef's for CYGPKG_LIBC_STDIO already. + One more has been added for _fopen() and _fclose(). + +1998-09-25 Bart Veer + + * src/clibincl/streambuf.inl (Cyg_StdioStreamBuffer): + PR 17487: Reorder the calls to initialize member fields, to + eliminate a compiler warning. + +Fri Sep 25 19:04:29 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/string/strtok.cxx, + src/time/clock.cxx: + Only define tracing variable and tracing level macro when + the relevant tracing level config options are set. Otherwise + keep the tracing level fixed at 0 + Fix for PR 17476 + + * include/pkgconf/libc.h: + Define trace levels only if parent CYGPKG_LIBC_TRACE is defined + for consistency with Configuration Tool + + +Fri Sep 25 17:24:45 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Make definition of vscanf() dependent on CYGFUN_LIBC_STDIO_ungetc + otherwise _vfscanf() won't be compiled. This therefore would + cause a link fail iff selective linking is not enabled. + Fix for PR 17455 + +Fri Sep 25 17:23:17 1998 Jonathan Larmour + + * src/stdlib/rand.cxx: + Make compilation dependent on CYGPKG_LIBC_RAND + Fix for PR 17473 + + * tests/stdlib/srand.c: + Make definition of dummy test pass conditional on CYGPKG_LIBC_RAND + not being defined, as well as CYGPKG_LIBC + Caused compilation failure when testing PR 17473 fix + +Mon Sep 21 17:11:04 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Make sscanf test conditional on CYGFUN_LIBC_STDIO_ungetc since + _vfscanf() only gets compiled if this is defined + Fix for PR 17346 + +1998-09-20 Mark Galassi + + * include/pkgconf/libc.h: updated CDL doc strings. + +Fri Sep 18 22:18:47 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_errno_p): + Rather than this function only being available in thread-safe mode, + instead make what it returns be either the per-thread errno, or + global errno depending on the configuration. + Include (conditionally) to support this change + +Wed Sep 16 11:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove "fix me" comment which I forgot to remove before + +Tue Sep 15 19:27:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Updated descriptions and a few other minor things after review. + Notably though, the NDEBUG config option has been removed + +1998-09-15 Bart Veer + + * include/pkgconf/libc.h: + PR 17201: removed dependency on CYGPKG_KERNEL in the option + CYGNUM_LIBC_MAIN_STACK_SIZE, since the actual dependencies cannot + be expressed sensibly in the current system. + +1998-09-11 Bart Veer + + * include/pkgconf/libc.h: + Sorting out dependencies for error package. + +1998-09-10 Mark Galassi + + * include/pkgconf/libc.h: started adding doc fields to the + cdl_package data, as a pilot for now. + +Wed Sep 9 17:41:23 1998 Hugo Tyson + + * include/pkgconf/libc.h: + Add option CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE to explicitly + control whether the empty delete functions (currently) in + kernel/.../common/delete.cxx are enabled; controls code bloat, see + the comments in delete.cxx. + +Fri Sep 4 16:43:38 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add a default CYG_TEST_PASS() to make sure the test infra doesn't + complain. + Also remove the unused string functionsa + +Fri Sep 4 15:43:48 1998 Hugo Tyson + + * src/stdlib/exit.cxx (__libc_exit): + * src/stdlib/_exit.cxx (__libc__exit): + * src/stdlib/malloc.cxx (_free): + * src/stdlib/abort.cxx (abort): + * src/support/cstartup.cxx (invoke_main): + Tracing system asserted cos it was being called incorrectly; these + are void functions so you shouldn't give a type to the function + reporting call. + +Fri Sep 4 15:03:10 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Fix CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE description to refer to + the table.cxx file, not table.h + +Fri Sep 4 14:38:52 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add description for CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE since + Proven won't be making any changes to the device driver + implementation after all. + Fix for PR 17148 + + * src/clibincl/stream.inl (set_position): + Remove "fix me" line. It is obvious that this will have to change + with a filesystem interface + Fix for PR 17147 + + * src/stdio/common/freopen.cxx: + Remove "fix me" - I know about this issue + Fix for PR 17145 + + * src/stdio/common/stream.cxx (read): + Remove "fix me" and change to use memcpy + Fix for PR 17144 + +Fri Sep 4 14:36:47 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Actually add it this time! + +Fri Sep 4 13:48:13 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add new tests for misc stdio output functions + + * tests/PKGconf.mak: + Build stdiooutput.c test + +Fri Sep 4 12:52:10 1998 Jonathan Larmour + + * src/clibincl/stream.inl (write_byte): + Remove bogus assert + + * tests/stdlib/getenv.c (main): + Check whether str is NULL before doing a strcmp() + + * tests/stdio/sprintf2.c (main): + Reformat to 76 columns + +Fri Sep 4 02:10:54 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/stdio/common/stream.cxx: + Add new peek_byte method to Cyg_StdioStream + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix up buffer access to work with new peek_byte method above + Fix for PR 16954 + +Thu Sep 3 19:40:11 1998 Jonathan Larmour + + * tests/stdlib/rand1.c, tests/stdlib/rand2.c, + tests/stdlib/rand3.c: + Add extra check for CYGPKG_LIBC_RAND to decide whether the test + is applicable or not + + * tests/stdlib/rand2.c (test): + Use CYGNUM_LIBC_RAND_SEED for default seed, not 1 + + * tests/string/strtok.c: + Add extra check for CYGFUN_LIBC_strtok to decide whether the + test is applicable or not + +Wed Sep 2 19:11:40 1998 Jonathan Larmour + + * src/stdio/input/fread.cxx, src/stdio/output/fwrite.cxx: + Add fread() and fwrite() functions + + * src/PKGconf.mak: + Build fread.cxx and fwrite.cxx from above + + * src/stdio/common/stream.cxx: + Reformat to 76 columns + In write(), move initialisation of *bytes_written to start + In read(), move initialisation of *bytes_read to start + + * include/stdio.h: + Reformat to 76 columns + + Replace all references to the ANSI + standard to instead by the ISO C standard + + Add commented argument names for "documentation" + + Add fread() and fwrite() prototypes + + * src/clibincl/stdiosupp.hxx: + Copy the above changes from stdio.h, and add _fread() and _fwrite() + prototypes + + * src/stdio/output/fputs.cxx, src/stdio/input/fgets.cxx: + Reformat to 76 columns + +Wed Sep 2 15:41:15 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Reformat to 76 columns + +Wed Sep 2 14:46:18 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Use trylock_me() instead of lock_me(), and loop to prevent + deadlocks + + * src/clibincl/stream.hxx, src/clibincl/stream.inl: + Add trylock_me() method + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/fflush.cxx: + Reformat to 76 columns + +Wed Sep 2 12:24:27 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change 0x7fff to 0x7fffffff. Oops! + give main stack size option a legal_values field + Undefine tracing by default + Add some more description in the header + +Tue Sep 1 20:02:07 1998 Jonathan Larmour + + * tests/i18n/setlocale.c (cyg_package_start): + Fix typo - extra "x" for no reason at all! :-) + +Tue Sep 1 19:44:58 1998 Jonathan Larmour + + * src/i18n/locale.cxx: + Fix bug in find_locale_data() that miscalculated size of + all_locales + + Make find_locale_data() match the locale "" and add some + other things in _setlocale() to ensure that "C" gets returned + when the default locale "" is passed. + + Only check the locale pointer when it is non-NULL + + * tests/i18n/setlocale.c: + New tests for setlocale() + + * tests/PKGconf.mak: + Update to build setlocale.c test + + * src/support/cstartup.cxx: + Don't actually call system default main() "main" otherwise GDB + gets confused and thinks its the entry point. Instead make a weak + alias and call the real function something different. + +Tue Sep 1 18:31:42 1998 Jonathan Larmour + + * src/i18n/locale.cxx (_setlocale): + Fix tracing macro name and remove "str maybe used before + initialised" warning + + * tests/stdlib/qsort.c: + Correct file description header + +Tue Sep 1 17:04:32 1998 Jonathan Larmour + + * include/locale.h, src/clibincl/i18nsupp.hxx, src/i18n/locale.cxx: + New files to add support for locales as defined by the ISO C + standard. i.e. setlocale() and localeconv() functions and some + other bits + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAX_LOCALE_NAME_SIZE config option for locale + support + + * src/PKGconf.mak: + build locale.cxx + + * include/errno.h, src/clibincl/ctypesupp.hxx: + Tidy up to 76 columns + +Tue Sep 1 00:24:22 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Move environment-related options from stdlib into new + CYGPKG_LIBC_STARTUP component. Also add options for main()'s + arguments (CYGPKG_LIBC_ARGUMENTS), main()'s default stack size + (CYGNUM_LIBC_MAIN_STACK_SIZE), number of atexit handlers + (CYGNUM_LIBC_ATEXIT_HANDLERS), and whether _exit() stops the + system (CYGSEM_LIBC_EXIT_STOPS_SYSTEM). + + * src/clibincl/stdlibsupp.hxx: + Fix a few comment bugs, and add new + cyg_libc_invoke_atexit_handlers() function prototype + + * src/stdlib/_exit.cxx, src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Implement exit(), atexit() and _exit() correctly now. Also + includes cyg_libc_invoke_atexit_handlers() in atexit.cxx. Now + we get the correct behaviour of atexit(), and exit() invokes the + atexit handlers and fflushs all the stdio streams. Add plenty of + tracing of asserts too. + + * src/support/cstartup.cxx: + Make main_thread object an exported global. Allow user-settable + arguments. Add MUCH more tracing and asserts. Improve comments. + Tidy up to 76 columns + + * tests/stdlib/atexit.c: + Add simple test for atexit() and it calling registered functions + + * tests/PKGconf.mak: + Build atexit.c test + +Mon Aug 31 18:54:48 1998 Jonathan Larmour + + * src/stdlib/getenv.cxx, tests/stdlib/getenv.c: + Add support for getenv(), and some tests to ensure it works + + * src/PKGconf.mak, tests/PKGconf.mak: + Update to include getenv.cxx and getenv.c test + + * src/clibincl/clibdata.hxx: + remove prototype for environ - we expect files needing it to + define it themselves + + * src/support/clibdata.cxx: + Tidy up to 76 columns and add definition of char **environ, but + with a configurable initialiser (see libc.h below) + + * tests/stdlib/abs.c (main): + Tidy up to 76 columns + + * src/stdlib/malloc.cxx: + Tidy up to 76 columns and remove warning for undefined _memcpy() + by changing to memcpy(), and casting away signedness + + * include/pkgconf/libc.h: + Add CYGPKG_LIBC_ENVIRONMENT and CYGDAT_LIBC_DEFAULT_ENVIRONMENT + configuration options + + * include/pkgconf/libc.h, src/clibincl/clibdata.hxx: + Tidy up to 76 columns + + * include/stdlib.h: + Add getenv() prototype and tidy up to 76 columns + + * src/clibincl/stdlibsupp.hxx: + Add _getenv() prototype + +Mon Aug 31 13:37:08 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Add realloc() + + * tests/stdlib/realloc.c: + Add this file to test new realloc() functionality + + * tests/PKGconf.mak: + Build realloc test + + * tests/stdlib/malloc3.c (main), tests/stdlib/malloc2.c (main), + tests/stdlib/malloc1.c (main): + Conditionalise local vars to prevent warnings + + * tests/stdlib/malloc3.c (fill_with_data): + Move '{' into "verb" line + + * include/pkgconf/libc.h: + Require infra tracing support to allow tracing + + * include/stdlib.h: + Add realloc() + + * src/clibincl/stdlibsupp.hxx: + Update the commented argument names from stdlib.h, including realloc() + +1998-08-28 Bart Veer + + * include/pkgconf/libc.h: + * src/clibincl/clibdata.hxx, src/time/clock.cxx: + + Updated for new kernel configuration option symbol names + +Fri Aug 28 19:18:25 1998 Hugo Tyson + + Changed the entry below to sat "tx39" instead of "mn10300". + It's been a long week. + +Fri Aug 28 18:59:20 1998 Hugo Tyson + + * src/support/cstartup.cxx: Add a weakly named main to allow the + default configuration to link on the tx39 which has no + scalextric linking yet. The static Cyg_Thread main_thread object + below continues to exist, though unreferenced, so all its + descendants must exist too. + +Fri Aug 28 08:54:29 1998 Jonathan Larmour + + * include/stdlib.h: + Add commented argument names Add exit(), and atexit(). And move + these along with abort() and _exit() to a new section. + + * src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Add trivial versions of atexit() and exit() + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAIN_STACK_SIZE config option + + * include/sys/cstartup.h, src/support/cstartup.cxx, src/PKGconf.mak: + New files to provide a new function cyg_iso_c_support(), which + invokes main "correctly". + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/srand.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcoll2.c, tests/string/strcpy1.c, + tests/string/strcpy2.c, tests/string/strcspn.c, + tests/string/strlen.c, tests/string/strncat1.c, + tests/string/strncat2.c, tests/string/strncpy1.c, + tests/string/strncpy2.c, tests/string/strpbrk.c, + tests/string/strrchr.c, tests/string/strspn.c, + tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, + tests/time/clock.c: + + Modify all tests to use new startup mechanism, and cyg_iso_c_start() + +Fri Aug 28 00:29:38 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Add #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO around all accesses to + flags.last_buffer_op_was_read. Fix for PR 16997 + +Thu Aug 27 01:12:42 1998 Jonathan Larmour + + * include/sys/file_if.h: + Fix comments and remove cyg_get_file_star() + +Wed Aug 26 20:24:32 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove #define CYGPKG_LIBC is that is meant to live in + after all + +Wed Aug 26 19:39:23 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + More fixes to CDL stuff to make it work better, and look better on + the screen + +Tue Aug 25 20:21:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Make some fixes after running the ConfigTool + +Tue Aug 25 16:46:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_STDIO_BUFSIZE): + Fix typo of CYGNUM_LIBC_STDIO_BUFSIZE + +Tue Aug 25 15:10:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Tidy up CDL stuff a bit more, prior to checking it actually works. + +Tue Aug 25 11:38:52 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c (main): + Prevent calls to CYG_TEST_STILL_ALIVE for now + +Tue Aug 25 05:39:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change cosmetic paragraph alignment. + +Tue Aug 25 03:11:34 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Make stderr initialise with buffer size 0. + For PR 16955 + +Mon Aug 24 17:38:46 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + First pass at CDL-ifying the C library configuration. Currently + deliberately disabled as there a few outstanding issues. + +Mon Aug 24 16:14:22 1998 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx (_vfnprintf): + clear up warning for unused argument + + * tests/stdlib/malloc2.c (NUM_ITERATIONS): + Lower to 100 from 50000 so it won't take too long under the simulator + +Thu Aug 20 17:48:43 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Remove now unnecessary inclusion of kernel/ktypes.h + +Wed Aug 19 19:19:14 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, + tests/stdio/sscanf.c, tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, + tests/stdlib/strtoul.c, tests/string/strtok.c, + tests/time/clock.c: + Add parameters to "main()" to silence warnings + +Wed Aug 19 18:52:59 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx (refill_read_buffer): + Put conditional error check into same #ifdef and if as what was being + checked in the first place! + +Wed Aug 19 18:49:19 1998 Jonathan Larmour + + * src/clibincl/stream.inl: + Reorder Cyg_StdioStream::check_this() to be first to silence + warnings + +Tue Aug 18 16:10:03 1998 Jonathan Larmour + + * ecc/language/c/libc/current/src/clibincl/clibdata.hxx, + ecc/language/c/libc/current/src/errno/errno.cxx, + ecc/language/c/libc/current/src/stdio/common/fopen.cxx, + ecc/language/c/libc/current/src/stdlib/rand.cxx, + ecc/language/c/libc/current/src/string/strtok.cxx: + Rename CYGIMP_LIBC_INTERNAL_DATA_PREAMBLE, + CYGIMP_LIBC_INTERNAL_DATA_ALLOC_CHECK_PREAMBLE, + CYGVAR_LIBC_INTERNAL_DATA, and + CYGIMP_LIBC_INTERNAL_DATA_CHECK to all have CYGPRI_ prefix instead + as recommended by the config name rules + + +Tue Aug 18 14:31:19 1998 Jonathan Larmour + + * src/stdio/common/setvbuf.cxx (_setvbuf): + Rename variable names in assert line, otherwise doesn't build + with asserts on! + +Sun Aug 16 18:15:12 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix some bugs, although there are some left to fix still. Unrelated + to the rest of the checkins, so I will check the partial fix in now. + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx: + Add parameters to constructor to allow more things to be done at + construction time. + + Now we have "new", remove separate "construct" method + + Add more documentation on constructor + + As requested by code review, where possible, move boolean flags + into separate packed bitfield structure for space efficiency + + Make readbuf_char be usable all the time rather than when configured + not to be buffering, as it is also needed for non-buffered mode i.e. + _IONBF + + * src/stdio/common/fopen.cxx: + Change to use new method of construction from above, using new + + Use thread-specific data, rather than global. And so change errnos + to access errno entry specifically + + Make process_mode() check for append mode too + + Reformat for coding standards to have { in same line as "verb" + + * src/stdio/common/setvbuf.cxx: + + Change to cope with different way of dealing with buffering policy + flags etc. in Cyg_StdioStream + + * src/stdio/common/vsnprintf.cxx, src/stdio/common/vsscanf.cxx, + src/support/clibdata.cxx: + Change construction of streams to use new parameters added above, + and change to use _IONBF mode for string stdio functions, + otherwise its a waste of memory. And use _IONBF for stderr as the + ISO standard tells us to! + + Reformat for coding standards to have { in same line as "verb" + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Change constructor so that it can be set with default size and + dynamic buffer (if applicable) + + Fix minor bug in destructor - should only call free when allocated + dynamically + + Change get_buffer_size to return -1 if the buffer was not allowed + to be set up + + * src/stdio/common/streambuf.cxx: + Remove unnecessary stdio.h include and add extra comment to whether + to free bit in set_buffer() + + * src/stdio/common/freopen.cxx: + Change @@@ to standard fix me string + + * src/stdio/output/fputc.cxx: + Remove unnecessary "written" variable + +Thu Aug 13 15:37:28 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: + Included use of "fix me" line to ensure this is discussed before + release + + * include/stdlib.h, src/stdlib/abort.cxx, src/PKGconf.mak: + Add abort.cxx to implement abort(), albeit naively + +Thu Jul 30 18:03:09 1998 Jonathan Larmour + + * src/stdio/common/vsscanf.cxx (_vsscanf), + src/stdio/common/vsnprintf.cxx (_vsnprintf): + Fix initialiser of pseudo string device table that didn't get updated + when the table changed (Bad proven, no biscuit). + + * src/clibincl/stream.inl (~Cyg_StdioStream): + Move invalidation of magic_validity_word to after unlock_me(), + otherwise it always fails! + +Tue Jul 28 21:29:53 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Shorten over-long lines + +Tue Jul 28 20:28:23 1998 Jonathan Larmour + + * src/clibincl/stream.hxx (class Cyg_StdioStream), + src/clibincl/stream.inl, src/stdio/common/stream.cxx: + Clarify some comments and get the CYGDBG_DEFINE_CHECK_THIS and + CYG_ASSERTCLASS stuff going + + * src/clibincl/stream.inl: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 15:31:06 1998 Jonathan Larmour + + * src/clibincl/streambuf.inl, src/stdio/common/streambuf.cxx: + Move set_buffer() from streambuf.inl to new file streambuf.cxx + + * src/PKGconf.mak (COMPILE): + Build new file streambuf.cxx + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + Add METHODS comment + + * src/stdio/common/stream.cxx: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 00:26:36 1998 Jonathan Larmour + + * include/stdlib.inl, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/div.cxx, + src/stdlib/ldiv.cxx, src/stdlib/qsort.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/string/strtok.cxx: + + Include proper Berkeley license inline in the file, rather than + referring to an external file + + * doc/COPYING.UCB: + Remove, now that it isn't referred to any more + +Mon Jul 27 23:34:26 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl, include/errno.h, + include/stdio.h, include/stdio.inl, include/stdlib.h, + include/stdlib.inl, include/string.h, include/string.inl, + include/time.h, include/sys/file_if.h, src/PKGconf.mak, + src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/stdiosupp.hxx, + src/clibincl/stream.hxx, src/clibincl/streambuf.hxx, + src/clibincl/streambuf.inl, src/clibincl/stringsupp.hxx, + src/clibincl/timesupp.hxx, src/ctype/isalnum.cxx, + src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, + src/ctype/islower.cxx, src/ctype/isprint.cxx, + src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, + src/ctype/tolower.cxx, src/ctype/toupper.cxx, + src/errno/errno.cxx, src/stdio/common/snprintf.cxx, + src/stdio/common/sprintf.cxx, src/stdio/common/sscanf.cxx, + src/stdio/common/stdioinlines.cxx, src/stdio/common/stream.cxx, + src/stdio/common/ungetc.cxx, src/stdio/common/vsnprintf.cxx, + src/stdio/common/vsscanf.cxx, src/stdio/input/fgetc.cxx, + src/stdio/input/fgets.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/gets.cxx, src/stdio/input/scanf.cxx, + src/stdio/output/fnprintf.cxx, src/stdio/output/fprintf.cxx, + src/stdio/output/fputc.cxx, src/stdio/output/fputs.cxx, + src/stdio/output/printf.cxx, src/stdlib/_exit.cxx, + src/stdlib/abs.cxx, src/stdlib/atof.cxx, src/stdlib/atoi.cxx, + src/stdlib/atol.cxx, src/stdlib/div.cxx, src/stdlib/labs.cxx, + src/stdlib/ldiv.cxx, src/stdlib/rand.cxx, src/stdlib/strtod.cxx, + src/string/memchr.cxx, src/string/memcmp.cxx, + src/string/memmove.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, + src/string/strcoll.cxx, src/string/strcpy.cxx, + src/string/strcspn.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx, src/string/strpbrk.cxx, + src/string/strrchr.cxx, src/string/strspn.cxx, + src/string/strstr.cxx, src/string/strsuppt.cxx, + src/string/strtok.cxx, src/string/strxfrm.cxx, + src/support/clibdata.cxx, src/time/clock.cxx: + Untabify + +Mon Jul 27 23:14:18 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/stdlib/malloc.cxx, src/stdlib/qsort.cxx, + tests/ctype/ctype.c, tests/stdlib/rand3.c, tests/stdlib/malloc3.c: + Remove all mentions of "register" in variable declarations. Also + untabify where needed + + * src/stdlib/bsearch.cxx: + Untabify this too + + +Mon Jul 27 22:18:51 1998 Jonathan Larmour + + * src/stdio/output/fputc.cxx (_fputc): + Replace call to stream write() with call to write_byte() + + * src/clibincl/stream.inl (write_byte): + Add asserts for stream write() returning odd values for how much has + been written + + (bytes_available_to_read): + Remove "register" def for variable declaration + +Mon Jul 27 22:06:22 1998 Jonathan Larmour + + * src/stdio/common/stdiosupp.cxx: + Remove #if 0'd cyg_get_file_star() and unnecessary pseudo string + device definition + +Mon Jul 27 21:57:25 1998 Jonathan Larmour + + * include/pkgconf/libc.h, src/support/clibdata.cxx: + Change CYGXXX_LIBC_STDIO_DEFAULT_CONSOLE to + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE + +Mon Jul 27 21:49:23 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/setjmpsupp.hxx, + src/clibincl/stdiosupp.hxx, src/clibincl/stdlibsupp.hxx, + src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl, + src/clibincl/stringsupp.hxx, src/clibincl/timesupp.hxx: + + Change CYGONCE_LIBC_*_{HXX,INL} to CYGONCE_LIBC_CLIBINCL_*_{HXX,INL} + +Mon Jul 27 21:34:05 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change #define XXXXX 1 to #define XXXXX where applicable as per code + review + + Also remove obsolete CYGIMP_LIBC_THREAD_START_SUSPENDS_SELF + +Mon Jul 27 19:42:27 1998 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): + Use #ifdef, not #if for config options + +Mon Jul 27 15:01:51 BST 1998 Chris Provenzano + + * src/stdio/common/stream.cxx, src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx: + Fixes to compile with the new Cyg_IORB field names. + +Thu Jul 9 03:40:21 1998 Jonathan Larmour + + * tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Adjust starting of tests to possibly start scheduler since + strtol/stroul rely on errno, which may be a per-thread variable + +Thu Jul 9 03:06:25 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx, src/stdio/common/setvbuf.cxx: + Consolidate read and write buffers into single buffer, as it should + have been all along + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Add drain_buffer() method to speed up the case when we want the + buffer completely emptied + +Tue Jul 7 21:26:33 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Add a couple of new tests that check that very long strings work too + +Wed Jul 1 19:52:39 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/streambuf.hxx: + Do not permit copy constructors + + * src/clibincl/stream.inl, src/stdio/common/fclose.cxx: + Make sure we use #ifdef and not #if + + * src/clibincl/streambuf.inl: + Use member initialisation list rather than explicit initialisation to + reduce warnings + +Wed Jul 1 19:17:55 1998 Jonathan Larmour + + * include/pkgconf/libc.h and all files using config options: + Rename configuration defines to make them more standard + +Thu Jun 25 20:09:30 1998 Jonathan Larmour + + * src/string/strcat.cxx: + Add parentheses on check to silence warning + (Verified by proven) + +Thu Jun 25 19:30:01 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Make sure that the malloc pool is initialised before other things + can use it. This is done with the hot new constructor ordering + feature. + +Thu Jun 25 18:27:03 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Remove bogus ifdef if floating point is _not_ wanted + +Thu Jun 25 17:31:42 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Fix argument checking to allow first argument of NULL + +Thu Jun 25 04:18:50 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_strtok_last_p): + Remove bogus assertion + + * src/stdlib/malloc.cxx: + Got sense of alignment check assertion the wrong way round, so negate + it + +Thu Jun 25 03:56:35 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: + Fix argument checking assertions with legitimate nulls here too + +Thu Jun 25 03:46:32 1998 Jonathan Larmour + + * src/stdlib/strtoul.cxx, src/stdlib/strtol.cxx: + Fix argument checking assertions to cope with legitimate nulls + +Wed Jun 24 09:01:45 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Remove extraneous info messages + +Wed Jun 24 05:59:17 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c: + + Change large automatic arrays to static arrays to prevent overuse + of a potentially small stack + +Wed Jun 24 05:45:28 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/string/strtok.c, tests/time/clock.c: + + Increase thread stack size from 4K to 32K as in some cases it was + too small. + + +Tue Jun 23 20:12:31 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Add extra tests, including floating point conversion testing + +Tue Jun 23 17:01:06 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Make sure this is only compiled if CYGFUN_LIBC_strtok is defined + +Tue Jun 23 06:10:13 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + add some comments - that's all + + * src/stdio/common/stream.cxx: + fix case in refill_read_buffer() for what to do when there's nothing + left. Now return EAGAIN + + * src/stdio/common/vsscanf.cxx, src/stdio/input/vfscanf.cxx: + Get sscanf working properly and passing tests. Also make sure it + ignores FP when its not configured + + * src/stdlib/atof.cxx: + Only compile at all if strtod() is present + + +Mon Jun 22 19:13:42 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise strtok_last and rand_seed better + +Mon Jun 22 14:14:12 1998 Jonathan Larmour + + * tests/stdlib/malloc3.c: + Add test for checking that mallocing and freeing repeatedly works + + * tests/PKGconf.mak: + Update to reflect addition of the above + +Mon Jun 22 13:09:33 BST 1998 Chris Provenzano + + * src/stdio/common/fopen.cxx + * src/stdio/common/stream.cxx + * src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx + Include cyg/devs/common/iorb.h instead of iorb.hxx + + * src/stdio/common/stream.cxx + Use read_blocking and write_blocking instead of just read and + write when accessing devices through the virtual device table. + +Sun Jun 21 18:19:13 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Propagate change of return code handling for puts from stdio.inl + into here + + * src/stdio/output/fputc.cxx: + make sure the right type is used for output - byte not int + + * src/support/clibdata.cxx: + Fix #define config mistook. #endif was in wrong place + +Sun Jun 21 16:11:04 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Allow explicit construction to get around a bug when + dynamically allocating per-thread structure + +Sun Jun 21 16:02:51 1998 Jonathan Larmour + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, tests/stdlib/qsort.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + + Update tests to "do the right thing" with all configuration settings + + +Sun Jun 21 04:54:14 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + I have to be careful not to use setjmp() in a way not exactly + defined by the standard, so make sure I do, and add a comment + documenting these ways. + + Also ensure this test does the right thing in all configurations + +Sun Jun 21 04:38:15 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add extra checks for invalid configurations + Also make default for thread safety OFF + + * src/clibincl/clibdata.inl: + Adjust indentation + + * src/stdio/output/vfnprintf.cxx: + Make printf of -0.0 floating point do the right thing + +Sun Jun 21 04:28:00 1998 Jonathan Larmour + + * src/stdio/common/snprintf.cxx, src/stdio/common/sprintf.cxx, + src/stdio/common/sscanf.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/scanf.cxx, src/stdio/output/fnprintf.cxx, + src/stdio/output/fprintf.cxx, src/stdio/output/printf.cxx: + + Had to remove inline functions with varargs. Which means separating + out each function from stdioinlines.cxx into a separate file, as they + no longer belong there. So all the above files were created. + + * include/stdio.inl, src/PKGconf.mak, + src/stdio/common/stdioinlines.cxx: + Changed to take account of the above + + +Sun Jun 21 03:58:42 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c: + Update with floating-point tests. Also make sure they DTRT in all + configurations + +Fri Jun 19 19:33:06 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + accidentally initialised stdin/out/err twice + +Fri Jun 19 19:09:29 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Another typo + +Fri Jun 19 18:59:07 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Missing #endif typo + +Fri Jun 19 18:51:42 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Fix initialisation of static data members. Unsure how it worked at + all before! + +Fri Jun 19 18:01:01 1998 Jonathan Larmour + + * include/stdio.inl: + puts should check whether fputs returns non-negative, rather than + non-zero + +Fri Jun 19 17:22:52 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl: + Make inclusion of get_errno_p conditional on thread-safety + +Wed Jun 17 10:55:32 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Add weak alias of vfscanf() to _vfscanf() + +Wed Jun 17 09:10:41 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Initialise err to silence compiler warning + +Wed Jun 17 08:59:20 1998 Jonathan Larmour + + * Most important is the addition of floating point support in + src/stdio/output/vfnprintf.cxx and src/stdio/input/vfscanf.cxx. This + also required the addition of atof() and strtod() in stdlib which is + definitely no bad thing! Other than that... + + * Fix a whole bunch of stuff I messed up first time round. Also the + sprintf and sscanf tests are included again. + +Tue Jun 16 16:38:02 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Typo with not putting comment character at the beginning. Sigh. + +Tue Jun 16 14:53:09 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Forgot to (temporarily) remove fputs test for now + +Mon Jun 15 20:40:03 1998 Jonathan Larmour + + Everything to do with stdio has almost completely changed, so there's + not much point documenting individual changes. + +Mon Jun 15 18:36:01 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c: + Stop it moaning quite as much when it fails by making it exit sooner + + * tests/time/clock.c : + This isn't a compound testcase + +Thu Jun 11 17:59:13 1998 Jonathan Larmour + + * include/assert.h + Reverse sense of NDEBUG ifdef, that was left in accidentally due + to testing + +Thu Jun 11 04:58:08 1998 Jonathan Larmour + + * include/errno.h, include/string.h, src/clibincl/stringsupp.hxx: + Modify as I've now added an "error" package which defines the error + codes and strerror() + + * src/errno/strerror.cxx: + Moved to new error package and thus deleted + +Wed Jun 10 18:37:37 1998 Jonathan Larmour + + * include/assert.h: + create this header and add assert() function + +Wed Jun 10 16:23:57 1998 Jonathan Larmour + + * include/stdlib.h, src/clibincl/stdlibsupp.hxx, src/stdlib/malloc.cxx: + Add malloc(), calloc() and free() functions + + * include/pkgconf/libc.h: + Add malloc memory pool size option + + * tests/stdlib/malloc1.c, tests/stdlib/malloc2.c: + new tests for malloc + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for new files + +Wed Jun 10 15:06:16 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + Add another test + +Tue Jun 9 18:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add some setjmp config's and a macro for the noreturn attribute + + * include/setjmp.h, include/setjmp.inl, src/clibincl/setjmpsupp.hxx, + src/setjmp/longjmp.cxx, tests/setjmp/setjmp.c: + Added to implement and test setjmp() and longjmp() + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for newly added files + +Thu Jun 4 01:29:18 1998 Jonathan Larmour + + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, src/string/strcpy.cxx, + src/string/strlen.cxx, src/string/strncat.cxx, + src/string/strncmp.cxx, src/string/strncpy.cxx: + Rename CYGIMP_LIBC_PREFER_SMALL_TO_FAST to + CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST + + Also use slower but smaller version when __OPTIMIZE_SIZE__ is + defined (which comes from using gcc -Os) + +Fri May 29 16:15:04 1998 Jonathan Larmour + + * include/ctype.inl, src/ctype/isxdigit.cxx: + Fix bug that numerals aren't considered hex digits + + * include/time.h: + Change clock_t and time_t to be signed so that they can accept -1, as + required by other libc functions + + * src/clibincl/clibdata.hxx: + Fix typo that CYGIMP_LIBC_THREAD_SUPPORT should be ..._SAFETY + Also fix macro to allocate thread-specific data to not set variables + in a different stack-frame + + * tests/ctype/ctype.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/stdlib/qsort.c: + make ctr unsigned to prevent warnings + + * tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/string/strrchr.c: + Fix off by one error + + * tests/string/strspn.c: + Fix case-sensitivity problem, and off-by-one error + + * tests/string/strxfrm1.c: + Remove bogus bit of test that doesn't apply to strxfrm, and fix typo + + +Fri May 22 16:33:04 1998 Jonathan Larmour + + * src/PKGconf.mak + Remove CXXFLAGS line now that its redundant + + * tests/everything! + Do a blitz change of all tests - break some of them down into + different files, add new tests, standardize format, fix bugs, + update for recent header file changes and much more! + +Wed May 20 17:50:04 1998 Jonathan Larmour + + * tests/PKGconf.mak: + interim checkin for different dir structure for Bart + +Fri May 15 20:30:46 1998 Jonathan Larmour + + * Tidy up some loose ends I forgot: rename src/include directory to + src/clibincl. And add clibdata.inl and timesupp.hxx in there. + +Thu May 14 19:56:32 1998 Jonathan Larmour + + * Basically everything has changed in the C library. Files have + been moved, renamed, deleted and reworked. This is a major + revision, and now starts from this new baseline rather than doing + incremental changes. + +Fri Apr 17 18:43:02 1998 Jonathan Larmour + + * src/ECCconf.mak: + added for new build system (actually Bart did this, but didn't + update this ChangeLog) + +Fri Apr 17 15:03:25 1998 Hugo Tyson + + * src/stdio/device/sim.cxx: + Make it build with CYG_EMPTY_STATEMENT; the unadorned one is being + removed. + +Thu Apr 16 00:24:24 1998 Jonathan Larmour + + * All source files: + replace ECCIMP_LIBC_* conditional ifdef with CYGIMP_LIBC_* + + * include/eccconf/libc.h: + improve comments and reorder a bit + +Wed Apr 8 14:35:20 1998 Jonathan Larmour + + * Makefile.am, src/Makefile.am, tests/Makefile.am, configure.in: + many changes to integrate build structure from release tree + + * src/ctype/Makefile.am, src/ctype/Makefile.in, src/errno/Makefile.am, + src/errno/Makefile.in, src/stdio/Makefile.am, src/stdio/Makefile.in, + src/stdio/common/Makefile.am, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.am, src/stdio/device/Makefile.in, + src/stdio/output/Makefile.am, src/stdio/output/Makefile.in, + src/stdio/input/Makefile.am, src/stdio/input/Makefile.in, + src/stdlib/Makefile.am, src/stdlib/Makefile.in, + src/string/Makefile.am, src/string/Makefile.in, + src/support/Makefile.am, src/support/Makefile.in, + src/time/Makefile.am, src/time/Makefile.in: + Remove as they are now redundant with above changes + + * include/Makefile.am: + Add to support above changes + + * include/eccconf/libc.h: + Change include file for configuration from kernel to system + + * src/include/kerndiag.hxx, src/stdio/device/kerndiag.cxx, + src/time/clockfn.cxx: + Change kernel include file to eccconf/kernel.h + + * src/include/strngdev.h: + remove unnecessary kernel include + + * Makefile.in, aclocal.m4, configure, src/Makefile.in, + tests/Makefile.in, include/Makefile.in: + regenerate + +Mon Apr 6 20:55:07 1998 Jonathan Larmour + + * src/stdlib/abs.cxx, src/stdlib/atoi.cxx, src/stdlib/atol.cxx, + src/stdlib/div.cxx, src/stdlib/labs.cxx, src/stdlib/ldiv.cxx: + Separated out functions from stdlib.cxx into separate files + + * src/stdlib/stdlib.cxx: + removed to be replaced by above files + + * Makefile.am, src/stdlib/Makefile.am: + modified to support building above and not building stdlib.cxx + + * src/support/tsd.cxx: + Remove unnecessary header file includes + + * Makefile.in, src/stdlib/Makefile.in: + regenerated + +Mon Apr 6 19:19:42 1998 Jonathan Larmour + + * src/support/tsd.cxx, include/eccconf/libc.h: + remove lame hack for tx39 compiler now that its fixed + + * src/include/sim.hxx: + define constants as static to placate compiler + +Thu Apr 2 21:01:21 1998 Jonathan Larmour + + * src/ctype/ctype.cxx: + deleted and separated out into below files + + * src/ctype/isalnum.cxx, src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, src/ctype/islower.cxx, + src/ctype/isprint.cxx, src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, src/ctype/tolower.cxx, + src/ctype/toupper.cxx: + Separated out individual ctype functions from ctype.cxx into separate + files + + * Makefile.am, src/ctype/Makefile.am: + modified to reflect above deletion/additions + + * Makefile.in, src/ctype/Makefile.in: + regenerated + +Thu Apr 2 19:08:26 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: optimise using prefix increments + +Thu Apr 2 15:18:15 1998 Jonathan Larmour + + * src/string/strchr.cxx: optimise setting of mask a little + +Thu Mar 26 14:07:01 1998 Jonathan Larmour + + * src/support/tsd.cxx: fixed some typos + +Thu Mar 26 11:58:47 1998 Jonathan Larmour + + * include/eccconf/libc.h, src/support/tsd.cxx: + Implement workaround for tx39 compiler bug. + + * src/include/strsuppt.hxx: + remove prototypes for _memcpy() and _memset() as they are now in the + kernel + +Wed Mar 25 18:31:53 1998 Jonathan Larmour + + * Makefile.am, src/string/Makefile.am: memcpy() and memset() are + now in the kernel so remove them from build + * include/string.h: add a comment to say as much + * Makefile.in, src/string/Makefile.in: regenerate + +Wed Mar 25 15:30:42 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx, src/include/file_if.inl: + Change _exit workaround to not cause a compiler optimisation + problem. Now just references _exit rather than calls it. + +Wed Mar 25 14:59:49 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fix bug causing tests to fail completely + for this function + +Wed Mar 25 12:55:53 1998 Jonathan Larmour + + * src/include/sim.hxx: add types to constants (oops!) + * Makefile.am: link src/stdio/device/sim.cxx + * Makefile.in: regenerated + +Wed Mar 25 04:14:30 1998 Jonathan Larmour + + * src/include/file_if.hxx, src/include/file_if.inl, + src/include/kerndiag.hxx, src/include/sim.hxx, + src/include/stdio_if.hxx, src/include/strngdev.hxx, + src/include/tsd.hxx, src/stdio/common/clearerr.cxx, + src/stdio/common/clearerr.cxx, src/stdio/common/feof.cxx, + src/stdio/common/ferror.cxx, src/stdio/common/file_if.cxx, + src/stdio/common/vsprintf.cxx, + src/stdio/device/kerndiag.cxx, src/stdio/device/sim.cxx, + src/stdio/device/strngdev.cxx, src/stdio/output/fputc.cxx, + src/stdio/output/fputs.cxx, src/stdio/output/puts.cxx, + src/stdio/output/vfnprintf.cxx, src/support/tsd.cxx: + Modified to support buffered reads including renaming + _EccInternalFileStruct to __EccStdioStream which is what affects + most of these files + * src/include/file_if.inl, src/stdio/common/file_if.cxx: added for + the above reason + * src/stdio/common/sscanf.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/input/Makefile.am: added to provide sscanf() functionality + * include/ctype.h, include/stdio.h, include/stdlib.h, + include/string.h, include/eccconf/libc.h, src/ctype/ctype.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/stdio/common/stdio.cxx: + rename *_INLINES macros with prefix CYG rather than ECC + * include/errno.h, src/errno/errno.cxx, src/errno/strerror.cxx: + rename ErrNo to _ErrNo and add EAGAIN and EWOULDBLOCK error codes + * configure.in, Makefile.am, src/stdio/Makefile.am, + src/stdio/input/Makefile.am: add support for building + file_if.cxx sscanf.cxx and vfscanf.cxx + * src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/input/Makefile.in, configure, Makefile.in: regenerated + +Tue Mar 24 19:51:40 1998 Jonathan Larmour + + * src/time/clockfn.cxx, src/time/clock.cxx: + Renamed clock.cxx to clockfn.cxx (preserving CVS history) + * Makefile.am, src/time/Makefile.am: updated to reflect name change + * Makefile.in, src/time/Makefile.in: regenerated + +Tue Mar 24 16:28:06 1998 Jonathan Larmour + + * include/ctype.inl: Swap around definitions to get right order so + inlining works + +Tue Mar 24 14:43:05 1998 Jonathan Larmour + + * include/ctype.h, include/stdio.h, include/stdlib.h, include/string.h: + modify to only conditionally include inlines + * src/ctype/ctype.cxx, src/stdio/common/stdio.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/ctype/Makefile.am: Add to provide real linkable alternatives + to inline functions + * Makefile.am, configure.in, src/Makefile.am, + src/stdio/common/Makefile.am, src/stdlib/Makefile.am, + src/string/Makefile.am: modified to support previous additions + * include/eccconf/libc.h: redefine inline macro to add extern inline, + and add conditional defines for inline functions. Also rename + space vs. speed macro to have CYG instead of ECC prefix + * include/stdio.inl: fix comment typo + * src/stdlib/qsort.cxx: fix to define inline functions properly + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/memcpy.cxx, + src/string/memset.cxx, src/string/strcat.cxx, src/string/strchr.cxx, + src/string/strcmp.cxx, src/string/strcpy.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx + * Makefile.in, configure, src/Makefile.in, src/ctype/Makefile.in, + src/stdio/common/Makefile.in, src/stdlib/Makefile.in, + src/string/Makefile.in: regenerate + + +Mon Mar 23 19:19:49 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: added to support temporary _exit + * include/stdlib.h, include/stdlib.inl: added support for _exit and + added abs(), labs(), div() and ldiv() functions + * src/include/file_if.hxx: added support for _exit kludge + * src/stdlib/qsort.cxx: Added Berkeley copyright message + * src/time/clock.cxx: Include correct kernel config header as + CYG_CONFIGURATION rather than + * Makefile.am src/stdlib/Makefile.am: added support for _exit + * Makefile.in, src/stdlib/Makefile.in: regenerated + +Mon Mar 23 14:41:07 1998 Jonathan Larmour + + * Replace ECCPKG_ANSI_LIBC with CYGPKG_ANSI_LIBC in all source files + +Mon Mar 23 14:28:44 1998 Jonathan Larmour + + * include/string.inl: add file to provide strcoll() + * include/string.h: include string.inl + * ctype.h: include ctype.inl (oops!) + * include/stdlib.h: include stdlib.inl (oops!) + +Mon Mar 23 13:30:38 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl: added to provide ANSI ctype + functionality + * include/stdlib.h, include/stdlib.inl, src/include/stdlibbsp.hxx, + src/stdlib/Makefile.am, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/stdlib/srand.cxx, + src/stdlib/strtol.cxx, src/stdlib/strtoul.cxx: Added to provide + many stdlib functions + * src/include/tsd.hxx: modified to support rand() random number + seed, and added some comments + * configure.in, Makefile.am, src/Makefile.am: modified to support + addition of above new sources + * include/eccconf/libc.h: Add extra helpful comments, and #include + kernel config file + * src/time/clock.cxx: #include clock.inl and fix to call + get_resolution() properly now + * Makefile.in, configure, src/Makefile.in, src/errno/Makefile.in, + src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.in, src/stdio/output/Makefile.in, + src/stdlib/Makefile.in, src/strings/Makefile.in, + src/support/Makefile.in, src/time/Makefile.in, + tests/Makefile.in: regenerated + + +Sun Mar 22 21:29:25 1998 Jonathan Larmour + + * include/time.h, src/include/timesupp.hxx, src/time/clock.cxx, + src/time/Makefile.am: added to provide clock() function + * src/Makefile.am: modified to try to build in src/time directory + * include/eccconf/libc.h: added and is now the main configuration + file for this package + * acconfig.h, include/libcconf.h.in, include/stamp-h.in: removed + due to usage of libc.h above instead + * Almost all *.h, *.hxx and *.cxx: replaced LIBC_CONFIG_HEADER + defined include with simple + * configure.in: remove AM_CONFIG_HEADER of libcconf.h and + LIBC_CONFIG_HEADER definition. Also remove usage of builtin + memcpy() etc. from gcc, and generate src/time/Makefile + * Makefile.am: link in src/time/clock.o + * src/include/file_if.hxx, src/include/sim.hxx: use config header + to decide whether C library is to be used + * Makefile.in, aclocal.m4, configure, src/Makefile.in: regenerated + +Fri Mar 20 18:08:10 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fixed bug with ignoring terminating NULL + +1998-03-20 Chris Tarpy + + * configure: - regenerated + * Makefile.am: - Support added for libc testcases + * Makefile.in: regenerated + * configure.in: set c compiler, descend test dir + * tests/Makefile.in: added + * tests/Makefile.am: added + * tests/tcdiag.cxx : added + + +Thu Mar 19 11:41:56 1998 Jonathan Larmour + + * Initial check-in of everything + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/setjmp/current/cdl/setjmp.cdl b/packages/language/c/libc/setjmp/current/cdl/setjmp.cdl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/setjmp/current/cdl/setjmp.cdl @@ -0,0 +1,106 @@ +# ==================================================================== +# +# setjmp.cdl +# +# C library setjmp/longjmp related configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jlarmour +# Contributors: +# Date: 2000-04-14 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_LIBC_SETJMP { + display "ISO C library setjmp/longjmp functions" + description " + This package provides non-local jumps based on setjmp() and + longjmp() in as specified by the ISO C + standard - ISO/IEC 9899:1990." + doc redirect/the-iso-standard-c-and-math-libraries.html + include_dir cyg/libc/setjmp + parent CYGPKG_LIBC + requires CYGPKG_ISOINFRA + implements CYGINT_ISO_SETJMP + requires { CYGBLD_ISO_SETJMP_HEADER == "" } + + compile longjmp.cxx + +# ==================================================================== + + +# ==================================================================== + + cdl_component CYGPKG_LIBC_SETJMP_OPTIONS { + display "C library setjmp build options" + flavor none + no_define + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_LIBC_SETJMP_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building this package. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_LIBC_SETJMP_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building this package. These flags are removed from + the set of global flags if present." + } + + cdl_option CYGPKG_LIBC_SETJMP_TESTS { + display "C library setjmp tests" + flavor data + no_define + calculated { "tests/setjmp" } + description " + This option specifies the set of tests for this package." + } + } +} + +# ==================================================================== +# EOF setjmp.cdl diff --git a/packages/language/c/libc/setjmp/current/include/setjmp.h b/packages/language/c/libc/setjmp/current/include/setjmp.h new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/setjmp/current/include/setjmp.h @@ -0,0 +1,83 @@ +#ifndef CYGONCE_LIBC_SETJMP_H +#define CYGONCE_LIBC_SETJMP_H +/*=========================================================================== +// +// setjmp.h +// +// ISO C standard non-local jumps +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: Header file to implement ISO C standard non-local jumps as +// per ISO C para 7.6 +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//=========================================================================*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#include /* HAL architecture specific implementation */ + +/* TYPE DEFINITIONS */ + +/* jmp_buf as per ANSI 7.6. This is simply the underlying HAL buffer */ + +typedef hal_jmp_buf jmp_buf; + +/* MACROS */ + +/* setjmp() function, as described in ANSI para 7.6.1.1 */ +#define setjmp( __env__ ) hal_setjmp( __env__ ) + +/* FUNCTION PROTOTYPES */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* longjmp() function, as described in ANSI para 7.6.2.1 */ +extern void +longjmp( jmp_buf, int ) __attribute__((__noreturn__)); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* CYGONCE_LIBC_SETJMP_H multiple inclusion protection */ + +/* EOF setjmp.h */ diff --git a/packages/language/c/libc/setjmp/current/src/longjmp.cxx b/packages/language/c/libc/setjmp/current/src/longjmp.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/setjmp/current/src/longjmp.cxx @@ -0,0 +1,93 @@ +//=========================================================================== +// +// longjmp.cxx +// +// ISO C standard longjmp() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: Implements ISO standard non-local jump function longjmp() +// per ISO C para 7.6.2.1. This is the "real" alternative to +// the inline version of longjmp() +// +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // Common tracing code +#include // Common assertion code +#include // HAL architecture specific implementation + +// We don't want the inline version of longjmp() defined here +#ifdef CYGIMP_LIBC_SETJMP_INLINES +# undef CYGIMP_LIBC_SETJMP_INLINES +#endif + +#include // Header for setjmp/longjmp + + +// FUNCTIONS + +void +longjmp( jmp_buf cyg_buf, int cyg_val) +{ + CYG_REPORT_FUNCNAME( "longjmp" ); + CYG_REPORT_FUNCARG2( "&cyg_buf=%08x, cyg_val=%d", &cyg_buf, cyg_val ); + + // ANSI says that if we are passed cyg_val==0, then we change it to 1 + if (cyg_val == 0) + ++cyg_val; + + // we let the HAL do the work + + HAL_REORDER_BARRIER(); // prevent any chance of optimisation re-ordering + hal_longjmp( cyg_buf, cyg_val ); + HAL_REORDER_BARRIER(); // prevent any chance of optimisation re-ordering + +#ifdef CYGDBG_USE_ASSERTS + CYG_ASSERT( 0, "longjmp should not have reached this point!" ); +#else + for (;;) + CYG_EMPTY_STATEMENT; +#endif +} // longjmp() + +// EOF longjmp.cxx diff --git a/packages/language/c/libc/setjmp/current/tests/setjmp.c b/packages/language/c/libc/setjmp/current/tests/setjmp.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/setjmp/current/tests/setjmp.c @@ -0,0 +1,223 @@ +//=========================================================================== +// +// setjmp.c +// +// Tests for ANSI standard setjmp() and longjmp() functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: Contains test code for C library setjmp() and longjmp() +// functions +// The ANSI standard allows setjmp calls to be used ONLY in the +// forms: +// while (setjmp (jumpbuf)) +// while (setjmp (jumpbuf) < 42) +// while (!setjmp (jumpbuf)) +// setjmp (jumpbuf); +// result = setjmp(jumpbuf); +// +// Or "while" can also be "if" or "switch" or the implicit +// while of "for". +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// INCLUDES + +#include // Test infrastructure header +#include // Header for what we're testing + +// GLOBALS + +static jmp_buf jbuf, jbuf2, jbuf3; + + +// FUNCTIONS + +static int +test_fun( void ) +{ + volatile int i=0; // add something to the stack to confuse things + + longjmp( jbuf, 5 ); + i+=5; + + return i; +} // test_fun(); + + +int +main( int argc, char *argv[] ) +{ + static int static_i=0; // temporary variable + int j=0; // ditto + volatile int vol_k=0, vol_l=0; // ditto + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "setjmp()/longjmp() functions"); + + // Test 1 + if ( setjmp(jbuf) == 0 ) + { + static_i=1; + longjmp(jbuf, 1); + static_i=2; + } // if + + CYG_TEST_PASS_FAIL( static_i==1, "Simple test 1" ); + + // Test 2 + j=2; + + if ( !setjmp(jbuf) ) + { + static_i=3; + longjmp(jbuf, 1); + static_i=4; + j=3; + } // if + + CYG_TEST_PASS_FAIL( (static_i==3) && (j==2), "Simple test 2" ); + + // Test 3 + + static_i=0; + switch (setjmp(jbuf)) + { + case 0: + static_i++; + if (static_i!=1) + CYG_TEST_FAIL("Test of value passed to longjmp()"); + else + longjmp(jbuf, 5); + break; + case 5: + static_i++; + CYG_TEST_PASS_FAIL( (static_i==2),"Test of value passed to longjmp()"); + break; + default: + CYG_TEST_FAIL( "Test of value passed to longjmp()"); + break; + } // switch + + // Test 3 + + static_i=0; + switch (setjmp(jbuf)) + { + case 0: + static_i++; + if (static_i!=1) + CYG_TEST_FAIL("Test of value passed to longjmp() being 0"); + else + longjmp(jbuf, 0); + break; + case 1: + static_i++; + CYG_TEST_PASS_FAIL( (static_i==2), + "Test of value passed to longjmp() being 0"); + break; + default: + CYG_TEST_FAIL( "Test of value passed to longjmp() being 0"); + break; + } // switch + + + // Test 4 + + vol_k=0; + static_i=0; + setjmp( jbuf ); + + static_i++; + setjmp( jbuf2 ); + + static_i++; + setjmp( jbuf3 ); + + if (vol_k==0) + { + vol_k++; + longjmp( jbuf2, 1 ); + } + else + { + CYG_TEST_PASS_FAIL( (vol_k==1) && (static_i==3), "Multiple setjmp's" ); + } + + // Test 5 + + vol_k=3; + if ( (j=setjmp(jbuf)) == 0 ) + { + volatile int l; // put something extra on the stack to confuse things + + vol_k++; + l=test_fun(); + l++; + vol_k=l; + } // if + + CYG_TEST_PASS_FAIL( (j==5) && (vol_k==4), "longjmp from a function" ); + + // Test 6 + + vol_k=0; + + vol_l=setjmp(jbuf); + + vol_k += 3; + + if (!vol_l) + test_fun(); + + vol_l=setjmp(jbuf); + + vol_k += 7; + + if (!vol_l) + test_fun(); + + CYG_TEST_PASS_FAIL ( (vol_k == 20), "Repeated longjmps from a function" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "setjmp()/longjmp() functions"); + +} // main() + +// EOF setjmp.c diff --git a/packages/language/c/libc/signals/current/ChangeLog b/packages/language/c/libc/signals/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/signals/current/ChangeLog @@ -0,0 +1,37 @@ +2000-05-16 Jesper Skov + + * tests/signal2.c: Also reset DIV_BY_ZERO vector. + +2000-05-02 Jonathan Larmour + + * New package + Separated original libc out into separate packages on functional + boundaries. + Header files are now managed by isoinfra package + Plenty of cleanups done, but no major functionality changes + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/signals/current/ChangeLog.libc b/packages/language/c/libc/signals/current/ChangeLog.libc new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/signals/current/ChangeLog.libc @@ -0,0 +1,2727 @@ +This ChangeLog file is now obsolete. This is the original ChangeLog from when +libc was one large package, before being separated. It is included for +historical reasons. + +2000-04-05 Jesper Skov + + * src/time/settime.cxx: + * src/time/time.cxx: + Wallclock moved to io/. + +2000-03-28 John Dallaway + + * cdl/string.cdl, + cdl/stdlib.cdl, + cdl/stdio.cdl, + cdl/libc.cdl: + + Adjust documentation URLs. + +2000-03-27 Jesper Skov + + * src/clibincl/stream.inl (check_this): Use cyb_bool instead of bool. + +2000-03-06 Jesper Skov + + * tests/time/strftime.c (test): Adjust test to match below change. + +2000-03-02 Jonathan Larmour + + * src/time/strftime.cxx (do_format): Make sure %m counts from + 1..12 rather than 0..11. Fix for case 103300 + +2000-02-29 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: Correctly use 'n' parameter to + restrict length. Credit due to Andrew Lunn here as well. + Resolves 103057-CR-1 + + * tests/stdio/sprintf2.c (test): + Add snprintf tests to verify the correct behaviour of restricting + output length + +2000-02-10 Jesper Skov + + * tests/signal/signal2.c (main): + Also reclaim DATA_TLB_MISS vector if available. + +2000-01-31 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-28 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-19 Hugo Tyson + + * cdl/*.cdl: Add descriptions to a number of options &c which were + lacking same, also tidied up other typos as noticed en passant. + +1999-11-11 Bart Veer + + * cdl/string.cdl: + Switch to a single boolean configuration option for code size vs. + speed optimization. + +1999-11-03 John Dallaway + + * cdl/libc.cdl: Define tests. + +1999-10-19 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: We can now remove Berkeley + advertising clause + * src/stdlib/div.cxx: ditto + * src/stdlib/ldiv.cxx: ditto + * src/stdlib/strtol.cxx: ditto + * src/stdlib/strtoul.cxx: ditto + * src/string/strtok.cxx: ditto + +1999-10-19 John Dallaway + + * cdl/libc.cdl: + + Define CDL options for package-specific CFLAGS. + +1999-10-08 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_THREAD_PRIORITY): Change + default to 10 to keep test farm happy + * cdl/startup.cdl: Likewise + +1999-10-07 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Specify radio buttons using CDL interfaces. + +1999-10-06 Jonathan Larmour + + * cdl/stdio.cdl: Change default to /dev/ttydiag as per 1999-10-01 + change below + * cdl/startup.cdl: Add new form CDL for the startup changes as + per 1999-10-05 + +1999-10-05 Jonathan Larmour + + * include/libc.h: Add CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM to allow + the user to supply their own stack. + Rename CYGNUM_LIBC_MAIN_STACK_SIZE to + CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE and reparent under + CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + Add CYGNUM_LIBC_MAIN_THREAD_PRIORITY to provide main() thread + priority + + * src/support/mainthread.cxx: Add support for user-supplied stack + Allow user to specify thread priority + + These changes fix CR 101069 + +1999-10-01 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE): Change + default to /dev/ttydiag to get correct console-like behaviour + Also don't preclude use if haldiag package isn't included + (case 102065) + +1999-09-15 Jesper Skov + + * tests/signal/signal2.c (cause_fpe): Try both float and integer + division by zero. + +1999-09-10 Jesper Skov + + * src/stdlib/malloc.cxx (cyg_libc_get_malloc_pool): Added for + stress_threads test. + +1999-09-07 Jesper Skov + PRs 20243, 20433 + * tests/signal/signal2.c: Disabled test3 on ARM. + +1999-09-02 Hugo Tyson + + * include/assert.h: Make the sense of NDEBUG correct; it is "set" + when NOT debugging. Fix for CR 101983-CR-1 + See Stroustrup, "The C++ Programming Language." + +1999-08-18 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): Set buffer size 0 when not + buffering + Fix for case 101868 + +1999-08-17 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Implement radio buttons using "FIXME radio" hack in + description field for now. + +1999-08-12 John Dallaway + + * cdl/stdlib.cdl: + Take advantage of MACRONAME_ENUMVAL macros output by CDL. + +1999-08-06 Jonathan Larmour + + * tests/stdio/sprintf2.c (test): Don't rely on 2.345 being exactly + representable in binary as a difference of 1 ulp will make it round + the wrong way. + +1999-07-16 Jonathan Larmour + + * src/stdio/input/fgetc.cxx: + Include outline versions of getc() (actually just a symbol alias for + fgetc() ) and getchar() + Some minor clean-ups + Add tracing/assertions + + * src/stdio/input/fputc.cxx: + Likewise (except applied to putc() and putchar()) + + * src/stdio/common/stdioinlines.cxx (_puts): + Call fputc() not _fputc() + + * src/clibincl/stdiosupp.hxx: + Remove now obsolete prototypes for _fgetc() and _fputc() + + * include/stdio.h: + Don't bother with getc()/putc() macros any more, just call + them as functions + Include protos for getc(), putc(), getchar() and putchar() functions + +1999-06-21 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for SH EDK7708. + +1999-06-11 Jonathan Larmour + + * include/stdio.h: Make FILEs array types so they won't be + given $gp relocations on MIPS targets + +1999-05-27 Jesper Skov + + * tests/time/ctime.c: Fixed compiler warning. + +1999-05-25 Jonathan Larmour + + * tests/signal/signal2.c (main): + Update CYGPKG_HAL_TX39 -> CYGPKG_HAL_MIPS_TX39 due to recent MIPS + HAL changes + Fix for PR 20116 + +1999-04-30 Jesper Skov + PR 19945/19946 workaround + * tests/signal/signal2.c: Disabled test 3 for PowerPC sim. + +1999-04-19 Jonathan Larmour + + * include/time.inl: + Ensure all calls to cyg_libc_time_year_is_leap() are with the full + year, and not the direct contents of a struct tm, which are (year-1900) + +1999-04-19 Jesper Skov + PR 19308, 19410, 19528 + * tests/time/clock.c (test): Also disable data cache which may + affect timing when tracing/assertions are enabled. + +1999-04-15 Jonathan Larmour + + * src/clibincl/stdiosupp.hxx: + Add prototype for new cyg_libc_stdio_flush_all_but() function + + * src/clibincl/stream.hxx: + Don't include stdiosupp.hxx any more to prevent circular dependency, + therefore manually provide _setvbuf prototype + Make sure pkgconf/kernel.h is included before mutex.hxx + + * src/clibincl/stream.inl (Cyg_StdioStream::set_error()): + Add missing unlock_me() + + * src/stdio/common/fflush.cxx: + Separate most of code for fflush(NULL) into separate + cyg_libc_stdio_flush_all_but() function, which has the extra + capability of omitting one stream + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Add missing clibincl/stdiosupp.hxx include + + * src/stdio/common/stream.cxx (Cyg_StdioStream::read()): + When reading, ensure we flush all output streams + + * src/stdio/common/stream.cxx (Cyg_StdioStream::flush_output_unlocked): + Flush the device as well + +1999-04-15 Jonathan Larmour + + * src/stdio/common/streambuf.cxx (set_buffer): + * src/stdio/common/stdioinlines.cxx (_setbuf): + * src/clibincl/streambuf.inl: + * src/clibincl/streambuf.hxx: + * src/clibincl/stream.hxx (class Cyg_StdioStream): + * include/pkgconf/libc.h: + * include/stdio.inl (setbuf): + Fix dumb typo: BUFSIZE -> BUFSIZ + This fixes PR19837 + +1999-04-15 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx (_setbuf): + * include/stdio.inl (setbuf): + Use _IONBF when buf==NULL, and _IOLBF otherwise. + Fix for PR 19836 + +1999-04-15 John Dallaway + + * include/pkgconf/libc.h: Tidy display string capitalization. + +1999-04-12 Jonathan Larmour + + * include/pkgconf/libc.h: + Clarify CDL description of CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE + + * tests/signal/signal2.c: Try harder to generate an exception by + accessing a misaligned address + Don't handle SIGTRAP any more + Part of fix for PRs 19731/19607 + +1999-04-07 Jesper Skov + PR 19667 + * src/support/mainthread.cxx: + Changed to use the new Cyg_Thread constructor. + +1999-04-07 Hugo Tyson + + * tests/signal/signal2.c (main): Use new macro + HAL_VSR_SET_TO_ECOS_HANDLER if defined, to wrest control from + CygMon, for example, by reinstalling eCos' default VSRs for + exceptions that we are provoking. + +1999-03-29 Jonathan Larmour + + * src/signal/siginit.cxx: Include stdlib.h for exit() + Fix for PR 19720 + +1999-03-29 Jonathan Larmour + + * tests/time/clock.c (test): Disable instruction cache + Hopefully fixes PR 19308 + +1999-03-29 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for PPC as it cannot + trap division by zero. + +1999-03-26 Jonathan Larmour + + * src/support/main.cxx (main): Invoke cyg_user_start() if no kernel + Only sensible thing to do in our default main in a non-kernel config + +1999-03-25 Jonathan Larmour + + * tests/time/time.c: + Increase MAX_TIMEOUT since the sparclite gets very close to overrunning + it even when working. + Should return -1 iff CYGSEM_LIBC_TIME_TIME_WORKING isn't defined + Cosmetic changes + +1999-03-25 Hugo Tyson + + * tests/time/time.c (test): Take into account setting of + CYGSEM_LIBC_TIME_SETTIME_WORKING ie. does cyg_libc_time_settime() + work? If not, check that it returns an error. + This was exposed by the random combo in PR#19479. + +1999-03-23 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 to + CYGIMP_... + + Add another rand implementation CYGIMP_LIBC_RAND_SIMPLE1 which is + the default + + Part of fix for PR 19562 + + * include/sys/cstartup.h: + Tidy and remove unnecessary dependencies + + * src/stdlib/rand.cxx: + Rename algorithms from CYGSEM_... to CYGIMP_... + Add new "simple1" algorithm + + * tests/ctype/ctype.c: + Tidy + + * tests/stdlib/rand3.c: + Fix so that 0..RAND_MAX is split evenly over buckets, which it wasn't + before + Deal with case of RAND_MAX not being divisible by NUM_BUCKETS + exactly + Increase TEST_LENGTH to 200000 to provide more representative sample + Add CYG_TEST_INFO output to help ensure it doesn't time out + Tidy + + * tests/stdlib/rand4.c: + Only fail if more than _two_ thirds (rather than one third) match. + This is because half would match for a perfectly random distribution + This is the rest of the fix for PR 19562 + Cosmetic changes + +1999-03-22 Hugo Tyson + + * src/support/mainthread.cxx (CYGNUM_LIBC_MAIN_STACK_SIZE): + Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of + CYGNUM_HAL_MINIMUM_STACK_SIZE. + +1999-03-22 Jonathan Larmour + + * tests/PKGconf.mak: Add -Wno-format when building strftime otherwise + it generates warnings for things that we do want to test (null + string, and %y format) + +1999-03-19 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Put brackets back round negative number since sdf says the config + tool is fixed now (PR 19537) + + Add new CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 + options for different rand() algorithms in a so far failed attempt + to fix PR 19562 + + * src/stdlib/rand.cxx: + Add new optional algorithm from Knuth vol.2 + + * tests/stdlib/rand4.c: + Some tidies + Don't run test when using simplest algorithm + + * tests/signal/signal2.c (main): + Don't try to make an FPE on tx39 - its possible to detect but requires + too much HAL work to be sensible + +1999-03-18 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Use HAL_ENABLE_INTERRUPTS() rather than kernel to enable interrupts + +1999-03-18 Mark Galassi + + * tests/PKGconf.mak (TESTS): added rand4 compilation. + + * tests/stdlib/rand4.c: added this test for periodicity in the + least significant bit of rand(). + +1999-03-18 Jonathan Larmour + + * include/pkgconf/libc.h: Remove CYGFUN_LIBC_TIME_POSIX dependency + on CYGPKG_LIBC_STDIO + + * src/stdlib/itoa.cxx: + New file to convert integers to ascii + + * include/stdlib.h: + Add proto for new cyg_libc_itoa() function + + * include/time.inl: + Rework __asctime_r() to use memcpy() and cyg_libc_itoa() rather than + sprintf() + + * src/PKGconf.mak: + Build stdlib/itoa.cxx + + The above changes fix PR 19448 + +1999-03-17 Jonathan Larmour + + * include/time.h: Add #define of __time_t_defined to placate newlib + if it is used by accident. This is just a temporary workaround though. + +1999-03-16 Gary Thomas + + * src/PKGconf.mak: Add compile option to step around ARM compiler bug. + +1999-03-16 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Don't use parentheses for now + + * src/stdio/common/stream.cxx (refill_read_buffer): + Silence bogus compiler warning + +1999-03-16 Jesper Skov + + * tests/signal/signal2.c (main): Enable SIGSEGV test for + i386/Linux. + + +1999-03-15 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Only enable interrupts if they were disabled + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: + Add FIX ME line as a reminder that the workaround there can go away + in future + + * include/pkgconf/libc.h: + Add proper define for CYGSEM_LIBC_EXIT_CALLS_FFLUSH + Put brackets round negative CYGNUM_LIBC_TIME_DST_DEFAULT_STATE define + Fix run time typo + + * include/time.inl (__localtime_r): + Include sys/timeutil.h before this to get + cyg_libc_time_normalize_structtm() + +1999-03-12 Gary Thomas + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: Remove 'const' from char arrays since + this fails [silently] on ARM when -fwritable-strings (PR19440) + +1999-03-12 Jesper Skov + + * tests/signal/signal2.c (main): Compiler warnings fix was + slightly broken. + +1999-03-12 Jesper Skov + PR 19473 + * tests/signal/signal2.c (main): + Disabling SIGTRAP handling on i386/Linux is not a good idea. +1999-03-11 Jesper Skov + PR 19473 + * tests/signal/signal2.c: + Added compiler warnings fix. + Added N/A handling for i386/Linux. + +1999-03-10 Gary Thomas + + * include/pkgconf/libc.h: Force "haldiag" device to be present. + 'asctime' and friends need 'stdio' as well. + + * include/time.inl: Fix syntax error on difftime() declaration. + +1999-03-08 Gary Thomas + + * src/clibincl/stream.hxx: needed for this file. + + * src/stdio/common/vsscanf.cxx (str_read): Fix problem with string + pointer [created by merge with new I/O package]. + +1999-03-05 John Dallaway + + * include/pkgconf/libc.h: + Add legal values for CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET + and CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET. + +1999-03-05 Jonathan Larmour + + * include/time.inl (cyg_libc_time_year_is_leap): + Fix bug with modulo year 400 + Fix typo in asctime_r macro + Fix gmtime_r, and mktime as a result of testing + + * tests/time/asctime.c, tests/time/ctime.c, tests/time/gmtime.c, + tests/time/gmtime.c, tests/time/localtime.c, tests/time/mktime.c, + tests/time/strftime.c, tests/time/time.c: + New tests + + * tests/PKGconf.mak: + Build above new tests + + * include/pkgconf/libc.h: + Add reminder FIX ME about extra config option + + * src/time/strftime.cxx: + Fix %w and %Y parameters as a result of testing + + * src/time/timeutil.cxx: + Fix cyg_libc_time_normalize_structtm() as a result of testing + of mktime() + + * tests/time/clock.c: + Reformat, remove obsolete bits and tidy + + * include/time.h: + Add Cyg_libc_time_dst type and new functions + cyg_libc_time_setzoneoffsets(), cyg_libc_time_setdst(), + cyg_libc_time_getzoneoffsets(), cyg_libc_time_settime() + + * include/time.inl: + Implement the above functions. This allows us to adjust for timezone + diffences and set the time. + Change localtime() to adjust for STD/DST + Change mktime() to adjust for STD/DST + + * include/libc.h: + Add new config options CYGSEM_LIBC_TIME_SETTIME_WORKING + and component CYGPKG_LIBC_TIME_ZONES containing options + CYGNUM_LIBC_TIME_DST_DEFAULT_STATE, + CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET, + CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET + + * src/strftime.cxx: + Adjust handling of %Z to _not_ deal with STD/DST + + * src/time/settime.cxx: + New file to implement cyg_libc_time_settime() + + * src/PKGconf.mak: + Build settime.cxx + + * src/time/timeutil.cxx: + Supply outline versions of cyg_libc_time_setzoneoffsets(), + cyg_libc_time_setdst(), and cyg_libc_time_getzoneoffsets() + Add variables for STD/DST state + Some minor comment changes + + * include/errno.h: + Use CYGBLD_ATTRIB_CONST instead of __attribute__((const)) directly + + * include/signal.h: + Change format of function comment headers + + * include/signal.inl: + Restrict errno.h inclusion to when its actually used + Fix a spelling typo + + * include/stdlib.h: + Add CYGBLD_ATTRIB_CONST to abs, div, labs, ldiv + + * include/stdlib.inl: + Reformat and tidy + Include new versions of div and ldiv which are more portable and + are cleanly rewritten so aren't covered by the BSD licence, which + is now removed + + * src/stdlib/div.cxx, src/stdlib/ldiv.cxx: + Non-inline, non-BSD and portable versions of the new versions of div + and ldiv from stdlib.inl + + * include/time.h: + Much reformatting, tidying and improving comments + Change CLOCKS_PER_SEC from 1000 to 1000000 + Add new functions asctime_r, ctime_r, gmtime_r, localtime_r, clock, + difftime, mktime, time, asctime, ctime, gmtime, localtime, strftime + Include new time.inl file + + * include/pkgconf/libc.h: + Add new options CYGSEM_LIBC_TIME_CLOCK_WORKING, + CYGSEM_LIBC_TIME_TIME_WORKING, CYGFUN_LIBC_TIME_POSIX, + CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL, CYGIMP_LIBC_TIME_ASCTIME_INLINE, + CYGIMP_LIBC_TIME_CTIME_INLINE, CYGIMP_LIBC_TIME_DIFFTIME_INLINE, + CYGIMP_LIBC_TIME_GMTIME_INLINE, CYGIMP_LIBC_TIME_LOCALTIME_INLINE, + CYGIMP_LIBC_TIME_MKTIME_INLINE, CYGIMP_LIBC_TIME_ASCTIME_R_INLINE, + CYGIMP_LIBC_TIME_CTIME_R_INLINE, CYGIMP_LIBC_TIME_GMTIME_R_INLINE, + and CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE + + * time/asctime.cxx, time/asctime_r.cxx, time/clock.cxx, time/ctime.cxx, + time/ctime_r.cxx, time/difftime.cxx, time/gmtime.cxx, + time/gmtime_r.cxx, time/localtime.cxx, time/localtime_r.cxx, + time/mktime.cxx, time/strftime.cxx, time/time.cxx, time/timeutil.cxx, + include/time.inl: + New files to implement the new time functions. Many of them simply + provide the outline definitions, but the real body of the function + comes from time.inl + + * src/PKGconf.mak: + Build new .cxx files + + * src/clibincl/stdlibsupp.hxx: + Remove _div and _ldiv prototypes since they're no longer needed + + * src/clibincl/timesupp.hxx: + Delete as its now obsolete + + * src/time/clock.cxx: + Use new CYGSEM_LIBC_TIME_CLOCK_WORKING option to control whether it + just returns (clock_t)-1 or not. + Much reformatting and tidying + Change real imlpementation from _clock to __clock + Use CYGBLD_ATTRIB_WEAK_ALIAS now + + * tests/stdlib/div.c, tests/stdlib/ldiv.c: + Add some extra tests for handling of negative numbers + Reformat and tidy a bit, including removing the test for CYGPKG_LIBC + since its now always defined if the test is to be compiled + + * tests/time/clock.c: + Remove duplication CYG_TEST_INFO line + Check if unimplemented using "(clock_t)-1" and not just "-1" + +1999-03-04 Jonathan Larmour + + * src/stdlib/system.cxx: + Make sure system() is a weak alias for __system() + + * include/pkgconf/libc.h: Rework CDL description for + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE and change its default to + "/dev/haldiag" + + * src/stdio/common/stream.cxx: + Check that dev is valid when passed to stream constructor + + * src/stdio/common/stdiosupp.cxx: + Tidy + + * src/support/mainthread.cxx: Make this depend on + CYGSEM_LIBC_STARTUP_MAIN_THREAD rather than just CYGPKG_KERNEL + +1999-03-04 Gary Thomas + + Merged in changes from 'ecos-new_devs-19990216-branch' + + (1999-02-24 Jonathan Larmour ) + + * src/stdio/common/stream.cxx: + Add "fix me" comments and remove a couple of commented out lines + + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Revert to using pointer to string for private data, not just string. + This preserves the state across multiple calls + + (1999-02-24 Gary Thomas ) + + * src/stdio/common/vsscanf.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/stream.cxx: + * src/stdio/common/stdiosupp.cxx: + * src/stdio/common/fopen.cxx: + * src/clibincl/stream.inl: + * src/clibincl/stream.hxx: + * src/clibincl/stdiosupp.hxx: + * include/pkgconf/libc.h: Changes for new I/O system. + +1999-03-03 Jonathan Larmour + + * tests/stdlib/atexit.c: Forgot to config atexit test for + CYGFUN_LIBC_ATEXIT option + + * include/pkgconf/libc.h: + Require CYGVAR_KERNEL_THREADS_DATA for CYGSEM_LIBC_PER_THREAD_STRTOK + This fixes PR 19362 + Require CYGPKG_KERNEL for thread safe streams + Also don't need "requires CYGPKG_KERNEL" for per-thread rand and errno + if we already require a finer granularity kernel option + +1999-02-25 Jonathan Larmour + + * include/pkgconf/libc.h: Fix CYGNUM_LIBC_MAIN_STACK_SIZE by changing + CYGPKG_LIBC_STARTUP_MAIN_THREAD -> CYGSEM_LIBC_STARTUP_MAIN_THREAD + Fix for PR 19304 + +1999-02-23 Jonathan Larmour + + * src/stdlib/system.cxx: Add to implement trivial system() call + * include/stdlib.h: Add system() prototype + * src/PKGconf.mak: Build system.cxx + + * tests/ctype/ctype.c, tests/i18n/setlocale.c, tests/setjmp/setjmp.c, + tests/signal/signal1.c, tests/signal/signal2.c, + tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdio/stdiooutput.c, tests/stdlib/atexit.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/getenv.c, tests/stdlib/labs.c, + tests/stdlib/ldiv.c, tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/realloc.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + Use CYG_TEST_NA() macro for non-applicable test configurations + +1999-02-20 Jonathan Larmour + + * include/signal.h: + * include/signal.inl: + * src/signal/raise.cxx: + * src/signal/siginit.cxx: + * src/signal/signal.cxx: + * tests/signal/signal1.c + * tests/signal/signal2.c: + New files to implement ISO standard signals + + * src/PKGconf.mak (TESTS): + * tests/PKGconf.mak (TESTS): + Update to build new files above + + * include/stdlib.h: + * src/clibincl/stdlibsupp.hxx: + Comment and QA changes (including giving better names to some types) + + * include/libc.h: + Add new configuration options for signals + Add new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + Add a note to CYGNUM_LIBC_MAIN_STACK_SIZE option that it may be + overriden by HAL + Add new CYGFUN_LIBC_ATEXIT option and move ...ATEXIT_HANDLERS under + it + Add new CYGSEM_LIBC_EXIT_CALLS_FFLUSH option + Require CYGSEM_LIBC_STARTUP_MAIN_THREAD for "Invoke default static + constructors" option + + * src/stdlib/atexit.cxx: + Support above CYGFUN_LIBC_ATEXIT and QA changes + + * src/stdlib/exit.cxx: + Support for above new libc.h options, and some QA changes + + * src/support/cstartup.cxx: + Add support for new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + + * src/support/mainthread.cxx: + Override main stack size if the HAL has a minimum + + * src/string/strncpy.cxx: + Use improved algorithm for aligned copies - imported from newlib + QA changes + + * src/stdlib/abort.cxx: + Support raise(SIGABRT), and some QA + + * include/errno.h: + Add const attribute + + * tests/stdlib/abs.c: + QA improvements + +1999-02-04 Jesper Skov + + * src/support/cstartup.cxx: Only define cyg_libc_main_thread when + the kernel is around. + +1999-02-01 Jesper Skov + + * tests/time/clock.c: Joined the two test/NOP checks into + one. + Increased tolerance in attempt to fix PRs 18737,18787,18846. + Fixed typo. + +1999-01-28 Jonathan Larmour + + * src/string/strtok.cxx: + * src/stdlib/rand.cxx: + Include if we use kernel header files + +1999-01-25 Jonathan Larmour + + * tests/stdio/sscanf.c (test): + CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT should be + CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + Fix for PR 18786 + + * src/string/strtok.cxx: + * src/stdio/common/stdiofiles.cxx: + * src/errno/errno.cxx: + * src/stdlib/rand.cxx: + Give mutex protection objects a libc constructor priority + + * src/support/invokemain.cxx: + Add prototype for cyg_hal_invoke_constructors() + + * src/support/mainthread.cxx: + Give cyg_libc_dummy_constructor_obj a libc constructor priority, + and make its class have a public constructor + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/stdin.cxx: + Give cyg_libc_stdio_stdin/out/err static objects a libc constructor + priority + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + * src/clibincl/stream.hxx (class Cyg_StdioStream): + Remove private copy constructor. Needed to make prioritised + static constructors work. Fix for PR 18898 + +1999-01-22 Jonathan Larmour + + * src/errno/errno.cxx: + Include pkgconf/kernel.h otherwise it fails with per-thread errno + enabled + + * include/pkgconf/libc.h: + Enable per-thread errno by default since that is what POSIX would + want + + * tests/time/clock.c (test): + Placate compiler by initializing clock_first/second/third anyway, + even though they won't be in practice. This is only a test program + so adding an extra instruction doesn't matter. + + * src/i18n/locale.cxx (_setlocale): + Placate compiler, since it is dumb, by nesting, not serializing, if's + This is an idempotent change, but screws up the formatting :-(. + + * src/string/strpbrk.cxx (_strpbrk): + Change while loop to do loop to placate compiler. It'll even save an + instruction too (wow!) + +1999-01-22 John Dallaway + + * include/pkgconf/libc.h: + Add closing curly brace to CYGPKG_LIBC_STRING_STRTOK definition + +1999-01-21 Jonathan Larmour + + * include/errno.h: + Tidy up and add to header description + Change cyg_get_errno_p() to cyg_libc_get_errno_p() + Remove ifdef CYGPKG_LIBC + + * include/sys/file_if.h: + Remove - move contents to stdio.h + + * include/stdio.h: + Tidy up header description + Move FILE typedef here from sys/file_if.h + SEEK_SET, SEEK_CUR, SEEK_END defined to 0, 1, 2 respectively + for backwards compatibility with old UNIX + Change definitions of stdin/out/err to be addresses of FILE + globals - even though they're actually Cyg_StdioStream it'll work + + * include/pkgconf/libc.h: + Make CYGPRI_LIBC_WEAK et al macros depend on new ones in infra + Reorganise trace options under the individual components they are + associated with. + Reorganise thread-safety options under the individual components + they are associated with. + Add new CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS option + Misc. reformatting + Remove dependency on pkgconf/kernel.h - Configuration Tool will + generate check macros anyway. + Remove CYGPKG_LIBC_TRACE, CYGFUN_LIBC_strtok, CYGPKG_LIBC_RAND + options + Tidy up description header + + * src/clibincl/clibdata.hxx: + * src/clibincl/clibdata.inl: + * src/support/clibdata.cxx: + Remove and instead rely on each component to initialise its own data + + * src/clibincl/stdiofiles.hxx, src/clibincl/stdiofiles.inl: + New files to contain global file list and lock (if applicable). + Implemented as class with member access functions + + * src/errno/errno.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Rename cyg_get_errno_p() to cyg_libc_get_errno_p() + + * src/stdio/common/fclose.cxx: + * src/stdio/common/fflush.cxx: + * src/stdio/common/fopen.cxx: + * src/stdio/common/freopen.cxx: + Remove ifdef CYGPKG_LIBC + Use new global file access method from stdiofiles.hxx + Tidy up description header + Use new CYGBLD_ATTRIB_WEAK_ALIAS + Access errno "normally" rather than clibdata way + + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx + * src/stdio/common/stderr.cxx: + New files. Implement Cyg_StdioStream objects for each stream. In + separate self-contained files so using one doesn't bring in the + others + + * src/stdio/common/stdiofiles.cxx: + New file. Implements global files array and lock + + * src/stdlib/_exit.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Use infra CYGBLD* macros + + * src/stdlib/malloc.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Add pkgconf/kernel.h now that pkgconf/libc.h doesn't have it + Use infra CYGBLD* macros + Make pool visible externally with weak attribute and new name + cyg_libc_malloc_memorypool + + * src/stdlib/rand.cxx: + * src/stdlib/strtok.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Use infra CYGBLD* macros + + * src/support/cstartup.cxx: + Split into smaller files to make selective linking work better, + fix i386 port problem and make GDB happy + + * src/support/environ.cxx: + * src/support/invokemain.cxx: + * src/support/main.cxx: + * src/support/mainthread.cxx: + New files from bits of the old cstartup.cxx + Add support for CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG + + * src/PKGconf.mak: + Update to reflect file additions/deletion + + * tests/stdlib/rand1.c: + * tests/stdlib/rand2.c: + * tests/stdlib/rand3.c: + * tests/stdlib/srand.c: + Make conform to coding standards + Remove ifdef CYGPKG_LIBC_RAND + Tidy up description header + + * tests/string/strtok.c: + Make conform to coding standards + Remove ifdef CYGFUN_LIBC_strtok + Tidy up description header + +1999-01-15 Mark Galassi + + * tests/stdlib/getenv.c (main): added tests for the case in which + the user does not supply environ and in which the user supplies a + NULL environ. + +1999-01-15 Jesper Skov + + * src/support/cstartup.cxx: Added workaround for weak aliasing + problem in i386 gcc. + + +1999-01-15 Gary Thomas + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_STACK_SIZE): + (CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE): Change defaults to be + more reasonable on small systems. + +1999-01-04 Jonathan Larmour + + * src/support/clibdata.cxx: + Minor bug with environ not being initialised correctly by + default + +1998-12-24 Bart Veer + + * src/clibincl/stream.inl (Cyg_StdioStream): + check_this() member functions should now be const + +1998-12-22 Jonathan Larmour + + * src/string/memchr.cxx (_memchr): + treat search value parameter to memchr as an unsigned byte, + not a signed int - copied fix from newlib PR 18471 + +1998-12-21 Jonathan Larmour + + * tests/stdlib/realloc.c: + * tests/stdlib/malloc3.c: + * tests/stdlib/malloc2.c: + Warning cleanup + +1998-12-14 Jonathan Larmour + + * tests/stdlib/malloc2.c, tests/stdlib/malloc3.c, + tests/stdlib/realloc.c: + Only run these tests when we have a coalescing memory allocator + +1998-12-14 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Only check buffer init success if buffering + + * src/stdio/common/streambuf.cxx (set_buffer): + Check for diff of requested size against buffer_size, not + get_buffer_size(), since this may return -1, which won't be + equal to size, and will cause malloc to be called + +1998-12-01 Jesper Skov + + * tests/stdlib/getenv.c (main): Don't declare variables when they + are not used. + +Thu Nov 26 17:59:12 1998 Jonathan Larmour + + * tests/string/strncpy1.c: + Fix off-by-one error since it called my_strcmp() and not + my_strncmp(), which meant in included the trailing NULL when it + shouldn't have. + +1998-11-26 Jesper Skov + + * src/stdlib/qsort.cxx (_qsort): + * src/stdlib/rand.cxx (_srand): + Changed CYG_REPORT_FUNCNAMETYPE to CYG_REPORT_FUNCNAME in void + functions. + +Mon Oct 26 18:49:00 1998 Jonathan Larmour + + * src/support/cstartup.cxx (cyg_libc_dummy_main): + Silence compiler warning with cast of char * to CYG_ADDRWORD + +Wed Oct 28 17:31:21 1998 Jonathan Larmour + + * src/time/clock.cxx (_clock): + Reorder scaling expression as it was both incorrect and risked + overflow. + Fix for PR 18076 + +Mon Oct 19 14:40:06 1998 Jonathan Larmour + + * include/stdio.h (EOF): + Change from -64 to (-1), to allow broken code to work :-/ + Also change other negative defines to be within parentheses + +1998-10-19 Mark Galassi + + * include/pkgconf/libc.h: updated the doc URL + +Thu Oct 15 21:33:44 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Only include kernel thread headers when we're in thread-safe mode + + * src/time/clock.cxx: + Only include kernel clock headers if there's a kernel with the + right functionality available + + * tests/time/clock.c: + Remove unnecessary inclusion of + + Above changes are required for PR 17229 + +Wed Oct 14 16:38:55 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise inclusion of clibincl/stdiosupp.hxx and + clibincl/stream.hxx. Tidying up PR 17502 + +Wed Oct 14 14:08:56 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGPKG_LIBC_STRING_OPTIMISATIONS to + CYGPKG_LIBC_STRING_OPTIMIZATIONS to make it truely merkin. + +Tue Oct 13 19:34:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_ARGUMENTS): + Add a default argv[0] of "" as many programs assume argc>0 + The standard allows argv[0] to be "" if the program name + is not available + +1998-09-26 Bart Veer + + * src/clibincl/stdiosupp.hxx: + PR 17502: this header file now does nothing if the stdio option + is disabled completely. This is the same behaviour is + clibincl/stream.hxx, although arguably the #ifdef protection + should happen wherever the header file is #include'd rather than + in the header file itself. + + * src/clibincl/clibdata.hxx: + PR 17502: this header file still #include's internal stdio-related + header files and references the FILE structure, even if stdio is + disabled. There were some #ifdef's for CYGPKG_LIBC_STDIO already. + One more has been added for _fopen() and _fclose(). + +1998-09-25 Bart Veer + + * src/clibincl/streambuf.inl (Cyg_StdioStreamBuffer): + PR 17487: Reorder the calls to initialize member fields, to + eliminate a compiler warning. + +Fri Sep 25 19:04:29 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/string/strtok.cxx, + src/time/clock.cxx: + Only define tracing variable and tracing level macro when + the relevant tracing level config options are set. Otherwise + keep the tracing level fixed at 0 + Fix for PR 17476 + + * include/pkgconf/libc.h: + Define trace levels only if parent CYGPKG_LIBC_TRACE is defined + for consistency with Configuration Tool + + +Fri Sep 25 17:24:45 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Make definition of vscanf() dependent on CYGFUN_LIBC_STDIO_ungetc + otherwise _vfscanf() won't be compiled. This therefore would + cause a link fail iff selective linking is not enabled. + Fix for PR 17455 + +Fri Sep 25 17:23:17 1998 Jonathan Larmour + + * src/stdlib/rand.cxx: + Make compilation dependent on CYGPKG_LIBC_RAND + Fix for PR 17473 + + * tests/stdlib/srand.c: + Make definition of dummy test pass conditional on CYGPKG_LIBC_RAND + not being defined, as well as CYGPKG_LIBC + Caused compilation failure when testing PR 17473 fix + +Mon Sep 21 17:11:04 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Make sscanf test conditional on CYGFUN_LIBC_STDIO_ungetc since + _vfscanf() only gets compiled if this is defined + Fix for PR 17346 + +1998-09-20 Mark Galassi + + * include/pkgconf/libc.h: updated CDL doc strings. + +Fri Sep 18 22:18:47 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_errno_p): + Rather than this function only being available in thread-safe mode, + instead make what it returns be either the per-thread errno, or + global errno depending on the configuration. + Include (conditionally) to support this change + +Wed Sep 16 11:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove "fix me" comment which I forgot to remove before + +Tue Sep 15 19:27:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Updated descriptions and a few other minor things after review. + Notably though, the NDEBUG config option has been removed + +1998-09-15 Bart Veer + + * include/pkgconf/libc.h: + PR 17201: removed dependency on CYGPKG_KERNEL in the option + CYGNUM_LIBC_MAIN_STACK_SIZE, since the actual dependencies cannot + be expressed sensibly in the current system. + +1998-09-11 Bart Veer + + * include/pkgconf/libc.h: + Sorting out dependencies for error package. + +1998-09-10 Mark Galassi + + * include/pkgconf/libc.h: started adding doc fields to the + cdl_package data, as a pilot for now. + +Wed Sep 9 17:41:23 1998 Hugo Tyson + + * include/pkgconf/libc.h: + Add option CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE to explicitly + control whether the empty delete functions (currently) in + kernel/.../common/delete.cxx are enabled; controls code bloat, see + the comments in delete.cxx. + +Fri Sep 4 16:43:38 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add a default CYG_TEST_PASS() to make sure the test infra doesn't + complain. + Also remove the unused string functionsa + +Fri Sep 4 15:43:48 1998 Hugo Tyson + + * src/stdlib/exit.cxx (__libc_exit): + * src/stdlib/_exit.cxx (__libc__exit): + * src/stdlib/malloc.cxx (_free): + * src/stdlib/abort.cxx (abort): + * src/support/cstartup.cxx (invoke_main): + Tracing system asserted cos it was being called incorrectly; these + are void functions so you shouldn't give a type to the function + reporting call. + +Fri Sep 4 15:03:10 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Fix CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE description to refer to + the table.cxx file, not table.h + +Fri Sep 4 14:38:52 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add description for CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE since + Proven won't be making any changes to the device driver + implementation after all. + Fix for PR 17148 + + * src/clibincl/stream.inl (set_position): + Remove "fix me" line. It is obvious that this will have to change + with a filesystem interface + Fix for PR 17147 + + * src/stdio/common/freopen.cxx: + Remove "fix me" - I know about this issue + Fix for PR 17145 + + * src/stdio/common/stream.cxx (read): + Remove "fix me" and change to use memcpy + Fix for PR 17144 + +Fri Sep 4 14:36:47 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Actually add it this time! + +Fri Sep 4 13:48:13 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add new tests for misc stdio output functions + + * tests/PKGconf.mak: + Build stdiooutput.c test + +Fri Sep 4 12:52:10 1998 Jonathan Larmour + + * src/clibincl/stream.inl (write_byte): + Remove bogus assert + + * tests/stdlib/getenv.c (main): + Check whether str is NULL before doing a strcmp() + + * tests/stdio/sprintf2.c (main): + Reformat to 76 columns + +Fri Sep 4 02:10:54 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/stdio/common/stream.cxx: + Add new peek_byte method to Cyg_StdioStream + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix up buffer access to work with new peek_byte method above + Fix for PR 16954 + +Thu Sep 3 19:40:11 1998 Jonathan Larmour + + * tests/stdlib/rand1.c, tests/stdlib/rand2.c, + tests/stdlib/rand3.c: + Add extra check for CYGPKG_LIBC_RAND to decide whether the test + is applicable or not + + * tests/stdlib/rand2.c (test): + Use CYGNUM_LIBC_RAND_SEED for default seed, not 1 + + * tests/string/strtok.c: + Add extra check for CYGFUN_LIBC_strtok to decide whether the + test is applicable or not + +Wed Sep 2 19:11:40 1998 Jonathan Larmour + + * src/stdio/input/fread.cxx, src/stdio/output/fwrite.cxx: + Add fread() and fwrite() functions + + * src/PKGconf.mak: + Build fread.cxx and fwrite.cxx from above + + * src/stdio/common/stream.cxx: + Reformat to 76 columns + In write(), move initialisation of *bytes_written to start + In read(), move initialisation of *bytes_read to start + + * include/stdio.h: + Reformat to 76 columns + + Replace all references to the ANSI + standard to instead by the ISO C standard + + Add commented argument names for "documentation" + + Add fread() and fwrite() prototypes + + * src/clibincl/stdiosupp.hxx: + Copy the above changes from stdio.h, and add _fread() and _fwrite() + prototypes + + * src/stdio/output/fputs.cxx, src/stdio/input/fgets.cxx: + Reformat to 76 columns + +Wed Sep 2 15:41:15 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Reformat to 76 columns + +Wed Sep 2 14:46:18 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Use trylock_me() instead of lock_me(), and loop to prevent + deadlocks + + * src/clibincl/stream.hxx, src/clibincl/stream.inl: + Add trylock_me() method + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/fflush.cxx: + Reformat to 76 columns + +Wed Sep 2 12:24:27 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change 0x7fff to 0x7fffffff. Oops! + give main stack size option a legal_values field + Undefine tracing by default + Add some more description in the header + +Tue Sep 1 20:02:07 1998 Jonathan Larmour + + * tests/i18n/setlocale.c (cyg_package_start): + Fix typo - extra "x" for no reason at all! :-) + +Tue Sep 1 19:44:58 1998 Jonathan Larmour + + * src/i18n/locale.cxx: + Fix bug in find_locale_data() that miscalculated size of + all_locales + + Make find_locale_data() match the locale "" and add some + other things in _setlocale() to ensure that "C" gets returned + when the default locale "" is passed. + + Only check the locale pointer when it is non-NULL + + * tests/i18n/setlocale.c: + New tests for setlocale() + + * tests/PKGconf.mak: + Update to build setlocale.c test + + * src/support/cstartup.cxx: + Don't actually call system default main() "main" otherwise GDB + gets confused and thinks its the entry point. Instead make a weak + alias and call the real function something different. + +Tue Sep 1 18:31:42 1998 Jonathan Larmour + + * src/i18n/locale.cxx (_setlocale): + Fix tracing macro name and remove "str maybe used before + initialised" warning + + * tests/stdlib/qsort.c: + Correct file description header + +Tue Sep 1 17:04:32 1998 Jonathan Larmour + + * include/locale.h, src/clibincl/i18nsupp.hxx, src/i18n/locale.cxx: + New files to add support for locales as defined by the ISO C + standard. i.e. setlocale() and localeconv() functions and some + other bits + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAX_LOCALE_NAME_SIZE config option for locale + support + + * src/PKGconf.mak: + build locale.cxx + + * include/errno.h, src/clibincl/ctypesupp.hxx: + Tidy up to 76 columns + +Tue Sep 1 00:24:22 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Move environment-related options from stdlib into new + CYGPKG_LIBC_STARTUP component. Also add options for main()'s + arguments (CYGPKG_LIBC_ARGUMENTS), main()'s default stack size + (CYGNUM_LIBC_MAIN_STACK_SIZE), number of atexit handlers + (CYGNUM_LIBC_ATEXIT_HANDLERS), and whether _exit() stops the + system (CYGSEM_LIBC_EXIT_STOPS_SYSTEM). + + * src/clibincl/stdlibsupp.hxx: + Fix a few comment bugs, and add new + cyg_libc_invoke_atexit_handlers() function prototype + + * src/stdlib/_exit.cxx, src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Implement exit(), atexit() and _exit() correctly now. Also + includes cyg_libc_invoke_atexit_handlers() in atexit.cxx. Now + we get the correct behaviour of atexit(), and exit() invokes the + atexit handlers and fflushs all the stdio streams. Add plenty of + tracing of asserts too. + + * src/support/cstartup.cxx: + Make main_thread object an exported global. Allow user-settable + arguments. Add MUCH more tracing and asserts. Improve comments. + Tidy up to 76 columns + + * tests/stdlib/atexit.c: + Add simple test for atexit() and it calling registered functions + + * tests/PKGconf.mak: + Build atexit.c test + +Mon Aug 31 18:54:48 1998 Jonathan Larmour + + * src/stdlib/getenv.cxx, tests/stdlib/getenv.c: + Add support for getenv(), and some tests to ensure it works + + * src/PKGconf.mak, tests/PKGconf.mak: + Update to include getenv.cxx and getenv.c test + + * src/clibincl/clibdata.hxx: + remove prototype for environ - we expect files needing it to + define it themselves + + * src/support/clibdata.cxx: + Tidy up to 76 columns and add definition of char **environ, but + with a configurable initialiser (see libc.h below) + + * tests/stdlib/abs.c (main): + Tidy up to 76 columns + + * src/stdlib/malloc.cxx: + Tidy up to 76 columns and remove warning for undefined _memcpy() + by changing to memcpy(), and casting away signedness + + * include/pkgconf/libc.h: + Add CYGPKG_LIBC_ENVIRONMENT and CYGDAT_LIBC_DEFAULT_ENVIRONMENT + configuration options + + * include/pkgconf/libc.h, src/clibincl/clibdata.hxx: + Tidy up to 76 columns + + * include/stdlib.h: + Add getenv() prototype and tidy up to 76 columns + + * src/clibincl/stdlibsupp.hxx: + Add _getenv() prototype + +Mon Aug 31 13:37:08 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Add realloc() + + * tests/stdlib/realloc.c: + Add this file to test new realloc() functionality + + * tests/PKGconf.mak: + Build realloc test + + * tests/stdlib/malloc3.c (main), tests/stdlib/malloc2.c (main), + tests/stdlib/malloc1.c (main): + Conditionalise local vars to prevent warnings + + * tests/stdlib/malloc3.c (fill_with_data): + Move '{' into "verb" line + + * include/pkgconf/libc.h: + Require infra tracing support to allow tracing + + * include/stdlib.h: + Add realloc() + + * src/clibincl/stdlibsupp.hxx: + Update the commented argument names from stdlib.h, including realloc() + +1998-08-28 Bart Veer + + * include/pkgconf/libc.h: + * src/clibincl/clibdata.hxx, src/time/clock.cxx: + + Updated for new kernel configuration option symbol names + +Fri Aug 28 19:18:25 1998 Hugo Tyson + + Changed the entry below to sat "tx39" instead of "mn10300". + It's been a long week. + +Fri Aug 28 18:59:20 1998 Hugo Tyson + + * src/support/cstartup.cxx: Add a weakly named main to allow the + default configuration to link on the tx39 which has no + scalextric linking yet. The static Cyg_Thread main_thread object + below continues to exist, though unreferenced, so all its + descendants must exist too. + +Fri Aug 28 08:54:29 1998 Jonathan Larmour + + * include/stdlib.h: + Add commented argument names Add exit(), and atexit(). And move + these along with abort() and _exit() to a new section. + + * src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Add trivial versions of atexit() and exit() + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAIN_STACK_SIZE config option + + * include/sys/cstartup.h, src/support/cstartup.cxx, src/PKGconf.mak: + New files to provide a new function cyg_iso_c_support(), which + invokes main "correctly". + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/srand.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcoll2.c, tests/string/strcpy1.c, + tests/string/strcpy2.c, tests/string/strcspn.c, + tests/string/strlen.c, tests/string/strncat1.c, + tests/string/strncat2.c, tests/string/strncpy1.c, + tests/string/strncpy2.c, tests/string/strpbrk.c, + tests/string/strrchr.c, tests/string/strspn.c, + tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, + tests/time/clock.c: + + Modify all tests to use new startup mechanism, and cyg_iso_c_start() + +Fri Aug 28 00:29:38 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Add #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO around all accesses to + flags.last_buffer_op_was_read. Fix for PR 16997 + +Thu Aug 27 01:12:42 1998 Jonathan Larmour + + * include/sys/file_if.h: + Fix comments and remove cyg_get_file_star() + +Wed Aug 26 20:24:32 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove #define CYGPKG_LIBC is that is meant to live in + after all + +Wed Aug 26 19:39:23 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + More fixes to CDL stuff to make it work better, and look better on + the screen + +Tue Aug 25 20:21:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Make some fixes after running the ConfigTool + +Tue Aug 25 16:46:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_STDIO_BUFSIZE): + Fix typo of CYGNUM_LIBC_STDIO_BUFSIZE + +Tue Aug 25 15:10:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Tidy up CDL stuff a bit more, prior to checking it actually works. + +Tue Aug 25 11:38:52 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c (main): + Prevent calls to CYG_TEST_STILL_ALIVE for now + +Tue Aug 25 05:39:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change cosmetic paragraph alignment. + +Tue Aug 25 03:11:34 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Make stderr initialise with buffer size 0. + For PR 16955 + +Mon Aug 24 17:38:46 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + First pass at CDL-ifying the C library configuration. Currently + deliberately disabled as there a few outstanding issues. + +Mon Aug 24 16:14:22 1998 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx (_vfnprintf): + clear up warning for unused argument + + * tests/stdlib/malloc2.c (NUM_ITERATIONS): + Lower to 100 from 50000 so it won't take too long under the simulator + +Thu Aug 20 17:48:43 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Remove now unnecessary inclusion of kernel/ktypes.h + +Wed Aug 19 19:19:14 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, + tests/stdio/sscanf.c, tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, + tests/stdlib/strtoul.c, tests/string/strtok.c, + tests/time/clock.c: + Add parameters to "main()" to silence warnings + +Wed Aug 19 18:52:59 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx (refill_read_buffer): + Put conditional error check into same #ifdef and if as what was being + checked in the first place! + +Wed Aug 19 18:49:19 1998 Jonathan Larmour + + * src/clibincl/stream.inl: + Reorder Cyg_StdioStream::check_this() to be first to silence + warnings + +Tue Aug 18 16:10:03 1998 Jonathan Larmour + + * ecc/language/c/libc/current/src/clibincl/clibdata.hxx, + ecc/language/c/libc/current/src/errno/errno.cxx, + ecc/language/c/libc/current/src/stdio/common/fopen.cxx, + ecc/language/c/libc/current/src/stdlib/rand.cxx, + ecc/language/c/libc/current/src/string/strtok.cxx: + Rename CYGIMP_LIBC_INTERNAL_DATA_PREAMBLE, + CYGIMP_LIBC_INTERNAL_DATA_ALLOC_CHECK_PREAMBLE, + CYGVAR_LIBC_INTERNAL_DATA, and + CYGIMP_LIBC_INTERNAL_DATA_CHECK to all have CYGPRI_ prefix instead + as recommended by the config name rules + + +Tue Aug 18 14:31:19 1998 Jonathan Larmour + + * src/stdio/common/setvbuf.cxx (_setvbuf): + Rename variable names in assert line, otherwise doesn't build + with asserts on! + +Sun Aug 16 18:15:12 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix some bugs, although there are some left to fix still. Unrelated + to the rest of the checkins, so I will check the partial fix in now. + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx: + Add parameters to constructor to allow more things to be done at + construction time. + + Now we have "new", remove separate "construct" method + + Add more documentation on constructor + + As requested by code review, where possible, move boolean flags + into separate packed bitfield structure for space efficiency + + Make readbuf_char be usable all the time rather than when configured + not to be buffering, as it is also needed for non-buffered mode i.e. + _IONBF + + * src/stdio/common/fopen.cxx: + Change to use new method of construction from above, using new + + Use thread-specific data, rather than global. And so change errnos + to access errno entry specifically + + Make process_mode() check for append mode too + + Reformat for coding standards to have { in same line as "verb" + + * src/stdio/common/setvbuf.cxx: + + Change to cope with different way of dealing with buffering policy + flags etc. in Cyg_StdioStream + + * src/stdio/common/vsnprintf.cxx, src/stdio/common/vsscanf.cxx, + src/support/clibdata.cxx: + Change construction of streams to use new parameters added above, + and change to use _IONBF mode for string stdio functions, + otherwise its a waste of memory. And use _IONBF for stderr as the + ISO standard tells us to! + + Reformat for coding standards to have { in same line as "verb" + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Change constructor so that it can be set with default size and + dynamic buffer (if applicable) + + Fix minor bug in destructor - should only call free when allocated + dynamically + + Change get_buffer_size to return -1 if the buffer was not allowed + to be set up + + * src/stdio/common/streambuf.cxx: + Remove unnecessary stdio.h include and add extra comment to whether + to free bit in set_buffer() + + * src/stdio/common/freopen.cxx: + Change @@@ to standard fix me string + + * src/stdio/output/fputc.cxx: + Remove unnecessary "written" variable + +Thu Aug 13 15:37:28 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: + Included use of "fix me" line to ensure this is discussed before + release + + * include/stdlib.h, src/stdlib/abort.cxx, src/PKGconf.mak: + Add abort.cxx to implement abort(), albeit naively + +Thu Jul 30 18:03:09 1998 Jonathan Larmour + + * src/stdio/common/vsscanf.cxx (_vsscanf), + src/stdio/common/vsnprintf.cxx (_vsnprintf): + Fix initialiser of pseudo string device table that didn't get updated + when the table changed (Bad proven, no biscuit). + + * src/clibincl/stream.inl (~Cyg_StdioStream): + Move invalidation of magic_validity_word to after unlock_me(), + otherwise it always fails! + +Tue Jul 28 21:29:53 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Shorten over-long lines + +Tue Jul 28 20:28:23 1998 Jonathan Larmour + + * src/clibincl/stream.hxx (class Cyg_StdioStream), + src/clibincl/stream.inl, src/stdio/common/stream.cxx: + Clarify some comments and get the CYGDBG_DEFINE_CHECK_THIS and + CYG_ASSERTCLASS stuff going + + * src/clibincl/stream.inl: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 15:31:06 1998 Jonathan Larmour + + * src/clibincl/streambuf.inl, src/stdio/common/streambuf.cxx: + Move set_buffer() from streambuf.inl to new file streambuf.cxx + + * src/PKGconf.mak (COMPILE): + Build new file streambuf.cxx + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + Add METHODS comment + + * src/stdio/common/stream.cxx: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 00:26:36 1998 Jonathan Larmour + + * include/stdlib.inl, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/div.cxx, + src/stdlib/ldiv.cxx, src/stdlib/qsort.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/string/strtok.cxx: + + Include proper Berkeley license inline in the file, rather than + referring to an external file + + * doc/COPYING.UCB: + Remove, now that it isn't referred to any more + +Mon Jul 27 23:34:26 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl, include/errno.h, + include/stdio.h, include/stdio.inl, include/stdlib.h, + include/stdlib.inl, include/string.h, include/string.inl, + include/time.h, include/sys/file_if.h, src/PKGconf.mak, + src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/stdiosupp.hxx, + src/clibincl/stream.hxx, src/clibincl/streambuf.hxx, + src/clibincl/streambuf.inl, src/clibincl/stringsupp.hxx, + src/clibincl/timesupp.hxx, src/ctype/isalnum.cxx, + src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, + src/ctype/islower.cxx, src/ctype/isprint.cxx, + src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, + src/ctype/tolower.cxx, src/ctype/toupper.cxx, + src/errno/errno.cxx, src/stdio/common/snprintf.cxx, + src/stdio/common/sprintf.cxx, src/stdio/common/sscanf.cxx, + src/stdio/common/stdioinlines.cxx, src/stdio/common/stream.cxx, + src/stdio/common/ungetc.cxx, src/stdio/common/vsnprintf.cxx, + src/stdio/common/vsscanf.cxx, src/stdio/input/fgetc.cxx, + src/stdio/input/fgets.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/gets.cxx, src/stdio/input/scanf.cxx, + src/stdio/output/fnprintf.cxx, src/stdio/output/fprintf.cxx, + src/stdio/output/fputc.cxx, src/stdio/output/fputs.cxx, + src/stdio/output/printf.cxx, src/stdlib/_exit.cxx, + src/stdlib/abs.cxx, src/stdlib/atof.cxx, src/stdlib/atoi.cxx, + src/stdlib/atol.cxx, src/stdlib/div.cxx, src/stdlib/labs.cxx, + src/stdlib/ldiv.cxx, src/stdlib/rand.cxx, src/stdlib/strtod.cxx, + src/string/memchr.cxx, src/string/memcmp.cxx, + src/string/memmove.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, + src/string/strcoll.cxx, src/string/strcpy.cxx, + src/string/strcspn.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx, src/string/strpbrk.cxx, + src/string/strrchr.cxx, src/string/strspn.cxx, + src/string/strstr.cxx, src/string/strsuppt.cxx, + src/string/strtok.cxx, src/string/strxfrm.cxx, + src/support/clibdata.cxx, src/time/clock.cxx: + Untabify + +Mon Jul 27 23:14:18 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/stdlib/malloc.cxx, src/stdlib/qsort.cxx, + tests/ctype/ctype.c, tests/stdlib/rand3.c, tests/stdlib/malloc3.c: + Remove all mentions of "register" in variable declarations. Also + untabify where needed + + * src/stdlib/bsearch.cxx: + Untabify this too + + +Mon Jul 27 22:18:51 1998 Jonathan Larmour + + * src/stdio/output/fputc.cxx (_fputc): + Replace call to stream write() with call to write_byte() + + * src/clibincl/stream.inl (write_byte): + Add asserts for stream write() returning odd values for how much has + been written + + (bytes_available_to_read): + Remove "register" def for variable declaration + +Mon Jul 27 22:06:22 1998 Jonathan Larmour + + * src/stdio/common/stdiosupp.cxx: + Remove #if 0'd cyg_get_file_star() and unnecessary pseudo string + device definition + +Mon Jul 27 21:57:25 1998 Jonathan Larmour + + * include/pkgconf/libc.h, src/support/clibdata.cxx: + Change CYGXXX_LIBC_STDIO_DEFAULT_CONSOLE to + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE + +Mon Jul 27 21:49:23 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/setjmpsupp.hxx, + src/clibincl/stdiosupp.hxx, src/clibincl/stdlibsupp.hxx, + src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl, + src/clibincl/stringsupp.hxx, src/clibincl/timesupp.hxx: + + Change CYGONCE_LIBC_*_{HXX,INL} to CYGONCE_LIBC_CLIBINCL_*_{HXX,INL} + +Mon Jul 27 21:34:05 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change #define XXXXX 1 to #define XXXXX where applicable as per code + review + + Also remove obsolete CYGIMP_LIBC_THREAD_START_SUSPENDS_SELF + +Mon Jul 27 19:42:27 1998 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): + Use #ifdef, not #if for config options + +Mon Jul 27 15:01:51 BST 1998 Chris Provenzano + + * src/stdio/common/stream.cxx, src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx: + Fixes to compile with the new Cyg_IORB field names. + +Thu Jul 9 03:40:21 1998 Jonathan Larmour + + * tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Adjust starting of tests to possibly start scheduler since + strtol/stroul rely on errno, which may be a per-thread variable + +Thu Jul 9 03:06:25 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx, src/stdio/common/setvbuf.cxx: + Consolidate read and write buffers into single buffer, as it should + have been all along + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Add drain_buffer() method to speed up the case when we want the + buffer completely emptied + +Tue Jul 7 21:26:33 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Add a couple of new tests that check that very long strings work too + +Wed Jul 1 19:52:39 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/streambuf.hxx: + Do not permit copy constructors + + * src/clibincl/stream.inl, src/stdio/common/fclose.cxx: + Make sure we use #ifdef and not #if + + * src/clibincl/streambuf.inl: + Use member initialisation list rather than explicit initialisation to + reduce warnings + +Wed Jul 1 19:17:55 1998 Jonathan Larmour + + * include/pkgconf/libc.h and all files using config options: + Rename configuration defines to make them more standard + +Thu Jun 25 20:09:30 1998 Jonathan Larmour + + * src/string/strcat.cxx: + Add parentheses on check to silence warning + (Verified by proven) + +Thu Jun 25 19:30:01 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Make sure that the malloc pool is initialised before other things + can use it. This is done with the hot new constructor ordering + feature. + +Thu Jun 25 18:27:03 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Remove bogus ifdef if floating point is _not_ wanted + +Thu Jun 25 17:31:42 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Fix argument checking to allow first argument of NULL + +Thu Jun 25 04:18:50 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_strtok_last_p): + Remove bogus assertion + + * src/stdlib/malloc.cxx: + Got sense of alignment check assertion the wrong way round, so negate + it + +Thu Jun 25 03:56:35 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: + Fix argument checking assertions with legitimate nulls here too + +Thu Jun 25 03:46:32 1998 Jonathan Larmour + + * src/stdlib/strtoul.cxx, src/stdlib/strtol.cxx: + Fix argument checking assertions to cope with legitimate nulls + +Wed Jun 24 09:01:45 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Remove extraneous info messages + +Wed Jun 24 05:59:17 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c: + + Change large automatic arrays to static arrays to prevent overuse + of a potentially small stack + +Wed Jun 24 05:45:28 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/string/strtok.c, tests/time/clock.c: + + Increase thread stack size from 4K to 32K as in some cases it was + too small. + + +Tue Jun 23 20:12:31 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Add extra tests, including floating point conversion testing + +Tue Jun 23 17:01:06 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Make sure this is only compiled if CYGFUN_LIBC_strtok is defined + +Tue Jun 23 06:10:13 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + add some comments - that's all + + * src/stdio/common/stream.cxx: + fix case in refill_read_buffer() for what to do when there's nothing + left. Now return EAGAIN + + * src/stdio/common/vsscanf.cxx, src/stdio/input/vfscanf.cxx: + Get sscanf working properly and passing tests. Also make sure it + ignores FP when its not configured + + * src/stdlib/atof.cxx: + Only compile at all if strtod() is present + + +Mon Jun 22 19:13:42 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise strtok_last and rand_seed better + +Mon Jun 22 14:14:12 1998 Jonathan Larmour + + * tests/stdlib/malloc3.c: + Add test for checking that mallocing and freeing repeatedly works + + * tests/PKGconf.mak: + Update to reflect addition of the above + +Mon Jun 22 13:09:33 BST 1998 Chris Provenzano + + * src/stdio/common/fopen.cxx + * src/stdio/common/stream.cxx + * src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx + Include cyg/devs/common/iorb.h instead of iorb.hxx + + * src/stdio/common/stream.cxx + Use read_blocking and write_blocking instead of just read and + write when accessing devices through the virtual device table. + +Sun Jun 21 18:19:13 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Propagate change of return code handling for puts from stdio.inl + into here + + * src/stdio/output/fputc.cxx: + make sure the right type is used for output - byte not int + + * src/support/clibdata.cxx: + Fix #define config mistook. #endif was in wrong place + +Sun Jun 21 16:11:04 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Allow explicit construction to get around a bug when + dynamically allocating per-thread structure + +Sun Jun 21 16:02:51 1998 Jonathan Larmour + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, tests/stdlib/qsort.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + + Update tests to "do the right thing" with all configuration settings + + +Sun Jun 21 04:54:14 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + I have to be careful not to use setjmp() in a way not exactly + defined by the standard, so make sure I do, and add a comment + documenting these ways. + + Also ensure this test does the right thing in all configurations + +Sun Jun 21 04:38:15 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add extra checks for invalid configurations + Also make default for thread safety OFF + + * src/clibincl/clibdata.inl: + Adjust indentation + + * src/stdio/output/vfnprintf.cxx: + Make printf of -0.0 floating point do the right thing + +Sun Jun 21 04:28:00 1998 Jonathan Larmour + + * src/stdio/common/snprintf.cxx, src/stdio/common/sprintf.cxx, + src/stdio/common/sscanf.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/scanf.cxx, src/stdio/output/fnprintf.cxx, + src/stdio/output/fprintf.cxx, src/stdio/output/printf.cxx: + + Had to remove inline functions with varargs. Which means separating + out each function from stdioinlines.cxx into a separate file, as they + no longer belong there. So all the above files were created. + + * include/stdio.inl, src/PKGconf.mak, + src/stdio/common/stdioinlines.cxx: + Changed to take account of the above + + +Sun Jun 21 03:58:42 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c: + Update with floating-point tests. Also make sure they DTRT in all + configurations + +Fri Jun 19 19:33:06 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + accidentally initialised stdin/out/err twice + +Fri Jun 19 19:09:29 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Another typo + +Fri Jun 19 18:59:07 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Missing #endif typo + +Fri Jun 19 18:51:42 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Fix initialisation of static data members. Unsure how it worked at + all before! + +Fri Jun 19 18:01:01 1998 Jonathan Larmour + + * include/stdio.inl: + puts should check whether fputs returns non-negative, rather than + non-zero + +Fri Jun 19 17:22:52 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl: + Make inclusion of get_errno_p conditional on thread-safety + +Wed Jun 17 10:55:32 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Add weak alias of vfscanf() to _vfscanf() + +Wed Jun 17 09:10:41 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Initialise err to silence compiler warning + +Wed Jun 17 08:59:20 1998 Jonathan Larmour + + * Most important is the addition of floating point support in + src/stdio/output/vfnprintf.cxx and src/stdio/input/vfscanf.cxx. This + also required the addition of atof() and strtod() in stdlib which is + definitely no bad thing! Other than that... + + * Fix a whole bunch of stuff I messed up first time round. Also the + sprintf and sscanf tests are included again. + +Tue Jun 16 16:38:02 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Typo with not putting comment character at the beginning. Sigh. + +Tue Jun 16 14:53:09 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Forgot to (temporarily) remove fputs test for now + +Mon Jun 15 20:40:03 1998 Jonathan Larmour + + Everything to do with stdio has almost completely changed, so there's + not much point documenting individual changes. + +Mon Jun 15 18:36:01 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c: + Stop it moaning quite as much when it fails by making it exit sooner + + * tests/time/clock.c : + This isn't a compound testcase + +Thu Jun 11 17:59:13 1998 Jonathan Larmour + + * include/assert.h + Reverse sense of NDEBUG ifdef, that was left in accidentally due + to testing + +Thu Jun 11 04:58:08 1998 Jonathan Larmour + + * include/errno.h, include/string.h, src/clibincl/stringsupp.hxx: + Modify as I've now added an "error" package which defines the error + codes and strerror() + + * src/errno/strerror.cxx: + Moved to new error package and thus deleted + +Wed Jun 10 18:37:37 1998 Jonathan Larmour + + * include/assert.h: + create this header and add assert() function + +Wed Jun 10 16:23:57 1998 Jonathan Larmour + + * include/stdlib.h, src/clibincl/stdlibsupp.hxx, src/stdlib/malloc.cxx: + Add malloc(), calloc() and free() functions + + * include/pkgconf/libc.h: + Add malloc memory pool size option + + * tests/stdlib/malloc1.c, tests/stdlib/malloc2.c: + new tests for malloc + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for new files + +Wed Jun 10 15:06:16 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + Add another test + +Tue Jun 9 18:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add some setjmp config's and a macro for the noreturn attribute + + * include/setjmp.h, include/setjmp.inl, src/clibincl/setjmpsupp.hxx, + src/setjmp/longjmp.cxx, tests/setjmp/setjmp.c: + Added to implement and test setjmp() and longjmp() + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for newly added files + +Thu Jun 4 01:29:18 1998 Jonathan Larmour + + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, src/string/strcpy.cxx, + src/string/strlen.cxx, src/string/strncat.cxx, + src/string/strncmp.cxx, src/string/strncpy.cxx: + Rename CYGIMP_LIBC_PREFER_SMALL_TO_FAST to + CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST + + Also use slower but smaller version when __OPTIMIZE_SIZE__ is + defined (which comes from using gcc -Os) + +Fri May 29 16:15:04 1998 Jonathan Larmour + + * include/ctype.inl, src/ctype/isxdigit.cxx: + Fix bug that numerals aren't considered hex digits + + * include/time.h: + Change clock_t and time_t to be signed so that they can accept -1, as + required by other libc functions + + * src/clibincl/clibdata.hxx: + Fix typo that CYGIMP_LIBC_THREAD_SUPPORT should be ..._SAFETY + Also fix macro to allocate thread-specific data to not set variables + in a different stack-frame + + * tests/ctype/ctype.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/stdlib/qsort.c: + make ctr unsigned to prevent warnings + + * tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/string/strrchr.c: + Fix off by one error + + * tests/string/strspn.c: + Fix case-sensitivity problem, and off-by-one error + + * tests/string/strxfrm1.c: + Remove bogus bit of test that doesn't apply to strxfrm, and fix typo + + +Fri May 22 16:33:04 1998 Jonathan Larmour + + * src/PKGconf.mak + Remove CXXFLAGS line now that its redundant + + * tests/everything! + Do a blitz change of all tests - break some of them down into + different files, add new tests, standardize format, fix bugs, + update for recent header file changes and much more! + +Wed May 20 17:50:04 1998 Jonathan Larmour + + * tests/PKGconf.mak: + interim checkin for different dir structure for Bart + +Fri May 15 20:30:46 1998 Jonathan Larmour + + * Tidy up some loose ends I forgot: rename src/include directory to + src/clibincl. And add clibdata.inl and timesupp.hxx in there. + +Thu May 14 19:56:32 1998 Jonathan Larmour + + * Basically everything has changed in the C library. Files have + been moved, renamed, deleted and reworked. This is a major + revision, and now starts from this new baseline rather than doing + incremental changes. + +Fri Apr 17 18:43:02 1998 Jonathan Larmour + + * src/ECCconf.mak: + added for new build system (actually Bart did this, but didn't + update this ChangeLog) + +Fri Apr 17 15:03:25 1998 Hugo Tyson + + * src/stdio/device/sim.cxx: + Make it build with CYG_EMPTY_STATEMENT; the unadorned one is being + removed. + +Thu Apr 16 00:24:24 1998 Jonathan Larmour + + * All source files: + replace ECCIMP_LIBC_* conditional ifdef with CYGIMP_LIBC_* + + * include/eccconf/libc.h: + improve comments and reorder a bit + +Wed Apr 8 14:35:20 1998 Jonathan Larmour + + * Makefile.am, src/Makefile.am, tests/Makefile.am, configure.in: + many changes to integrate build structure from release tree + + * src/ctype/Makefile.am, src/ctype/Makefile.in, src/errno/Makefile.am, + src/errno/Makefile.in, src/stdio/Makefile.am, src/stdio/Makefile.in, + src/stdio/common/Makefile.am, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.am, src/stdio/device/Makefile.in, + src/stdio/output/Makefile.am, src/stdio/output/Makefile.in, + src/stdio/input/Makefile.am, src/stdio/input/Makefile.in, + src/stdlib/Makefile.am, src/stdlib/Makefile.in, + src/string/Makefile.am, src/string/Makefile.in, + src/support/Makefile.am, src/support/Makefile.in, + src/time/Makefile.am, src/time/Makefile.in: + Remove as they are now redundant with above changes + + * include/Makefile.am: + Add to support above changes + + * include/eccconf/libc.h: + Change include file for configuration from kernel to system + + * src/include/kerndiag.hxx, src/stdio/device/kerndiag.cxx, + src/time/clockfn.cxx: + Change kernel include file to eccconf/kernel.h + + * src/include/strngdev.h: + remove unnecessary kernel include + + * Makefile.in, aclocal.m4, configure, src/Makefile.in, + tests/Makefile.in, include/Makefile.in: + regenerate + +Mon Apr 6 20:55:07 1998 Jonathan Larmour + + * src/stdlib/abs.cxx, src/stdlib/atoi.cxx, src/stdlib/atol.cxx, + src/stdlib/div.cxx, src/stdlib/labs.cxx, src/stdlib/ldiv.cxx: + Separated out functions from stdlib.cxx into separate files + + * src/stdlib/stdlib.cxx: + removed to be replaced by above files + + * Makefile.am, src/stdlib/Makefile.am: + modified to support building above and not building stdlib.cxx + + * src/support/tsd.cxx: + Remove unnecessary header file includes + + * Makefile.in, src/stdlib/Makefile.in: + regenerated + +Mon Apr 6 19:19:42 1998 Jonathan Larmour + + * src/support/tsd.cxx, include/eccconf/libc.h: + remove lame hack for tx39 compiler now that its fixed + + * src/include/sim.hxx: + define constants as static to placate compiler + +Thu Apr 2 21:01:21 1998 Jonathan Larmour + + * src/ctype/ctype.cxx: + deleted and separated out into below files + + * src/ctype/isalnum.cxx, src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, src/ctype/islower.cxx, + src/ctype/isprint.cxx, src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, src/ctype/tolower.cxx, + src/ctype/toupper.cxx: + Separated out individual ctype functions from ctype.cxx into separate + files + + * Makefile.am, src/ctype/Makefile.am: + modified to reflect above deletion/additions + + * Makefile.in, src/ctype/Makefile.in: + regenerated + +Thu Apr 2 19:08:26 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: optimise using prefix increments + +Thu Apr 2 15:18:15 1998 Jonathan Larmour + + * src/string/strchr.cxx: optimise setting of mask a little + +Thu Mar 26 14:07:01 1998 Jonathan Larmour + + * src/support/tsd.cxx: fixed some typos + +Thu Mar 26 11:58:47 1998 Jonathan Larmour + + * include/eccconf/libc.h, src/support/tsd.cxx: + Implement workaround for tx39 compiler bug. + + * src/include/strsuppt.hxx: + remove prototypes for _memcpy() and _memset() as they are now in the + kernel + +Wed Mar 25 18:31:53 1998 Jonathan Larmour + + * Makefile.am, src/string/Makefile.am: memcpy() and memset() are + now in the kernel so remove them from build + * include/string.h: add a comment to say as much + * Makefile.in, src/string/Makefile.in: regenerate + +Wed Mar 25 15:30:42 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx, src/include/file_if.inl: + Change _exit workaround to not cause a compiler optimisation + problem. Now just references _exit rather than calls it. + +Wed Mar 25 14:59:49 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fix bug causing tests to fail completely + for this function + +Wed Mar 25 12:55:53 1998 Jonathan Larmour + + * src/include/sim.hxx: add types to constants (oops!) + * Makefile.am: link src/stdio/device/sim.cxx + * Makefile.in: regenerated + +Wed Mar 25 04:14:30 1998 Jonathan Larmour + + * src/include/file_if.hxx, src/include/file_if.inl, + src/include/kerndiag.hxx, src/include/sim.hxx, + src/include/stdio_if.hxx, src/include/strngdev.hxx, + src/include/tsd.hxx, src/stdio/common/clearerr.cxx, + src/stdio/common/clearerr.cxx, src/stdio/common/feof.cxx, + src/stdio/common/ferror.cxx, src/stdio/common/file_if.cxx, + src/stdio/common/vsprintf.cxx, + src/stdio/device/kerndiag.cxx, src/stdio/device/sim.cxx, + src/stdio/device/strngdev.cxx, src/stdio/output/fputc.cxx, + src/stdio/output/fputs.cxx, src/stdio/output/puts.cxx, + src/stdio/output/vfnprintf.cxx, src/support/tsd.cxx: + Modified to support buffered reads including renaming + _EccInternalFileStruct to __EccStdioStream which is what affects + most of these files + * src/include/file_if.inl, src/stdio/common/file_if.cxx: added for + the above reason + * src/stdio/common/sscanf.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/input/Makefile.am: added to provide sscanf() functionality + * include/ctype.h, include/stdio.h, include/stdlib.h, + include/string.h, include/eccconf/libc.h, src/ctype/ctype.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/stdio/common/stdio.cxx: + rename *_INLINES macros with prefix CYG rather than ECC + * include/errno.h, src/errno/errno.cxx, src/errno/strerror.cxx: + rename ErrNo to _ErrNo and add EAGAIN and EWOULDBLOCK error codes + * configure.in, Makefile.am, src/stdio/Makefile.am, + src/stdio/input/Makefile.am: add support for building + file_if.cxx sscanf.cxx and vfscanf.cxx + * src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/input/Makefile.in, configure, Makefile.in: regenerated + +Tue Mar 24 19:51:40 1998 Jonathan Larmour + + * src/time/clockfn.cxx, src/time/clock.cxx: + Renamed clock.cxx to clockfn.cxx (preserving CVS history) + * Makefile.am, src/time/Makefile.am: updated to reflect name change + * Makefile.in, src/time/Makefile.in: regenerated + +Tue Mar 24 16:28:06 1998 Jonathan Larmour + + * include/ctype.inl: Swap around definitions to get right order so + inlining works + +Tue Mar 24 14:43:05 1998 Jonathan Larmour + + * include/ctype.h, include/stdio.h, include/stdlib.h, include/string.h: + modify to only conditionally include inlines + * src/ctype/ctype.cxx, src/stdio/common/stdio.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/ctype/Makefile.am: Add to provide real linkable alternatives + to inline functions + * Makefile.am, configure.in, src/Makefile.am, + src/stdio/common/Makefile.am, src/stdlib/Makefile.am, + src/string/Makefile.am: modified to support previous additions + * include/eccconf/libc.h: redefine inline macro to add extern inline, + and add conditional defines for inline functions. Also rename + space vs. speed macro to have CYG instead of ECC prefix + * include/stdio.inl: fix comment typo + * src/stdlib/qsort.cxx: fix to define inline functions properly + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/memcpy.cxx, + src/string/memset.cxx, src/string/strcat.cxx, src/string/strchr.cxx, + src/string/strcmp.cxx, src/string/strcpy.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx + * Makefile.in, configure, src/Makefile.in, src/ctype/Makefile.in, + src/stdio/common/Makefile.in, src/stdlib/Makefile.in, + src/string/Makefile.in: regenerate + + +Mon Mar 23 19:19:49 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: added to support temporary _exit + * include/stdlib.h, include/stdlib.inl: added support for _exit and + added abs(), labs(), div() and ldiv() functions + * src/include/file_if.hxx: added support for _exit kludge + * src/stdlib/qsort.cxx: Added Berkeley copyright message + * src/time/clock.cxx: Include correct kernel config header as + CYG_CONFIGURATION rather than + * Makefile.am src/stdlib/Makefile.am: added support for _exit + * Makefile.in, src/stdlib/Makefile.in: regenerated + +Mon Mar 23 14:41:07 1998 Jonathan Larmour + + * Replace ECCPKG_ANSI_LIBC with CYGPKG_ANSI_LIBC in all source files + +Mon Mar 23 14:28:44 1998 Jonathan Larmour + + * include/string.inl: add file to provide strcoll() + * include/string.h: include string.inl + * ctype.h: include ctype.inl (oops!) + * include/stdlib.h: include stdlib.inl (oops!) + +Mon Mar 23 13:30:38 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl: added to provide ANSI ctype + functionality + * include/stdlib.h, include/stdlib.inl, src/include/stdlibbsp.hxx, + src/stdlib/Makefile.am, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/stdlib/srand.cxx, + src/stdlib/strtol.cxx, src/stdlib/strtoul.cxx: Added to provide + many stdlib functions + * src/include/tsd.hxx: modified to support rand() random number + seed, and added some comments + * configure.in, Makefile.am, src/Makefile.am: modified to support + addition of above new sources + * include/eccconf/libc.h: Add extra helpful comments, and #include + kernel config file + * src/time/clock.cxx: #include clock.inl and fix to call + get_resolution() properly now + * Makefile.in, configure, src/Makefile.in, src/errno/Makefile.in, + src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.in, src/stdio/output/Makefile.in, + src/stdlib/Makefile.in, src/strings/Makefile.in, + src/support/Makefile.in, src/time/Makefile.in, + tests/Makefile.in: regenerated + + +Sun Mar 22 21:29:25 1998 Jonathan Larmour + + * include/time.h, src/include/timesupp.hxx, src/time/clock.cxx, + src/time/Makefile.am: added to provide clock() function + * src/Makefile.am: modified to try to build in src/time directory + * include/eccconf/libc.h: added and is now the main configuration + file for this package + * acconfig.h, include/libcconf.h.in, include/stamp-h.in: removed + due to usage of libc.h above instead + * Almost all *.h, *.hxx and *.cxx: replaced LIBC_CONFIG_HEADER + defined include with simple + * configure.in: remove AM_CONFIG_HEADER of libcconf.h and + LIBC_CONFIG_HEADER definition. Also remove usage of builtin + memcpy() etc. from gcc, and generate src/time/Makefile + * Makefile.am: link in src/time/clock.o + * src/include/file_if.hxx, src/include/sim.hxx: use config header + to decide whether C library is to be used + * Makefile.in, aclocal.m4, configure, src/Makefile.in: regenerated + +Fri Mar 20 18:08:10 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fixed bug with ignoring terminating NULL + +1998-03-20 Chris Tarpy + + * configure: - regenerated + * Makefile.am: - Support added for libc testcases + * Makefile.in: regenerated + * configure.in: set c compiler, descend test dir + * tests/Makefile.in: added + * tests/Makefile.am: added + * tests/tcdiag.cxx : added + + +Thu Mar 19 11:41:56 1998 Jonathan Larmour + + * Initial check-in of everything + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/signals/current/cdl/signals.cdl b/packages/language/c/libc/signals/current/cdl/signals.cdl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/signals/current/cdl/signals.cdl @@ -0,0 +1,269 @@ +# ==================================================================== +# +# signals.cdl +# +# C library signal related configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jlarmour +# Contributors: +# Date: 2000-04-14 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_LIBC_SIGNALS { + display "ISO C library signal functions" + description " + This component controls signal functionality, + as implemented in ISO/IEC 9899:1990 chapter 7.7 with + the signal() and raise() functions. As well as + allowing a program to send itself signals, it is + also possible to cause hardware exceptions to + be signalled to the program in a similar way." + doc redirect/the-iso-standard-c-and-math-libraries.html + include_dir cyg/libc/signals + parent CYGPKG_LIBC + implements CYGINT_ISO_SIGNAL_NUMBERS + implements CYGINT_ISO_SIGNAL_IMPL + requires { CYGBLD_ISO_SIGNAL_NUMBERS_HEADER == \ + "" } + requires { CYGBLD_ISO_SIGNAL_IMPL_HEADER == \ + "" } + requires CYGPKG_ISOINFRA + compile raise.cxx siginit.cxx signal.cxx + +# ==================================================================== + + cdl_option CYGSEM_LIBC_SIGNALS_THREAD_SAFE { + display "Thread safe signals" + requires CYGPKG_KERNEL + default_value 1 + description " + Because signal handlers are global, and not + thread-specific (as mandated by POSIX 1003.1) + it is possible for multiple threads to clash + and corrupt data if setting the same signal + handler at the same time. With this option + enabled, a kernel mutex will be used to protect + the shared data." + } + + cdl_component CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS { + display "Hardware exceptions cause signals" + flavor bool + requires CYGSEM_KERNEL_EXCEPTIONS_GLOBAL + requires CYGSEM_KERNEL_EXCEPTIONS_DECODE + default_value 0 + description " + This causes hardware exceptions like + arithmetic exceptions (e.g. divide by zero) + or bad memory accesses to be passed through as + signals. It is thus possible for a program to + handle these exceptions in a generic way using + the appropriate signal handlers. The details of + exactly which exceptions are passed through + under what circumstances depend on the + underlying HAL implementation. Consequently it + must be remembered that signal handlers cannot + be guaranteed to be invoked in the expected + circumstances if you do not know about the + underlying HAL implementation - it is possible + that the architecture is unable to detect that + exception." + + cdl_option CYGSEM_LIBC_SIGNALS_CHAIN_HWEXCEPTIONS { + display "Chain old exception handlers" + requires !CYGPKG_HAL_I386_LINUX + default_value 1 + description " + When hardware exceptions are generated, it + is possible to chain into the old kernel exception + handler before calling any registered signal + handler. If this is not required, disable this + option and only the signal handler will be + called when this exception occurs. Disabling + this option will also save some space and code + usage." + } + } + + cdl_component CYGPKG_LIBC_SIGNALS_INLINE { + display "Inline versions of functions" + flavor none + description " + Some functions can be made inline instead of + being function calls. These can be set here." + + cdl_option CYGIMP_LIBC_SIGNALS_RAISE_INLINE { + display "raise()" + default_value 1 + description " + Enabling this option makes raise() an inline function." + } + + cdl_option CYGIMP_LIBC_SIGNALS_SIGNAL_INLINE { + display "signal()" + default_value 1 + description " + Enabling this option makes signal() an inline function." + } + } + + cdl_component CYGPKG_LIBC_SIGNALS_ERROR_HANDLING { + display "Error handling" + flavor none + description " + You may or may not want errno to be set by + certain functions. Not using errno could save + both space, code, and avoid worrying about + interactions between multiple threads when + setting it." + + cdl_option CYGSEM_LIBC_SIGNALS_BAD_SIGNAL_FATAL { + display "Bad signal fatal" + requires CYGDBG_USE_ASSERTS + default_value 0 + description " + Enabling this option will cause an assertion + failure if the signal handling code is + passed a bad signal. Otherwise an error will + be returned, or in the case of a + hardware-generated exception it will be silently + ignored." + } + + cdl_option CYGSEM_LIBC_SIGNALS_RAISE_SETS_ERRNO { + display "raise() sets errno" + requires CYGINT_ISO_ERRNO + requires CYGINT_ISO_ERRNO_CODES + default_value 1 + description " + You may or may not want errno to be set by + raise() on error conditions. Not using errno + could save both space, code, and avoid worrying + about interactions between multiple threads when + setting it. Strictly ISO C does not mandate + that errno be set by raise()." + } + + cdl_option CYGSEM_LIBC_SIGNALS_SIGNAL_SETS_ERRNO { + display "signal() sets errno" + requires CYGINT_ISO_ERRNO + requires CYGINT_ISO_ERRNO_CODES + default_value 1 + description " + You may or may not want errno to be set by + signal() on error conditions. Not using errno + could save both space, code, and avoid worrying + about interactions between multiple threads when + setting it. Strictly ISO C mandates + that errno be set by signal()." + } + } + + cdl_component CYGPKG_LIBC_SIGNALS_TRACING { + display "Tracing" + flavor none + description " + These options control the trace output for the C + library internal signal implementation." + + cdl_option CYGNUM_LIBC_SIGNALS_RAISE_TRACE_LEVEL { + display "Default trace level for raise()" + flavor data + legal_values 0 to 1 + default_value 0 + description " + This gives the default tracing level for the + raise() function. Higher numbers are more + verbose." + } + + cdl_option CYGNUM_LIBC_SIGNALS_HWHANDLER_TRACE_LEVEL { + display "Default hardware exception handler trace level" + flavor data + legal_values 0 to 1 + default_value 0 + description " + This gives the default tracing level for the + hardware exception handler function (if enabled). + Higher numbers are more verbose." + } + } + +# ==================================================================== + + cdl_component CYGPKG_LIBC_SIGNALS_OPTIONS { + display "C library signal functions build options" + flavor none + no_define + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_LIBC_SIGNALS_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the C library. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_LIBC_SIGNALS_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the C library. These flags are removed from + the set of global flags if present." + } + + cdl_option CYGPKG_LIBC_SIGNALS_TESTS { + display "C library signal function tests" + flavor data + no_define + calculated { "tests/signal1 tests/signal2" } + description " + This option specifies the set of tests for the C library + signal functions." + } + } +} + +# ==================================================================== +# EOF signals.cdl diff --git a/packages/language/c/libc/signals/current/include/signal.h b/packages/language/c/libc/signals/current/include/signal.h new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/signals/current/include/signal.h @@ -0,0 +1,215 @@ +#ifndef CYGONCE_LIBC_SIGNALS_SIGNAL_H +#define CYGONCE_LIBC_SIGNALS_SIGNAL_H +//======================================================================== +// +// signal.h +// +// Definitions for ISO C and POSIX 1003.1 signals +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-18 +// Purpose: Provides description of interface to ISO C and POSIX 1003.1 +// signal functionality +// Description: +// Usage: Do not include this file directly - use #include +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // libc signals configuration + +// INCLUDES + +#include // Common type definitions and support + +#ifdef CYGSEM_LIBC_SIGNALS_POSIX +# include // _POSIX_* macros +#endif + + +// TYPE DEFINITIONS + +// Integral type that can be accessed atomically - from ISO C 7.7 +typedef cyg_atomic sig_atomic_t; + +// Type of signal handler functions +typedef void (*__sighandler_t)(int); + +#ifdef CYGSEM_LIBC_SIGNALS_POSIX + +// Signal sets from POSIX 1003.1 chap 3.3.3 and other chaps +typedef cyg_uint32 sigset_t; + +// POSIX 1003.1 chap 3.3.1.2 +union sigval { + int sival_int; // used when application-defined value is an int + void *sival_ptr; // used when application-defined value is a pointer +}; + +// Signal information structure passed to a __siginfoaction_t style handler +// from POSIX 1003.1 chap 3.3.1.3 +typedef struct { + int si_signo; // signal number + int si_code; // cause of signal + union sigval si_value; // signal value +} siginfo_t; + + +// Type of signal handler used if SA_SIGINFO is set in flags to sigaction +// from POSIX 1003.1 chap 3.3.1.3 +typedef void (*__siginfoaction_t)(int __signo, siginfo_t *__info, + void *__context); + +// struct sigaction describes the action to be taken when we get a signal +// From POSIX 1003.1 chap. 3.3.4.2 +struct sigaction { + sigset_t sa_mask; // Additional signals to be blocked + int sa_flags; // Special flags + union { + __sighandler_t sa_handler; // signal handler + __siginfoaction_t sa_sigaction; // Function to call instead of + // sa_handler if SA_SIGINFO is + // set in sa_flags + } __sigactionhandler; +#define sa_handler __sigactionhandler.sa_handler +#define sa_sigaction __sigactionhandler.sa_sigaction +}; + + +#endif // ifdef CYGSEM_LIBC_SIGNALS_POSIX + + +// CONSTANTS + +// Signal handlers for use with signal(). We avoid 0 because in an embedded +// system this may be e.g. start of ROM and thus a possible function pointer +// for reset! + +#define SIG_DFL ((__sighandler_t) 1) // Default action +#define SIG_IGN ((__sighandler_t) 2) // Ignore action +#define SIG_ERR ((__sighandler_t)-1) // Error return + +// NB. We do not need to restrict SIG* definitions (e.g. by eliminating +// POSIX signals) when using strict ISO C (permitted in 7.7) + +#define SIGNULL 0 // Reserved signal - do not use (POSIX 3.3.1.1) +#define SIGHUP 1 // Hangup on controlling terminal (POSIX) +#define SIGINT 2 // Interactive attention (ISO C) +#define SIGQUIT 3 // Interactive termination (POSIX) +#define SIGILL 4 // Illegal instruction (not reset when caught) (ISO C) +#define SIGTRAP 5 // Trace trap (not reset when caught) +#define SIGIOT 6 // IOT instruction +#define SIGABRT 6 // Abnormal termination - used by abort() (ISO C) +#define SIGEMT 7 // EMT instruction +#define SIGFPE 8 // Floating Point Exception e.g. div by 0 (ISO C) +#define SIGKILL 9 // Kill (cannot be caught or ignored) (POSIX) +#if 1 // FIXME - should be #ifdef _POSIX_MEMORY_PROTECTION? +# define SIGBUS 10 // Bus error (POSIX) +#endif +#define SIGSEGV 11 // Invalid memory reference (ISO C) +#define SIGSYS 12 // Bad argument to system call (used by anything?) +#define SIGPIPE 13 // Write on a pipe with no one to read it (POSIX) +#define SIGALRM 14 // Alarm timeout (POSIX) +#define SIGTERM 15 // Software termination request (ISO C) +#define SIGUSR1 16 // Application-defined signal 1 (POSIX) +#define SIGUSR2 17 // Application-defined signal 2 (POSIX) + +#define CYGNUM_LIBC_SIGNALS 18 // Maximum signal number + 1 + +#ifdef _POSIX_JOB_CONTROL +# define SIGCHLD 18 // Child process terminated or stopped (POSIX) +# define SIGCONT 19 // Continue if stopped (POSIX) +# define SIGSTOP 20 // Stop (cannot be caught or ignored) (POSIX) +# define SIGTSTP 21 // Interactive stop (POSIX) +# define SIGTTIN 22 // Terminal read attempted by backgrounded + // process (POSIX) +# define SIGTTOU 23 // Terminal write attempted by backgrounded + // process (POSIX) +#undef CYGNUM_LIBC_SIGNALS +#define CYGNUM_LIBC_SIGNALS 24 +#endif + +// FIXME - strictly by POSIX in 3.3.1.1 we should define SIGRTMIN/SIGRTMAX +// But if so, to what value if it _isn't_ supported?! + +#ifdef CYGSEM_LIBC_SIGNALS_POSIX +// sa_flag bits in struct sigaction +#define SA_NOCLDSTOP 1 // Don't generate SIGCHLD when children stop +#define SA_SIGINFO 2 // Use the __siginfoaction_t style signal + // handler, instead of the single argument handler +#endif // ifdef CYGSEM_LIBC_SIGNALS_POSIX + + +// FUNCTION PROTOTYPES + +#ifdef __cplusplus +extern "C" { +#endif + +//=========================================================================== + +// ISO C functions + +////////////////////////////// +// signal() - ISO C 7.7.1 // +////////////////////////////// +// +// Installs a new signal handler for the specified signal, and returns +// the old handler +// + +extern __sighandler_t +signal(int __sig, __sighandler_t __handler); + +/////////////////////////// +// raise() - ISO C 7.7.2 // +/////////////////////////// +// +// Raises the signal, which will cause the current signal handler for +// that signal to be called +// + +extern int +raise(int __sig); + + +#ifdef __cplusplus +} // extern "C" +#endif + +#include + +#endif // CYGONCE_LIBC_SIGNALS_SIGNAL_H multiple inclusion protection + +// EOF signal.h diff --git a/packages/language/c/libc/signals/current/include/signal.inl b/packages/language/c/libc/signals/current/include/signal.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/signals/current/include/signal.inl @@ -0,0 +1,269 @@ +#ifndef CYGONCE_LIBC_SIGNALS_SIGNAL_INL +#define CYGONCE_LIBC_SIGNALS_SIGNAL_INL +//======================================================================== +// +// signal.inl +// +// Inline functions for implementation of ISO C and POSIX signals +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-18 +// Purpose: Implements required inline functions of ISO C and +// POSIX 1003.1 signals +// Description: +// Usage: Do not include this file directly, instead use +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // libc signals configuration + +// INCLUDES + +#include // Header for this file, just in case +#include // Assertion infrastructure +#include // Tracing infrastructure + +// GLOBALS + +extern __sighandler_t cyg_libc_signal_handlers[]; +#ifdef CYGDBG_USE_TRACING +extern cyg_uint8 cyg_libc_signals_raise_trace_level; +#endif + +// DEFINES + +// The following are overriden by the libc implementation to get a non-inline +// version to prevent duplication of code +#ifndef CYGPRI_LIBC_SIGNALS_RAISE_INLINE +# define CYGPRI_LIBC_SIGNALS_RAISE_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_SIGNALS_SIGNAL_INLINE +# define CYGPRI_LIBC_SIGNALS_SIGNAL_INLINE extern __inline__ +#endif + +// FUNCTION PROTOTYPES + +#ifdef __cplusplus +extern "C" { +#endif + +// Default signal handler - SIG_DFL +extern void cyg_libc_signals_default_handler(int __sig); + +#ifdef CYGSEM_LIBC_SIGNALS_THREAD_SAFE +extern cyg_bool cyg_libc_signals_lock_do_lock(void); +extern void cyg_libc_signals_lock_do_unlock(void); +#endif + +// INLINE FUNCTIONS + +///////////////////////////// +// cyg_libc_signals_lock() // +///////////////////////////// + +static inline cyg_bool +cyg_libc_signals_lock(void) +{ +#ifdef CYGSEM_LIBC_SIGNALS_THREAD_SAFE + return cyg_libc_signals_lock_do_lock(); +#else + return true; +#endif +} // cyg_libc_signals_lock() + +/////////////////////////////// +// cyg_libc_signals_unlock() // +/////////////////////////////// + +static inline void +cyg_libc_signals_unlock(void) +{ +#ifdef CYGSEM_LIBC_SIGNALS_THREAD_SAFE + cyg_libc_signals_lock_do_unlock(); +#else + return; +#endif +} // cyg_libc_signals_unlock() + +// ISO C functions + +////////////////////////////// +// signal() - ISO C 7.7.1 // +////////////////////////////// + + +#ifdef CYGIMP_LIBC_SIGNALS_SIGNAL_INLINE + +#ifdef CYGSEM_LIBC_SIGNALS_SIGNAL_SETS_ERRNO +# include // errno +#endif + +CYGPRI_LIBC_SIGNALS_SIGNAL_INLINE __sighandler_t +signal(int __sig, __sighandler_t __handler) +{ + __sighandler_t __old_handler; + CYG_REPORT_FUNCNAMETYPE( "__signal", "returning %08x" ); + + CYG_REPORT_FUNCARG2( "signal number = %d, requested handler is at %08x", + __sig, __handler ); + + // check valid signal - raise should not raise the null signal either + if ( (__sig >= CYGNUM_LIBC_SIGNALS) || (__sig <= 0) ) { + +#ifdef CYGSEM_LIBC_SIGNALS_BAD_SIGNAL_FATAL + CYG_FAIL("__signal() passed bad signal number"); +#else +# ifdef CYGSEM_LIBC_SIGNALS_SIGNAL_SETS_ERRNO + errno = EINVAL; +# endif + return SIG_ERR; +#endif + } + + // paranoia + CYG_CHECK_DATA_PTR( cyg_libc_signal_handlers, + "signal handler array is invalid!" ); + if ( (__handler != SIG_IGN) && (__handler != SIG_DFL) ) + CYG_CHECK_FUNC_PTR( __handler, "__signal() passed invalid handler"); + + if (!cyg_libc_signals_lock()) { +#ifdef CYGSEM_LIBC_SIGNALS_SIGNAL_SETS_ERRNO + errno = EINTR; +#endif + return SIG_ERR; + } // if + + __old_handler = cyg_libc_signal_handlers[__sig]; + cyg_libc_signal_handlers[__sig] = __handler; + + cyg_libc_signals_unlock(); + + CYG_REPORT_RETVAL( __old_handler ); + + return __old_handler; +} // signal() +#endif // ifdef CYGIMP_LIBC_SIGNALS_SIGNAL_INLINE + + +/////////////////////////// +// raise() - ISO C 7.7.2 // +/////////////////////////// + +#ifdef CYGIMP_LIBC_SIGNALS_RAISE_INLINE + +#ifdef CYGSEM_LIBC_SIGNALS_RAISE_SETS_ERRNO +# include // errno +#endif + +CYGPRI_LIBC_SIGNALS_RAISE_INLINE int +raise(int __sig) +{ + int __ret=0; + __sighandler_t __sigfun; + + CYG_REPORT_FUNCNAMETYPE( "__raise", "returning %d" ); + + CYG_REPORT_FUNCARG1( "signal number = %d", __sig ); + + // check valid signal - raise should not raise the null signal either + if ( (__sig >= CYGNUM_LIBC_SIGNALS) || (__sig <= 0) ) { + +#ifdef CYGSEM_LIBC_SIGNALS_BAD_SIGNAL_FATAL + CYG_FAIL("__raise() passed bad signal number"); +#else +# ifdef CYGSEM_LIBC_SIGNALS_RAISE_SETS_ERRNO + errno = EINVAL; +# endif + return -1; +#endif + } + + // paranoia + CYG_CHECK_DATA_PTR( cyg_libc_signal_handlers, + "signal handler array is invalid!" ); + + if (!cyg_libc_signals_lock()) { +#ifdef CYGSEM_LIBC_SIGNALS_RAISE_SETS_ERRNO + errno = EINTR; +#endif + return -1; + } // if + + __sigfun = cyg_libc_signal_handlers[__sig]; + + switch ( (CYG_ADDRESS)__sigfun ) { + + case (CYG_ADDRESS)SIG_DFL: + CYG_TRACE0(cyg_libc_signals_raise_trace_level, + "signal handler returned is SIG_DFL"); + cyg_libc_signals_unlock(); + cyg_libc_signals_default_handler(__sig); + break; + + case (CYG_ADDRESS)SIG_IGN: + CYG_TRACE0(cyg_libc_signals_raise_trace_level, + "signal handler returned is SIG_IGN"); + cyg_libc_signals_unlock(); + + break; + + default: + CYG_TRACE1(cyg_libc_signals_raise_trace_level, + "signal handler returned is at %08x", __sigfun); + // call the signal handler directly + cyg_libc_signal_handlers[__sig] = SIG_DFL; + + cyg_libc_signals_unlock(); + CYG_CHECK_FUNC_PTR( __sigfun, "returned signal handler invalid!"); + + (*__sigfun)(__sig); + break; + } + + CYG_REPORT_RETVAL( __ret ); + + return __ret; +} // raise() +#endif // ifdef CYGIMP_LIBC_SIGNALS_RAISE_INLINE + + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // CYGONCE_LIBC_SIGNALS_SIGNAL_INL multiple inclusion protection + +// EOF signal.inl diff --git a/packages/language/c/libc/signals/current/src/raise.cxx b/packages/language/c/libc/signals/current/src/raise.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/signals/current/src/raise.cxx @@ -0,0 +1,69 @@ +//======================================================================== +// +// raise.cxx +// +// ISO C and POSIX 1003.1 signals implementation for raise() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-18 +// Purpose: Provide implementation of ISO C and POSIX 1003.1 raise() +// Description: This file provides the linkable symbol version of raise() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // libc signals configuration + +// INCLUDES + +#include // Common type definitions and support + +// The following lines allow __raise() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_SIGNALS_RAISE_INLINE +#ifndef CYGIMP_LIBC_SIGNALS_RAISE_INLINE +# define CYGIMP_LIBC_SIGNALS_RAISE_INLINE +#endif + +#include // Main signals definitions + +// GLOBALS + +#ifdef CYGDBG_USE_TRACING +cyg_uint8 +cyg_libc_signals_raise_trace_level = CYGNUM_LIBC_SIGNALS_RAISE_TRACE_LEVEL; +#endif + +// EOF raise.cxx diff --git a/packages/language/c/libc/signals/current/src/siginit.cxx b/packages/language/c/libc/signals/current/src/siginit.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/signals/current/src/siginit.cxx @@ -0,0 +1,425 @@ +//======================================================================== +// +// siginit.cxx +// +// ISO C and POSIX 1003.1 signals implementation +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-18 +// Purpose: Provide implementation of ISO C and POSIX 1003.1 signals +// Description: This file initializes all hardware exceptions, +// initializes the signal handler table and provides the +// default action function for signals +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // libc signals configuration + +// INCLUDES + +#include // Common type definitions and support +#include // Main signals definitions +#include // Assertion infrastructure +#include // Tracing infrastructure +#include // exit() + +#ifdef CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS +# include // required for kernel includes +# include // Kernel exception API +# include // Cyg_Thread::self() +# include // inline definitions for above +# include // Interrupt enable +# include // HAL interrupt control +#endif + +#ifdef CYGSEM_LIBC_SIGNALS_THREAD_SAFE +# include // required for kernel includes +# include +#endif + +// TYPE DEFINITIONS + +// define dummy class to allow initialization of cyg_libc_signal_handlers + +class Cyg_libc_signals_dummy_init_class { +public: + Cyg_libc_signals_dummy_init_class(); +}; + +#ifdef CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS + +struct exception_signal_mapping_t { + cyg_code exception; + int signal; +}; + +// EXTERNS + +extern cyg_exception_handler cyg_null_exception_handler; + +#endif // ifdef CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS + +// GLOBALS + +// main signal handlers +__sighandler_t cyg_libc_signal_handlers[CYGNUM_LIBC_SIGNALS]; + +#ifdef CYGSEM_LIBC_SIGNALS_THREAD_SAFE +Cyg_Mutex cyg_libc_signal_handlers_mutex CYG_INIT_PRIORITY(LIBC); +#endif + +// STATICS + +// dummy object to invoke constructor +static Cyg_libc_signals_dummy_init_class +cyg_libc_signals_dummy_init_obj CYG_INIT_PRIORITY(LIBC); + +#ifdef CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS + +# ifdef CYGDBG_USE_TRACING +static cyg_uint8 cyg_libc_signals_hwhandler_trace_level = + CYGNUM_LIBC_SIGNALS_HWHANDLER_TRACE_LEVEL; +# define TL1 (0 < cyg_libc_signals_hwhandler_trace_level) +# endif + +# ifdef CYGSEM_LIBC_SIGNALS_CHAIN_HWEXCEPTIONS +// old exception info so we can chain +// FIXME: consider malloced linked list config option +static struct { + cyg_exception_handler *old_handler; + CYG_ADDRWORD old_data; +} exception_chain_data[CYGNUM_HAL_EXCEPTION_COUNT]; +# endif + +// struct that maps exceptions to signals +static const struct exception_signal_mapping_t +exception_signal_mapping[] = { + +#ifdef CYGNUM_HAL_EXCEPTION_DATA_ACCESS + {CYGNUM_HAL_EXCEPTION_DATA_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_WRITE + {CYGNUM_HAL_EXCEPTION_DATA_WRITE, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_ACCESS + {CYGNUM_HAL_EXCEPTION_CODE_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_WRITE + {CYGNUM_HAL_EXCEPTION_CODE_WRITE, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_EXECUTE + {CYGNUM_HAL_EXCEPTION_CODE_EXECUTE, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_IO_ACCESS + {CYGNUM_HAL_EXCEPTION_IO_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_IO_WRITE + {CYGNUM_HAL_EXCEPTION_IO_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_ACCESS + {CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_ACCESS, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_WRITE + {CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_WRITE, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_TLBMISS_ACCESS + {CYGNUM_HAL_EXCEPTION_CODE_TLBMISS_ACCESS, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_TLBMISS_WRITE + {CYGNUM_HAL_EXCEPTION_CODE_TLBMISS_WRITE, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_TLBERROR_ACCESS + {CYGNUM_HAL_EXCEPTION_DATA_TLBERROR_ACCESS, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_TLBERROR_WRITE + {CYGNUM_HAL_EXCEPTION_DATA_TLBERROR_WRITE, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_TLBERROR_ACCESS + {CYGNUM_HAL_EXCEPTION_CODE_TLBERROR_ACCESS, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_CODE_TLBERROR_WRITE + {CYGNUM_HAL_EXCEPTION_CODE_TLBERROR_WRITE, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS + {CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_WRITE + {CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_WRITE, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_IO_UNALIGNED_ACCESS + {CYGNUM_HAL_EXCEPTION_IO_UNALIGNED_ACCESS, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_IO_UNALIGNED_WRITE + {CYGNUM_HAL_EXCEPTION_IO_UNALIGNED_WRITE, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION + {CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION, SIGILL}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_INTERRUPT + {CYGNUM_HAL_EXCEPTION_INTERRUPT, SIGINT}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_TRAP + {CYGNUM_HAL_EXCEPTION_TRAP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DIV_BY_ZERO + {CYGNUM_HAL_EXCEPTION_DIV_BY_ZERO, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_OVERFLOW + {CYGNUM_HAL_EXCEPTION_OVERFLOW, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_BOUNDS + {CYGNUM_HAL_EXCEPTION_BOUNDS, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_SINGLE_STEP + {CYGNUM_HAL_EXCEPTION_SINGLE_STEP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_INSTRUCTION_BP + {CYGNUM_HAL_EXCEPTION_INSTRUCTION_BP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_PERIPHERAL_BP + {CYGNUM_HAL_EXCEPTION_PERIPHERAL_BP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_BP + {CYGNUM_HAL_EXCEPTION_DATA_BP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DEVELOPMENT_BP + {CYGNUM_HAL_EXCEPTION_DEVELOPMENT_BP, SIGTRAP}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_STACK_OVERFLOW + {CYGNUM_HAL_EXCEPTION_STACK_OVERFLOW, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_STACK_FAULT + {CYGNUM_HAL_EXCEPTION_STACK_FAULT, SIGSEGV}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_PARITY + {CYGNUM_HAL_EXCEPTION_PARITY, SIGBUS}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_FPU + {CYGNUM_HAL_EXCEPTION_FPU, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_FPU_NOT_AVAIL + {CYGNUM_HAL_EXCEPTION_FPU_NOT_AVAIL, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_FPU_OVERFLOW + {CYGNUM_HAL_EXCEPTION_FPU_OVERFLOW, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_FPU_UNDERFLOW + {CYGNUM_HAL_EXCEPTION_FPU_UNDERFLOW, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_FPU_DIV_BY_ZERO + {CYGNUM_HAL_EXCEPTION_FPU_DIV_BY_ZERO, SIGFPE}, +#endif +#ifdef CYGNUM_HAL_EXCEPTION_SYSTEM_CALL + {CYGNUM_HAL_EXCEPTION_SYSTEM_CALL, SIGSYS}, +#endif + {0, 0} // dummy value to ensure compiler is happy +}; + + +// FUNCTIONS + +///////////////////////////////////////// +// cyg_libc_signals_hwexcept_handler() // +///////////////////////////////////////// + +// FIXME: should be able to get this work with +// CYGSEM_KERNEL_EXCEPTIONS_DECODE disabled as well as enabled +static void +cyg_libc_signals_hwexcept_handler( CYG_ADDRWORD data, cyg_code exception, + CYG_ADDRWORD info) +{ + int signal = (int)data; + int ret; + + CYG_REPORT_FUNCNAME("cyg_libc_signals_hwexcept_handler"); + + CYG_REPORT_FUNCARG3( "data = %08x, exception = %d, info = %08x", + data, exception, info ); + +#ifdef CYGSEM_LIBC_SIGNALS_BAD_SIGNAL_FATAL + CYG_PRECONDITION((signal > 0) && (signal < CYGNUM_LIBC_SIGNALS), + "Signal number not valid!"); +#endif + +// chain first as it may be more useful more low-level stuff needed +#ifdef CYGSEM_LIBC_SIGNALS_CHAIN_HWEXCEPTIONS + // map exception to 0..CYGNUM_HAL_EXCEPTION_COUNT + exception -= CYGNUM_HAL_EXCEPTION_MIN; + + // special case for null handler since it is only for uncaught exceptions + + if (exception_chain_data[exception].old_handler != + cyg_null_exception_handler) { + (*exception_chain_data[exception].old_handler)( + exception_chain_data[exception].old_data, exception, info); + CYG_TRACE0(TL1, "Chained exception handler returned"); + } // if +#endif + +#ifndef CYGSEM_LIBC_SIGNALS_BAD_SIGNAL_FATAL + // if not fatal, silently return + if ((signal <= 0) || (signal >= CYGNUM_LIBC_SIGNALS)) { + CYG_REPORT_RETURN(); + return; + } +#endif + + CYG_TRACE0(TL1, "Enabling interrupts"); + HAL_ENABLE_INTERRUPTS(); + + CYG_TRACE0(TL1, "Raising signal"); + ret = raise(signal); + + if (ret) { + CYG_TRACE1(TL1, "raise() returned non-zero value %d!!!", ret); + } // if + + CYG_REPORT_RETURN(); +} // cyg_libc_signals_hwexcept_handler() + + +////////////////// +// reg_except() // +////////////////// + +static void inline +reg_except( cyg_code exception, int signal ) +{ + Cyg_Thread::self()->register_exception( + exception, &cyg_libc_signals_hwexcept_handler, (CYG_ADDRWORD)signal, +#ifdef CYGSEM_LIBC_SIGNALS_CHAIN_HWEXCEPTIONS + &exception_chain_data[exception - + CYGNUM_HAL_EXCEPTION_MIN].old_handler, + &exception_chain_data[exception - CYGNUM_HAL_EXCEPTION_MIN].old_data +#else + NULL, NULL +#endif + ); + +} // reg_except(); + +#endif // ifdef CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS + +/////////////////////////////////////////////////// +// Cyg_libc_signals_dummy_init_class constructor // +/////////////////////////////////////////////////// + +Cyg_libc_signals_dummy_init_class::Cyg_libc_signals_dummy_init_class() +{ + cyg_ucount8 i; + + CYG_REPORT_FUNCNAME("Cyg_libc_signals_dummy_init_class constructor"); + + // FIXME: some should be SIG_IGN? + for (i=0; i= + CYGNUM_HAL_EXCEPTION_MIN), + "Asked to register bad exception"); + + CYG_ASSERT( (exception_signal_mapping[i].signal > 0) && + (exception_signal_mapping[i].signal < + CYGNUM_LIBC_SIGNALS), "Asked to register bad signal" ); + + reg_except( exception_signal_mapping[i].exception, + exception_signal_mapping[i].signal); + } +#endif + + CYG_REPORT_RETURN(); +} // Cyg_libc_signals_dummy_init_class() constructor + + +//////////////////////////////////////// +// cyg_libc_signals_default_handler() // +//////////////////////////////////////// + +// Default signal handler - SIG_DFL +externC void +cyg_libc_signals_default_handler(int sig) +{ + CYG_REPORT_FUNCNAME( "cyg_libc_signals_default_handler" ); + + CYG_REPORT_FUNCARG1( "signal number = %d", sig ); + + exit(1000 + sig); // FIXME + + CYG_REPORT_RETURN(); +} // cyg_libc_signals_default_handler() + +#ifdef CYGSEM_LIBC_SIGNALS_THREAD_SAFE +///////////////////////////////////// +// cyg_libc_signals_lock_do_lock() // +///////////////////////////////////// + +externC cyg_bool +cyg_libc_signals_lock_do_lock(void) +{ + cyg_bool ret; + CYG_REPORT_FUNCNAMETYPE("cyg_libc_signals_lock_do_lock", "returning %d"); + + ret = cyg_libc_signal_handlers_mutex.lock(); + + CYG_REPORT_RETVAL(ret); + + return ret; +} // cyg_libc_signals_lock_do_lock() + +/////////////////////////////////////// +// cyg_libc_signals_lock_do_unlock() // +/////////////////////////////////////// + +externC void +cyg_libc_signals_lock_do_unlock(void) +{ + CYG_REPORT_FUNCNAME("cyg_libc_signals_lock_do_unlock"); + + cyg_libc_signal_handlers_mutex.unlock(); + + CYG_REPORT_RETURN(); +} // cyg_libc_signals_lock_do_unlock() + +#endif // ifdef CYGSEM_LIBC_SIGNALS_THREAD_SAFE + +// EOF siginit.cxx diff --git a/packages/language/c/libc/signals/current/src/signal.cxx b/packages/language/c/libc/signals/current/src/signal.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/signals/current/src/signal.cxx @@ -0,0 +1,62 @@ +//======================================================================== +// +// signal.cxx +// +// ISO C and POSIX 1003.1 signals implementation +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-18 +// Purpose: Provide implementation of ISO C and POSIX 1003.1 signals +// Description: This file provides the linkable symbol version of raise() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // libc signals configuration + +// INCLUDES + +#include // Common type definitions and support + +// The following lines allow __raise() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_SIGNALS_SIGNAL_INLINE +#ifndef CYGIMP_LIBC_SIGNALS_SIGNAL_INLINE +# define CYGIMP_LIBC_SIGNALS_SIGNAL_INLINE +#endif + +#include // Main signals definitions + +// EOF signal.cxx diff --git a/packages/language/c/libc/signals/current/tests/signal1.c b/packages/language/c/libc/signals/current/tests/signal1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/signals/current/tests/signal1.c @@ -0,0 +1,200 @@ +//======================================================================== +// +// signal1.c +// +// ISO C signal handling test +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-18 +// Purpose: Test signal functionality +// Description: This file contains a number of tests for ISO C signal +// handling +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // libc signals configuration + +// INCLUDES + +#include // Common type definitions and support +#include // Test infrastructure +#include // Signal functions +#include // setjmp(), longjmp() +#include // abort() + +// STATICS + +static int state; +static jmp_buf jbuf; + +// FUNCTIONS + +static void +myhandler1(int signal) +{ + CYG_TEST_INFO("myhandler1 called"); + ++state; +} // myhandler1() + +static void +myhandler2(int signal) +{ + CYG_TEST_INFO("myhandler2 called"); + ++state; + longjmp(jbuf, 1); +} // myhandler2() + +int +main( int argc, char *argv[] ) +{ + __sighandler_t handler1; + int rc; + + // special callout to request GDB to alter its handling of signals + CYG_TEST_GDBCMD("handle SIGTERM nostop"); + CYG_TEST_GDBCMD("handle SIGABRT nostop"); + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C " + "library signal functions"); + + // Test 1 + + CYG_TEST_INFO("Test 1"); + state = 1; + handler1 = signal(SIGTERM, &myhandler1); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "SIGTERM handler initialized to default"); + + rc = raise(SIGTERM); + + CYG_TEST_PASS_FAIL(0==rc, "raise(SIGTERM) did not return error"); + + CYG_TEST_PASS_FAIL(2==state, "SIGTERM handler returned correctly"); + + // Test 2 + + CYG_TEST_INFO("Test 2"); + + state = 2; + handler1 = signal(SIGTERM, &myhandler2); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "SIGTERM handler reset to default after test 1"); + + handler1 = signal(SIGTERM, &myhandler1); + + CYG_TEST_PASS_FAIL(handler1 == &myhandler2, + "SIGTERM handler was set correctly"); + + rc = raise(SIGTERM); + + CYG_TEST_PASS_FAIL(0==rc, "raise(SIGTERM) did not return error"); + + CYG_TEST_PASS_FAIL(3==state, "SIGTERM handler returned correctly"); + + // Test 3 + + CYG_TEST_INFO("Test 3"); + + handler1 = signal(SIGTERM, &myhandler2); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "SIGTERM handler reset to default after test 2"); + + handler1 = signal(SIGTERM, SIG_DFL); + + CYG_TEST_PASS_FAIL(handler1 == &myhandler2, + "SIGTERM handler was set correctly"); + + // Test 4 + + CYG_TEST_INFO("Test 4"); + + state = 4; + handler1 = signal(SIGTERM, SIG_IGN); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "SIGTERM handler was set correctly after test 3"); + rc = raise(SIGTERM); + + CYG_TEST_PASS_FAIL(0==rc, "raise(SIGTERM) did not return error"); + + CYG_TEST_PASS_FAIL(4==state, "SIGTERM ignored"); + + // Test 5 + + CYG_TEST_INFO("Test 5"); + + state = 5; + handler1 = signal(SIGTERM, &myhandler2); + + // SIG_IGN doesn't reset back to SIG_DFL after a raise() + CYG_TEST_PASS_FAIL(handler1 == SIG_IGN, + "SIGTERM handler was set correctly after test 4"); + + if (0==setjmp(jbuf)) { + raise(SIGTERM); + CYG_TEST_FAIL("raise returned"); + } + + CYG_TEST_PASS_FAIL(6==state, "SIGTERM handler returned correctly"); + + // Test 6 + + CYG_TEST_INFO("Test 6"); + + state = 6; + handler1 = signal(SIGABRT, &myhandler2); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "SIGABRT handler initialized to default"); + + if (0==setjmp(jbuf)) { + abort(); + CYG_TEST_FAIL("abort returned"); + } + + CYG_TEST_PASS_FAIL(7==state, "SIGABRT handler returned correctly"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C " + "library signal functions"); + +} // main() + +// EOF signal1.c diff --git a/packages/language/c/libc/signals/current/tests/signal2.c b/packages/language/c/libc/signals/current/tests/signal2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/signals/current/tests/signal2.c @@ -0,0 +1,276 @@ +//======================================================================== +// +// signal2.c +// +// ISO C signal handling test +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-18 +// Purpose: Test hardware signal functionality +// Description: This file contains a number of tests for ISO C signal +// handling when used with hardware exceptions +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include +#include // C library signals configuration + +// INCLUDES + +#include // Common type definitions and support +#include // Test infrastructure + +#ifdef CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS + +#include // exception ranges & + // HAL_VSR_SET_TO_ECOS_HANDLER + +#include // Signal functions +#include // setjmp(), longjmp() + +// STATICS + +static int state; +static jmp_buf jbuf; +#endif + +// FUNCTIONS + +#ifdef CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS + +static void +myhandler(int sig) +{ + __sighandler_t handler1; + + CYG_TEST_INFO("myhandler() called"); + ++state; + + handler1 = signal(sig, &myhandler); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "handler reset itself to default"); + + longjmp(jbuf, 1); +} // myhandler() + +static void +cause_memerror(void) +{ + volatile int x; + volatile CYG_ADDRESS p=(CYG_ADDRESS) &state; + + do { + // do a read which prevents us accidentally writing over something + // important. Make it misaligned to increase the chances of an + // exception happening + x = *(volatile int *)(p+1); + p += (CYG_ADDRESS)0x100000; + } while(p != 0); +} // cause_memerror() + +// num must always be 0 - do it this way in case the optimizer tries to +// get smart +static int +cause_fpe(int num) +{ + double a; + + a = 1.0/num; // Depending on FPU emulation and/or + // the FPU architecture, this may + // cause an exception. + // (float division by zero) + + return ((int)a)/num; // This may cause an exception if + // the architecture supports it. + // (integer division by zero). +} // cause_fpe() + +#endif + +int +main( int argc, char *argv[] ) +{ +#ifdef CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS + __sighandler_t handler1; + + // special callout to request GDB to alter its handling of signals + CYG_TEST_GDBCMD("handle SIGBUS nostop"); + CYG_TEST_GDBCMD("handle SIGSEGV nostop"); + CYG_TEST_GDBCMD("handle SIGILL nostop"); + CYG_TEST_GDBCMD("handle SIGFPE nostop"); + CYG_TEST_GDBCMD("handle SIGSYS nostop"); + +// Not sure about this - Jifl. Do any of our targets generate SIGTRAP anyway? +#if 0 +#ifndef CYGPKG_HAL_I386_LINUX + CYG_TEST_GDBCMD("handle SIGTRAP nostop pass"); +#endif +#endif +#endif // ifdef CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS + + CYG_TEST_INIT(); + +#ifdef CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS + // Avoid compiler warnings if tests are not applicable. + if (0) cause_memerror(); + if (0) cause_fpe(0); +#endif + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C " + "library signal functions"); + +// Now reset the exception handlers various to eCos handlers so that we +// have control; this is the target side equivalent of the CYG_TEST_GDBCMD +// lines above: +#ifdef HAL_VSR_SET_TO_ECOS_HANDLER + // Reclaim the VSR off CygMon possibly +#ifdef CYGNUM_HAL_EXCEPTION_DATA_ACCESS + HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DATA_ACCESS, NULL ); +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_ACCESS + HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_ACCESS, NULL ); +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS + HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS, NULL ); +#endif +#ifdef CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION + HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION, NULL ); +#endif +#ifdef CYGNUM_HAL_EXCEPTION_DIV_BY_ZERO + HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DIV_BY_ZERO, NULL ); +#endif +#endif + +#ifdef CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS + + + // Test 1 + + CYG_TEST_INFO("Test 1"); + + handler1 = signal(SIGSEGV, &myhandler); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "SIGSEGV handler initialized to default"); + + + handler1 = signal(SIGBUS, &myhandler); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "SIGBUS handler initialized to default"); + + + handler1 = signal(SIGILL, &myhandler); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "SIGILL handler initialized to default"); + + handler1 = signal(SIGSYS, &myhandler); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "SIGSYS handler initialized to default"); + + handler1 = signal(SIGTRAP, &myhandler); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "SIGTRAP handler initialized to default"); + + handler1 = signal(SIGFPE, &myhandler); + + CYG_TEST_PASS_FAIL(handler1 == SIG_DFL, + "SIGFPE handler initialized to default"); + + // Test 2 + + CYG_TEST_INFO("Test 2"); + + state = 2; + +#if defined(CYGPKG_HAL_POWERPC_SIM) + // The exception generated by the SIM is not recognized by GDB. + // PR 19945 workaround. + CYG_TEST_PASS("Test 2 not applicable to PowerPC SIM"); +#else + if (0==setjmp(jbuf)) { + cause_memerror(); + CYG_TEST_FAIL("Didn't cause exception"); + } + + CYG_TEST_PASS_FAIL(3==state, "handler returned correctly"); +#endif + + // Test 3 + + CYG_TEST_INFO("Test 3"); + + state = 3; + +#if defined(CYGPKG_HAL_SH_EDK7708) + CYG_TEST_PASS("Test 3 not applicable to sh 7708"); +#elif defined(CYGPKG_HAL_MN10300) + CYG_TEST_PASS("Test 3 not applicable to mn10300"); +#elif defined(CYGPKG_HAL_MIPS_TX39) + CYG_TEST_PASS("Test 3 not applicable to mips-tx39"); +#elif defined(CYGPKG_HAL_SPARCLITE) + CYG_TEST_PASS("Test 3 not applicable to sparclite"); +#elif defined(CYGPKG_HAL_I386_LINUX) + CYG_TEST_PASS("Test 3 not applicable to i386/Linux"); + // See linux.S for details. +#elif defined(CYGPKG_HAL_POWERPC) + CYG_TEST_PASS("Test 3 not applicable to PowerPC"); +#elif defined(CYGPKG_HAL_ARM) + CYG_TEST_PASS("Test 3 not applicable to ARM"); +#else + + if (0==setjmp(jbuf)) { + (void)cause_fpe(0); + CYG_TEST_FAIL("Didn't cause exception"); + } + + CYG_TEST_PASS_FAIL(4==state, "handler returned correctly"); +#endif + +#else + CYG_TEST_NA("Testing not applicable to this configuration"); +#endif + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C " + "library signal functions"); + +} // main() + +// EOF signal2.c diff --git a/packages/language/c/libc/startup/current/ChangeLog b/packages/language/c/libc/startup/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/ChangeLog @@ -0,0 +1,66 @@ +2000-08-07 Jonathan Larmour + + * src/invokemain.cxx: Declare cyg_hal_stop_constructors + +2000-07-31 Jonathan Larmour + + * src/cstartup.cxx: Fix typo + +2000-07-19 Jonathan Larmour + + * cdl/startup.cdl: + Make a "radio button" choice between how main() gets invoked (eCos + thread vs. cyg_user_start vs. someone else doing it) + + * src/mainthread.cxx: Move cyg_libc_dummy_constructor_class to + src/invokemain.cxx + + * src/invokemain.cxx: Invoke pthread_exit() instead of exit() if + relevant + + * src/cstartup.cxx: + Only fiddle with cyg_user_start() if + CYGSEM_LIBC_STARTUP_MAIN_INITCONTEXT defined + +2000-07-04 Jonathan Larmour + + * src/abort.cxx: Fix configuration dependency on CYGINT_ISO_SIGNAL_IMPL + +2000-05-20 Jonathan Larmour + + * cdl/startup.cdl (CYGSEM_LIBC_EXIT_STOPS_SYSTEM): + default to 0 always + +2000-05-02 Jonathan Larmour + + * New package + Separated original libc out into separate packages on functional + boundaries. + Header files are now managed by isoinfra package + Plenty of cleanups done, but no major functionality changes + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/startup/current/ChangeLog.libc b/packages/language/c/libc/startup/current/ChangeLog.libc new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/ChangeLog.libc @@ -0,0 +1,2727 @@ +This ChangeLog file is now obsolete. This is the original ChangeLog from when +libc was one large package, before being separated. It is included for +historical reasons. + +2000-04-05 Jesper Skov + + * src/time/settime.cxx: + * src/time/time.cxx: + Wallclock moved to io/. + +2000-03-28 John Dallaway + + * cdl/string.cdl, + cdl/stdlib.cdl, + cdl/stdio.cdl, + cdl/libc.cdl: + + Adjust documentation URLs. + +2000-03-27 Jesper Skov + + * src/clibincl/stream.inl (check_this): Use cyb_bool instead of bool. + +2000-03-06 Jesper Skov + + * tests/time/strftime.c (test): Adjust test to match below change. + +2000-03-02 Jonathan Larmour + + * src/time/strftime.cxx (do_format): Make sure %m counts from + 1..12 rather than 0..11. Fix for case 103300 + +2000-02-29 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: Correctly use 'n' parameter to + restrict length. Credit due to Andrew Lunn here as well. + Resolves 103057-CR-1 + + * tests/stdio/sprintf2.c (test): + Add snprintf tests to verify the correct behaviour of restricting + output length + +2000-02-10 Jesper Skov + + * tests/signal/signal2.c (main): + Also reclaim DATA_TLB_MISS vector if available. + +2000-01-31 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-28 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-19 Hugo Tyson + + * cdl/*.cdl: Add descriptions to a number of options &c which were + lacking same, also tidied up other typos as noticed en passant. + +1999-11-11 Bart Veer + + * cdl/string.cdl: + Switch to a single boolean configuration option for code size vs. + speed optimization. + +1999-11-03 John Dallaway + + * cdl/libc.cdl: Define tests. + +1999-10-19 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: We can now remove Berkeley + advertising clause + * src/stdlib/div.cxx: ditto + * src/stdlib/ldiv.cxx: ditto + * src/stdlib/strtol.cxx: ditto + * src/stdlib/strtoul.cxx: ditto + * src/string/strtok.cxx: ditto + +1999-10-19 John Dallaway + + * cdl/libc.cdl: + + Define CDL options for package-specific CFLAGS. + +1999-10-08 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_THREAD_PRIORITY): Change + default to 10 to keep test farm happy + * cdl/startup.cdl: Likewise + +1999-10-07 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Specify radio buttons using CDL interfaces. + +1999-10-06 Jonathan Larmour + + * cdl/stdio.cdl: Change default to /dev/ttydiag as per 1999-10-01 + change below + * cdl/startup.cdl: Add new form CDL for the startup changes as + per 1999-10-05 + +1999-10-05 Jonathan Larmour + + * include/libc.h: Add CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM to allow + the user to supply their own stack. + Rename CYGNUM_LIBC_MAIN_STACK_SIZE to + CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE and reparent under + CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + Add CYGNUM_LIBC_MAIN_THREAD_PRIORITY to provide main() thread + priority + + * src/support/mainthread.cxx: Add support for user-supplied stack + Allow user to specify thread priority + + These changes fix CR 101069 + +1999-10-01 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE): Change + default to /dev/ttydiag to get correct console-like behaviour + Also don't preclude use if haldiag package isn't included + (case 102065) + +1999-09-15 Jesper Skov + + * tests/signal/signal2.c (cause_fpe): Try both float and integer + division by zero. + +1999-09-10 Jesper Skov + + * src/stdlib/malloc.cxx (cyg_libc_get_malloc_pool): Added for + stress_threads test. + +1999-09-07 Jesper Skov + PRs 20243, 20433 + * tests/signal/signal2.c: Disabled test3 on ARM. + +1999-09-02 Hugo Tyson + + * include/assert.h: Make the sense of NDEBUG correct; it is "set" + when NOT debugging. Fix for CR 101983-CR-1 + See Stroustrup, "The C++ Programming Language." + +1999-08-18 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): Set buffer size 0 when not + buffering + Fix for case 101868 + +1999-08-17 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Implement radio buttons using "FIXME radio" hack in + description field for now. + +1999-08-12 John Dallaway + + * cdl/stdlib.cdl: + Take advantage of MACRONAME_ENUMVAL macros output by CDL. + +1999-08-06 Jonathan Larmour + + * tests/stdio/sprintf2.c (test): Don't rely on 2.345 being exactly + representable in binary as a difference of 1 ulp will make it round + the wrong way. + +1999-07-16 Jonathan Larmour + + * src/stdio/input/fgetc.cxx: + Include outline versions of getc() (actually just a symbol alias for + fgetc() ) and getchar() + Some minor clean-ups + Add tracing/assertions + + * src/stdio/input/fputc.cxx: + Likewise (except applied to putc() and putchar()) + + * src/stdio/common/stdioinlines.cxx (_puts): + Call fputc() not _fputc() + + * src/clibincl/stdiosupp.hxx: + Remove now obsolete prototypes for _fgetc() and _fputc() + + * include/stdio.h: + Don't bother with getc()/putc() macros any more, just call + them as functions + Include protos for getc(), putc(), getchar() and putchar() functions + +1999-06-21 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for SH EDK7708. + +1999-06-11 Jonathan Larmour + + * include/stdio.h: Make FILEs array types so they won't be + given $gp relocations on MIPS targets + +1999-05-27 Jesper Skov + + * tests/time/ctime.c: Fixed compiler warning. + +1999-05-25 Jonathan Larmour + + * tests/signal/signal2.c (main): + Update CYGPKG_HAL_TX39 -> CYGPKG_HAL_MIPS_TX39 due to recent MIPS + HAL changes + Fix for PR 20116 + +1999-04-30 Jesper Skov + PR 19945/19946 workaround + * tests/signal/signal2.c: Disabled test 3 for PowerPC sim. + +1999-04-19 Jonathan Larmour + + * include/time.inl: + Ensure all calls to cyg_libc_time_year_is_leap() are with the full + year, and not the direct contents of a struct tm, which are (year-1900) + +1999-04-19 Jesper Skov + PR 19308, 19410, 19528 + * tests/time/clock.c (test): Also disable data cache which may + affect timing when tracing/assertions are enabled. + +1999-04-15 Jonathan Larmour + + * src/clibincl/stdiosupp.hxx: + Add prototype for new cyg_libc_stdio_flush_all_but() function + + * src/clibincl/stream.hxx: + Don't include stdiosupp.hxx any more to prevent circular dependency, + therefore manually provide _setvbuf prototype + Make sure pkgconf/kernel.h is included before mutex.hxx + + * src/clibincl/stream.inl (Cyg_StdioStream::set_error()): + Add missing unlock_me() + + * src/stdio/common/fflush.cxx: + Separate most of code for fflush(NULL) into separate + cyg_libc_stdio_flush_all_but() function, which has the extra + capability of omitting one stream + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Add missing clibincl/stdiosupp.hxx include + + * src/stdio/common/stream.cxx (Cyg_StdioStream::read()): + When reading, ensure we flush all output streams + + * src/stdio/common/stream.cxx (Cyg_StdioStream::flush_output_unlocked): + Flush the device as well + +1999-04-15 Jonathan Larmour + + * src/stdio/common/streambuf.cxx (set_buffer): + * src/stdio/common/stdioinlines.cxx (_setbuf): + * src/clibincl/streambuf.inl: + * src/clibincl/streambuf.hxx: + * src/clibincl/stream.hxx (class Cyg_StdioStream): + * include/pkgconf/libc.h: + * include/stdio.inl (setbuf): + Fix dumb typo: BUFSIZE -> BUFSIZ + This fixes PR19837 + +1999-04-15 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx (_setbuf): + * include/stdio.inl (setbuf): + Use _IONBF when buf==NULL, and _IOLBF otherwise. + Fix for PR 19836 + +1999-04-15 John Dallaway + + * include/pkgconf/libc.h: Tidy display string capitalization. + +1999-04-12 Jonathan Larmour + + * include/pkgconf/libc.h: + Clarify CDL description of CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE + + * tests/signal/signal2.c: Try harder to generate an exception by + accessing a misaligned address + Don't handle SIGTRAP any more + Part of fix for PRs 19731/19607 + +1999-04-07 Jesper Skov + PR 19667 + * src/support/mainthread.cxx: + Changed to use the new Cyg_Thread constructor. + +1999-04-07 Hugo Tyson + + * tests/signal/signal2.c (main): Use new macro + HAL_VSR_SET_TO_ECOS_HANDLER if defined, to wrest control from + CygMon, for example, by reinstalling eCos' default VSRs for + exceptions that we are provoking. + +1999-03-29 Jonathan Larmour + + * src/signal/siginit.cxx: Include stdlib.h for exit() + Fix for PR 19720 + +1999-03-29 Jonathan Larmour + + * tests/time/clock.c (test): Disable instruction cache + Hopefully fixes PR 19308 + +1999-03-29 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for PPC as it cannot + trap division by zero. + +1999-03-26 Jonathan Larmour + + * src/support/main.cxx (main): Invoke cyg_user_start() if no kernel + Only sensible thing to do in our default main in a non-kernel config + +1999-03-25 Jonathan Larmour + + * tests/time/time.c: + Increase MAX_TIMEOUT since the sparclite gets very close to overrunning + it even when working. + Should return -1 iff CYGSEM_LIBC_TIME_TIME_WORKING isn't defined + Cosmetic changes + +1999-03-25 Hugo Tyson + + * tests/time/time.c (test): Take into account setting of + CYGSEM_LIBC_TIME_SETTIME_WORKING ie. does cyg_libc_time_settime() + work? If not, check that it returns an error. + This was exposed by the random combo in PR#19479. + +1999-03-23 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 to + CYGIMP_... + + Add another rand implementation CYGIMP_LIBC_RAND_SIMPLE1 which is + the default + + Part of fix for PR 19562 + + * include/sys/cstartup.h: + Tidy and remove unnecessary dependencies + + * src/stdlib/rand.cxx: + Rename algorithms from CYGSEM_... to CYGIMP_... + Add new "simple1" algorithm + + * tests/ctype/ctype.c: + Tidy + + * tests/stdlib/rand3.c: + Fix so that 0..RAND_MAX is split evenly over buckets, which it wasn't + before + Deal with case of RAND_MAX not being divisible by NUM_BUCKETS + exactly + Increase TEST_LENGTH to 200000 to provide more representative sample + Add CYG_TEST_INFO output to help ensure it doesn't time out + Tidy + + * tests/stdlib/rand4.c: + Only fail if more than _two_ thirds (rather than one third) match. + This is because half would match for a perfectly random distribution + This is the rest of the fix for PR 19562 + Cosmetic changes + +1999-03-22 Hugo Tyson + + * src/support/mainthread.cxx (CYGNUM_LIBC_MAIN_STACK_SIZE): + Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of + CYGNUM_HAL_MINIMUM_STACK_SIZE. + +1999-03-22 Jonathan Larmour + + * tests/PKGconf.mak: Add -Wno-format when building strftime otherwise + it generates warnings for things that we do want to test (null + string, and %y format) + +1999-03-19 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Put brackets back round negative number since sdf says the config + tool is fixed now (PR 19537) + + Add new CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 + options for different rand() algorithms in a so far failed attempt + to fix PR 19562 + + * src/stdlib/rand.cxx: + Add new optional algorithm from Knuth vol.2 + + * tests/stdlib/rand4.c: + Some tidies + Don't run test when using simplest algorithm + + * tests/signal/signal2.c (main): + Don't try to make an FPE on tx39 - its possible to detect but requires + too much HAL work to be sensible + +1999-03-18 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Use HAL_ENABLE_INTERRUPTS() rather than kernel to enable interrupts + +1999-03-18 Mark Galassi + + * tests/PKGconf.mak (TESTS): added rand4 compilation. + + * tests/stdlib/rand4.c: added this test for periodicity in the + least significant bit of rand(). + +1999-03-18 Jonathan Larmour + + * include/pkgconf/libc.h: Remove CYGFUN_LIBC_TIME_POSIX dependency + on CYGPKG_LIBC_STDIO + + * src/stdlib/itoa.cxx: + New file to convert integers to ascii + + * include/stdlib.h: + Add proto for new cyg_libc_itoa() function + + * include/time.inl: + Rework __asctime_r() to use memcpy() and cyg_libc_itoa() rather than + sprintf() + + * src/PKGconf.mak: + Build stdlib/itoa.cxx + + The above changes fix PR 19448 + +1999-03-17 Jonathan Larmour + + * include/time.h: Add #define of __time_t_defined to placate newlib + if it is used by accident. This is just a temporary workaround though. + +1999-03-16 Gary Thomas + + * src/PKGconf.mak: Add compile option to step around ARM compiler bug. + +1999-03-16 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Don't use parentheses for now + + * src/stdio/common/stream.cxx (refill_read_buffer): + Silence bogus compiler warning + +1999-03-16 Jesper Skov + + * tests/signal/signal2.c (main): Enable SIGSEGV test for + i386/Linux. + + +1999-03-15 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Only enable interrupts if they were disabled + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: + Add FIX ME line as a reminder that the workaround there can go away + in future + + * include/pkgconf/libc.h: + Add proper define for CYGSEM_LIBC_EXIT_CALLS_FFLUSH + Put brackets round negative CYGNUM_LIBC_TIME_DST_DEFAULT_STATE define + Fix run time typo + + * include/time.inl (__localtime_r): + Include sys/timeutil.h before this to get + cyg_libc_time_normalize_structtm() + +1999-03-12 Gary Thomas + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: Remove 'const' from char arrays since + this fails [silently] on ARM when -fwritable-strings (PR19440) + +1999-03-12 Jesper Skov + + * tests/signal/signal2.c (main): Compiler warnings fix was + slightly broken. + +1999-03-12 Jesper Skov + PR 19473 + * tests/signal/signal2.c (main): + Disabling SIGTRAP handling on i386/Linux is not a good idea. +1999-03-11 Jesper Skov + PR 19473 + * tests/signal/signal2.c: + Added compiler warnings fix. + Added N/A handling for i386/Linux. + +1999-03-10 Gary Thomas + + * include/pkgconf/libc.h: Force "haldiag" device to be present. + 'asctime' and friends need 'stdio' as well. + + * include/time.inl: Fix syntax error on difftime() declaration. + +1999-03-08 Gary Thomas + + * src/clibincl/stream.hxx: needed for this file. + + * src/stdio/common/vsscanf.cxx (str_read): Fix problem with string + pointer [created by merge with new I/O package]. + +1999-03-05 John Dallaway + + * include/pkgconf/libc.h: + Add legal values for CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET + and CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET. + +1999-03-05 Jonathan Larmour + + * include/time.inl (cyg_libc_time_year_is_leap): + Fix bug with modulo year 400 + Fix typo in asctime_r macro + Fix gmtime_r, and mktime as a result of testing + + * tests/time/asctime.c, tests/time/ctime.c, tests/time/gmtime.c, + tests/time/gmtime.c, tests/time/localtime.c, tests/time/mktime.c, + tests/time/strftime.c, tests/time/time.c: + New tests + + * tests/PKGconf.mak: + Build above new tests + + * include/pkgconf/libc.h: + Add reminder FIX ME about extra config option + + * src/time/strftime.cxx: + Fix %w and %Y parameters as a result of testing + + * src/time/timeutil.cxx: + Fix cyg_libc_time_normalize_structtm() as a result of testing + of mktime() + + * tests/time/clock.c: + Reformat, remove obsolete bits and tidy + + * include/time.h: + Add Cyg_libc_time_dst type and new functions + cyg_libc_time_setzoneoffsets(), cyg_libc_time_setdst(), + cyg_libc_time_getzoneoffsets(), cyg_libc_time_settime() + + * include/time.inl: + Implement the above functions. This allows us to adjust for timezone + diffences and set the time. + Change localtime() to adjust for STD/DST + Change mktime() to adjust for STD/DST + + * include/libc.h: + Add new config options CYGSEM_LIBC_TIME_SETTIME_WORKING + and component CYGPKG_LIBC_TIME_ZONES containing options + CYGNUM_LIBC_TIME_DST_DEFAULT_STATE, + CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET, + CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET + + * src/strftime.cxx: + Adjust handling of %Z to _not_ deal with STD/DST + + * src/time/settime.cxx: + New file to implement cyg_libc_time_settime() + + * src/PKGconf.mak: + Build settime.cxx + + * src/time/timeutil.cxx: + Supply outline versions of cyg_libc_time_setzoneoffsets(), + cyg_libc_time_setdst(), and cyg_libc_time_getzoneoffsets() + Add variables for STD/DST state + Some minor comment changes + + * include/errno.h: + Use CYGBLD_ATTRIB_CONST instead of __attribute__((const)) directly + + * include/signal.h: + Change format of function comment headers + + * include/signal.inl: + Restrict errno.h inclusion to when its actually used + Fix a spelling typo + + * include/stdlib.h: + Add CYGBLD_ATTRIB_CONST to abs, div, labs, ldiv + + * include/stdlib.inl: + Reformat and tidy + Include new versions of div and ldiv which are more portable and + are cleanly rewritten so aren't covered by the BSD licence, which + is now removed + + * src/stdlib/div.cxx, src/stdlib/ldiv.cxx: + Non-inline, non-BSD and portable versions of the new versions of div + and ldiv from stdlib.inl + + * include/time.h: + Much reformatting, tidying and improving comments + Change CLOCKS_PER_SEC from 1000 to 1000000 + Add new functions asctime_r, ctime_r, gmtime_r, localtime_r, clock, + difftime, mktime, time, asctime, ctime, gmtime, localtime, strftime + Include new time.inl file + + * include/pkgconf/libc.h: + Add new options CYGSEM_LIBC_TIME_CLOCK_WORKING, + CYGSEM_LIBC_TIME_TIME_WORKING, CYGFUN_LIBC_TIME_POSIX, + CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL, CYGIMP_LIBC_TIME_ASCTIME_INLINE, + CYGIMP_LIBC_TIME_CTIME_INLINE, CYGIMP_LIBC_TIME_DIFFTIME_INLINE, + CYGIMP_LIBC_TIME_GMTIME_INLINE, CYGIMP_LIBC_TIME_LOCALTIME_INLINE, + CYGIMP_LIBC_TIME_MKTIME_INLINE, CYGIMP_LIBC_TIME_ASCTIME_R_INLINE, + CYGIMP_LIBC_TIME_CTIME_R_INLINE, CYGIMP_LIBC_TIME_GMTIME_R_INLINE, + and CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE + + * time/asctime.cxx, time/asctime_r.cxx, time/clock.cxx, time/ctime.cxx, + time/ctime_r.cxx, time/difftime.cxx, time/gmtime.cxx, + time/gmtime_r.cxx, time/localtime.cxx, time/localtime_r.cxx, + time/mktime.cxx, time/strftime.cxx, time/time.cxx, time/timeutil.cxx, + include/time.inl: + New files to implement the new time functions. Many of them simply + provide the outline definitions, but the real body of the function + comes from time.inl + + * src/PKGconf.mak: + Build new .cxx files + + * src/clibincl/stdlibsupp.hxx: + Remove _div and _ldiv prototypes since they're no longer needed + + * src/clibincl/timesupp.hxx: + Delete as its now obsolete + + * src/time/clock.cxx: + Use new CYGSEM_LIBC_TIME_CLOCK_WORKING option to control whether it + just returns (clock_t)-1 or not. + Much reformatting and tidying + Change real imlpementation from _clock to __clock + Use CYGBLD_ATTRIB_WEAK_ALIAS now + + * tests/stdlib/div.c, tests/stdlib/ldiv.c: + Add some extra tests for handling of negative numbers + Reformat and tidy a bit, including removing the test for CYGPKG_LIBC + since its now always defined if the test is to be compiled + + * tests/time/clock.c: + Remove duplication CYG_TEST_INFO line + Check if unimplemented using "(clock_t)-1" and not just "-1" + +1999-03-04 Jonathan Larmour + + * src/stdlib/system.cxx: + Make sure system() is a weak alias for __system() + + * include/pkgconf/libc.h: Rework CDL description for + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE and change its default to + "/dev/haldiag" + + * src/stdio/common/stream.cxx: + Check that dev is valid when passed to stream constructor + + * src/stdio/common/stdiosupp.cxx: + Tidy + + * src/support/mainthread.cxx: Make this depend on + CYGSEM_LIBC_STARTUP_MAIN_THREAD rather than just CYGPKG_KERNEL + +1999-03-04 Gary Thomas + + Merged in changes from 'ecos-new_devs-19990216-branch' + + (1999-02-24 Jonathan Larmour ) + + * src/stdio/common/stream.cxx: + Add "fix me" comments and remove a couple of commented out lines + + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Revert to using pointer to string for private data, not just string. + This preserves the state across multiple calls + + (1999-02-24 Gary Thomas ) + + * src/stdio/common/vsscanf.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/stream.cxx: + * src/stdio/common/stdiosupp.cxx: + * src/stdio/common/fopen.cxx: + * src/clibincl/stream.inl: + * src/clibincl/stream.hxx: + * src/clibincl/stdiosupp.hxx: + * include/pkgconf/libc.h: Changes for new I/O system. + +1999-03-03 Jonathan Larmour + + * tests/stdlib/atexit.c: Forgot to config atexit test for + CYGFUN_LIBC_ATEXIT option + + * include/pkgconf/libc.h: + Require CYGVAR_KERNEL_THREADS_DATA for CYGSEM_LIBC_PER_THREAD_STRTOK + This fixes PR 19362 + Require CYGPKG_KERNEL for thread safe streams + Also don't need "requires CYGPKG_KERNEL" for per-thread rand and errno + if we already require a finer granularity kernel option + +1999-02-25 Jonathan Larmour + + * include/pkgconf/libc.h: Fix CYGNUM_LIBC_MAIN_STACK_SIZE by changing + CYGPKG_LIBC_STARTUP_MAIN_THREAD -> CYGSEM_LIBC_STARTUP_MAIN_THREAD + Fix for PR 19304 + +1999-02-23 Jonathan Larmour + + * src/stdlib/system.cxx: Add to implement trivial system() call + * include/stdlib.h: Add system() prototype + * src/PKGconf.mak: Build system.cxx + + * tests/ctype/ctype.c, tests/i18n/setlocale.c, tests/setjmp/setjmp.c, + tests/signal/signal1.c, tests/signal/signal2.c, + tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdio/stdiooutput.c, tests/stdlib/atexit.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/getenv.c, tests/stdlib/labs.c, + tests/stdlib/ldiv.c, tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/realloc.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + Use CYG_TEST_NA() macro for non-applicable test configurations + +1999-02-20 Jonathan Larmour + + * include/signal.h: + * include/signal.inl: + * src/signal/raise.cxx: + * src/signal/siginit.cxx: + * src/signal/signal.cxx: + * tests/signal/signal1.c + * tests/signal/signal2.c: + New files to implement ISO standard signals + + * src/PKGconf.mak (TESTS): + * tests/PKGconf.mak (TESTS): + Update to build new files above + + * include/stdlib.h: + * src/clibincl/stdlibsupp.hxx: + Comment and QA changes (including giving better names to some types) + + * include/libc.h: + Add new configuration options for signals + Add new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + Add a note to CYGNUM_LIBC_MAIN_STACK_SIZE option that it may be + overriden by HAL + Add new CYGFUN_LIBC_ATEXIT option and move ...ATEXIT_HANDLERS under + it + Add new CYGSEM_LIBC_EXIT_CALLS_FFLUSH option + Require CYGSEM_LIBC_STARTUP_MAIN_THREAD for "Invoke default static + constructors" option + + * src/stdlib/atexit.cxx: + Support above CYGFUN_LIBC_ATEXIT and QA changes + + * src/stdlib/exit.cxx: + Support for above new libc.h options, and some QA changes + + * src/support/cstartup.cxx: + Add support for new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + + * src/support/mainthread.cxx: + Override main stack size if the HAL has a minimum + + * src/string/strncpy.cxx: + Use improved algorithm for aligned copies - imported from newlib + QA changes + + * src/stdlib/abort.cxx: + Support raise(SIGABRT), and some QA + + * include/errno.h: + Add const attribute + + * tests/stdlib/abs.c: + QA improvements + +1999-02-04 Jesper Skov + + * src/support/cstartup.cxx: Only define cyg_libc_main_thread when + the kernel is around. + +1999-02-01 Jesper Skov + + * tests/time/clock.c: Joined the two test/NOP checks into + one. + Increased tolerance in attempt to fix PRs 18737,18787,18846. + Fixed typo. + +1999-01-28 Jonathan Larmour + + * src/string/strtok.cxx: + * src/stdlib/rand.cxx: + Include if we use kernel header files + +1999-01-25 Jonathan Larmour + + * tests/stdio/sscanf.c (test): + CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT should be + CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + Fix for PR 18786 + + * src/string/strtok.cxx: + * src/stdio/common/stdiofiles.cxx: + * src/errno/errno.cxx: + * src/stdlib/rand.cxx: + Give mutex protection objects a libc constructor priority + + * src/support/invokemain.cxx: + Add prototype for cyg_hal_invoke_constructors() + + * src/support/mainthread.cxx: + Give cyg_libc_dummy_constructor_obj a libc constructor priority, + and make its class have a public constructor + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/stdin.cxx: + Give cyg_libc_stdio_stdin/out/err static objects a libc constructor + priority + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + * src/clibincl/stream.hxx (class Cyg_StdioStream): + Remove private copy constructor. Needed to make prioritised + static constructors work. Fix for PR 18898 + +1999-01-22 Jonathan Larmour + + * src/errno/errno.cxx: + Include pkgconf/kernel.h otherwise it fails with per-thread errno + enabled + + * include/pkgconf/libc.h: + Enable per-thread errno by default since that is what POSIX would + want + + * tests/time/clock.c (test): + Placate compiler by initializing clock_first/second/third anyway, + even though they won't be in practice. This is only a test program + so adding an extra instruction doesn't matter. + + * src/i18n/locale.cxx (_setlocale): + Placate compiler, since it is dumb, by nesting, not serializing, if's + This is an idempotent change, but screws up the formatting :-(. + + * src/string/strpbrk.cxx (_strpbrk): + Change while loop to do loop to placate compiler. It'll even save an + instruction too (wow!) + +1999-01-22 John Dallaway + + * include/pkgconf/libc.h: + Add closing curly brace to CYGPKG_LIBC_STRING_STRTOK definition + +1999-01-21 Jonathan Larmour + + * include/errno.h: + Tidy up and add to header description + Change cyg_get_errno_p() to cyg_libc_get_errno_p() + Remove ifdef CYGPKG_LIBC + + * include/sys/file_if.h: + Remove - move contents to stdio.h + + * include/stdio.h: + Tidy up header description + Move FILE typedef here from sys/file_if.h + SEEK_SET, SEEK_CUR, SEEK_END defined to 0, 1, 2 respectively + for backwards compatibility with old UNIX + Change definitions of stdin/out/err to be addresses of FILE + globals - even though they're actually Cyg_StdioStream it'll work + + * include/pkgconf/libc.h: + Make CYGPRI_LIBC_WEAK et al macros depend on new ones in infra + Reorganise trace options under the individual components they are + associated with. + Reorganise thread-safety options under the individual components + they are associated with. + Add new CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS option + Misc. reformatting + Remove dependency on pkgconf/kernel.h - Configuration Tool will + generate check macros anyway. + Remove CYGPKG_LIBC_TRACE, CYGFUN_LIBC_strtok, CYGPKG_LIBC_RAND + options + Tidy up description header + + * src/clibincl/clibdata.hxx: + * src/clibincl/clibdata.inl: + * src/support/clibdata.cxx: + Remove and instead rely on each component to initialise its own data + + * src/clibincl/stdiofiles.hxx, src/clibincl/stdiofiles.inl: + New files to contain global file list and lock (if applicable). + Implemented as class with member access functions + + * src/errno/errno.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Rename cyg_get_errno_p() to cyg_libc_get_errno_p() + + * src/stdio/common/fclose.cxx: + * src/stdio/common/fflush.cxx: + * src/stdio/common/fopen.cxx: + * src/stdio/common/freopen.cxx: + Remove ifdef CYGPKG_LIBC + Use new global file access method from stdiofiles.hxx + Tidy up description header + Use new CYGBLD_ATTRIB_WEAK_ALIAS + Access errno "normally" rather than clibdata way + + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx + * src/stdio/common/stderr.cxx: + New files. Implement Cyg_StdioStream objects for each stream. In + separate self-contained files so using one doesn't bring in the + others + + * src/stdio/common/stdiofiles.cxx: + New file. Implements global files array and lock + + * src/stdlib/_exit.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Use infra CYGBLD* macros + + * src/stdlib/malloc.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Add pkgconf/kernel.h now that pkgconf/libc.h doesn't have it + Use infra CYGBLD* macros + Make pool visible externally with weak attribute and new name + cyg_libc_malloc_memorypool + + * src/stdlib/rand.cxx: + * src/stdlib/strtok.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Use infra CYGBLD* macros + + * src/support/cstartup.cxx: + Split into smaller files to make selective linking work better, + fix i386 port problem and make GDB happy + + * src/support/environ.cxx: + * src/support/invokemain.cxx: + * src/support/main.cxx: + * src/support/mainthread.cxx: + New files from bits of the old cstartup.cxx + Add support for CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG + + * src/PKGconf.mak: + Update to reflect file additions/deletion + + * tests/stdlib/rand1.c: + * tests/stdlib/rand2.c: + * tests/stdlib/rand3.c: + * tests/stdlib/srand.c: + Make conform to coding standards + Remove ifdef CYGPKG_LIBC_RAND + Tidy up description header + + * tests/string/strtok.c: + Make conform to coding standards + Remove ifdef CYGFUN_LIBC_strtok + Tidy up description header + +1999-01-15 Mark Galassi + + * tests/stdlib/getenv.c (main): added tests for the case in which + the user does not supply environ and in which the user supplies a + NULL environ. + +1999-01-15 Jesper Skov + + * src/support/cstartup.cxx: Added workaround for weak aliasing + problem in i386 gcc. + + +1999-01-15 Gary Thomas + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_STACK_SIZE): + (CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE): Change defaults to be + more reasonable on small systems. + +1999-01-04 Jonathan Larmour + + * src/support/clibdata.cxx: + Minor bug with environ not being initialised correctly by + default + +1998-12-24 Bart Veer + + * src/clibincl/stream.inl (Cyg_StdioStream): + check_this() member functions should now be const + +1998-12-22 Jonathan Larmour + + * src/string/memchr.cxx (_memchr): + treat search value parameter to memchr as an unsigned byte, + not a signed int - copied fix from newlib PR 18471 + +1998-12-21 Jonathan Larmour + + * tests/stdlib/realloc.c: + * tests/stdlib/malloc3.c: + * tests/stdlib/malloc2.c: + Warning cleanup + +1998-12-14 Jonathan Larmour + + * tests/stdlib/malloc2.c, tests/stdlib/malloc3.c, + tests/stdlib/realloc.c: + Only run these tests when we have a coalescing memory allocator + +1998-12-14 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Only check buffer init success if buffering + + * src/stdio/common/streambuf.cxx (set_buffer): + Check for diff of requested size against buffer_size, not + get_buffer_size(), since this may return -1, which won't be + equal to size, and will cause malloc to be called + +1998-12-01 Jesper Skov + + * tests/stdlib/getenv.c (main): Don't declare variables when they + are not used. + +Thu Nov 26 17:59:12 1998 Jonathan Larmour + + * tests/string/strncpy1.c: + Fix off-by-one error since it called my_strcmp() and not + my_strncmp(), which meant in included the trailing NULL when it + shouldn't have. + +1998-11-26 Jesper Skov + + * src/stdlib/qsort.cxx (_qsort): + * src/stdlib/rand.cxx (_srand): + Changed CYG_REPORT_FUNCNAMETYPE to CYG_REPORT_FUNCNAME in void + functions. + +Mon Oct 26 18:49:00 1998 Jonathan Larmour + + * src/support/cstartup.cxx (cyg_libc_dummy_main): + Silence compiler warning with cast of char * to CYG_ADDRWORD + +Wed Oct 28 17:31:21 1998 Jonathan Larmour + + * src/time/clock.cxx (_clock): + Reorder scaling expression as it was both incorrect and risked + overflow. + Fix for PR 18076 + +Mon Oct 19 14:40:06 1998 Jonathan Larmour + + * include/stdio.h (EOF): + Change from -64 to (-1), to allow broken code to work :-/ + Also change other negative defines to be within parentheses + +1998-10-19 Mark Galassi + + * include/pkgconf/libc.h: updated the doc URL + +Thu Oct 15 21:33:44 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Only include kernel thread headers when we're in thread-safe mode + + * src/time/clock.cxx: + Only include kernel clock headers if there's a kernel with the + right functionality available + + * tests/time/clock.c: + Remove unnecessary inclusion of + + Above changes are required for PR 17229 + +Wed Oct 14 16:38:55 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise inclusion of clibincl/stdiosupp.hxx and + clibincl/stream.hxx. Tidying up PR 17502 + +Wed Oct 14 14:08:56 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGPKG_LIBC_STRING_OPTIMISATIONS to + CYGPKG_LIBC_STRING_OPTIMIZATIONS to make it truely merkin. + +Tue Oct 13 19:34:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_ARGUMENTS): + Add a default argv[0] of "" as many programs assume argc>0 + The standard allows argv[0] to be "" if the program name + is not available + +1998-09-26 Bart Veer + + * src/clibincl/stdiosupp.hxx: + PR 17502: this header file now does nothing if the stdio option + is disabled completely. This is the same behaviour is + clibincl/stream.hxx, although arguably the #ifdef protection + should happen wherever the header file is #include'd rather than + in the header file itself. + + * src/clibincl/clibdata.hxx: + PR 17502: this header file still #include's internal stdio-related + header files and references the FILE structure, even if stdio is + disabled. There were some #ifdef's for CYGPKG_LIBC_STDIO already. + One more has been added for _fopen() and _fclose(). + +1998-09-25 Bart Veer + + * src/clibincl/streambuf.inl (Cyg_StdioStreamBuffer): + PR 17487: Reorder the calls to initialize member fields, to + eliminate a compiler warning. + +Fri Sep 25 19:04:29 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/string/strtok.cxx, + src/time/clock.cxx: + Only define tracing variable and tracing level macro when + the relevant tracing level config options are set. Otherwise + keep the tracing level fixed at 0 + Fix for PR 17476 + + * include/pkgconf/libc.h: + Define trace levels only if parent CYGPKG_LIBC_TRACE is defined + for consistency with Configuration Tool + + +Fri Sep 25 17:24:45 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Make definition of vscanf() dependent on CYGFUN_LIBC_STDIO_ungetc + otherwise _vfscanf() won't be compiled. This therefore would + cause a link fail iff selective linking is not enabled. + Fix for PR 17455 + +Fri Sep 25 17:23:17 1998 Jonathan Larmour + + * src/stdlib/rand.cxx: + Make compilation dependent on CYGPKG_LIBC_RAND + Fix for PR 17473 + + * tests/stdlib/srand.c: + Make definition of dummy test pass conditional on CYGPKG_LIBC_RAND + not being defined, as well as CYGPKG_LIBC + Caused compilation failure when testing PR 17473 fix + +Mon Sep 21 17:11:04 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Make sscanf test conditional on CYGFUN_LIBC_STDIO_ungetc since + _vfscanf() only gets compiled if this is defined + Fix for PR 17346 + +1998-09-20 Mark Galassi + + * include/pkgconf/libc.h: updated CDL doc strings. + +Fri Sep 18 22:18:47 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_errno_p): + Rather than this function only being available in thread-safe mode, + instead make what it returns be either the per-thread errno, or + global errno depending on the configuration. + Include (conditionally) to support this change + +Wed Sep 16 11:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove "fix me" comment which I forgot to remove before + +Tue Sep 15 19:27:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Updated descriptions and a few other minor things after review. + Notably though, the NDEBUG config option has been removed + +1998-09-15 Bart Veer + + * include/pkgconf/libc.h: + PR 17201: removed dependency on CYGPKG_KERNEL in the option + CYGNUM_LIBC_MAIN_STACK_SIZE, since the actual dependencies cannot + be expressed sensibly in the current system. + +1998-09-11 Bart Veer + + * include/pkgconf/libc.h: + Sorting out dependencies for error package. + +1998-09-10 Mark Galassi + + * include/pkgconf/libc.h: started adding doc fields to the + cdl_package data, as a pilot for now. + +Wed Sep 9 17:41:23 1998 Hugo Tyson + + * include/pkgconf/libc.h: + Add option CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE to explicitly + control whether the empty delete functions (currently) in + kernel/.../common/delete.cxx are enabled; controls code bloat, see + the comments in delete.cxx. + +Fri Sep 4 16:43:38 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add a default CYG_TEST_PASS() to make sure the test infra doesn't + complain. + Also remove the unused string functionsa + +Fri Sep 4 15:43:48 1998 Hugo Tyson + + * src/stdlib/exit.cxx (__libc_exit): + * src/stdlib/_exit.cxx (__libc__exit): + * src/stdlib/malloc.cxx (_free): + * src/stdlib/abort.cxx (abort): + * src/support/cstartup.cxx (invoke_main): + Tracing system asserted cos it was being called incorrectly; these + are void functions so you shouldn't give a type to the function + reporting call. + +Fri Sep 4 15:03:10 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Fix CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE description to refer to + the table.cxx file, not table.h + +Fri Sep 4 14:38:52 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add description for CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE since + Proven won't be making any changes to the device driver + implementation after all. + Fix for PR 17148 + + * src/clibincl/stream.inl (set_position): + Remove "fix me" line. It is obvious that this will have to change + with a filesystem interface + Fix for PR 17147 + + * src/stdio/common/freopen.cxx: + Remove "fix me" - I know about this issue + Fix for PR 17145 + + * src/stdio/common/stream.cxx (read): + Remove "fix me" and change to use memcpy + Fix for PR 17144 + +Fri Sep 4 14:36:47 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Actually add it this time! + +Fri Sep 4 13:48:13 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add new tests for misc stdio output functions + + * tests/PKGconf.mak: + Build stdiooutput.c test + +Fri Sep 4 12:52:10 1998 Jonathan Larmour + + * src/clibincl/stream.inl (write_byte): + Remove bogus assert + + * tests/stdlib/getenv.c (main): + Check whether str is NULL before doing a strcmp() + + * tests/stdio/sprintf2.c (main): + Reformat to 76 columns + +Fri Sep 4 02:10:54 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/stdio/common/stream.cxx: + Add new peek_byte method to Cyg_StdioStream + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix up buffer access to work with new peek_byte method above + Fix for PR 16954 + +Thu Sep 3 19:40:11 1998 Jonathan Larmour + + * tests/stdlib/rand1.c, tests/stdlib/rand2.c, + tests/stdlib/rand3.c: + Add extra check for CYGPKG_LIBC_RAND to decide whether the test + is applicable or not + + * tests/stdlib/rand2.c (test): + Use CYGNUM_LIBC_RAND_SEED for default seed, not 1 + + * tests/string/strtok.c: + Add extra check for CYGFUN_LIBC_strtok to decide whether the + test is applicable or not + +Wed Sep 2 19:11:40 1998 Jonathan Larmour + + * src/stdio/input/fread.cxx, src/stdio/output/fwrite.cxx: + Add fread() and fwrite() functions + + * src/PKGconf.mak: + Build fread.cxx and fwrite.cxx from above + + * src/stdio/common/stream.cxx: + Reformat to 76 columns + In write(), move initialisation of *bytes_written to start + In read(), move initialisation of *bytes_read to start + + * include/stdio.h: + Reformat to 76 columns + + Replace all references to the ANSI + standard to instead by the ISO C standard + + Add commented argument names for "documentation" + + Add fread() and fwrite() prototypes + + * src/clibincl/stdiosupp.hxx: + Copy the above changes from stdio.h, and add _fread() and _fwrite() + prototypes + + * src/stdio/output/fputs.cxx, src/stdio/input/fgets.cxx: + Reformat to 76 columns + +Wed Sep 2 15:41:15 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Reformat to 76 columns + +Wed Sep 2 14:46:18 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Use trylock_me() instead of lock_me(), and loop to prevent + deadlocks + + * src/clibincl/stream.hxx, src/clibincl/stream.inl: + Add trylock_me() method + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/fflush.cxx: + Reformat to 76 columns + +Wed Sep 2 12:24:27 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change 0x7fff to 0x7fffffff. Oops! + give main stack size option a legal_values field + Undefine tracing by default + Add some more description in the header + +Tue Sep 1 20:02:07 1998 Jonathan Larmour + + * tests/i18n/setlocale.c (cyg_package_start): + Fix typo - extra "x" for no reason at all! :-) + +Tue Sep 1 19:44:58 1998 Jonathan Larmour + + * src/i18n/locale.cxx: + Fix bug in find_locale_data() that miscalculated size of + all_locales + + Make find_locale_data() match the locale "" and add some + other things in _setlocale() to ensure that "C" gets returned + when the default locale "" is passed. + + Only check the locale pointer when it is non-NULL + + * tests/i18n/setlocale.c: + New tests for setlocale() + + * tests/PKGconf.mak: + Update to build setlocale.c test + + * src/support/cstartup.cxx: + Don't actually call system default main() "main" otherwise GDB + gets confused and thinks its the entry point. Instead make a weak + alias and call the real function something different. + +Tue Sep 1 18:31:42 1998 Jonathan Larmour + + * src/i18n/locale.cxx (_setlocale): + Fix tracing macro name and remove "str maybe used before + initialised" warning + + * tests/stdlib/qsort.c: + Correct file description header + +Tue Sep 1 17:04:32 1998 Jonathan Larmour + + * include/locale.h, src/clibincl/i18nsupp.hxx, src/i18n/locale.cxx: + New files to add support for locales as defined by the ISO C + standard. i.e. setlocale() and localeconv() functions and some + other bits + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAX_LOCALE_NAME_SIZE config option for locale + support + + * src/PKGconf.mak: + build locale.cxx + + * include/errno.h, src/clibincl/ctypesupp.hxx: + Tidy up to 76 columns + +Tue Sep 1 00:24:22 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Move environment-related options from stdlib into new + CYGPKG_LIBC_STARTUP component. Also add options for main()'s + arguments (CYGPKG_LIBC_ARGUMENTS), main()'s default stack size + (CYGNUM_LIBC_MAIN_STACK_SIZE), number of atexit handlers + (CYGNUM_LIBC_ATEXIT_HANDLERS), and whether _exit() stops the + system (CYGSEM_LIBC_EXIT_STOPS_SYSTEM). + + * src/clibincl/stdlibsupp.hxx: + Fix a few comment bugs, and add new + cyg_libc_invoke_atexit_handlers() function prototype + + * src/stdlib/_exit.cxx, src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Implement exit(), atexit() and _exit() correctly now. Also + includes cyg_libc_invoke_atexit_handlers() in atexit.cxx. Now + we get the correct behaviour of atexit(), and exit() invokes the + atexit handlers and fflushs all the stdio streams. Add plenty of + tracing of asserts too. + + * src/support/cstartup.cxx: + Make main_thread object an exported global. Allow user-settable + arguments. Add MUCH more tracing and asserts. Improve comments. + Tidy up to 76 columns + + * tests/stdlib/atexit.c: + Add simple test for atexit() and it calling registered functions + + * tests/PKGconf.mak: + Build atexit.c test + +Mon Aug 31 18:54:48 1998 Jonathan Larmour + + * src/stdlib/getenv.cxx, tests/stdlib/getenv.c: + Add support for getenv(), and some tests to ensure it works + + * src/PKGconf.mak, tests/PKGconf.mak: + Update to include getenv.cxx and getenv.c test + + * src/clibincl/clibdata.hxx: + remove prototype for environ - we expect files needing it to + define it themselves + + * src/support/clibdata.cxx: + Tidy up to 76 columns and add definition of char **environ, but + with a configurable initialiser (see libc.h below) + + * tests/stdlib/abs.c (main): + Tidy up to 76 columns + + * src/stdlib/malloc.cxx: + Tidy up to 76 columns and remove warning for undefined _memcpy() + by changing to memcpy(), and casting away signedness + + * include/pkgconf/libc.h: + Add CYGPKG_LIBC_ENVIRONMENT and CYGDAT_LIBC_DEFAULT_ENVIRONMENT + configuration options + + * include/pkgconf/libc.h, src/clibincl/clibdata.hxx: + Tidy up to 76 columns + + * include/stdlib.h: + Add getenv() prototype and tidy up to 76 columns + + * src/clibincl/stdlibsupp.hxx: + Add _getenv() prototype + +Mon Aug 31 13:37:08 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Add realloc() + + * tests/stdlib/realloc.c: + Add this file to test new realloc() functionality + + * tests/PKGconf.mak: + Build realloc test + + * tests/stdlib/malloc3.c (main), tests/stdlib/malloc2.c (main), + tests/stdlib/malloc1.c (main): + Conditionalise local vars to prevent warnings + + * tests/stdlib/malloc3.c (fill_with_data): + Move '{' into "verb" line + + * include/pkgconf/libc.h: + Require infra tracing support to allow tracing + + * include/stdlib.h: + Add realloc() + + * src/clibincl/stdlibsupp.hxx: + Update the commented argument names from stdlib.h, including realloc() + +1998-08-28 Bart Veer + + * include/pkgconf/libc.h: + * src/clibincl/clibdata.hxx, src/time/clock.cxx: + + Updated for new kernel configuration option symbol names + +Fri Aug 28 19:18:25 1998 Hugo Tyson + + Changed the entry below to sat "tx39" instead of "mn10300". + It's been a long week. + +Fri Aug 28 18:59:20 1998 Hugo Tyson + + * src/support/cstartup.cxx: Add a weakly named main to allow the + default configuration to link on the tx39 which has no + scalextric linking yet. The static Cyg_Thread main_thread object + below continues to exist, though unreferenced, so all its + descendants must exist too. + +Fri Aug 28 08:54:29 1998 Jonathan Larmour + + * include/stdlib.h: + Add commented argument names Add exit(), and atexit(). And move + these along with abort() and _exit() to a new section. + + * src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Add trivial versions of atexit() and exit() + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAIN_STACK_SIZE config option + + * include/sys/cstartup.h, src/support/cstartup.cxx, src/PKGconf.mak: + New files to provide a new function cyg_iso_c_support(), which + invokes main "correctly". + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/srand.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcoll2.c, tests/string/strcpy1.c, + tests/string/strcpy2.c, tests/string/strcspn.c, + tests/string/strlen.c, tests/string/strncat1.c, + tests/string/strncat2.c, tests/string/strncpy1.c, + tests/string/strncpy2.c, tests/string/strpbrk.c, + tests/string/strrchr.c, tests/string/strspn.c, + tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, + tests/time/clock.c: + + Modify all tests to use new startup mechanism, and cyg_iso_c_start() + +Fri Aug 28 00:29:38 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Add #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO around all accesses to + flags.last_buffer_op_was_read. Fix for PR 16997 + +Thu Aug 27 01:12:42 1998 Jonathan Larmour + + * include/sys/file_if.h: + Fix comments and remove cyg_get_file_star() + +Wed Aug 26 20:24:32 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove #define CYGPKG_LIBC is that is meant to live in + after all + +Wed Aug 26 19:39:23 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + More fixes to CDL stuff to make it work better, and look better on + the screen + +Tue Aug 25 20:21:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Make some fixes after running the ConfigTool + +Tue Aug 25 16:46:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_STDIO_BUFSIZE): + Fix typo of CYGNUM_LIBC_STDIO_BUFSIZE + +Tue Aug 25 15:10:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Tidy up CDL stuff a bit more, prior to checking it actually works. + +Tue Aug 25 11:38:52 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c (main): + Prevent calls to CYG_TEST_STILL_ALIVE for now + +Tue Aug 25 05:39:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change cosmetic paragraph alignment. + +Tue Aug 25 03:11:34 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Make stderr initialise with buffer size 0. + For PR 16955 + +Mon Aug 24 17:38:46 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + First pass at CDL-ifying the C library configuration. Currently + deliberately disabled as there a few outstanding issues. + +Mon Aug 24 16:14:22 1998 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx (_vfnprintf): + clear up warning for unused argument + + * tests/stdlib/malloc2.c (NUM_ITERATIONS): + Lower to 100 from 50000 so it won't take too long under the simulator + +Thu Aug 20 17:48:43 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Remove now unnecessary inclusion of kernel/ktypes.h + +Wed Aug 19 19:19:14 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, + tests/stdio/sscanf.c, tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, + tests/stdlib/strtoul.c, tests/string/strtok.c, + tests/time/clock.c: + Add parameters to "main()" to silence warnings + +Wed Aug 19 18:52:59 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx (refill_read_buffer): + Put conditional error check into same #ifdef and if as what was being + checked in the first place! + +Wed Aug 19 18:49:19 1998 Jonathan Larmour + + * src/clibincl/stream.inl: + Reorder Cyg_StdioStream::check_this() to be first to silence + warnings + +Tue Aug 18 16:10:03 1998 Jonathan Larmour + + * ecc/language/c/libc/current/src/clibincl/clibdata.hxx, + ecc/language/c/libc/current/src/errno/errno.cxx, + ecc/language/c/libc/current/src/stdio/common/fopen.cxx, + ecc/language/c/libc/current/src/stdlib/rand.cxx, + ecc/language/c/libc/current/src/string/strtok.cxx: + Rename CYGIMP_LIBC_INTERNAL_DATA_PREAMBLE, + CYGIMP_LIBC_INTERNAL_DATA_ALLOC_CHECK_PREAMBLE, + CYGVAR_LIBC_INTERNAL_DATA, and + CYGIMP_LIBC_INTERNAL_DATA_CHECK to all have CYGPRI_ prefix instead + as recommended by the config name rules + + +Tue Aug 18 14:31:19 1998 Jonathan Larmour + + * src/stdio/common/setvbuf.cxx (_setvbuf): + Rename variable names in assert line, otherwise doesn't build + with asserts on! + +Sun Aug 16 18:15:12 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix some bugs, although there are some left to fix still. Unrelated + to the rest of the checkins, so I will check the partial fix in now. + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx: + Add parameters to constructor to allow more things to be done at + construction time. + + Now we have "new", remove separate "construct" method + + Add more documentation on constructor + + As requested by code review, where possible, move boolean flags + into separate packed bitfield structure for space efficiency + + Make readbuf_char be usable all the time rather than when configured + not to be buffering, as it is also needed for non-buffered mode i.e. + _IONBF + + * src/stdio/common/fopen.cxx: + Change to use new method of construction from above, using new + + Use thread-specific data, rather than global. And so change errnos + to access errno entry specifically + + Make process_mode() check for append mode too + + Reformat for coding standards to have { in same line as "verb" + + * src/stdio/common/setvbuf.cxx: + + Change to cope with different way of dealing with buffering policy + flags etc. in Cyg_StdioStream + + * src/stdio/common/vsnprintf.cxx, src/stdio/common/vsscanf.cxx, + src/support/clibdata.cxx: + Change construction of streams to use new parameters added above, + and change to use _IONBF mode for string stdio functions, + otherwise its a waste of memory. And use _IONBF for stderr as the + ISO standard tells us to! + + Reformat for coding standards to have { in same line as "verb" + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Change constructor so that it can be set with default size and + dynamic buffer (if applicable) + + Fix minor bug in destructor - should only call free when allocated + dynamically + + Change get_buffer_size to return -1 if the buffer was not allowed + to be set up + + * src/stdio/common/streambuf.cxx: + Remove unnecessary stdio.h include and add extra comment to whether + to free bit in set_buffer() + + * src/stdio/common/freopen.cxx: + Change @@@ to standard fix me string + + * src/stdio/output/fputc.cxx: + Remove unnecessary "written" variable + +Thu Aug 13 15:37:28 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: + Included use of "fix me" line to ensure this is discussed before + release + + * include/stdlib.h, src/stdlib/abort.cxx, src/PKGconf.mak: + Add abort.cxx to implement abort(), albeit naively + +Thu Jul 30 18:03:09 1998 Jonathan Larmour + + * src/stdio/common/vsscanf.cxx (_vsscanf), + src/stdio/common/vsnprintf.cxx (_vsnprintf): + Fix initialiser of pseudo string device table that didn't get updated + when the table changed (Bad proven, no biscuit). + + * src/clibincl/stream.inl (~Cyg_StdioStream): + Move invalidation of magic_validity_word to after unlock_me(), + otherwise it always fails! + +Tue Jul 28 21:29:53 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Shorten over-long lines + +Tue Jul 28 20:28:23 1998 Jonathan Larmour + + * src/clibincl/stream.hxx (class Cyg_StdioStream), + src/clibincl/stream.inl, src/stdio/common/stream.cxx: + Clarify some comments and get the CYGDBG_DEFINE_CHECK_THIS and + CYG_ASSERTCLASS stuff going + + * src/clibincl/stream.inl: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 15:31:06 1998 Jonathan Larmour + + * src/clibincl/streambuf.inl, src/stdio/common/streambuf.cxx: + Move set_buffer() from streambuf.inl to new file streambuf.cxx + + * src/PKGconf.mak (COMPILE): + Build new file streambuf.cxx + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + Add METHODS comment + + * src/stdio/common/stream.cxx: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 00:26:36 1998 Jonathan Larmour + + * include/stdlib.inl, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/div.cxx, + src/stdlib/ldiv.cxx, src/stdlib/qsort.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/string/strtok.cxx: + + Include proper Berkeley license inline in the file, rather than + referring to an external file + + * doc/COPYING.UCB: + Remove, now that it isn't referred to any more + +Mon Jul 27 23:34:26 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl, include/errno.h, + include/stdio.h, include/stdio.inl, include/stdlib.h, + include/stdlib.inl, include/string.h, include/string.inl, + include/time.h, include/sys/file_if.h, src/PKGconf.mak, + src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/stdiosupp.hxx, + src/clibincl/stream.hxx, src/clibincl/streambuf.hxx, + src/clibincl/streambuf.inl, src/clibincl/stringsupp.hxx, + src/clibincl/timesupp.hxx, src/ctype/isalnum.cxx, + src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, + src/ctype/islower.cxx, src/ctype/isprint.cxx, + src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, + src/ctype/tolower.cxx, src/ctype/toupper.cxx, + src/errno/errno.cxx, src/stdio/common/snprintf.cxx, + src/stdio/common/sprintf.cxx, src/stdio/common/sscanf.cxx, + src/stdio/common/stdioinlines.cxx, src/stdio/common/stream.cxx, + src/stdio/common/ungetc.cxx, src/stdio/common/vsnprintf.cxx, + src/stdio/common/vsscanf.cxx, src/stdio/input/fgetc.cxx, + src/stdio/input/fgets.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/gets.cxx, src/stdio/input/scanf.cxx, + src/stdio/output/fnprintf.cxx, src/stdio/output/fprintf.cxx, + src/stdio/output/fputc.cxx, src/stdio/output/fputs.cxx, + src/stdio/output/printf.cxx, src/stdlib/_exit.cxx, + src/stdlib/abs.cxx, src/stdlib/atof.cxx, src/stdlib/atoi.cxx, + src/stdlib/atol.cxx, src/stdlib/div.cxx, src/stdlib/labs.cxx, + src/stdlib/ldiv.cxx, src/stdlib/rand.cxx, src/stdlib/strtod.cxx, + src/string/memchr.cxx, src/string/memcmp.cxx, + src/string/memmove.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, + src/string/strcoll.cxx, src/string/strcpy.cxx, + src/string/strcspn.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx, src/string/strpbrk.cxx, + src/string/strrchr.cxx, src/string/strspn.cxx, + src/string/strstr.cxx, src/string/strsuppt.cxx, + src/string/strtok.cxx, src/string/strxfrm.cxx, + src/support/clibdata.cxx, src/time/clock.cxx: + Untabify + +Mon Jul 27 23:14:18 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/stdlib/malloc.cxx, src/stdlib/qsort.cxx, + tests/ctype/ctype.c, tests/stdlib/rand3.c, tests/stdlib/malloc3.c: + Remove all mentions of "register" in variable declarations. Also + untabify where needed + + * src/stdlib/bsearch.cxx: + Untabify this too + + +Mon Jul 27 22:18:51 1998 Jonathan Larmour + + * src/stdio/output/fputc.cxx (_fputc): + Replace call to stream write() with call to write_byte() + + * src/clibincl/stream.inl (write_byte): + Add asserts for stream write() returning odd values for how much has + been written + + (bytes_available_to_read): + Remove "register" def for variable declaration + +Mon Jul 27 22:06:22 1998 Jonathan Larmour + + * src/stdio/common/stdiosupp.cxx: + Remove #if 0'd cyg_get_file_star() and unnecessary pseudo string + device definition + +Mon Jul 27 21:57:25 1998 Jonathan Larmour + + * include/pkgconf/libc.h, src/support/clibdata.cxx: + Change CYGXXX_LIBC_STDIO_DEFAULT_CONSOLE to + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE + +Mon Jul 27 21:49:23 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/setjmpsupp.hxx, + src/clibincl/stdiosupp.hxx, src/clibincl/stdlibsupp.hxx, + src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl, + src/clibincl/stringsupp.hxx, src/clibincl/timesupp.hxx: + + Change CYGONCE_LIBC_*_{HXX,INL} to CYGONCE_LIBC_CLIBINCL_*_{HXX,INL} + +Mon Jul 27 21:34:05 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change #define XXXXX 1 to #define XXXXX where applicable as per code + review + + Also remove obsolete CYGIMP_LIBC_THREAD_START_SUSPENDS_SELF + +Mon Jul 27 19:42:27 1998 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): + Use #ifdef, not #if for config options + +Mon Jul 27 15:01:51 BST 1998 Chris Provenzano + + * src/stdio/common/stream.cxx, src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx: + Fixes to compile with the new Cyg_IORB field names. + +Thu Jul 9 03:40:21 1998 Jonathan Larmour + + * tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Adjust starting of tests to possibly start scheduler since + strtol/stroul rely on errno, which may be a per-thread variable + +Thu Jul 9 03:06:25 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx, src/stdio/common/setvbuf.cxx: + Consolidate read and write buffers into single buffer, as it should + have been all along + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Add drain_buffer() method to speed up the case when we want the + buffer completely emptied + +Tue Jul 7 21:26:33 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Add a couple of new tests that check that very long strings work too + +Wed Jul 1 19:52:39 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/streambuf.hxx: + Do not permit copy constructors + + * src/clibincl/stream.inl, src/stdio/common/fclose.cxx: + Make sure we use #ifdef and not #if + + * src/clibincl/streambuf.inl: + Use member initialisation list rather than explicit initialisation to + reduce warnings + +Wed Jul 1 19:17:55 1998 Jonathan Larmour + + * include/pkgconf/libc.h and all files using config options: + Rename configuration defines to make them more standard + +Thu Jun 25 20:09:30 1998 Jonathan Larmour + + * src/string/strcat.cxx: + Add parentheses on check to silence warning + (Verified by proven) + +Thu Jun 25 19:30:01 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Make sure that the malloc pool is initialised before other things + can use it. This is done with the hot new constructor ordering + feature. + +Thu Jun 25 18:27:03 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Remove bogus ifdef if floating point is _not_ wanted + +Thu Jun 25 17:31:42 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Fix argument checking to allow first argument of NULL + +Thu Jun 25 04:18:50 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_strtok_last_p): + Remove bogus assertion + + * src/stdlib/malloc.cxx: + Got sense of alignment check assertion the wrong way round, so negate + it + +Thu Jun 25 03:56:35 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: + Fix argument checking assertions with legitimate nulls here too + +Thu Jun 25 03:46:32 1998 Jonathan Larmour + + * src/stdlib/strtoul.cxx, src/stdlib/strtol.cxx: + Fix argument checking assertions to cope with legitimate nulls + +Wed Jun 24 09:01:45 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Remove extraneous info messages + +Wed Jun 24 05:59:17 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c: + + Change large automatic arrays to static arrays to prevent overuse + of a potentially small stack + +Wed Jun 24 05:45:28 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/string/strtok.c, tests/time/clock.c: + + Increase thread stack size from 4K to 32K as in some cases it was + too small. + + +Tue Jun 23 20:12:31 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Add extra tests, including floating point conversion testing + +Tue Jun 23 17:01:06 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Make sure this is only compiled if CYGFUN_LIBC_strtok is defined + +Tue Jun 23 06:10:13 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + add some comments - that's all + + * src/stdio/common/stream.cxx: + fix case in refill_read_buffer() for what to do when there's nothing + left. Now return EAGAIN + + * src/stdio/common/vsscanf.cxx, src/stdio/input/vfscanf.cxx: + Get sscanf working properly and passing tests. Also make sure it + ignores FP when its not configured + + * src/stdlib/atof.cxx: + Only compile at all if strtod() is present + + +Mon Jun 22 19:13:42 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise strtok_last and rand_seed better + +Mon Jun 22 14:14:12 1998 Jonathan Larmour + + * tests/stdlib/malloc3.c: + Add test for checking that mallocing and freeing repeatedly works + + * tests/PKGconf.mak: + Update to reflect addition of the above + +Mon Jun 22 13:09:33 BST 1998 Chris Provenzano + + * src/stdio/common/fopen.cxx + * src/stdio/common/stream.cxx + * src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx + Include cyg/devs/common/iorb.h instead of iorb.hxx + + * src/stdio/common/stream.cxx + Use read_blocking and write_blocking instead of just read and + write when accessing devices through the virtual device table. + +Sun Jun 21 18:19:13 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Propagate change of return code handling for puts from stdio.inl + into here + + * src/stdio/output/fputc.cxx: + make sure the right type is used for output - byte not int + + * src/support/clibdata.cxx: + Fix #define config mistook. #endif was in wrong place + +Sun Jun 21 16:11:04 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Allow explicit construction to get around a bug when + dynamically allocating per-thread structure + +Sun Jun 21 16:02:51 1998 Jonathan Larmour + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, tests/stdlib/qsort.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + + Update tests to "do the right thing" with all configuration settings + + +Sun Jun 21 04:54:14 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + I have to be careful not to use setjmp() in a way not exactly + defined by the standard, so make sure I do, and add a comment + documenting these ways. + + Also ensure this test does the right thing in all configurations + +Sun Jun 21 04:38:15 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add extra checks for invalid configurations + Also make default for thread safety OFF + + * src/clibincl/clibdata.inl: + Adjust indentation + + * src/stdio/output/vfnprintf.cxx: + Make printf of -0.0 floating point do the right thing + +Sun Jun 21 04:28:00 1998 Jonathan Larmour + + * src/stdio/common/snprintf.cxx, src/stdio/common/sprintf.cxx, + src/stdio/common/sscanf.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/scanf.cxx, src/stdio/output/fnprintf.cxx, + src/stdio/output/fprintf.cxx, src/stdio/output/printf.cxx: + + Had to remove inline functions with varargs. Which means separating + out each function from stdioinlines.cxx into a separate file, as they + no longer belong there. So all the above files were created. + + * include/stdio.inl, src/PKGconf.mak, + src/stdio/common/stdioinlines.cxx: + Changed to take account of the above + + +Sun Jun 21 03:58:42 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c: + Update with floating-point tests. Also make sure they DTRT in all + configurations + +Fri Jun 19 19:33:06 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + accidentally initialised stdin/out/err twice + +Fri Jun 19 19:09:29 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Another typo + +Fri Jun 19 18:59:07 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Missing #endif typo + +Fri Jun 19 18:51:42 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Fix initialisation of static data members. Unsure how it worked at + all before! + +Fri Jun 19 18:01:01 1998 Jonathan Larmour + + * include/stdio.inl: + puts should check whether fputs returns non-negative, rather than + non-zero + +Fri Jun 19 17:22:52 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl: + Make inclusion of get_errno_p conditional on thread-safety + +Wed Jun 17 10:55:32 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Add weak alias of vfscanf() to _vfscanf() + +Wed Jun 17 09:10:41 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Initialise err to silence compiler warning + +Wed Jun 17 08:59:20 1998 Jonathan Larmour + + * Most important is the addition of floating point support in + src/stdio/output/vfnprintf.cxx and src/stdio/input/vfscanf.cxx. This + also required the addition of atof() and strtod() in stdlib which is + definitely no bad thing! Other than that... + + * Fix a whole bunch of stuff I messed up first time round. Also the + sprintf and sscanf tests are included again. + +Tue Jun 16 16:38:02 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Typo with not putting comment character at the beginning. Sigh. + +Tue Jun 16 14:53:09 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Forgot to (temporarily) remove fputs test for now + +Mon Jun 15 20:40:03 1998 Jonathan Larmour + + Everything to do with stdio has almost completely changed, so there's + not much point documenting individual changes. + +Mon Jun 15 18:36:01 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c: + Stop it moaning quite as much when it fails by making it exit sooner + + * tests/time/clock.c : + This isn't a compound testcase + +Thu Jun 11 17:59:13 1998 Jonathan Larmour + + * include/assert.h + Reverse sense of NDEBUG ifdef, that was left in accidentally due + to testing + +Thu Jun 11 04:58:08 1998 Jonathan Larmour + + * include/errno.h, include/string.h, src/clibincl/stringsupp.hxx: + Modify as I've now added an "error" package which defines the error + codes and strerror() + + * src/errno/strerror.cxx: + Moved to new error package and thus deleted + +Wed Jun 10 18:37:37 1998 Jonathan Larmour + + * include/assert.h: + create this header and add assert() function + +Wed Jun 10 16:23:57 1998 Jonathan Larmour + + * include/stdlib.h, src/clibincl/stdlibsupp.hxx, src/stdlib/malloc.cxx: + Add malloc(), calloc() and free() functions + + * include/pkgconf/libc.h: + Add malloc memory pool size option + + * tests/stdlib/malloc1.c, tests/stdlib/malloc2.c: + new tests for malloc + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for new files + +Wed Jun 10 15:06:16 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + Add another test + +Tue Jun 9 18:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add some setjmp config's and a macro for the noreturn attribute + + * include/setjmp.h, include/setjmp.inl, src/clibincl/setjmpsupp.hxx, + src/setjmp/longjmp.cxx, tests/setjmp/setjmp.c: + Added to implement and test setjmp() and longjmp() + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for newly added files + +Thu Jun 4 01:29:18 1998 Jonathan Larmour + + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, src/string/strcpy.cxx, + src/string/strlen.cxx, src/string/strncat.cxx, + src/string/strncmp.cxx, src/string/strncpy.cxx: + Rename CYGIMP_LIBC_PREFER_SMALL_TO_FAST to + CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST + + Also use slower but smaller version when __OPTIMIZE_SIZE__ is + defined (which comes from using gcc -Os) + +Fri May 29 16:15:04 1998 Jonathan Larmour + + * include/ctype.inl, src/ctype/isxdigit.cxx: + Fix bug that numerals aren't considered hex digits + + * include/time.h: + Change clock_t and time_t to be signed so that they can accept -1, as + required by other libc functions + + * src/clibincl/clibdata.hxx: + Fix typo that CYGIMP_LIBC_THREAD_SUPPORT should be ..._SAFETY + Also fix macro to allocate thread-specific data to not set variables + in a different stack-frame + + * tests/ctype/ctype.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/stdlib/qsort.c: + make ctr unsigned to prevent warnings + + * tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/string/strrchr.c: + Fix off by one error + + * tests/string/strspn.c: + Fix case-sensitivity problem, and off-by-one error + + * tests/string/strxfrm1.c: + Remove bogus bit of test that doesn't apply to strxfrm, and fix typo + + +Fri May 22 16:33:04 1998 Jonathan Larmour + + * src/PKGconf.mak + Remove CXXFLAGS line now that its redundant + + * tests/everything! + Do a blitz change of all tests - break some of them down into + different files, add new tests, standardize format, fix bugs, + update for recent header file changes and much more! + +Wed May 20 17:50:04 1998 Jonathan Larmour + + * tests/PKGconf.mak: + interim checkin for different dir structure for Bart + +Fri May 15 20:30:46 1998 Jonathan Larmour + + * Tidy up some loose ends I forgot: rename src/include directory to + src/clibincl. And add clibdata.inl and timesupp.hxx in there. + +Thu May 14 19:56:32 1998 Jonathan Larmour + + * Basically everything has changed in the C library. Files have + been moved, renamed, deleted and reworked. This is a major + revision, and now starts from this new baseline rather than doing + incremental changes. + +Fri Apr 17 18:43:02 1998 Jonathan Larmour + + * src/ECCconf.mak: + added for new build system (actually Bart did this, but didn't + update this ChangeLog) + +Fri Apr 17 15:03:25 1998 Hugo Tyson + + * src/stdio/device/sim.cxx: + Make it build with CYG_EMPTY_STATEMENT; the unadorned one is being + removed. + +Thu Apr 16 00:24:24 1998 Jonathan Larmour + + * All source files: + replace ECCIMP_LIBC_* conditional ifdef with CYGIMP_LIBC_* + + * include/eccconf/libc.h: + improve comments and reorder a bit + +Wed Apr 8 14:35:20 1998 Jonathan Larmour + + * Makefile.am, src/Makefile.am, tests/Makefile.am, configure.in: + many changes to integrate build structure from release tree + + * src/ctype/Makefile.am, src/ctype/Makefile.in, src/errno/Makefile.am, + src/errno/Makefile.in, src/stdio/Makefile.am, src/stdio/Makefile.in, + src/stdio/common/Makefile.am, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.am, src/stdio/device/Makefile.in, + src/stdio/output/Makefile.am, src/stdio/output/Makefile.in, + src/stdio/input/Makefile.am, src/stdio/input/Makefile.in, + src/stdlib/Makefile.am, src/stdlib/Makefile.in, + src/string/Makefile.am, src/string/Makefile.in, + src/support/Makefile.am, src/support/Makefile.in, + src/time/Makefile.am, src/time/Makefile.in: + Remove as they are now redundant with above changes + + * include/Makefile.am: + Add to support above changes + + * include/eccconf/libc.h: + Change include file for configuration from kernel to system + + * src/include/kerndiag.hxx, src/stdio/device/kerndiag.cxx, + src/time/clockfn.cxx: + Change kernel include file to eccconf/kernel.h + + * src/include/strngdev.h: + remove unnecessary kernel include + + * Makefile.in, aclocal.m4, configure, src/Makefile.in, + tests/Makefile.in, include/Makefile.in: + regenerate + +Mon Apr 6 20:55:07 1998 Jonathan Larmour + + * src/stdlib/abs.cxx, src/stdlib/atoi.cxx, src/stdlib/atol.cxx, + src/stdlib/div.cxx, src/stdlib/labs.cxx, src/stdlib/ldiv.cxx: + Separated out functions from stdlib.cxx into separate files + + * src/stdlib/stdlib.cxx: + removed to be replaced by above files + + * Makefile.am, src/stdlib/Makefile.am: + modified to support building above and not building stdlib.cxx + + * src/support/tsd.cxx: + Remove unnecessary header file includes + + * Makefile.in, src/stdlib/Makefile.in: + regenerated + +Mon Apr 6 19:19:42 1998 Jonathan Larmour + + * src/support/tsd.cxx, include/eccconf/libc.h: + remove lame hack for tx39 compiler now that its fixed + + * src/include/sim.hxx: + define constants as static to placate compiler + +Thu Apr 2 21:01:21 1998 Jonathan Larmour + + * src/ctype/ctype.cxx: + deleted and separated out into below files + + * src/ctype/isalnum.cxx, src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, src/ctype/islower.cxx, + src/ctype/isprint.cxx, src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, src/ctype/tolower.cxx, + src/ctype/toupper.cxx: + Separated out individual ctype functions from ctype.cxx into separate + files + + * Makefile.am, src/ctype/Makefile.am: + modified to reflect above deletion/additions + + * Makefile.in, src/ctype/Makefile.in: + regenerated + +Thu Apr 2 19:08:26 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: optimise using prefix increments + +Thu Apr 2 15:18:15 1998 Jonathan Larmour + + * src/string/strchr.cxx: optimise setting of mask a little + +Thu Mar 26 14:07:01 1998 Jonathan Larmour + + * src/support/tsd.cxx: fixed some typos + +Thu Mar 26 11:58:47 1998 Jonathan Larmour + + * include/eccconf/libc.h, src/support/tsd.cxx: + Implement workaround for tx39 compiler bug. + + * src/include/strsuppt.hxx: + remove prototypes for _memcpy() and _memset() as they are now in the + kernel + +Wed Mar 25 18:31:53 1998 Jonathan Larmour + + * Makefile.am, src/string/Makefile.am: memcpy() and memset() are + now in the kernel so remove them from build + * include/string.h: add a comment to say as much + * Makefile.in, src/string/Makefile.in: regenerate + +Wed Mar 25 15:30:42 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx, src/include/file_if.inl: + Change _exit workaround to not cause a compiler optimisation + problem. Now just references _exit rather than calls it. + +Wed Mar 25 14:59:49 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fix bug causing tests to fail completely + for this function + +Wed Mar 25 12:55:53 1998 Jonathan Larmour + + * src/include/sim.hxx: add types to constants (oops!) + * Makefile.am: link src/stdio/device/sim.cxx + * Makefile.in: regenerated + +Wed Mar 25 04:14:30 1998 Jonathan Larmour + + * src/include/file_if.hxx, src/include/file_if.inl, + src/include/kerndiag.hxx, src/include/sim.hxx, + src/include/stdio_if.hxx, src/include/strngdev.hxx, + src/include/tsd.hxx, src/stdio/common/clearerr.cxx, + src/stdio/common/clearerr.cxx, src/stdio/common/feof.cxx, + src/stdio/common/ferror.cxx, src/stdio/common/file_if.cxx, + src/stdio/common/vsprintf.cxx, + src/stdio/device/kerndiag.cxx, src/stdio/device/sim.cxx, + src/stdio/device/strngdev.cxx, src/stdio/output/fputc.cxx, + src/stdio/output/fputs.cxx, src/stdio/output/puts.cxx, + src/stdio/output/vfnprintf.cxx, src/support/tsd.cxx: + Modified to support buffered reads including renaming + _EccInternalFileStruct to __EccStdioStream which is what affects + most of these files + * src/include/file_if.inl, src/stdio/common/file_if.cxx: added for + the above reason + * src/stdio/common/sscanf.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/input/Makefile.am: added to provide sscanf() functionality + * include/ctype.h, include/stdio.h, include/stdlib.h, + include/string.h, include/eccconf/libc.h, src/ctype/ctype.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/stdio/common/stdio.cxx: + rename *_INLINES macros with prefix CYG rather than ECC + * include/errno.h, src/errno/errno.cxx, src/errno/strerror.cxx: + rename ErrNo to _ErrNo and add EAGAIN and EWOULDBLOCK error codes + * configure.in, Makefile.am, src/stdio/Makefile.am, + src/stdio/input/Makefile.am: add support for building + file_if.cxx sscanf.cxx and vfscanf.cxx + * src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/input/Makefile.in, configure, Makefile.in: regenerated + +Tue Mar 24 19:51:40 1998 Jonathan Larmour + + * src/time/clockfn.cxx, src/time/clock.cxx: + Renamed clock.cxx to clockfn.cxx (preserving CVS history) + * Makefile.am, src/time/Makefile.am: updated to reflect name change + * Makefile.in, src/time/Makefile.in: regenerated + +Tue Mar 24 16:28:06 1998 Jonathan Larmour + + * include/ctype.inl: Swap around definitions to get right order so + inlining works + +Tue Mar 24 14:43:05 1998 Jonathan Larmour + + * include/ctype.h, include/stdio.h, include/stdlib.h, include/string.h: + modify to only conditionally include inlines + * src/ctype/ctype.cxx, src/stdio/common/stdio.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/ctype/Makefile.am: Add to provide real linkable alternatives + to inline functions + * Makefile.am, configure.in, src/Makefile.am, + src/stdio/common/Makefile.am, src/stdlib/Makefile.am, + src/string/Makefile.am: modified to support previous additions + * include/eccconf/libc.h: redefine inline macro to add extern inline, + and add conditional defines for inline functions. Also rename + space vs. speed macro to have CYG instead of ECC prefix + * include/stdio.inl: fix comment typo + * src/stdlib/qsort.cxx: fix to define inline functions properly + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/memcpy.cxx, + src/string/memset.cxx, src/string/strcat.cxx, src/string/strchr.cxx, + src/string/strcmp.cxx, src/string/strcpy.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx + * Makefile.in, configure, src/Makefile.in, src/ctype/Makefile.in, + src/stdio/common/Makefile.in, src/stdlib/Makefile.in, + src/string/Makefile.in: regenerate + + +Mon Mar 23 19:19:49 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: added to support temporary _exit + * include/stdlib.h, include/stdlib.inl: added support for _exit and + added abs(), labs(), div() and ldiv() functions + * src/include/file_if.hxx: added support for _exit kludge + * src/stdlib/qsort.cxx: Added Berkeley copyright message + * src/time/clock.cxx: Include correct kernel config header as + CYG_CONFIGURATION rather than + * Makefile.am src/stdlib/Makefile.am: added support for _exit + * Makefile.in, src/stdlib/Makefile.in: regenerated + +Mon Mar 23 14:41:07 1998 Jonathan Larmour + + * Replace ECCPKG_ANSI_LIBC with CYGPKG_ANSI_LIBC in all source files + +Mon Mar 23 14:28:44 1998 Jonathan Larmour + + * include/string.inl: add file to provide strcoll() + * include/string.h: include string.inl + * ctype.h: include ctype.inl (oops!) + * include/stdlib.h: include stdlib.inl (oops!) + +Mon Mar 23 13:30:38 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl: added to provide ANSI ctype + functionality + * include/stdlib.h, include/stdlib.inl, src/include/stdlibbsp.hxx, + src/stdlib/Makefile.am, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/stdlib/srand.cxx, + src/stdlib/strtol.cxx, src/stdlib/strtoul.cxx: Added to provide + many stdlib functions + * src/include/tsd.hxx: modified to support rand() random number + seed, and added some comments + * configure.in, Makefile.am, src/Makefile.am: modified to support + addition of above new sources + * include/eccconf/libc.h: Add extra helpful comments, and #include + kernel config file + * src/time/clock.cxx: #include clock.inl and fix to call + get_resolution() properly now + * Makefile.in, configure, src/Makefile.in, src/errno/Makefile.in, + src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.in, src/stdio/output/Makefile.in, + src/stdlib/Makefile.in, src/strings/Makefile.in, + src/support/Makefile.in, src/time/Makefile.in, + tests/Makefile.in: regenerated + + +Sun Mar 22 21:29:25 1998 Jonathan Larmour + + * include/time.h, src/include/timesupp.hxx, src/time/clock.cxx, + src/time/Makefile.am: added to provide clock() function + * src/Makefile.am: modified to try to build in src/time directory + * include/eccconf/libc.h: added and is now the main configuration + file for this package + * acconfig.h, include/libcconf.h.in, include/stamp-h.in: removed + due to usage of libc.h above instead + * Almost all *.h, *.hxx and *.cxx: replaced LIBC_CONFIG_HEADER + defined include with simple + * configure.in: remove AM_CONFIG_HEADER of libcconf.h and + LIBC_CONFIG_HEADER definition. Also remove usage of builtin + memcpy() etc. from gcc, and generate src/time/Makefile + * Makefile.am: link in src/time/clock.o + * src/include/file_if.hxx, src/include/sim.hxx: use config header + to decide whether C library is to be used + * Makefile.in, aclocal.m4, configure, src/Makefile.in: regenerated + +Fri Mar 20 18:08:10 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fixed bug with ignoring terminating NULL + +1998-03-20 Chris Tarpy + + * configure: - regenerated + * Makefile.am: - Support added for libc testcases + * Makefile.in: regenerated + * configure.in: set c compiler, descend test dir + * tests/Makefile.in: added + * tests/Makefile.am: added + * tests/tcdiag.cxx : added + + +Thu Mar 19 11:41:56 1998 Jonathan Larmour + + * Initial check-in of everything + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/startup/current/cdl/startup.cdl b/packages/language/c/libc/startup/current/cdl/startup.cdl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/cdl/startup.cdl @@ -0,0 +1,325 @@ +# ==================================================================== +# +# startup.cdl +# +# ISO environment startup/termination related configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jlarmour +# Contributors: +# Date: 2000-04-14 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_LIBC_STARTUP { + display "ISO environment startup/termination" + description " + This package manages the control of the + environment (in the general sense) that an + application would require for full ISO C / POSIX + compatibility, including a main() entry point + supplied with arguments and an environment + (as retrievable by the getenv() function). + It also includes at the other end of things, + what happens when main() returns or exit() is + called." + doc redirect/c-library-startup.html + include_dir cyg/libc/startup + parent CYGPKG_LIBC + requires CYGPKG_ISOINFRA + requires { CYGINT_LIBC_STARTUP_CONTEXT == 1 } + implements CYGINT_ISO_EXIT + implements CYGINT_ISO_MAIN_STARTUP + implements CYGINT_ISO_ENVIRON + + compile _exit.cxx abort.cxx atexit.cxx \ + environ.cxx exit.cxx invokemain.cxx \ + main.cxx mainthread.cxx + + compile -library=libextras.a cstartup.cxx + +# ==================================================================== + + + cdl_option CYGDAT_LIBC_ARGUMENTS { + display "Arguments to main()" + flavor data + default_value {"{\"\", NULL}"} + description " + This option allows the setting of the arguments + to the main function. This only has any effect + when cyg_iso_c_start() is used to start the + ISO C compatibility. This will automatically + invoke main() in an ISO C compatible fashion. + This option is in fact used as argv, and so is + an n-tuple of string constants. The final + entry must be NULL. Conventionally if argv\[0\] + is supplied, it is used to inform the program + of its name." + } + + + cdl_component CYGPKG_LIBC_STARTUP_CONTEXT { + display "Startup context for main()" + flavor none + no_define + description "This component describes the options available for + what context main() is invoked in, such as in a thread + etc." + + cdl_interface CYGINT_LIBC_STARTUP_CONTEXT { + display "Startup context implementors" + } + + + cdl_option CYGSEM_LIBC_STARTUP_MAIN_INITCONTEXT { + display "Invoked from initialization context" + description "With this option selected, main() will be + called via cyg_user_start() (unless the program + overrides the default cyg_user_start()). This + means it is run in the context of the system + initialization code, without the eCos kernel + scheduler running, and using the startup stack. + This means that any functions that may require + interactions with a running kernel will not + work (including libc functions, if configured + to be thread safe for example), so you should + restrict yourself to only calling fully + re-entrant functions from within main() in + this case." + flavor bool + default_value { 0 == CYGPKG_KERNEL && 0 == CYGPKG_POSIX_PTHREAD } + implements CYGINT_LIBC_STARTUP_CONTEXT + } + + cdl_component CYGSEM_LIBC_STARTUP_MAIN_THREAD { + display "Invoked as eCos thread" + requires CYGPKG_KERNEL + flavor bool + default_value { 0 != CYGPKG_KERNEL && 0 == CYGPKG_POSIX_PTHREAD } + implements CYGINT_LIBC_STARTUP_CONTEXT + description " + With this option selected, main() is invoked from an eCos + thread." + + cdl_component CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM { + display "System provides stack for main()'s thread" + description " + This option controls whether the stack of + main()'s thread is provided by the application or + provided by the system. When disabled, the + application must declare a pointer variable + cyg_libc_main_stack which is a pointer to an + appropriately aligned region of memory. The + application must also declare a variable of + type `int' called cyg_libc_main_stack_size + which contains the size of the stack in bytes. + This must be a multiple of 8." + flavor bool + default_value 1 + + cdl_option CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE { + display "main()'s default thread stack size" + flavor data + legal_values 16 to 0x7fffffff + default_value 8192 + description " + With an eCos kernel, when the cyg_iso_c_start() + function is used to invoke the user-supplied + main() function in an ISO C compatible fashion, + a separate thread is created to call main(). + This option controls the size of that thread's + stack, which is allocated in the BSS. It + must be a multiple of 8. Note, a low number + here may be overriden by the HAL if there is + a minimum requirement to process interrupts + etc." + } + } + + cdl_option CYGNUM_LIBC_MAIN_THREAD_PRIORITY { + display "Priority of main()'s thread" + description " + This option is used to provide the thread + priority which main()'s thread runs at. Be + sure to check that this number is appropriate + for the kernel scheduler chosen. Different + kernel schedulers impose different restrictions + on the usable priorities." + flavor data + legal_values 0 to 0x7fffffff + default_value 10 + } + } + + cdl_option CYGSEM_LIBC_STARTUP_MAIN_OTHER { + display "Invoked elsewhere" + description "With this option selected, main() must be + invoked by a separate package, or by the user." + flavor bool + default_value { 0 != CYGPKG_POSIX_PTHREAD } + implements CYGINT_LIBC_STARTUP_CONTEXT + } + } + + cdl_component CYGFUN_LIBC_ATEXIT { + display "Include atexit() function" + flavor bool + default_value 1 + description " + This option enables the use of the atexit() + function, and ensure that the atexit handlers + are invoked from within exit() as defined in + the ISO C standard." + + cdl_option CYGNUM_LIBC_ATEXIT_HANDLERS { + display "Number of functions atexit() supports" + flavor data + legal_values 1 to 0x7fffffff + default_value 32 + description " + This option sets the number of functions + that atexit() has room for. In other words, + the number of separate atexit() calls that + can be made before calling exit() or returning + from main() ( in an environment controlled by + cyg_iso_c_start() ). For strict compliance + with the ISO C standard this should be at + least 32." + } + } + + cdl_option CYGSEM_LIBC_EXIT_CALLS_FFLUSH { + display "Make exit() call fflush()" + requires CYGINT_ISO_STDIO_FILEACCESS + default_value { 0 != CYGINT_ISO_STDIO_FILEACCESS } + description " + This option will ensure that all output + streams are flushed when exitting using + exit() as prescribed by the ISO C standard." + } + + cdl_option CYGSEM_LIBC_EXIT_STOPS_SYSTEM { + display "_exit() stops all threads" + requires CYGPKG_KERNEL + default_value 0 + description " + If this option is enabled then _exit(), + which is called from exit() which itself is + called on return from main(), stops the eCos + scheduler. For strict POSIX 1003.1 + compatibility this would be the normal + behaviour. To allow the thread to simply + exit, without affecting other threads, simply + leave this option disabled. If there is no eCos + scheduler, then _exit() simply loops + irrespective of the setting of this option." + } + + cdl_option CYGDAT_LIBC_DEFAULT_ENVIRONMENT { + display "Default environment" + flavor data + default_value {"{ NULL }"} + description " + This option allows the setting of the default + contents of the environment. This is in fact + the contents of the global environment pointer + char **environ defined by POSIX 1003.1. Strings + must be of the form NAME=VALUE, and the final + entry must be NULL." + } + + cdl_option CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS { + display "Invoke default static constructors" + requires CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG + requires CYGSEM_LIBC_STARTUP_MAIN_THREAD + default_value 0 + description " + This option causes the C library to call + static constructors with default priority + from within the context of the main() thread, + working with the co-operation of the HAL. + This may be needed for environments that + expect static constructors to be run in a + thread context. Note that this uses an object + with priority 65534. Therefore do not use + priority 65534 for any other static objects + with this option enabled." + } + + +# ==================================================================== + + cdl_component CYGPKG_LIBC_STARTUP_OPTIONS { + display "ISO environment startup/termination build options" + flavor none + no_define + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_LIBC_STARTUP_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building this package. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_LIBC_STARTUP_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building this package. These flags are removed from + the set of global flags if present." + } + + cdl_option CYGPKG_LIBC_STARTUP_TESTS { + display "ISO environment startup/termination tests" + flavor data + no_define + calculated { "tests/atexit" } + description " + This option specifies the set of tests for this package." + } + } +} + +# ==================================================================== +# EOF startup.cdl diff --git a/packages/language/c/libc/startup/current/src/_exit.cxx b/packages/language/c/libc/startup/current/src/_exit.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/src/_exit.cxx @@ -0,0 +1,100 @@ +//======================================================================== +// +// _exit.cxx +// +// _exit() as from POSIX 1003.1 section 3.2.2 "Terminate a process" +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-28 +// Purpose: Provides POSIX 1003.1 _exit() function +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header +#include + +// INCLUDES + +#include // Common type definitions and support +#include // Common tracing support +#include // Common assertion support +#include // Header for all stdlib functions + // (like this one) +#ifdef CYGPKG_KERNEL +# include // kernel configuration +# include // eCos kernel for thread termination +# include // and +# include // for stopping the scheduler +# include +#endif + + +// FUNCTIONS + +externC void +_exit( int status ) +{ + CYG_REPORT_FUNCTION(); // shouldn't return, but CYG_FAIL will catch it + CYG_REPORT_FUNCARG1DV( status ); + +#ifdef CYGPKG_KERNEL + +# ifdef CYGSEM_LIBC_EXIT_STOPS_SYSTEM + + Cyg_Scheduler::lock(); // prevent rescheduling + + for (;;) + CYG_EMPTY_STATEMENT; + +# else + + Cyg_Thread::exit(); + +# endif +#endif + + // loop forever + for (;;) + CYG_EMPTY_STATEMENT; + + CYG_FAIL( "_exit() returning!!!" ); + + CYG_REPORT_RETURN(); +} // _exit() + + +// EOF _exit.cxx diff --git a/packages/language/c/libc/startup/current/src/abort.cxx b/packages/language/c/libc/startup/current/src/abort.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/src/abort.cxx @@ -0,0 +1,89 @@ +//=========================================================================== +// +// abort.cxx +// +// Implementation of the abort() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-28 +// Purpose: Implement the ISO C abort() function from 7.10.4.1 +// Description: This implements abort() simply by raising SIGABRT as +// required by ISO C +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header +#include // CYGINT_ISO_SIGNAL_IMPL + +// INCLUDES + +#include // Common type definitions and support +#include // Tracing support + +#include // Header for all stdlib functions + // (like this one) +#if CYGINT_ISO_SIGNAL_IMPL > 0 +# include +#endif + +// FUNCTIONS + +externC void +abort( void ) +{ + CYG_REPORT_FUNCNAME( "abort" ); + +#if CYGINT_ISO_SIGNAL_IMPL > 0 + int rc; + + rc = raise(SIGABRT); + + CYG_TRACE1(1, "raise(SIGABRT) returned!!! rc=%d", rc); + + CYG_FAIL("raise(SIGABRT) returned"); + +#endif + + // ISO C clearly says that abort() cannot return to its caller + + // loop forever + for (;;) + CYG_EMPTY_STATEMENT; + + CYG_REPORT_RETURN(); +} // abort() + +// EOF abort.cxx diff --git a/packages/language/c/libc/startup/current/src/atexit.cxx b/packages/language/c/libc/startup/current/src/atexit.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/src/atexit.cxx @@ -0,0 +1,128 @@ +//======================================================================== +// +// atexit.cxx +// +// Implementation of the atexit() function +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// Include atexit() ? +#ifdef CYGFUN_LIBC_ATEXIT + +// INCLUDES + +#include // Common type definitions and support +#include // Common tracing support +#include // Common assertion support +#include // Header for all stdlib functions + // (like this one) + +// STATICS + +// cyg_libc_atexit_handlers contains the functions to call. +// cyg_libc_atexit_handlers_count contains the number of valid handlers +// or you can consider the next free handler slot in +// cyg_libc_atexit_handlers. + +static __atexit_fn_t +cyg_libc_atexit_handlers[ CYGNUM_LIBC_ATEXIT_HANDLERS ]; + +static cyg_ucount32 cyg_libc_atexit_handlers_count; + + +// FUNCTIONS + +externC void +cyg_libc_invoke_atexit_handlers( void ) +{ + CYG_REPORT_FUNCNAME( "cyg_libc_invoke_atexit_handlers"); + CYG_REPORT_FUNCARGVOID(); + + cyg_ucount32 i; + + for (i=cyg_libc_atexit_handlers_count; i>0; --i) { + + CYG_TRACE1( true, + "Calling function registered with atexit at addr %08x", + cyg_libc_atexit_handlers[i-1] ); + CYG_CHECK_FUNC_PTR( cyg_libc_atexit_handlers[i-1], + "Function to call in atexit handler list " + "isn't valid! Even though it was when " + "entered!" ); + + (*cyg_libc_atexit_handlers[i-1])(); + + } // for + + CYG_REPORT_RETURN(); +} // cyg_libc_invoke_atexit_handlers() + + +externC int +atexit( __atexit_fn_t func_to_register ) +{ + CYG_REPORT_FUNCNAMETYPE( "atexit", "returning %d" ); + CYG_REPORT_FUNCARG1XV( func_to_register ); + + CYG_CHECK_FUNC_PTR( func_to_register, + "atexit() not passed a valid function argument!" ); + + // have we any slots left? + if (cyg_libc_atexit_handlers_count >= + sizeof(cyg_libc_atexit_handlers)/sizeof(__atexit_fn_t) ) { + + CYG_REPORT_RETVAL( 1 ); + return 1; // failure + } // if + + cyg_libc_atexit_handlers[cyg_libc_atexit_handlers_count++] = + func_to_register; + + CYG_REPORT_RETVAL(0); + return 0; +} // atexit() + + +#endif // ifdef CYGFUN_LIBC_ATEXIT + +// EOF atexit.cxx diff --git a/packages/language/c/libc/startup/current/src/cstartup.cxx b/packages/language/c/libc/startup/current/src/cstartup.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/src/cstartup.cxx @@ -0,0 +1,136 @@ +//======================================================================= +// +// cstartup.cxx +// +// Support for startup of ISO C environment +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // CYGPKG_KERNEL +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // Common tracing support + +#ifdef CYGPKG_KERNEL +# include // eCos kernel configuration +# include // eCos thread support +# include +#endif + + +// FUNCTION PROTOTYPES + +externC void +cyg_libc_invoke_main( CYG_ADDRWORD ); + +// EXTERNS + +#ifdef CYGSEM_LIBC_STARTUP_MAIN_THREAD +extern Cyg_Thread cyg_libc_main_thread; + +// FUNCTIONS + +externC void +cyg_iso_c_start( void ) +{ + static int initialized=0; + + CYG_REPORT_FUNCNAME( "cyg_iso_c_start" ); + CYG_REPORT_FUNCARGVOID(); + + if (initialized++ == 0) { + CYG_TRACE0( true, "Resuming cyg_libc_main_thread" ); + cyg_libc_main_thread.resume(); + } + CYG_REPORT_RETURN(); + +} // cyg_iso_c_start() + +// define an object that will automatically call cyg_iso_c_start() + +class cyg_libc_startup_dummy_constructor_class { +public: + cyg_libc_startup_dummy_constructor_class() { cyg_iso_c_start(); } +}; + +static cyg_libc_startup_dummy_constructor_class cyg_libc_startup_obj + CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC); + +#elif defined( CYGSEM_LIBC_STARTUP_MAIN_INITCONTEXT ) + +// otherwise replace the default cyg_user_start(), but of course keep +// it a weak symbol in case the user wants to override + +externC void +cyg_user_start(void) CYGBLD_ATTRIB_WEAK; + +externC void +cyg_user_start(void) +{ + cyg_libc_invoke_main(0); +} + +externC void +cyg_iso_c_start( void ) +{ + static int initialized=0; + + CYG_REPORT_FUNCNAME( "cyg_iso_c_start" ); + CYG_REPORT_FUNCARGVOID(); + + // In case they want to explicitly invoke the C library from + // cyg_user_start() themselves + if (initialized++ == 0) { + cyg_libc_invoke_main(0); + } + CYG_REPORT_RETURN(); +} +#else + +externC void +cyg_iso_c_start( void ) {} + +#endif + +// EOF cstartup.cxx diff --git a/packages/language/c/libc/startup/current/src/environ.cxx b/packages/language/c/libc/startup/current/src/environ.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/src/environ.cxx @@ -0,0 +1,62 @@ +//======================================================================== +// +// environ.cxx +// +// C library definition and allocation of POSIX 1003.1 environ +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: Provide extern char **environ as required by POSIX 1003.1 +// Description: C library definition and allocation of POSIX 1003.1 environ +// Usage: You can override environ at startup if you wish simply +// by redefining yourself. Setting the libc.h configuration +// option is the intended method though. +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header +#include // NULL + +// GLOBALS + +// The global environment. The default can be configured in +// + +static char * const +cyg_libc_default_environ[] = CYGDAT_LIBC_DEFAULT_ENVIRONMENT; + +char **environ __attribute__((weak)) = (char **)cyg_libc_default_environ; + +// EOF environ.cxx diff --git a/packages/language/c/libc/startup/current/src/exit.cxx b/packages/language/c/libc/startup/current/src/exit.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/src/exit.cxx @@ -0,0 +1,98 @@ +//========================================================================= +// +// exit.cxx +// +// Implementation of the exit() function +// +//========================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//========================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // Common tracing support +#include // Common assertion support +#include // fflush() +#include // errno +#include // Header for all stdlib functions + // (like this one) +// EXTERNAL PROTOTYPES + +externC void +cyg_libc_invoke_atexit_handlers( void ); + +// FUNCTIONS + +externC void +exit( int status ) +{ + CYG_REPORT_FUNCTION(); // shouldn't return, but CYG_FAIL will catch it + CYG_REPORT_FUNCARG1DV( status ); + + // Strictly the only thing exit() does is invoke the atexit handlers + // and flush stdio buffers. Anything else is for _exit() + // within the implementation) + +#ifdef CYGFUN_LIBC_ATEXIT + // we start with the atexit handlers + cyg_libc_invoke_atexit_handlers(); +#endif + +#ifdef CYGSEM_LIBC_EXIT_CALLS_FFLUSH + + int rc; + + CYG_TRACE0( true, "Calling fflush( NULL )" ); + rc = fflush( NULL ); + + CYG_TRACE2( rc != 0, "fflush() returned non-zero. It returned %d and " + "errno indicates the error: %s", rc, strerror(errno) ); +#endif + + _exit( status ); + + CYG_FAIL( "__libc_exit() returning!!!" ); + + CYG_REPORT_RETURN(); +} // __libc_exit() + +// EOF exit.cxx diff --git a/packages/language/c/libc/startup/current/src/invokemain.cxx b/packages/language/c/libc/startup/current/src/invokemain.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/src/invokemain.cxx @@ -0,0 +1,122 @@ +//======================================================================= +// +// invokemain.cxx +// +// Support for startup of ISO C environment +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: Provide entry point for thread which then calls main() +// Description: cyg_libc_invoke_main() is used as the entry point for +// the thread object that is created to call the +// user-supplied main() function. It sets up the arguments +// (if any) and invokes exit() if main() returns +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header +#include + +// INCLUDES + +#include // Common type definitions and support +#include // Common tracing support +#include // Common assertion support +#include // exit() + +// EXTERNS + +externC cyg_bool cyg_hal_stop_constructors; + +// FUNCTION PROTOTYPES + +externC int +main( int argc, char *argv[] ); + +externC void +cyg_hal_invoke_constructors(void); + +externC void +pthread_exit( void *value_ptr ); + +// STATICS + +#ifdef CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS +class cyg_libc_dummy_constructor_class { +public: + cyg_libc_dummy_constructor_class(void) { ++cyg_hal_stop_constructors; } +}; + +static cyg_libc_dummy_constructor_class cyg_libc_dummy_constructor_obj + CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_PREDEFAULT); +#endif + +// FUNCTIONS + +externC void +cyg_libc_invoke_main( CYG_ADDRWORD ) +{ + CYG_REPORT_FUNCNAME( "cyg_libc_invoke_main" ); + CYG_REPORT_FUNCARG1( "argument is %s", "ignored" ); + +#ifdef CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS + // finish invoking constructors that weren't called by default + cyg_hal_invoke_constructors(); +#endif + + // argv[argc] must be NULL according to the ISO C standard 5.1.2.2.1 + char *temp_argv[] = CYGDAT_LIBC_ARGUMENTS ; + int rc; + + rc = main( (sizeof(temp_argv)/sizeof(char *)) - 1, &temp_argv[0] ); + + CYG_TRACE1( true, "main() has returned with code %d. Calling exit()", + rc ); + +#if CYGINT_ISO_PTHREAD_IMPL > 0 + // It is up to pthread_exit() to call exit() if needed + pthread_exit( (void *)rc ); + CYG_FAIL( "pthread_exit() returned!!!" ); +#else + exit(rc); + CYG_FAIL( "exit() returned!!!" ); +#endif + + CYG_REPORT_RETURN(); + +} // cyg_libc_invoke_main() + +// EOF invokemain.cxx diff --git a/packages/language/c/libc/startup/current/src/main.cxx b/packages/language/c/libc/startup/current/src/main.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/src/main.cxx @@ -0,0 +1,103 @@ +//======================================================================= +// +// main.cxx +// +// Default main() function +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: Provide a default empty main() function +// Description: This file provides a default empty main() function so +// that things don't fall apart if the user starts the +// ISO C environment (the default setting) but doesn't +// provide their own main(). This is taken advantage of +// in some tests (for example) +// Usage: Obviously simply override main() in your own program to +// prevent the use of the one below +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // for CYGPKG_KERNEL + +// INCLUDES + +#include // Common type definitions and support +#include // Common tracing support +#include // Common assertion support + +// FUNCTION PROTOTYPES + +// We provide a weakly named main to allow this to link if the user +// doesn't provide their own main. This isn't strictly good behaviour, +// but if the user wants good performance then of _course_ they should +// play with the config options and this won't be called. Or it might +// be "giving them enough rope" etc. :-) + +externC int +main( int argc, char *argv[] ) __attribute__((weak)); + +externC void +cyg_user_start(void); + +// FUNCTIONS + +externC int +main( int argc, char *argv[] ) +{ + CYG_REPORT_FUNCNAMETYPE("main", "returning %d" ); + + // try to be helpful by diagnosing malformed arguments + CYG_PRECONDITION( argv != NULL, "argv is NULL!" ); + CYG_PRECONDITION( argv[argc] == NULL, "argv[argc] isn't NULL!" ); + + CYG_REPORT_FUNCARG2("argc=%d, argv[0]=%s", argc, + (CYG_ADDRWORD)((argv[0]==NULL) ? "NULL" : argv[0]) ); + + CYG_TRACE0( true, "This is the system-supplied default main()" ); + + // If the kernel isn't present then cyg_libc_invoke_main() will have assumed + // main() is present and will call it. But if we're here, then + // evidently the user didn't supply one - which can't be right. So we + // assume that they have useful code to run in cyg_user_start() instead. + // Its better than just exiting +#ifndef CYGPKG_KERNEL + cyg_user_start(); +#endif + + CYG_REPORT_RETVAL(0); + return 0; // some CPUs have 0 hard-wired - faster than a reg +} // main() + +// EOF main.cxx diff --git a/packages/language/c/libc/startup/current/src/mainthread.cxx b/packages/language/c/libc/startup/current/src/mainthread.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/src/mainthread.cxx @@ -0,0 +1,125 @@ +//======================================================================= +// +// mainthread.cxx +// +// Support for startup of ISO C environment +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: Provides a thread object to call into a user-supplied +// main() +// Description: Here we define the thread object that calls +// cyg_libc_invoke_main() which in turn will invoke +// the user-supplied main() entry point function (or +// alternatively the dummy empty one supplied by eCos) +// Usage: Both the stack (cyg_libc_main_stack) and the thread +// (cyg_libc_main_thread) can be overriden if you provide +// your own symbols with those names. In the case of the +// stack obviously you need to ensure +// CYGNUM_LIBC_MAIN_STACK_SIZE corresponds to your own +// stack. +// The thread object is also available externally if you +// want to control it (suspend/resume/etc.) either by +// extern Cyg_Thread cyg_libc_main_thread; from C++, using +// the kernel C++ API, or +// extern cyg_handle_t cyg_libc_main_thread; from C using +// the kernel C API. +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +#ifdef CYGSEM_LIBC_STARTUP_MAIN_THREAD + +// INCLUDES + +#include // Common type definitions and support +#include // eCos kernel configuration +#include // eCos thread support +#include +#include // for CYGNUM_HAL_STACK_SIZE_TYPICAL + + +// EXTERNS + +#ifdef CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS +extern cyg_bool cyg_hal_stop_constructors; +#endif + +// FUNCTION PROTOTYPES + +externC void +cyg_libc_invoke_main( CYG_ADDRWORD ); + +// STATICS + +#ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + +// override stack size on some platforms +#ifdef CYGNUM_HAL_STACK_SIZE_TYPICAL +# if CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_TYPICAL +# undef CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE +# define CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL +# endif +#endif + +static cyg_uint8 cyg_libc_main_stack[ CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE ]; + +#else // !ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + +extern char *cyg_libc_main_stack; +extern int cyg_libc_main_stack_size; + +#endif // !ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + +// GLOBALS + +// let the main thread be global so people can play with it (e.g. suspend +// or resume etc.) if that's what they want to do +Cyg_Thread cyg_libc_main_thread CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC) = + Cyg_Thread(CYGNUM_LIBC_MAIN_THREAD_PRIORITY, + &cyg_libc_invoke_main, (CYG_ADDRWORD) 0, + "main", + (CYG_ADDRESS) &cyg_libc_main_stack[0], +#ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE +#else + cyg_libc_main_stack_size +#endif + ); + +#endif // ifdef CYGSEM_LIBC_STARTUP_MAIN_THREAD + +// EOF mainthread.cxx diff --git a/packages/language/c/libc/startup/current/tests/atexit.c b/packages/language/c/libc/startup/current/tests/atexit.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/startup/current/tests/atexit.c @@ -0,0 +1,129 @@ +//================================================================= +// +// atexit.c +// +// Testcase for C library atexit() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library atexit() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Main header for stdlib functions +#include // Testcase API + + +// STATICS + +static int stage; +static int failed; + +// FUNCTIONS + +#if defined(CYGFUN_LIBC_ATEXIT) + +static void +myfun1( void ) +{ + if (!failed) + { + CYG_TEST_PASS_FAIL( stage==0, "first function called correctly" ); + stage=1; + } // if +} // myfun1() + +static void +myfun2( void ) +{ + if (!failed) + { + CYG_TEST_PASS_FAIL( stage==1, "Second function called correctly" ); + stage=2; + } // if +} // myfun2() + +static void +myfun3( void ) +{ + if (!failed) + { + CYG_TEST_PASS_FAIL( stage==2, "Second function called correctly" ); + stage=3; + } // if + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C " + "library atexit() function"); + +} // myfun3() + +#endif // if defined(CYGFUN_LIBC_ATEXIT) + +int +main( int argc, char *argv[] ) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C " + "library atexit() function"); + +#if defined(CYGFUN_LIBC_ATEXIT) + + // we only have one test in us! We can only exit once :-) + + CYG_TEST_PASS_FAIL( atexit(&myfun3)==0, + "Simple registration of first atexit() function" ); + + CYG_TEST_PASS_FAIL( atexit(&myfun2)==0, + "Simple registration of second atexit() function" ); + + CYG_TEST_PASS_FAIL( atexit(&myfun1)==0, + "Simple registration of third atexit() function" ); + + return 0; +#else + CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C " + "library atexit() function"); + +#endif // if defined(CYGFUN_LIBC_ATEXIT) + +} // main() + +// EOF atexit.c diff --git a/packages/language/c/libc/stdio/current/ChangeLog b/packages/language/c/libc/stdio/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/ChangeLog @@ -0,0 +1,159 @@ +2000-08-09 Jonathan Larmour + + * include/io.inl: No need to include string.h + + * cdl/stdio.cdl: Add some more requires statements + +2000-08-07 Jonathan Larmour + + * src/common/stream.cxx (Cyg_StdioStream::Cyg_StdioStream): + Only call io_buf members conditionally. + +2000-08-03 Jonathan Larmour + + * src/common/fseek.cxx: Include assertion and tracing support since + they are used. + +2000-07-20 Nick Garnett + + * include/stream.hxx (class Cyg_StdioStream): Added get_dev() + accessor member function to return underlying device handle. + + * src/common/fopen.cxx: Added fdopen() and fileno(). Reorganized + fopen() so that code common with fdopen() is now in a separate + function. + + * src/common/stdiosupp.cxx (Cyg_libc_stdio_find_filename): Removed + compiler warning. + +2000-07-13 Nick Garnett + + * cdl/stdio.cdl: Added common/fseek.cxx to compile list. + Reorganized options for stream buffering: + CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF now controls whether the user + can attach their own buffer to the stream. + CYGSEM_LIBC_STDIO_SETVBUF_MALLOC controls whether buffers can be + malloced or only statically defined. + Added CYGPKG_LIBC_STDIO_FILEIO option to control whether the STDIO + package uses the FILEIO package for all IO, or goes directly to + the device drivers as before. + + * include/stdio.h: Added file positioning calls defined in section + 7.9.9 of the standard. + + * include/io.hxx: + * include/io.inl: + Added these files to define an abstraction layer for access to the + real device underlying an IO stream. Depending on + CYGPKG_LIBC_STDIO_FILEIO this either goes to the FILEIO package or + directly to the device drivers. + + * include/stream.hxx: + Modifications to use io.hxx abstractions. + Added second constructor for creating a buffer-only stream. + Added initialize() function which contains most of the common + stream initialization code. + Added a close() member function. + + * include/stream.inl: + Modifications to use io.hxx abstractions. + Moved most of the work of the destructor into close() member. + Added FILEIO version of set_position() member function. + + * include/streambuf.hxx: + * include/streambuf.inl: + * src/common/streambuf.cxx: + Rearranged to match new buffering configuration options. + + * src/common/stream.cxx: + Modifications to use io.hxx abstractions. + Added second constructor, and moved common initialization code to + initialize() member function. + Added code to make position member correctly track current file + position. + + * src/common/fopen.cxx: + Fixed handling of write/append in process_mode(). + Moved call of process_mode() to before call to cyg_stdio_open() so + that stream modes may be passed in. + Added code to detect an interactive stream and choose non-buffered + mode - fully buffered is now the default. + Added calls to cyg_stdio_close() where appropriate. + + * src/output/vfnprintf.cxx: Removed FLUSH() macro and its + uses. Deciding to flush should be in the hands of the buffer code, + or the user calling fflush(). + + * src/common/vsscanf.cxx: + Added FILEIO variant of vsscanf(). This uses a precharged stream + object to emulate input. + + * src/common/vsnprintf.cxx: + Added FILEIO variant of vsnprintf(). This uses the standard stream + object to print into the supplied buffer. + + * src/common/fseek.cxx: + Added this file to implement file positioning functions. + + * src/common/fclose.cxx (fclose): + Added call to Cyg_StdioStream::close(). + + * include/stdiosupp.hxx: + * src/common/stdiosupp.cxx: + Modified Cyg_libc_stdio_find_filename() to take mode, binary and + append arguments. + + * src/common/stdin.cxx: + * src/common/stdout.cxx: + * src/common/stderr.cxx: + Modified calls to Cyg_libc_stdio_find_filename() to pass + appropriate values for mode, binary and append arguments. + +2000-06-18 Jonathan Larmour + + * src/common/vsscanf.cxx: Add NULL select entry to DEVIO_TABLE + * src/common/vsnprintf.cxx: Likewise + +2000-05-25 Hugo Tyson + + * include/stream.inl (set_error): If the error is EEOF, set + the EOF flag (flags.at_eof) so that clients know. + + * src/input/fgetc.cxx (__fgetc): + * src/input/fgets.cxx (_fgets): + * src/input/fread.cxx (_fread): Correctly handle an error, + or EOF indication, from real_stream->refill_read_buffer(). + +2000-05-02 Jonathan Larmour + + * New package + Separated original libc out into separate packages on functional + boundaries. + Header files are now managed by isoinfra package + Plenty of cleanups done, but no major functionality changes + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/stdio/current/ChangeLog.libc b/packages/language/c/libc/stdio/current/ChangeLog.libc new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/ChangeLog.libc @@ -0,0 +1,2727 @@ +This ChangeLog file is now obsolete. This is the original ChangeLog from when +libc was one large package, before being separated. It is included for +historical reasons. + +2000-04-05 Jesper Skov + + * src/time/settime.cxx: + * src/time/time.cxx: + Wallclock moved to io/. + +2000-03-28 John Dallaway + + * cdl/string.cdl, + cdl/stdlib.cdl, + cdl/stdio.cdl, + cdl/libc.cdl: + + Adjust documentation URLs. + +2000-03-27 Jesper Skov + + * src/clibincl/stream.inl (check_this): Use cyb_bool instead of bool. + +2000-03-06 Jesper Skov + + * tests/time/strftime.c (test): Adjust test to match below change. + +2000-03-02 Jonathan Larmour + + * src/time/strftime.cxx (do_format): Make sure %m counts from + 1..12 rather than 0..11. Fix for case 103300 + +2000-02-29 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: Correctly use 'n' parameter to + restrict length. Credit due to Andrew Lunn here as well. + Resolves 103057-CR-1 + + * tests/stdio/sprintf2.c (test): + Add snprintf tests to verify the correct behaviour of restricting + output length + +2000-02-10 Jesper Skov + + * tests/signal/signal2.c (main): + Also reclaim DATA_TLB_MISS vector if available. + +2000-01-31 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-28 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-19 Hugo Tyson + + * cdl/*.cdl: Add descriptions to a number of options &c which were + lacking same, also tidied up other typos as noticed en passant. + +1999-11-11 Bart Veer + + * cdl/string.cdl: + Switch to a single boolean configuration option for code size vs. + speed optimization. + +1999-11-03 John Dallaway + + * cdl/libc.cdl: Define tests. + +1999-10-19 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: We can now remove Berkeley + advertising clause + * src/stdlib/div.cxx: ditto + * src/stdlib/ldiv.cxx: ditto + * src/stdlib/strtol.cxx: ditto + * src/stdlib/strtoul.cxx: ditto + * src/string/strtok.cxx: ditto + +1999-10-19 John Dallaway + + * cdl/libc.cdl: + + Define CDL options for package-specific CFLAGS. + +1999-10-08 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_THREAD_PRIORITY): Change + default to 10 to keep test farm happy + * cdl/startup.cdl: Likewise + +1999-10-07 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Specify radio buttons using CDL interfaces. + +1999-10-06 Jonathan Larmour + + * cdl/stdio.cdl: Change default to /dev/ttydiag as per 1999-10-01 + change below + * cdl/startup.cdl: Add new form CDL for the startup changes as + per 1999-10-05 + +1999-10-05 Jonathan Larmour + + * include/libc.h: Add CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM to allow + the user to supply their own stack. + Rename CYGNUM_LIBC_MAIN_STACK_SIZE to + CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE and reparent under + CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + Add CYGNUM_LIBC_MAIN_THREAD_PRIORITY to provide main() thread + priority + + * src/support/mainthread.cxx: Add support for user-supplied stack + Allow user to specify thread priority + + These changes fix CR 101069 + +1999-10-01 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE): Change + default to /dev/ttydiag to get correct console-like behaviour + Also don't preclude use if haldiag package isn't included + (case 102065) + +1999-09-15 Jesper Skov + + * tests/signal/signal2.c (cause_fpe): Try both float and integer + division by zero. + +1999-09-10 Jesper Skov + + * src/stdlib/malloc.cxx (cyg_libc_get_malloc_pool): Added for + stress_threads test. + +1999-09-07 Jesper Skov + PRs 20243, 20433 + * tests/signal/signal2.c: Disabled test3 on ARM. + +1999-09-02 Hugo Tyson + + * include/assert.h: Make the sense of NDEBUG correct; it is "set" + when NOT debugging. Fix for CR 101983-CR-1 + See Stroustrup, "The C++ Programming Language." + +1999-08-18 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): Set buffer size 0 when not + buffering + Fix for case 101868 + +1999-08-17 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Implement radio buttons using "FIXME radio" hack in + description field for now. + +1999-08-12 John Dallaway + + * cdl/stdlib.cdl: + Take advantage of MACRONAME_ENUMVAL macros output by CDL. + +1999-08-06 Jonathan Larmour + + * tests/stdio/sprintf2.c (test): Don't rely on 2.345 being exactly + representable in binary as a difference of 1 ulp will make it round + the wrong way. + +1999-07-16 Jonathan Larmour + + * src/stdio/input/fgetc.cxx: + Include outline versions of getc() (actually just a symbol alias for + fgetc() ) and getchar() + Some minor clean-ups + Add tracing/assertions + + * src/stdio/input/fputc.cxx: + Likewise (except applied to putc() and putchar()) + + * src/stdio/common/stdioinlines.cxx (_puts): + Call fputc() not _fputc() + + * src/clibincl/stdiosupp.hxx: + Remove now obsolete prototypes for _fgetc() and _fputc() + + * include/stdio.h: + Don't bother with getc()/putc() macros any more, just call + them as functions + Include protos for getc(), putc(), getchar() and putchar() functions + +1999-06-21 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for SH EDK7708. + +1999-06-11 Jonathan Larmour + + * include/stdio.h: Make FILEs array types so they won't be + given $gp relocations on MIPS targets + +1999-05-27 Jesper Skov + + * tests/time/ctime.c: Fixed compiler warning. + +1999-05-25 Jonathan Larmour + + * tests/signal/signal2.c (main): + Update CYGPKG_HAL_TX39 -> CYGPKG_HAL_MIPS_TX39 due to recent MIPS + HAL changes + Fix for PR 20116 + +1999-04-30 Jesper Skov + PR 19945/19946 workaround + * tests/signal/signal2.c: Disabled test 3 for PowerPC sim. + +1999-04-19 Jonathan Larmour + + * include/time.inl: + Ensure all calls to cyg_libc_time_year_is_leap() are with the full + year, and not the direct contents of a struct tm, which are (year-1900) + +1999-04-19 Jesper Skov + PR 19308, 19410, 19528 + * tests/time/clock.c (test): Also disable data cache which may + affect timing when tracing/assertions are enabled. + +1999-04-15 Jonathan Larmour + + * src/clibincl/stdiosupp.hxx: + Add prototype for new cyg_libc_stdio_flush_all_but() function + + * src/clibincl/stream.hxx: + Don't include stdiosupp.hxx any more to prevent circular dependency, + therefore manually provide _setvbuf prototype + Make sure pkgconf/kernel.h is included before mutex.hxx + + * src/clibincl/stream.inl (Cyg_StdioStream::set_error()): + Add missing unlock_me() + + * src/stdio/common/fflush.cxx: + Separate most of code for fflush(NULL) into separate + cyg_libc_stdio_flush_all_but() function, which has the extra + capability of omitting one stream + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Add missing clibincl/stdiosupp.hxx include + + * src/stdio/common/stream.cxx (Cyg_StdioStream::read()): + When reading, ensure we flush all output streams + + * src/stdio/common/stream.cxx (Cyg_StdioStream::flush_output_unlocked): + Flush the device as well + +1999-04-15 Jonathan Larmour + + * src/stdio/common/streambuf.cxx (set_buffer): + * src/stdio/common/stdioinlines.cxx (_setbuf): + * src/clibincl/streambuf.inl: + * src/clibincl/streambuf.hxx: + * src/clibincl/stream.hxx (class Cyg_StdioStream): + * include/pkgconf/libc.h: + * include/stdio.inl (setbuf): + Fix dumb typo: BUFSIZE -> BUFSIZ + This fixes PR19837 + +1999-04-15 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx (_setbuf): + * include/stdio.inl (setbuf): + Use _IONBF when buf==NULL, and _IOLBF otherwise. + Fix for PR 19836 + +1999-04-15 John Dallaway + + * include/pkgconf/libc.h: Tidy display string capitalization. + +1999-04-12 Jonathan Larmour + + * include/pkgconf/libc.h: + Clarify CDL description of CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE + + * tests/signal/signal2.c: Try harder to generate an exception by + accessing a misaligned address + Don't handle SIGTRAP any more + Part of fix for PRs 19731/19607 + +1999-04-07 Jesper Skov + PR 19667 + * src/support/mainthread.cxx: + Changed to use the new Cyg_Thread constructor. + +1999-04-07 Hugo Tyson + + * tests/signal/signal2.c (main): Use new macro + HAL_VSR_SET_TO_ECOS_HANDLER if defined, to wrest control from + CygMon, for example, by reinstalling eCos' default VSRs for + exceptions that we are provoking. + +1999-03-29 Jonathan Larmour + + * src/signal/siginit.cxx: Include stdlib.h for exit() + Fix for PR 19720 + +1999-03-29 Jonathan Larmour + + * tests/time/clock.c (test): Disable instruction cache + Hopefully fixes PR 19308 + +1999-03-29 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for PPC as it cannot + trap division by zero. + +1999-03-26 Jonathan Larmour + + * src/support/main.cxx (main): Invoke cyg_user_start() if no kernel + Only sensible thing to do in our default main in a non-kernel config + +1999-03-25 Jonathan Larmour + + * tests/time/time.c: + Increase MAX_TIMEOUT since the sparclite gets very close to overrunning + it even when working. + Should return -1 iff CYGSEM_LIBC_TIME_TIME_WORKING isn't defined + Cosmetic changes + +1999-03-25 Hugo Tyson + + * tests/time/time.c (test): Take into account setting of + CYGSEM_LIBC_TIME_SETTIME_WORKING ie. does cyg_libc_time_settime() + work? If not, check that it returns an error. + This was exposed by the random combo in PR#19479. + +1999-03-23 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 to + CYGIMP_... + + Add another rand implementation CYGIMP_LIBC_RAND_SIMPLE1 which is + the default + + Part of fix for PR 19562 + + * include/sys/cstartup.h: + Tidy and remove unnecessary dependencies + + * src/stdlib/rand.cxx: + Rename algorithms from CYGSEM_... to CYGIMP_... + Add new "simple1" algorithm + + * tests/ctype/ctype.c: + Tidy + + * tests/stdlib/rand3.c: + Fix so that 0..RAND_MAX is split evenly over buckets, which it wasn't + before + Deal with case of RAND_MAX not being divisible by NUM_BUCKETS + exactly + Increase TEST_LENGTH to 200000 to provide more representative sample + Add CYG_TEST_INFO output to help ensure it doesn't time out + Tidy + + * tests/stdlib/rand4.c: + Only fail if more than _two_ thirds (rather than one third) match. + This is because half would match for a perfectly random distribution + This is the rest of the fix for PR 19562 + Cosmetic changes + +1999-03-22 Hugo Tyson + + * src/support/mainthread.cxx (CYGNUM_LIBC_MAIN_STACK_SIZE): + Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of + CYGNUM_HAL_MINIMUM_STACK_SIZE. + +1999-03-22 Jonathan Larmour + + * tests/PKGconf.mak: Add -Wno-format when building strftime otherwise + it generates warnings for things that we do want to test (null + string, and %y format) + +1999-03-19 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Put brackets back round negative number since sdf says the config + tool is fixed now (PR 19537) + + Add new CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 + options for different rand() algorithms in a so far failed attempt + to fix PR 19562 + + * src/stdlib/rand.cxx: + Add new optional algorithm from Knuth vol.2 + + * tests/stdlib/rand4.c: + Some tidies + Don't run test when using simplest algorithm + + * tests/signal/signal2.c (main): + Don't try to make an FPE on tx39 - its possible to detect but requires + too much HAL work to be sensible + +1999-03-18 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Use HAL_ENABLE_INTERRUPTS() rather than kernel to enable interrupts + +1999-03-18 Mark Galassi + + * tests/PKGconf.mak (TESTS): added rand4 compilation. + + * tests/stdlib/rand4.c: added this test for periodicity in the + least significant bit of rand(). + +1999-03-18 Jonathan Larmour + + * include/pkgconf/libc.h: Remove CYGFUN_LIBC_TIME_POSIX dependency + on CYGPKG_LIBC_STDIO + + * src/stdlib/itoa.cxx: + New file to convert integers to ascii + + * include/stdlib.h: + Add proto for new cyg_libc_itoa() function + + * include/time.inl: + Rework __asctime_r() to use memcpy() and cyg_libc_itoa() rather than + sprintf() + + * src/PKGconf.mak: + Build stdlib/itoa.cxx + + The above changes fix PR 19448 + +1999-03-17 Jonathan Larmour + + * include/time.h: Add #define of __time_t_defined to placate newlib + if it is used by accident. This is just a temporary workaround though. + +1999-03-16 Gary Thomas + + * src/PKGconf.mak: Add compile option to step around ARM compiler bug. + +1999-03-16 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Don't use parentheses for now + + * src/stdio/common/stream.cxx (refill_read_buffer): + Silence bogus compiler warning + +1999-03-16 Jesper Skov + + * tests/signal/signal2.c (main): Enable SIGSEGV test for + i386/Linux. + + +1999-03-15 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Only enable interrupts if they were disabled + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: + Add FIX ME line as a reminder that the workaround there can go away + in future + + * include/pkgconf/libc.h: + Add proper define for CYGSEM_LIBC_EXIT_CALLS_FFLUSH + Put brackets round negative CYGNUM_LIBC_TIME_DST_DEFAULT_STATE define + Fix run time typo + + * include/time.inl (__localtime_r): + Include sys/timeutil.h before this to get + cyg_libc_time_normalize_structtm() + +1999-03-12 Gary Thomas + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: Remove 'const' from char arrays since + this fails [silently] on ARM when -fwritable-strings (PR19440) + +1999-03-12 Jesper Skov + + * tests/signal/signal2.c (main): Compiler warnings fix was + slightly broken. + +1999-03-12 Jesper Skov + PR 19473 + * tests/signal/signal2.c (main): + Disabling SIGTRAP handling on i386/Linux is not a good idea. +1999-03-11 Jesper Skov + PR 19473 + * tests/signal/signal2.c: + Added compiler warnings fix. + Added N/A handling for i386/Linux. + +1999-03-10 Gary Thomas + + * include/pkgconf/libc.h: Force "haldiag" device to be present. + 'asctime' and friends need 'stdio' as well. + + * include/time.inl: Fix syntax error on difftime() declaration. + +1999-03-08 Gary Thomas + + * src/clibincl/stream.hxx: needed for this file. + + * src/stdio/common/vsscanf.cxx (str_read): Fix problem with string + pointer [created by merge with new I/O package]. + +1999-03-05 John Dallaway + + * include/pkgconf/libc.h: + Add legal values for CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET + and CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET. + +1999-03-05 Jonathan Larmour + + * include/time.inl (cyg_libc_time_year_is_leap): + Fix bug with modulo year 400 + Fix typo in asctime_r macro + Fix gmtime_r, and mktime as a result of testing + + * tests/time/asctime.c, tests/time/ctime.c, tests/time/gmtime.c, + tests/time/gmtime.c, tests/time/localtime.c, tests/time/mktime.c, + tests/time/strftime.c, tests/time/time.c: + New tests + + * tests/PKGconf.mak: + Build above new tests + + * include/pkgconf/libc.h: + Add reminder FIX ME about extra config option + + * src/time/strftime.cxx: + Fix %w and %Y parameters as a result of testing + + * src/time/timeutil.cxx: + Fix cyg_libc_time_normalize_structtm() as a result of testing + of mktime() + + * tests/time/clock.c: + Reformat, remove obsolete bits and tidy + + * include/time.h: + Add Cyg_libc_time_dst type and new functions + cyg_libc_time_setzoneoffsets(), cyg_libc_time_setdst(), + cyg_libc_time_getzoneoffsets(), cyg_libc_time_settime() + + * include/time.inl: + Implement the above functions. This allows us to adjust for timezone + diffences and set the time. + Change localtime() to adjust for STD/DST + Change mktime() to adjust for STD/DST + + * include/libc.h: + Add new config options CYGSEM_LIBC_TIME_SETTIME_WORKING + and component CYGPKG_LIBC_TIME_ZONES containing options + CYGNUM_LIBC_TIME_DST_DEFAULT_STATE, + CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET, + CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET + + * src/strftime.cxx: + Adjust handling of %Z to _not_ deal with STD/DST + + * src/time/settime.cxx: + New file to implement cyg_libc_time_settime() + + * src/PKGconf.mak: + Build settime.cxx + + * src/time/timeutil.cxx: + Supply outline versions of cyg_libc_time_setzoneoffsets(), + cyg_libc_time_setdst(), and cyg_libc_time_getzoneoffsets() + Add variables for STD/DST state + Some minor comment changes + + * include/errno.h: + Use CYGBLD_ATTRIB_CONST instead of __attribute__((const)) directly + + * include/signal.h: + Change format of function comment headers + + * include/signal.inl: + Restrict errno.h inclusion to when its actually used + Fix a spelling typo + + * include/stdlib.h: + Add CYGBLD_ATTRIB_CONST to abs, div, labs, ldiv + + * include/stdlib.inl: + Reformat and tidy + Include new versions of div and ldiv which are more portable and + are cleanly rewritten so aren't covered by the BSD licence, which + is now removed + + * src/stdlib/div.cxx, src/stdlib/ldiv.cxx: + Non-inline, non-BSD and portable versions of the new versions of div + and ldiv from stdlib.inl + + * include/time.h: + Much reformatting, tidying and improving comments + Change CLOCKS_PER_SEC from 1000 to 1000000 + Add new functions asctime_r, ctime_r, gmtime_r, localtime_r, clock, + difftime, mktime, time, asctime, ctime, gmtime, localtime, strftime + Include new time.inl file + + * include/pkgconf/libc.h: + Add new options CYGSEM_LIBC_TIME_CLOCK_WORKING, + CYGSEM_LIBC_TIME_TIME_WORKING, CYGFUN_LIBC_TIME_POSIX, + CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL, CYGIMP_LIBC_TIME_ASCTIME_INLINE, + CYGIMP_LIBC_TIME_CTIME_INLINE, CYGIMP_LIBC_TIME_DIFFTIME_INLINE, + CYGIMP_LIBC_TIME_GMTIME_INLINE, CYGIMP_LIBC_TIME_LOCALTIME_INLINE, + CYGIMP_LIBC_TIME_MKTIME_INLINE, CYGIMP_LIBC_TIME_ASCTIME_R_INLINE, + CYGIMP_LIBC_TIME_CTIME_R_INLINE, CYGIMP_LIBC_TIME_GMTIME_R_INLINE, + and CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE + + * time/asctime.cxx, time/asctime_r.cxx, time/clock.cxx, time/ctime.cxx, + time/ctime_r.cxx, time/difftime.cxx, time/gmtime.cxx, + time/gmtime_r.cxx, time/localtime.cxx, time/localtime_r.cxx, + time/mktime.cxx, time/strftime.cxx, time/time.cxx, time/timeutil.cxx, + include/time.inl: + New files to implement the new time functions. Many of them simply + provide the outline definitions, but the real body of the function + comes from time.inl + + * src/PKGconf.mak: + Build new .cxx files + + * src/clibincl/stdlibsupp.hxx: + Remove _div and _ldiv prototypes since they're no longer needed + + * src/clibincl/timesupp.hxx: + Delete as its now obsolete + + * src/time/clock.cxx: + Use new CYGSEM_LIBC_TIME_CLOCK_WORKING option to control whether it + just returns (clock_t)-1 or not. + Much reformatting and tidying + Change real imlpementation from _clock to __clock + Use CYGBLD_ATTRIB_WEAK_ALIAS now + + * tests/stdlib/div.c, tests/stdlib/ldiv.c: + Add some extra tests for handling of negative numbers + Reformat and tidy a bit, including removing the test for CYGPKG_LIBC + since its now always defined if the test is to be compiled + + * tests/time/clock.c: + Remove duplication CYG_TEST_INFO line + Check if unimplemented using "(clock_t)-1" and not just "-1" + +1999-03-04 Jonathan Larmour + + * src/stdlib/system.cxx: + Make sure system() is a weak alias for __system() + + * include/pkgconf/libc.h: Rework CDL description for + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE and change its default to + "/dev/haldiag" + + * src/stdio/common/stream.cxx: + Check that dev is valid when passed to stream constructor + + * src/stdio/common/stdiosupp.cxx: + Tidy + + * src/support/mainthread.cxx: Make this depend on + CYGSEM_LIBC_STARTUP_MAIN_THREAD rather than just CYGPKG_KERNEL + +1999-03-04 Gary Thomas + + Merged in changes from 'ecos-new_devs-19990216-branch' + + (1999-02-24 Jonathan Larmour ) + + * src/stdio/common/stream.cxx: + Add "fix me" comments and remove a couple of commented out lines + + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Revert to using pointer to string for private data, not just string. + This preserves the state across multiple calls + + (1999-02-24 Gary Thomas ) + + * src/stdio/common/vsscanf.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/stream.cxx: + * src/stdio/common/stdiosupp.cxx: + * src/stdio/common/fopen.cxx: + * src/clibincl/stream.inl: + * src/clibincl/stream.hxx: + * src/clibincl/stdiosupp.hxx: + * include/pkgconf/libc.h: Changes for new I/O system. + +1999-03-03 Jonathan Larmour + + * tests/stdlib/atexit.c: Forgot to config atexit test for + CYGFUN_LIBC_ATEXIT option + + * include/pkgconf/libc.h: + Require CYGVAR_KERNEL_THREADS_DATA for CYGSEM_LIBC_PER_THREAD_STRTOK + This fixes PR 19362 + Require CYGPKG_KERNEL for thread safe streams + Also don't need "requires CYGPKG_KERNEL" for per-thread rand and errno + if we already require a finer granularity kernel option + +1999-02-25 Jonathan Larmour + + * include/pkgconf/libc.h: Fix CYGNUM_LIBC_MAIN_STACK_SIZE by changing + CYGPKG_LIBC_STARTUP_MAIN_THREAD -> CYGSEM_LIBC_STARTUP_MAIN_THREAD + Fix for PR 19304 + +1999-02-23 Jonathan Larmour + + * src/stdlib/system.cxx: Add to implement trivial system() call + * include/stdlib.h: Add system() prototype + * src/PKGconf.mak: Build system.cxx + + * tests/ctype/ctype.c, tests/i18n/setlocale.c, tests/setjmp/setjmp.c, + tests/signal/signal1.c, tests/signal/signal2.c, + tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdio/stdiooutput.c, tests/stdlib/atexit.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/getenv.c, tests/stdlib/labs.c, + tests/stdlib/ldiv.c, tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/realloc.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + Use CYG_TEST_NA() macro for non-applicable test configurations + +1999-02-20 Jonathan Larmour + + * include/signal.h: + * include/signal.inl: + * src/signal/raise.cxx: + * src/signal/siginit.cxx: + * src/signal/signal.cxx: + * tests/signal/signal1.c + * tests/signal/signal2.c: + New files to implement ISO standard signals + + * src/PKGconf.mak (TESTS): + * tests/PKGconf.mak (TESTS): + Update to build new files above + + * include/stdlib.h: + * src/clibincl/stdlibsupp.hxx: + Comment and QA changes (including giving better names to some types) + + * include/libc.h: + Add new configuration options for signals + Add new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + Add a note to CYGNUM_LIBC_MAIN_STACK_SIZE option that it may be + overriden by HAL + Add new CYGFUN_LIBC_ATEXIT option and move ...ATEXIT_HANDLERS under + it + Add new CYGSEM_LIBC_EXIT_CALLS_FFLUSH option + Require CYGSEM_LIBC_STARTUP_MAIN_THREAD for "Invoke default static + constructors" option + + * src/stdlib/atexit.cxx: + Support above CYGFUN_LIBC_ATEXIT and QA changes + + * src/stdlib/exit.cxx: + Support for above new libc.h options, and some QA changes + + * src/support/cstartup.cxx: + Add support for new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + + * src/support/mainthread.cxx: + Override main stack size if the HAL has a minimum + + * src/string/strncpy.cxx: + Use improved algorithm for aligned copies - imported from newlib + QA changes + + * src/stdlib/abort.cxx: + Support raise(SIGABRT), and some QA + + * include/errno.h: + Add const attribute + + * tests/stdlib/abs.c: + QA improvements + +1999-02-04 Jesper Skov + + * src/support/cstartup.cxx: Only define cyg_libc_main_thread when + the kernel is around. + +1999-02-01 Jesper Skov + + * tests/time/clock.c: Joined the two test/NOP checks into + one. + Increased tolerance in attempt to fix PRs 18737,18787,18846. + Fixed typo. + +1999-01-28 Jonathan Larmour + + * src/string/strtok.cxx: + * src/stdlib/rand.cxx: + Include if we use kernel header files + +1999-01-25 Jonathan Larmour + + * tests/stdio/sscanf.c (test): + CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT should be + CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + Fix for PR 18786 + + * src/string/strtok.cxx: + * src/stdio/common/stdiofiles.cxx: + * src/errno/errno.cxx: + * src/stdlib/rand.cxx: + Give mutex protection objects a libc constructor priority + + * src/support/invokemain.cxx: + Add prototype for cyg_hal_invoke_constructors() + + * src/support/mainthread.cxx: + Give cyg_libc_dummy_constructor_obj a libc constructor priority, + and make its class have a public constructor + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/stdin.cxx: + Give cyg_libc_stdio_stdin/out/err static objects a libc constructor + priority + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + * src/clibincl/stream.hxx (class Cyg_StdioStream): + Remove private copy constructor. Needed to make prioritised + static constructors work. Fix for PR 18898 + +1999-01-22 Jonathan Larmour + + * src/errno/errno.cxx: + Include pkgconf/kernel.h otherwise it fails with per-thread errno + enabled + + * include/pkgconf/libc.h: + Enable per-thread errno by default since that is what POSIX would + want + + * tests/time/clock.c (test): + Placate compiler by initializing clock_first/second/third anyway, + even though they won't be in practice. This is only a test program + so adding an extra instruction doesn't matter. + + * src/i18n/locale.cxx (_setlocale): + Placate compiler, since it is dumb, by nesting, not serializing, if's + This is an idempotent change, but screws up the formatting :-(. + + * src/string/strpbrk.cxx (_strpbrk): + Change while loop to do loop to placate compiler. It'll even save an + instruction too (wow!) + +1999-01-22 John Dallaway + + * include/pkgconf/libc.h: + Add closing curly brace to CYGPKG_LIBC_STRING_STRTOK definition + +1999-01-21 Jonathan Larmour + + * include/errno.h: + Tidy up and add to header description + Change cyg_get_errno_p() to cyg_libc_get_errno_p() + Remove ifdef CYGPKG_LIBC + + * include/sys/file_if.h: + Remove - move contents to stdio.h + + * include/stdio.h: + Tidy up header description + Move FILE typedef here from sys/file_if.h + SEEK_SET, SEEK_CUR, SEEK_END defined to 0, 1, 2 respectively + for backwards compatibility with old UNIX + Change definitions of stdin/out/err to be addresses of FILE + globals - even though they're actually Cyg_StdioStream it'll work + + * include/pkgconf/libc.h: + Make CYGPRI_LIBC_WEAK et al macros depend on new ones in infra + Reorganise trace options under the individual components they are + associated with. + Reorganise thread-safety options under the individual components + they are associated with. + Add new CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS option + Misc. reformatting + Remove dependency on pkgconf/kernel.h - Configuration Tool will + generate check macros anyway. + Remove CYGPKG_LIBC_TRACE, CYGFUN_LIBC_strtok, CYGPKG_LIBC_RAND + options + Tidy up description header + + * src/clibincl/clibdata.hxx: + * src/clibincl/clibdata.inl: + * src/support/clibdata.cxx: + Remove and instead rely on each component to initialise its own data + + * src/clibincl/stdiofiles.hxx, src/clibincl/stdiofiles.inl: + New files to contain global file list and lock (if applicable). + Implemented as class with member access functions + + * src/errno/errno.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Rename cyg_get_errno_p() to cyg_libc_get_errno_p() + + * src/stdio/common/fclose.cxx: + * src/stdio/common/fflush.cxx: + * src/stdio/common/fopen.cxx: + * src/stdio/common/freopen.cxx: + Remove ifdef CYGPKG_LIBC + Use new global file access method from stdiofiles.hxx + Tidy up description header + Use new CYGBLD_ATTRIB_WEAK_ALIAS + Access errno "normally" rather than clibdata way + + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx + * src/stdio/common/stderr.cxx: + New files. Implement Cyg_StdioStream objects for each stream. In + separate self-contained files so using one doesn't bring in the + others + + * src/stdio/common/stdiofiles.cxx: + New file. Implements global files array and lock + + * src/stdlib/_exit.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Use infra CYGBLD* macros + + * src/stdlib/malloc.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Add pkgconf/kernel.h now that pkgconf/libc.h doesn't have it + Use infra CYGBLD* macros + Make pool visible externally with weak attribute and new name + cyg_libc_malloc_memorypool + + * src/stdlib/rand.cxx: + * src/stdlib/strtok.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Use infra CYGBLD* macros + + * src/support/cstartup.cxx: + Split into smaller files to make selective linking work better, + fix i386 port problem and make GDB happy + + * src/support/environ.cxx: + * src/support/invokemain.cxx: + * src/support/main.cxx: + * src/support/mainthread.cxx: + New files from bits of the old cstartup.cxx + Add support for CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG + + * src/PKGconf.mak: + Update to reflect file additions/deletion + + * tests/stdlib/rand1.c: + * tests/stdlib/rand2.c: + * tests/stdlib/rand3.c: + * tests/stdlib/srand.c: + Make conform to coding standards + Remove ifdef CYGPKG_LIBC_RAND + Tidy up description header + + * tests/string/strtok.c: + Make conform to coding standards + Remove ifdef CYGFUN_LIBC_strtok + Tidy up description header + +1999-01-15 Mark Galassi + + * tests/stdlib/getenv.c (main): added tests for the case in which + the user does not supply environ and in which the user supplies a + NULL environ. + +1999-01-15 Jesper Skov + + * src/support/cstartup.cxx: Added workaround for weak aliasing + problem in i386 gcc. + + +1999-01-15 Gary Thomas + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_STACK_SIZE): + (CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE): Change defaults to be + more reasonable on small systems. + +1999-01-04 Jonathan Larmour + + * src/support/clibdata.cxx: + Minor bug with environ not being initialised correctly by + default + +1998-12-24 Bart Veer + + * src/clibincl/stream.inl (Cyg_StdioStream): + check_this() member functions should now be const + +1998-12-22 Jonathan Larmour + + * src/string/memchr.cxx (_memchr): + treat search value parameter to memchr as an unsigned byte, + not a signed int - copied fix from newlib PR 18471 + +1998-12-21 Jonathan Larmour + + * tests/stdlib/realloc.c: + * tests/stdlib/malloc3.c: + * tests/stdlib/malloc2.c: + Warning cleanup + +1998-12-14 Jonathan Larmour + + * tests/stdlib/malloc2.c, tests/stdlib/malloc3.c, + tests/stdlib/realloc.c: + Only run these tests when we have a coalescing memory allocator + +1998-12-14 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Only check buffer init success if buffering + + * src/stdio/common/streambuf.cxx (set_buffer): + Check for diff of requested size against buffer_size, not + get_buffer_size(), since this may return -1, which won't be + equal to size, and will cause malloc to be called + +1998-12-01 Jesper Skov + + * tests/stdlib/getenv.c (main): Don't declare variables when they + are not used. + +Thu Nov 26 17:59:12 1998 Jonathan Larmour + + * tests/string/strncpy1.c: + Fix off-by-one error since it called my_strcmp() and not + my_strncmp(), which meant in included the trailing NULL when it + shouldn't have. + +1998-11-26 Jesper Skov + + * src/stdlib/qsort.cxx (_qsort): + * src/stdlib/rand.cxx (_srand): + Changed CYG_REPORT_FUNCNAMETYPE to CYG_REPORT_FUNCNAME in void + functions. + +Mon Oct 26 18:49:00 1998 Jonathan Larmour + + * src/support/cstartup.cxx (cyg_libc_dummy_main): + Silence compiler warning with cast of char * to CYG_ADDRWORD + +Wed Oct 28 17:31:21 1998 Jonathan Larmour + + * src/time/clock.cxx (_clock): + Reorder scaling expression as it was both incorrect and risked + overflow. + Fix for PR 18076 + +Mon Oct 19 14:40:06 1998 Jonathan Larmour + + * include/stdio.h (EOF): + Change from -64 to (-1), to allow broken code to work :-/ + Also change other negative defines to be within parentheses + +1998-10-19 Mark Galassi + + * include/pkgconf/libc.h: updated the doc URL + +Thu Oct 15 21:33:44 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Only include kernel thread headers when we're in thread-safe mode + + * src/time/clock.cxx: + Only include kernel clock headers if there's a kernel with the + right functionality available + + * tests/time/clock.c: + Remove unnecessary inclusion of + + Above changes are required for PR 17229 + +Wed Oct 14 16:38:55 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise inclusion of clibincl/stdiosupp.hxx and + clibincl/stream.hxx. Tidying up PR 17502 + +Wed Oct 14 14:08:56 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGPKG_LIBC_STRING_OPTIMISATIONS to + CYGPKG_LIBC_STRING_OPTIMIZATIONS to make it truely merkin. + +Tue Oct 13 19:34:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_ARGUMENTS): + Add a default argv[0] of "" as many programs assume argc>0 + The standard allows argv[0] to be "" if the program name + is not available + +1998-09-26 Bart Veer + + * src/clibincl/stdiosupp.hxx: + PR 17502: this header file now does nothing if the stdio option + is disabled completely. This is the same behaviour is + clibincl/stream.hxx, although arguably the #ifdef protection + should happen wherever the header file is #include'd rather than + in the header file itself. + + * src/clibincl/clibdata.hxx: + PR 17502: this header file still #include's internal stdio-related + header files and references the FILE structure, even if stdio is + disabled. There were some #ifdef's for CYGPKG_LIBC_STDIO already. + One more has been added for _fopen() and _fclose(). + +1998-09-25 Bart Veer + + * src/clibincl/streambuf.inl (Cyg_StdioStreamBuffer): + PR 17487: Reorder the calls to initialize member fields, to + eliminate a compiler warning. + +Fri Sep 25 19:04:29 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/string/strtok.cxx, + src/time/clock.cxx: + Only define tracing variable and tracing level macro when + the relevant tracing level config options are set. Otherwise + keep the tracing level fixed at 0 + Fix for PR 17476 + + * include/pkgconf/libc.h: + Define trace levels only if parent CYGPKG_LIBC_TRACE is defined + for consistency with Configuration Tool + + +Fri Sep 25 17:24:45 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Make definition of vscanf() dependent on CYGFUN_LIBC_STDIO_ungetc + otherwise _vfscanf() won't be compiled. This therefore would + cause a link fail iff selective linking is not enabled. + Fix for PR 17455 + +Fri Sep 25 17:23:17 1998 Jonathan Larmour + + * src/stdlib/rand.cxx: + Make compilation dependent on CYGPKG_LIBC_RAND + Fix for PR 17473 + + * tests/stdlib/srand.c: + Make definition of dummy test pass conditional on CYGPKG_LIBC_RAND + not being defined, as well as CYGPKG_LIBC + Caused compilation failure when testing PR 17473 fix + +Mon Sep 21 17:11:04 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Make sscanf test conditional on CYGFUN_LIBC_STDIO_ungetc since + _vfscanf() only gets compiled if this is defined + Fix for PR 17346 + +1998-09-20 Mark Galassi + + * include/pkgconf/libc.h: updated CDL doc strings. + +Fri Sep 18 22:18:47 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_errno_p): + Rather than this function only being available in thread-safe mode, + instead make what it returns be either the per-thread errno, or + global errno depending on the configuration. + Include (conditionally) to support this change + +Wed Sep 16 11:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove "fix me" comment which I forgot to remove before + +Tue Sep 15 19:27:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Updated descriptions and a few other minor things after review. + Notably though, the NDEBUG config option has been removed + +1998-09-15 Bart Veer + + * include/pkgconf/libc.h: + PR 17201: removed dependency on CYGPKG_KERNEL in the option + CYGNUM_LIBC_MAIN_STACK_SIZE, since the actual dependencies cannot + be expressed sensibly in the current system. + +1998-09-11 Bart Veer + + * include/pkgconf/libc.h: + Sorting out dependencies for error package. + +1998-09-10 Mark Galassi + + * include/pkgconf/libc.h: started adding doc fields to the + cdl_package data, as a pilot for now. + +Wed Sep 9 17:41:23 1998 Hugo Tyson + + * include/pkgconf/libc.h: + Add option CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE to explicitly + control whether the empty delete functions (currently) in + kernel/.../common/delete.cxx are enabled; controls code bloat, see + the comments in delete.cxx. + +Fri Sep 4 16:43:38 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add a default CYG_TEST_PASS() to make sure the test infra doesn't + complain. + Also remove the unused string functionsa + +Fri Sep 4 15:43:48 1998 Hugo Tyson + + * src/stdlib/exit.cxx (__libc_exit): + * src/stdlib/_exit.cxx (__libc__exit): + * src/stdlib/malloc.cxx (_free): + * src/stdlib/abort.cxx (abort): + * src/support/cstartup.cxx (invoke_main): + Tracing system asserted cos it was being called incorrectly; these + are void functions so you shouldn't give a type to the function + reporting call. + +Fri Sep 4 15:03:10 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Fix CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE description to refer to + the table.cxx file, not table.h + +Fri Sep 4 14:38:52 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add description for CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE since + Proven won't be making any changes to the device driver + implementation after all. + Fix for PR 17148 + + * src/clibincl/stream.inl (set_position): + Remove "fix me" line. It is obvious that this will have to change + with a filesystem interface + Fix for PR 17147 + + * src/stdio/common/freopen.cxx: + Remove "fix me" - I know about this issue + Fix for PR 17145 + + * src/stdio/common/stream.cxx (read): + Remove "fix me" and change to use memcpy + Fix for PR 17144 + +Fri Sep 4 14:36:47 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Actually add it this time! + +Fri Sep 4 13:48:13 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add new tests for misc stdio output functions + + * tests/PKGconf.mak: + Build stdiooutput.c test + +Fri Sep 4 12:52:10 1998 Jonathan Larmour + + * src/clibincl/stream.inl (write_byte): + Remove bogus assert + + * tests/stdlib/getenv.c (main): + Check whether str is NULL before doing a strcmp() + + * tests/stdio/sprintf2.c (main): + Reformat to 76 columns + +Fri Sep 4 02:10:54 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/stdio/common/stream.cxx: + Add new peek_byte method to Cyg_StdioStream + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix up buffer access to work with new peek_byte method above + Fix for PR 16954 + +Thu Sep 3 19:40:11 1998 Jonathan Larmour + + * tests/stdlib/rand1.c, tests/stdlib/rand2.c, + tests/stdlib/rand3.c: + Add extra check for CYGPKG_LIBC_RAND to decide whether the test + is applicable or not + + * tests/stdlib/rand2.c (test): + Use CYGNUM_LIBC_RAND_SEED for default seed, not 1 + + * tests/string/strtok.c: + Add extra check for CYGFUN_LIBC_strtok to decide whether the + test is applicable or not + +Wed Sep 2 19:11:40 1998 Jonathan Larmour + + * src/stdio/input/fread.cxx, src/stdio/output/fwrite.cxx: + Add fread() and fwrite() functions + + * src/PKGconf.mak: + Build fread.cxx and fwrite.cxx from above + + * src/stdio/common/stream.cxx: + Reformat to 76 columns + In write(), move initialisation of *bytes_written to start + In read(), move initialisation of *bytes_read to start + + * include/stdio.h: + Reformat to 76 columns + + Replace all references to the ANSI + standard to instead by the ISO C standard + + Add commented argument names for "documentation" + + Add fread() and fwrite() prototypes + + * src/clibincl/stdiosupp.hxx: + Copy the above changes from stdio.h, and add _fread() and _fwrite() + prototypes + + * src/stdio/output/fputs.cxx, src/stdio/input/fgets.cxx: + Reformat to 76 columns + +Wed Sep 2 15:41:15 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Reformat to 76 columns + +Wed Sep 2 14:46:18 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Use trylock_me() instead of lock_me(), and loop to prevent + deadlocks + + * src/clibincl/stream.hxx, src/clibincl/stream.inl: + Add trylock_me() method + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/fflush.cxx: + Reformat to 76 columns + +Wed Sep 2 12:24:27 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change 0x7fff to 0x7fffffff. Oops! + give main stack size option a legal_values field + Undefine tracing by default + Add some more description in the header + +Tue Sep 1 20:02:07 1998 Jonathan Larmour + + * tests/i18n/setlocale.c (cyg_package_start): + Fix typo - extra "x" for no reason at all! :-) + +Tue Sep 1 19:44:58 1998 Jonathan Larmour + + * src/i18n/locale.cxx: + Fix bug in find_locale_data() that miscalculated size of + all_locales + + Make find_locale_data() match the locale "" and add some + other things in _setlocale() to ensure that "C" gets returned + when the default locale "" is passed. + + Only check the locale pointer when it is non-NULL + + * tests/i18n/setlocale.c: + New tests for setlocale() + + * tests/PKGconf.mak: + Update to build setlocale.c test + + * src/support/cstartup.cxx: + Don't actually call system default main() "main" otherwise GDB + gets confused and thinks its the entry point. Instead make a weak + alias and call the real function something different. + +Tue Sep 1 18:31:42 1998 Jonathan Larmour + + * src/i18n/locale.cxx (_setlocale): + Fix tracing macro name and remove "str maybe used before + initialised" warning + + * tests/stdlib/qsort.c: + Correct file description header + +Tue Sep 1 17:04:32 1998 Jonathan Larmour + + * include/locale.h, src/clibincl/i18nsupp.hxx, src/i18n/locale.cxx: + New files to add support for locales as defined by the ISO C + standard. i.e. setlocale() and localeconv() functions and some + other bits + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAX_LOCALE_NAME_SIZE config option for locale + support + + * src/PKGconf.mak: + build locale.cxx + + * include/errno.h, src/clibincl/ctypesupp.hxx: + Tidy up to 76 columns + +Tue Sep 1 00:24:22 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Move environment-related options from stdlib into new + CYGPKG_LIBC_STARTUP component. Also add options for main()'s + arguments (CYGPKG_LIBC_ARGUMENTS), main()'s default stack size + (CYGNUM_LIBC_MAIN_STACK_SIZE), number of atexit handlers + (CYGNUM_LIBC_ATEXIT_HANDLERS), and whether _exit() stops the + system (CYGSEM_LIBC_EXIT_STOPS_SYSTEM). + + * src/clibincl/stdlibsupp.hxx: + Fix a few comment bugs, and add new + cyg_libc_invoke_atexit_handlers() function prototype + + * src/stdlib/_exit.cxx, src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Implement exit(), atexit() and _exit() correctly now. Also + includes cyg_libc_invoke_atexit_handlers() in atexit.cxx. Now + we get the correct behaviour of atexit(), and exit() invokes the + atexit handlers and fflushs all the stdio streams. Add plenty of + tracing of asserts too. + + * src/support/cstartup.cxx: + Make main_thread object an exported global. Allow user-settable + arguments. Add MUCH more tracing and asserts. Improve comments. + Tidy up to 76 columns + + * tests/stdlib/atexit.c: + Add simple test for atexit() and it calling registered functions + + * tests/PKGconf.mak: + Build atexit.c test + +Mon Aug 31 18:54:48 1998 Jonathan Larmour + + * src/stdlib/getenv.cxx, tests/stdlib/getenv.c: + Add support for getenv(), and some tests to ensure it works + + * src/PKGconf.mak, tests/PKGconf.mak: + Update to include getenv.cxx and getenv.c test + + * src/clibincl/clibdata.hxx: + remove prototype for environ - we expect files needing it to + define it themselves + + * src/support/clibdata.cxx: + Tidy up to 76 columns and add definition of char **environ, but + with a configurable initialiser (see libc.h below) + + * tests/stdlib/abs.c (main): + Tidy up to 76 columns + + * src/stdlib/malloc.cxx: + Tidy up to 76 columns and remove warning for undefined _memcpy() + by changing to memcpy(), and casting away signedness + + * include/pkgconf/libc.h: + Add CYGPKG_LIBC_ENVIRONMENT and CYGDAT_LIBC_DEFAULT_ENVIRONMENT + configuration options + + * include/pkgconf/libc.h, src/clibincl/clibdata.hxx: + Tidy up to 76 columns + + * include/stdlib.h: + Add getenv() prototype and tidy up to 76 columns + + * src/clibincl/stdlibsupp.hxx: + Add _getenv() prototype + +Mon Aug 31 13:37:08 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Add realloc() + + * tests/stdlib/realloc.c: + Add this file to test new realloc() functionality + + * tests/PKGconf.mak: + Build realloc test + + * tests/stdlib/malloc3.c (main), tests/stdlib/malloc2.c (main), + tests/stdlib/malloc1.c (main): + Conditionalise local vars to prevent warnings + + * tests/stdlib/malloc3.c (fill_with_data): + Move '{' into "verb" line + + * include/pkgconf/libc.h: + Require infra tracing support to allow tracing + + * include/stdlib.h: + Add realloc() + + * src/clibincl/stdlibsupp.hxx: + Update the commented argument names from stdlib.h, including realloc() + +1998-08-28 Bart Veer + + * include/pkgconf/libc.h: + * src/clibincl/clibdata.hxx, src/time/clock.cxx: + + Updated for new kernel configuration option symbol names + +Fri Aug 28 19:18:25 1998 Hugo Tyson + + Changed the entry below to sat "tx39" instead of "mn10300". + It's been a long week. + +Fri Aug 28 18:59:20 1998 Hugo Tyson + + * src/support/cstartup.cxx: Add a weakly named main to allow the + default configuration to link on the tx39 which has no + scalextric linking yet. The static Cyg_Thread main_thread object + below continues to exist, though unreferenced, so all its + descendants must exist too. + +Fri Aug 28 08:54:29 1998 Jonathan Larmour + + * include/stdlib.h: + Add commented argument names Add exit(), and atexit(). And move + these along with abort() and _exit() to a new section. + + * src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Add trivial versions of atexit() and exit() + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAIN_STACK_SIZE config option + + * include/sys/cstartup.h, src/support/cstartup.cxx, src/PKGconf.mak: + New files to provide a new function cyg_iso_c_support(), which + invokes main "correctly". + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/srand.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcoll2.c, tests/string/strcpy1.c, + tests/string/strcpy2.c, tests/string/strcspn.c, + tests/string/strlen.c, tests/string/strncat1.c, + tests/string/strncat2.c, tests/string/strncpy1.c, + tests/string/strncpy2.c, tests/string/strpbrk.c, + tests/string/strrchr.c, tests/string/strspn.c, + tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, + tests/time/clock.c: + + Modify all tests to use new startup mechanism, and cyg_iso_c_start() + +Fri Aug 28 00:29:38 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Add #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO around all accesses to + flags.last_buffer_op_was_read. Fix for PR 16997 + +Thu Aug 27 01:12:42 1998 Jonathan Larmour + + * include/sys/file_if.h: + Fix comments and remove cyg_get_file_star() + +Wed Aug 26 20:24:32 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove #define CYGPKG_LIBC is that is meant to live in + after all + +Wed Aug 26 19:39:23 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + More fixes to CDL stuff to make it work better, and look better on + the screen + +Tue Aug 25 20:21:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Make some fixes after running the ConfigTool + +Tue Aug 25 16:46:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_STDIO_BUFSIZE): + Fix typo of CYGNUM_LIBC_STDIO_BUFSIZE + +Tue Aug 25 15:10:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Tidy up CDL stuff a bit more, prior to checking it actually works. + +Tue Aug 25 11:38:52 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c (main): + Prevent calls to CYG_TEST_STILL_ALIVE for now + +Tue Aug 25 05:39:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change cosmetic paragraph alignment. + +Tue Aug 25 03:11:34 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Make stderr initialise with buffer size 0. + For PR 16955 + +Mon Aug 24 17:38:46 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + First pass at CDL-ifying the C library configuration. Currently + deliberately disabled as there a few outstanding issues. + +Mon Aug 24 16:14:22 1998 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx (_vfnprintf): + clear up warning for unused argument + + * tests/stdlib/malloc2.c (NUM_ITERATIONS): + Lower to 100 from 50000 so it won't take too long under the simulator + +Thu Aug 20 17:48:43 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Remove now unnecessary inclusion of kernel/ktypes.h + +Wed Aug 19 19:19:14 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, + tests/stdio/sscanf.c, tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, + tests/stdlib/strtoul.c, tests/string/strtok.c, + tests/time/clock.c: + Add parameters to "main()" to silence warnings + +Wed Aug 19 18:52:59 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx (refill_read_buffer): + Put conditional error check into same #ifdef and if as what was being + checked in the first place! + +Wed Aug 19 18:49:19 1998 Jonathan Larmour + + * src/clibincl/stream.inl: + Reorder Cyg_StdioStream::check_this() to be first to silence + warnings + +Tue Aug 18 16:10:03 1998 Jonathan Larmour + + * ecc/language/c/libc/current/src/clibincl/clibdata.hxx, + ecc/language/c/libc/current/src/errno/errno.cxx, + ecc/language/c/libc/current/src/stdio/common/fopen.cxx, + ecc/language/c/libc/current/src/stdlib/rand.cxx, + ecc/language/c/libc/current/src/string/strtok.cxx: + Rename CYGIMP_LIBC_INTERNAL_DATA_PREAMBLE, + CYGIMP_LIBC_INTERNAL_DATA_ALLOC_CHECK_PREAMBLE, + CYGVAR_LIBC_INTERNAL_DATA, and + CYGIMP_LIBC_INTERNAL_DATA_CHECK to all have CYGPRI_ prefix instead + as recommended by the config name rules + + +Tue Aug 18 14:31:19 1998 Jonathan Larmour + + * src/stdio/common/setvbuf.cxx (_setvbuf): + Rename variable names in assert line, otherwise doesn't build + with asserts on! + +Sun Aug 16 18:15:12 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix some bugs, although there are some left to fix still. Unrelated + to the rest of the checkins, so I will check the partial fix in now. + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx: + Add parameters to constructor to allow more things to be done at + construction time. + + Now we have "new", remove separate "construct" method + + Add more documentation on constructor + + As requested by code review, where possible, move boolean flags + into separate packed bitfield structure for space efficiency + + Make readbuf_char be usable all the time rather than when configured + not to be buffering, as it is also needed for non-buffered mode i.e. + _IONBF + + * src/stdio/common/fopen.cxx: + Change to use new method of construction from above, using new + + Use thread-specific data, rather than global. And so change errnos + to access errno entry specifically + + Make process_mode() check for append mode too + + Reformat for coding standards to have { in same line as "verb" + + * src/stdio/common/setvbuf.cxx: + + Change to cope with different way of dealing with buffering policy + flags etc. in Cyg_StdioStream + + * src/stdio/common/vsnprintf.cxx, src/stdio/common/vsscanf.cxx, + src/support/clibdata.cxx: + Change construction of streams to use new parameters added above, + and change to use _IONBF mode for string stdio functions, + otherwise its a waste of memory. And use _IONBF for stderr as the + ISO standard tells us to! + + Reformat for coding standards to have { in same line as "verb" + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Change constructor so that it can be set with default size and + dynamic buffer (if applicable) + + Fix minor bug in destructor - should only call free when allocated + dynamically + + Change get_buffer_size to return -1 if the buffer was not allowed + to be set up + + * src/stdio/common/streambuf.cxx: + Remove unnecessary stdio.h include and add extra comment to whether + to free bit in set_buffer() + + * src/stdio/common/freopen.cxx: + Change @@@ to standard fix me string + + * src/stdio/output/fputc.cxx: + Remove unnecessary "written" variable + +Thu Aug 13 15:37:28 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: + Included use of "fix me" line to ensure this is discussed before + release + + * include/stdlib.h, src/stdlib/abort.cxx, src/PKGconf.mak: + Add abort.cxx to implement abort(), albeit naively + +Thu Jul 30 18:03:09 1998 Jonathan Larmour + + * src/stdio/common/vsscanf.cxx (_vsscanf), + src/stdio/common/vsnprintf.cxx (_vsnprintf): + Fix initialiser of pseudo string device table that didn't get updated + when the table changed (Bad proven, no biscuit). + + * src/clibincl/stream.inl (~Cyg_StdioStream): + Move invalidation of magic_validity_word to after unlock_me(), + otherwise it always fails! + +Tue Jul 28 21:29:53 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Shorten over-long lines + +Tue Jul 28 20:28:23 1998 Jonathan Larmour + + * src/clibincl/stream.hxx (class Cyg_StdioStream), + src/clibincl/stream.inl, src/stdio/common/stream.cxx: + Clarify some comments and get the CYGDBG_DEFINE_CHECK_THIS and + CYG_ASSERTCLASS stuff going + + * src/clibincl/stream.inl: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 15:31:06 1998 Jonathan Larmour + + * src/clibincl/streambuf.inl, src/stdio/common/streambuf.cxx: + Move set_buffer() from streambuf.inl to new file streambuf.cxx + + * src/PKGconf.mak (COMPILE): + Build new file streambuf.cxx + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + Add METHODS comment + + * src/stdio/common/stream.cxx: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 00:26:36 1998 Jonathan Larmour + + * include/stdlib.inl, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/div.cxx, + src/stdlib/ldiv.cxx, src/stdlib/qsort.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/string/strtok.cxx: + + Include proper Berkeley license inline in the file, rather than + referring to an external file + + * doc/COPYING.UCB: + Remove, now that it isn't referred to any more + +Mon Jul 27 23:34:26 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl, include/errno.h, + include/stdio.h, include/stdio.inl, include/stdlib.h, + include/stdlib.inl, include/string.h, include/string.inl, + include/time.h, include/sys/file_if.h, src/PKGconf.mak, + src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/stdiosupp.hxx, + src/clibincl/stream.hxx, src/clibincl/streambuf.hxx, + src/clibincl/streambuf.inl, src/clibincl/stringsupp.hxx, + src/clibincl/timesupp.hxx, src/ctype/isalnum.cxx, + src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, + src/ctype/islower.cxx, src/ctype/isprint.cxx, + src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, + src/ctype/tolower.cxx, src/ctype/toupper.cxx, + src/errno/errno.cxx, src/stdio/common/snprintf.cxx, + src/stdio/common/sprintf.cxx, src/stdio/common/sscanf.cxx, + src/stdio/common/stdioinlines.cxx, src/stdio/common/stream.cxx, + src/stdio/common/ungetc.cxx, src/stdio/common/vsnprintf.cxx, + src/stdio/common/vsscanf.cxx, src/stdio/input/fgetc.cxx, + src/stdio/input/fgets.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/gets.cxx, src/stdio/input/scanf.cxx, + src/stdio/output/fnprintf.cxx, src/stdio/output/fprintf.cxx, + src/stdio/output/fputc.cxx, src/stdio/output/fputs.cxx, + src/stdio/output/printf.cxx, src/stdlib/_exit.cxx, + src/stdlib/abs.cxx, src/stdlib/atof.cxx, src/stdlib/atoi.cxx, + src/stdlib/atol.cxx, src/stdlib/div.cxx, src/stdlib/labs.cxx, + src/stdlib/ldiv.cxx, src/stdlib/rand.cxx, src/stdlib/strtod.cxx, + src/string/memchr.cxx, src/string/memcmp.cxx, + src/string/memmove.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, + src/string/strcoll.cxx, src/string/strcpy.cxx, + src/string/strcspn.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx, src/string/strpbrk.cxx, + src/string/strrchr.cxx, src/string/strspn.cxx, + src/string/strstr.cxx, src/string/strsuppt.cxx, + src/string/strtok.cxx, src/string/strxfrm.cxx, + src/support/clibdata.cxx, src/time/clock.cxx: + Untabify + +Mon Jul 27 23:14:18 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/stdlib/malloc.cxx, src/stdlib/qsort.cxx, + tests/ctype/ctype.c, tests/stdlib/rand3.c, tests/stdlib/malloc3.c: + Remove all mentions of "register" in variable declarations. Also + untabify where needed + + * src/stdlib/bsearch.cxx: + Untabify this too + + +Mon Jul 27 22:18:51 1998 Jonathan Larmour + + * src/stdio/output/fputc.cxx (_fputc): + Replace call to stream write() with call to write_byte() + + * src/clibincl/stream.inl (write_byte): + Add asserts for stream write() returning odd values for how much has + been written + + (bytes_available_to_read): + Remove "register" def for variable declaration + +Mon Jul 27 22:06:22 1998 Jonathan Larmour + + * src/stdio/common/stdiosupp.cxx: + Remove #if 0'd cyg_get_file_star() and unnecessary pseudo string + device definition + +Mon Jul 27 21:57:25 1998 Jonathan Larmour + + * include/pkgconf/libc.h, src/support/clibdata.cxx: + Change CYGXXX_LIBC_STDIO_DEFAULT_CONSOLE to + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE + +Mon Jul 27 21:49:23 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/setjmpsupp.hxx, + src/clibincl/stdiosupp.hxx, src/clibincl/stdlibsupp.hxx, + src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl, + src/clibincl/stringsupp.hxx, src/clibincl/timesupp.hxx: + + Change CYGONCE_LIBC_*_{HXX,INL} to CYGONCE_LIBC_CLIBINCL_*_{HXX,INL} + +Mon Jul 27 21:34:05 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change #define XXXXX 1 to #define XXXXX where applicable as per code + review + + Also remove obsolete CYGIMP_LIBC_THREAD_START_SUSPENDS_SELF + +Mon Jul 27 19:42:27 1998 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): + Use #ifdef, not #if for config options + +Mon Jul 27 15:01:51 BST 1998 Chris Provenzano + + * src/stdio/common/stream.cxx, src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx: + Fixes to compile with the new Cyg_IORB field names. + +Thu Jul 9 03:40:21 1998 Jonathan Larmour + + * tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Adjust starting of tests to possibly start scheduler since + strtol/stroul rely on errno, which may be a per-thread variable + +Thu Jul 9 03:06:25 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx, src/stdio/common/setvbuf.cxx: + Consolidate read and write buffers into single buffer, as it should + have been all along + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Add drain_buffer() method to speed up the case when we want the + buffer completely emptied + +Tue Jul 7 21:26:33 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Add a couple of new tests that check that very long strings work too + +Wed Jul 1 19:52:39 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/streambuf.hxx: + Do not permit copy constructors + + * src/clibincl/stream.inl, src/stdio/common/fclose.cxx: + Make sure we use #ifdef and not #if + + * src/clibincl/streambuf.inl: + Use member initialisation list rather than explicit initialisation to + reduce warnings + +Wed Jul 1 19:17:55 1998 Jonathan Larmour + + * include/pkgconf/libc.h and all files using config options: + Rename configuration defines to make them more standard + +Thu Jun 25 20:09:30 1998 Jonathan Larmour + + * src/string/strcat.cxx: + Add parentheses on check to silence warning + (Verified by proven) + +Thu Jun 25 19:30:01 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Make sure that the malloc pool is initialised before other things + can use it. This is done with the hot new constructor ordering + feature. + +Thu Jun 25 18:27:03 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Remove bogus ifdef if floating point is _not_ wanted + +Thu Jun 25 17:31:42 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Fix argument checking to allow first argument of NULL + +Thu Jun 25 04:18:50 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_strtok_last_p): + Remove bogus assertion + + * src/stdlib/malloc.cxx: + Got sense of alignment check assertion the wrong way round, so negate + it + +Thu Jun 25 03:56:35 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: + Fix argument checking assertions with legitimate nulls here too + +Thu Jun 25 03:46:32 1998 Jonathan Larmour + + * src/stdlib/strtoul.cxx, src/stdlib/strtol.cxx: + Fix argument checking assertions to cope with legitimate nulls + +Wed Jun 24 09:01:45 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Remove extraneous info messages + +Wed Jun 24 05:59:17 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c: + + Change large automatic arrays to static arrays to prevent overuse + of a potentially small stack + +Wed Jun 24 05:45:28 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/string/strtok.c, tests/time/clock.c: + + Increase thread stack size from 4K to 32K as in some cases it was + too small. + + +Tue Jun 23 20:12:31 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Add extra tests, including floating point conversion testing + +Tue Jun 23 17:01:06 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Make sure this is only compiled if CYGFUN_LIBC_strtok is defined + +Tue Jun 23 06:10:13 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + add some comments - that's all + + * src/stdio/common/stream.cxx: + fix case in refill_read_buffer() for what to do when there's nothing + left. Now return EAGAIN + + * src/stdio/common/vsscanf.cxx, src/stdio/input/vfscanf.cxx: + Get sscanf working properly and passing tests. Also make sure it + ignores FP when its not configured + + * src/stdlib/atof.cxx: + Only compile at all if strtod() is present + + +Mon Jun 22 19:13:42 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise strtok_last and rand_seed better + +Mon Jun 22 14:14:12 1998 Jonathan Larmour + + * tests/stdlib/malloc3.c: + Add test for checking that mallocing and freeing repeatedly works + + * tests/PKGconf.mak: + Update to reflect addition of the above + +Mon Jun 22 13:09:33 BST 1998 Chris Provenzano + + * src/stdio/common/fopen.cxx + * src/stdio/common/stream.cxx + * src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx + Include cyg/devs/common/iorb.h instead of iorb.hxx + + * src/stdio/common/stream.cxx + Use read_blocking and write_blocking instead of just read and + write when accessing devices through the virtual device table. + +Sun Jun 21 18:19:13 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Propagate change of return code handling for puts from stdio.inl + into here + + * src/stdio/output/fputc.cxx: + make sure the right type is used for output - byte not int + + * src/support/clibdata.cxx: + Fix #define config mistook. #endif was in wrong place + +Sun Jun 21 16:11:04 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Allow explicit construction to get around a bug when + dynamically allocating per-thread structure + +Sun Jun 21 16:02:51 1998 Jonathan Larmour + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, tests/stdlib/qsort.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + + Update tests to "do the right thing" with all configuration settings + + +Sun Jun 21 04:54:14 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + I have to be careful not to use setjmp() in a way not exactly + defined by the standard, so make sure I do, and add a comment + documenting these ways. + + Also ensure this test does the right thing in all configurations + +Sun Jun 21 04:38:15 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add extra checks for invalid configurations + Also make default for thread safety OFF + + * src/clibincl/clibdata.inl: + Adjust indentation + + * src/stdio/output/vfnprintf.cxx: + Make printf of -0.0 floating point do the right thing + +Sun Jun 21 04:28:00 1998 Jonathan Larmour + + * src/stdio/common/snprintf.cxx, src/stdio/common/sprintf.cxx, + src/stdio/common/sscanf.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/scanf.cxx, src/stdio/output/fnprintf.cxx, + src/stdio/output/fprintf.cxx, src/stdio/output/printf.cxx: + + Had to remove inline functions with varargs. Which means separating + out each function from stdioinlines.cxx into a separate file, as they + no longer belong there. So all the above files were created. + + * include/stdio.inl, src/PKGconf.mak, + src/stdio/common/stdioinlines.cxx: + Changed to take account of the above + + +Sun Jun 21 03:58:42 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c: + Update with floating-point tests. Also make sure they DTRT in all + configurations + +Fri Jun 19 19:33:06 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + accidentally initialised stdin/out/err twice + +Fri Jun 19 19:09:29 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Another typo + +Fri Jun 19 18:59:07 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Missing #endif typo + +Fri Jun 19 18:51:42 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Fix initialisation of static data members. Unsure how it worked at + all before! + +Fri Jun 19 18:01:01 1998 Jonathan Larmour + + * include/stdio.inl: + puts should check whether fputs returns non-negative, rather than + non-zero + +Fri Jun 19 17:22:52 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl: + Make inclusion of get_errno_p conditional on thread-safety + +Wed Jun 17 10:55:32 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Add weak alias of vfscanf() to _vfscanf() + +Wed Jun 17 09:10:41 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Initialise err to silence compiler warning + +Wed Jun 17 08:59:20 1998 Jonathan Larmour + + * Most important is the addition of floating point support in + src/stdio/output/vfnprintf.cxx and src/stdio/input/vfscanf.cxx. This + also required the addition of atof() and strtod() in stdlib which is + definitely no bad thing! Other than that... + + * Fix a whole bunch of stuff I messed up first time round. Also the + sprintf and sscanf tests are included again. + +Tue Jun 16 16:38:02 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Typo with not putting comment character at the beginning. Sigh. + +Tue Jun 16 14:53:09 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Forgot to (temporarily) remove fputs test for now + +Mon Jun 15 20:40:03 1998 Jonathan Larmour + + Everything to do with stdio has almost completely changed, so there's + not much point documenting individual changes. + +Mon Jun 15 18:36:01 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c: + Stop it moaning quite as much when it fails by making it exit sooner + + * tests/time/clock.c : + This isn't a compound testcase + +Thu Jun 11 17:59:13 1998 Jonathan Larmour + + * include/assert.h + Reverse sense of NDEBUG ifdef, that was left in accidentally due + to testing + +Thu Jun 11 04:58:08 1998 Jonathan Larmour + + * include/errno.h, include/string.h, src/clibincl/stringsupp.hxx: + Modify as I've now added an "error" package which defines the error + codes and strerror() + + * src/errno/strerror.cxx: + Moved to new error package and thus deleted + +Wed Jun 10 18:37:37 1998 Jonathan Larmour + + * include/assert.h: + create this header and add assert() function + +Wed Jun 10 16:23:57 1998 Jonathan Larmour + + * include/stdlib.h, src/clibincl/stdlibsupp.hxx, src/stdlib/malloc.cxx: + Add malloc(), calloc() and free() functions + + * include/pkgconf/libc.h: + Add malloc memory pool size option + + * tests/stdlib/malloc1.c, tests/stdlib/malloc2.c: + new tests for malloc + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for new files + +Wed Jun 10 15:06:16 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + Add another test + +Tue Jun 9 18:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add some setjmp config's and a macro for the noreturn attribute + + * include/setjmp.h, include/setjmp.inl, src/clibincl/setjmpsupp.hxx, + src/setjmp/longjmp.cxx, tests/setjmp/setjmp.c: + Added to implement and test setjmp() and longjmp() + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for newly added files + +Thu Jun 4 01:29:18 1998 Jonathan Larmour + + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, src/string/strcpy.cxx, + src/string/strlen.cxx, src/string/strncat.cxx, + src/string/strncmp.cxx, src/string/strncpy.cxx: + Rename CYGIMP_LIBC_PREFER_SMALL_TO_FAST to + CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST + + Also use slower but smaller version when __OPTIMIZE_SIZE__ is + defined (which comes from using gcc -Os) + +Fri May 29 16:15:04 1998 Jonathan Larmour + + * include/ctype.inl, src/ctype/isxdigit.cxx: + Fix bug that numerals aren't considered hex digits + + * include/time.h: + Change clock_t and time_t to be signed so that they can accept -1, as + required by other libc functions + + * src/clibincl/clibdata.hxx: + Fix typo that CYGIMP_LIBC_THREAD_SUPPORT should be ..._SAFETY + Also fix macro to allocate thread-specific data to not set variables + in a different stack-frame + + * tests/ctype/ctype.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/stdlib/qsort.c: + make ctr unsigned to prevent warnings + + * tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/string/strrchr.c: + Fix off by one error + + * tests/string/strspn.c: + Fix case-sensitivity problem, and off-by-one error + + * tests/string/strxfrm1.c: + Remove bogus bit of test that doesn't apply to strxfrm, and fix typo + + +Fri May 22 16:33:04 1998 Jonathan Larmour + + * src/PKGconf.mak + Remove CXXFLAGS line now that its redundant + + * tests/everything! + Do a blitz change of all tests - break some of them down into + different files, add new tests, standardize format, fix bugs, + update for recent header file changes and much more! + +Wed May 20 17:50:04 1998 Jonathan Larmour + + * tests/PKGconf.mak: + interim checkin for different dir structure for Bart + +Fri May 15 20:30:46 1998 Jonathan Larmour + + * Tidy up some loose ends I forgot: rename src/include directory to + src/clibincl. And add clibdata.inl and timesupp.hxx in there. + +Thu May 14 19:56:32 1998 Jonathan Larmour + + * Basically everything has changed in the C library. Files have + been moved, renamed, deleted and reworked. This is a major + revision, and now starts from this new baseline rather than doing + incremental changes. + +Fri Apr 17 18:43:02 1998 Jonathan Larmour + + * src/ECCconf.mak: + added for new build system (actually Bart did this, but didn't + update this ChangeLog) + +Fri Apr 17 15:03:25 1998 Hugo Tyson + + * src/stdio/device/sim.cxx: + Make it build with CYG_EMPTY_STATEMENT; the unadorned one is being + removed. + +Thu Apr 16 00:24:24 1998 Jonathan Larmour + + * All source files: + replace ECCIMP_LIBC_* conditional ifdef with CYGIMP_LIBC_* + + * include/eccconf/libc.h: + improve comments and reorder a bit + +Wed Apr 8 14:35:20 1998 Jonathan Larmour + + * Makefile.am, src/Makefile.am, tests/Makefile.am, configure.in: + many changes to integrate build structure from release tree + + * src/ctype/Makefile.am, src/ctype/Makefile.in, src/errno/Makefile.am, + src/errno/Makefile.in, src/stdio/Makefile.am, src/stdio/Makefile.in, + src/stdio/common/Makefile.am, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.am, src/stdio/device/Makefile.in, + src/stdio/output/Makefile.am, src/stdio/output/Makefile.in, + src/stdio/input/Makefile.am, src/stdio/input/Makefile.in, + src/stdlib/Makefile.am, src/stdlib/Makefile.in, + src/string/Makefile.am, src/string/Makefile.in, + src/support/Makefile.am, src/support/Makefile.in, + src/time/Makefile.am, src/time/Makefile.in: + Remove as they are now redundant with above changes + + * include/Makefile.am: + Add to support above changes + + * include/eccconf/libc.h: + Change include file for configuration from kernel to system + + * src/include/kerndiag.hxx, src/stdio/device/kerndiag.cxx, + src/time/clockfn.cxx: + Change kernel include file to eccconf/kernel.h + + * src/include/strngdev.h: + remove unnecessary kernel include + + * Makefile.in, aclocal.m4, configure, src/Makefile.in, + tests/Makefile.in, include/Makefile.in: + regenerate + +Mon Apr 6 20:55:07 1998 Jonathan Larmour + + * src/stdlib/abs.cxx, src/stdlib/atoi.cxx, src/stdlib/atol.cxx, + src/stdlib/div.cxx, src/stdlib/labs.cxx, src/stdlib/ldiv.cxx: + Separated out functions from stdlib.cxx into separate files + + * src/stdlib/stdlib.cxx: + removed to be replaced by above files + + * Makefile.am, src/stdlib/Makefile.am: + modified to support building above and not building stdlib.cxx + + * src/support/tsd.cxx: + Remove unnecessary header file includes + + * Makefile.in, src/stdlib/Makefile.in: + regenerated + +Mon Apr 6 19:19:42 1998 Jonathan Larmour + + * src/support/tsd.cxx, include/eccconf/libc.h: + remove lame hack for tx39 compiler now that its fixed + + * src/include/sim.hxx: + define constants as static to placate compiler + +Thu Apr 2 21:01:21 1998 Jonathan Larmour + + * src/ctype/ctype.cxx: + deleted and separated out into below files + + * src/ctype/isalnum.cxx, src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, src/ctype/islower.cxx, + src/ctype/isprint.cxx, src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, src/ctype/tolower.cxx, + src/ctype/toupper.cxx: + Separated out individual ctype functions from ctype.cxx into separate + files + + * Makefile.am, src/ctype/Makefile.am: + modified to reflect above deletion/additions + + * Makefile.in, src/ctype/Makefile.in: + regenerated + +Thu Apr 2 19:08:26 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: optimise using prefix increments + +Thu Apr 2 15:18:15 1998 Jonathan Larmour + + * src/string/strchr.cxx: optimise setting of mask a little + +Thu Mar 26 14:07:01 1998 Jonathan Larmour + + * src/support/tsd.cxx: fixed some typos + +Thu Mar 26 11:58:47 1998 Jonathan Larmour + + * include/eccconf/libc.h, src/support/tsd.cxx: + Implement workaround for tx39 compiler bug. + + * src/include/strsuppt.hxx: + remove prototypes for _memcpy() and _memset() as they are now in the + kernel + +Wed Mar 25 18:31:53 1998 Jonathan Larmour + + * Makefile.am, src/string/Makefile.am: memcpy() and memset() are + now in the kernel so remove them from build + * include/string.h: add a comment to say as much + * Makefile.in, src/string/Makefile.in: regenerate + +Wed Mar 25 15:30:42 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx, src/include/file_if.inl: + Change _exit workaround to not cause a compiler optimisation + problem. Now just references _exit rather than calls it. + +Wed Mar 25 14:59:49 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fix bug causing tests to fail completely + for this function + +Wed Mar 25 12:55:53 1998 Jonathan Larmour + + * src/include/sim.hxx: add types to constants (oops!) + * Makefile.am: link src/stdio/device/sim.cxx + * Makefile.in: regenerated + +Wed Mar 25 04:14:30 1998 Jonathan Larmour + + * src/include/file_if.hxx, src/include/file_if.inl, + src/include/kerndiag.hxx, src/include/sim.hxx, + src/include/stdio_if.hxx, src/include/strngdev.hxx, + src/include/tsd.hxx, src/stdio/common/clearerr.cxx, + src/stdio/common/clearerr.cxx, src/stdio/common/feof.cxx, + src/stdio/common/ferror.cxx, src/stdio/common/file_if.cxx, + src/stdio/common/vsprintf.cxx, + src/stdio/device/kerndiag.cxx, src/stdio/device/sim.cxx, + src/stdio/device/strngdev.cxx, src/stdio/output/fputc.cxx, + src/stdio/output/fputs.cxx, src/stdio/output/puts.cxx, + src/stdio/output/vfnprintf.cxx, src/support/tsd.cxx: + Modified to support buffered reads including renaming + _EccInternalFileStruct to __EccStdioStream which is what affects + most of these files + * src/include/file_if.inl, src/stdio/common/file_if.cxx: added for + the above reason + * src/stdio/common/sscanf.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/input/Makefile.am: added to provide sscanf() functionality + * include/ctype.h, include/stdio.h, include/stdlib.h, + include/string.h, include/eccconf/libc.h, src/ctype/ctype.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/stdio/common/stdio.cxx: + rename *_INLINES macros with prefix CYG rather than ECC + * include/errno.h, src/errno/errno.cxx, src/errno/strerror.cxx: + rename ErrNo to _ErrNo and add EAGAIN and EWOULDBLOCK error codes + * configure.in, Makefile.am, src/stdio/Makefile.am, + src/stdio/input/Makefile.am: add support for building + file_if.cxx sscanf.cxx and vfscanf.cxx + * src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/input/Makefile.in, configure, Makefile.in: regenerated + +Tue Mar 24 19:51:40 1998 Jonathan Larmour + + * src/time/clockfn.cxx, src/time/clock.cxx: + Renamed clock.cxx to clockfn.cxx (preserving CVS history) + * Makefile.am, src/time/Makefile.am: updated to reflect name change + * Makefile.in, src/time/Makefile.in: regenerated + +Tue Mar 24 16:28:06 1998 Jonathan Larmour + + * include/ctype.inl: Swap around definitions to get right order so + inlining works + +Tue Mar 24 14:43:05 1998 Jonathan Larmour + + * include/ctype.h, include/stdio.h, include/stdlib.h, include/string.h: + modify to only conditionally include inlines + * src/ctype/ctype.cxx, src/stdio/common/stdio.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/ctype/Makefile.am: Add to provide real linkable alternatives + to inline functions + * Makefile.am, configure.in, src/Makefile.am, + src/stdio/common/Makefile.am, src/stdlib/Makefile.am, + src/string/Makefile.am: modified to support previous additions + * include/eccconf/libc.h: redefine inline macro to add extern inline, + and add conditional defines for inline functions. Also rename + space vs. speed macro to have CYG instead of ECC prefix + * include/stdio.inl: fix comment typo + * src/stdlib/qsort.cxx: fix to define inline functions properly + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/memcpy.cxx, + src/string/memset.cxx, src/string/strcat.cxx, src/string/strchr.cxx, + src/string/strcmp.cxx, src/string/strcpy.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx + * Makefile.in, configure, src/Makefile.in, src/ctype/Makefile.in, + src/stdio/common/Makefile.in, src/stdlib/Makefile.in, + src/string/Makefile.in: regenerate + + +Mon Mar 23 19:19:49 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: added to support temporary _exit + * include/stdlib.h, include/stdlib.inl: added support for _exit and + added abs(), labs(), div() and ldiv() functions + * src/include/file_if.hxx: added support for _exit kludge + * src/stdlib/qsort.cxx: Added Berkeley copyright message + * src/time/clock.cxx: Include correct kernel config header as + CYG_CONFIGURATION rather than + * Makefile.am src/stdlib/Makefile.am: added support for _exit + * Makefile.in, src/stdlib/Makefile.in: regenerated + +Mon Mar 23 14:41:07 1998 Jonathan Larmour + + * Replace ECCPKG_ANSI_LIBC with CYGPKG_ANSI_LIBC in all source files + +Mon Mar 23 14:28:44 1998 Jonathan Larmour + + * include/string.inl: add file to provide strcoll() + * include/string.h: include string.inl + * ctype.h: include ctype.inl (oops!) + * include/stdlib.h: include stdlib.inl (oops!) + +Mon Mar 23 13:30:38 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl: added to provide ANSI ctype + functionality + * include/stdlib.h, include/stdlib.inl, src/include/stdlibbsp.hxx, + src/stdlib/Makefile.am, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/stdlib/srand.cxx, + src/stdlib/strtol.cxx, src/stdlib/strtoul.cxx: Added to provide + many stdlib functions + * src/include/tsd.hxx: modified to support rand() random number + seed, and added some comments + * configure.in, Makefile.am, src/Makefile.am: modified to support + addition of above new sources + * include/eccconf/libc.h: Add extra helpful comments, and #include + kernel config file + * src/time/clock.cxx: #include clock.inl and fix to call + get_resolution() properly now + * Makefile.in, configure, src/Makefile.in, src/errno/Makefile.in, + src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.in, src/stdio/output/Makefile.in, + src/stdlib/Makefile.in, src/strings/Makefile.in, + src/support/Makefile.in, src/time/Makefile.in, + tests/Makefile.in: regenerated + + +Sun Mar 22 21:29:25 1998 Jonathan Larmour + + * include/time.h, src/include/timesupp.hxx, src/time/clock.cxx, + src/time/Makefile.am: added to provide clock() function + * src/Makefile.am: modified to try to build in src/time directory + * include/eccconf/libc.h: added and is now the main configuration + file for this package + * acconfig.h, include/libcconf.h.in, include/stamp-h.in: removed + due to usage of libc.h above instead + * Almost all *.h, *.hxx and *.cxx: replaced LIBC_CONFIG_HEADER + defined include with simple + * configure.in: remove AM_CONFIG_HEADER of libcconf.h and + LIBC_CONFIG_HEADER definition. Also remove usage of builtin + memcpy() etc. from gcc, and generate src/time/Makefile + * Makefile.am: link in src/time/clock.o + * src/include/file_if.hxx, src/include/sim.hxx: use config header + to decide whether C library is to be used + * Makefile.in, aclocal.m4, configure, src/Makefile.in: regenerated + +Fri Mar 20 18:08:10 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fixed bug with ignoring terminating NULL + +1998-03-20 Chris Tarpy + + * configure: - regenerated + * Makefile.am: - Support added for libc testcases + * Makefile.in: regenerated + * configure.in: set c compiler, descend test dir + * tests/Makefile.in: added + * tests/Makefile.am: added + * tests/tcdiag.cxx : added + + +Thu Mar 19 11:41:56 1998 Jonathan Larmour + + * Initial check-in of everything + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/stdio/current/cdl/stdio.cdl b/packages/language/c/libc/stdio/current/cdl/stdio.cdl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/cdl/stdio.cdl @@ -0,0 +1,390 @@ +# ==================================================================== +# +# stdio.cdl +# +# C library stdio related configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jlarmour +# Contributors: +# Date: 2000-04-14 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_LIBC_STDIO { + display "ISO C library standard input/output functions" + description " + This package provides standard input/output functions associated + with the header file as specified by the + ISO C standard - ISO/IEC 9899:1990." + doc redirect/the-iso-standard-c-and-math-libraries.html + include_dir cyg/libc/stdio + parent CYGPKG_LIBC + requires CYGPKG_IO + requires CYGPKG_IO_SERIAL_HALDIAG + implements CYGINT_ISO_STDIO_FILETYPES + implements CYGINT_ISO_STDIO_FILEACCESS + implements CYGINT_ISO_STDIO_FORMATTED_IO + implements CYGINT_ISO_STDIO_CHAR_IO + implements CYGINT_ISO_STDIO_DIRECT_IO + implements CYGINT_ISO_STDIO_ERROR + requires { CYGBLD_ISO_STDIO_FILETYPES_HEADER == \ + "" } + requires { CYGBLD_ISO_STDIO_FILEACCESS_HEADER == \ + "" } + requires { CYGBLD_ISO_STDIO_FORMATTED_IO_HEADER == \ + "" } + requires { CYGBLD_ISO_STDIO_CHAR_IO_HEADER == \ + "" } + requires { CYGBLD_ISO_STDIO_DIRECT_IO_HEADER == \ + "" } + requires { CYGBLD_ISO_STDIO_ERROR_HEADER == \ + "" } + requires CYGPKG_ISOINFRA + requires CYGINT_ISO_ERRNO_CODES + requires CYGINT_ISO_ERRNO + requires CYGINT_ISO_STRERROR + requires CYGINT_ISO_STRING_STRFUNCS + requires CYGINT_ISO_STRING_MEMFUNCS + + compile common/fclose.cxx common/fflush.cxx \ + common/fopen.cxx common/freopen.cxx \ + common/setvbuf.cxx common/snprintf.cxx \ + common/sprintf.cxx common/sscanf.cxx \ + common/stderr.cxx common/stdin.cxx \ + common/stdiofiles.cxx common/fseek.cxx \ + common/stdioinlines.cxx common/stdiosupp.cxx \ + common/stdout.cxx common/stream.cxx \ + common/streambuf.cxx common/ungetc.cxx \ + common/vsnprintf.cxx common/vsscanf.cxx \ + input/fgetc.cxx input/fgets.cxx \ + input/fread.cxx input/fscanf.cxx \ + input/gets.cxx input/scanf.cxx \ + input/vfscanf.cxx output/fnprintf.cxx \ + output/fprintf.cxx output/fputc.cxx \ + output/fputs.cxx output/fwrite.cxx \ + output/printf.cxx output/vfnprintf.cxx + +# ==================================================================== + + cdl_option CYGIMP_LIBC_STDIO_INLINES { + display "Inline versions of functions" + default_value 1 + description " + This option chooses whether some of the + particularly simple functions from + are available as inline + functions. This may improve performance, and as + the functions are small, may even improve code + size." + } + + cdl_option FOPEN_MAX { + display "Permitted number of open files" + flavor data + legal_values 3 to 0x7fffffff + default_value 8 + description " + This option controls the guaranteed minimum + number of simultaneously open files. The ISO + C standard requires it to be defined (para + 7.9.1), and if strictly compliant, it must be + at least 8 (para 7.9.3). In practice it can be + as low as 3 - for stdin, stdout and stderr." + } + + cdl_option FILENAME_MAX { + display "Maximum length of filename" + flavor data + legal_values 1 to 0x7fffffff + default_value 16 + description " + This option defines the maximum allowed size of + a filename in characters. The ISO C standard + requires it to be defined (para 7.9.1)." + } + + cdl_option L_tmpnam { + display "Maximum length of filenames for temporary files" + flavor data + legal_values 1 to 0x7fffffff + default_value 16 + description " + This option defines the maximum allowed size of + filenames for temporary files as generated by + tmpnam(). It is measured in characters, and the + ISO C standard requires it to be defined (para + 7.9.1)." + } + + cdl_option TMP_MAX { + display "Unique file names generated by tmpnam()" + flavor data + legal_values 0 to 0x7fffffff + default_value 0 + description " + This option defines the minimum number of + unique file names generated by tmpnam(). The + ISO C standard requires it to be defined (para + 7.9.1)." + } + + cdl_component CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO { + display "Buffered I/O" + flavor bool + default_value 1 + description " + This option controls whether input/output + through the functions is buffered. + This may save some memory per file. It + is equivalent to putting every file into + non-buffered mode (_IONBF) through setvbuf(), + except now it can never be altered back to + buffered mode. Disabling buffering is strictly + non-compliant with the ISO C standard." + + cdl_option CYGNUM_LIBC_STDIO_BUFSIZE { + display "Default buffer size" + flavor data + legal_values 1 to 0x7fffffff + default_value 256 + description " + This option defines the default size of buffer + used with calls to setbuf(), and is the default + size for buffered streams that have not had + either setbuf() or setvbuf() invoked on them. + It is exactly equivalent to the standard + constant BUFSIZ, except that it is 0 if + CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO is disabled. + The ISO C standard requires this to be defined + (para 7.9.1), and says it must be at least 256 + (para 7.9.2)." + } + + cdl_option CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF { + display "setbuf()/setvbuf() allows dynamic setting" + default_value 1 + description " + This option controls whether I/O buffers are + implemented dynamically within the stdio + implementation. Otherwise they will be static, + and cannot be changed by setbuf()/setvbuf(). If + they are static (i.e. this option is disabled), + any attempt to use an arbitrary buffer size, or + to pass a user-supplied buffer to setbuf() or + setvbuf() will fail - the buffer is implemented + internally as a static array taking the size + of the configuration option BUFSIZ. The only + exception is if a user buffer is not supplied, + and the buffer size requested is less than + BUFSIZ. In this case, the buffer will + be configured to only use that amount of + buffering. However the unused memory left over + will NOT be freed. If this option is enabled, + then setvbuf() can be used to assign a user supplied + buffer to the stream. + Either setting can be considered to + be compliant with the ISO C standard." + } + + cdl_option CYGSEM_LIBC_STDIO_SETVBUF_MALLOC { + display "setbuf()/setvbuf() uses malloc()" + requires CYGINT_ISO_MALLOC + requires CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF + default_value { 0 != CYGINT_ISO_MALLOC } + description " + This option controls whether buffers set by setbuf() and + setvbuf() may be allocated using malloc()." + } + + } + # Define BUFSIZ with same value as ..._BUFSIZE or 0 + cdl_option BUFSIZ { + display "Default buffer size (BUFSIZ)" + flavor data + calculated CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO \ + ? "CYGNUM_LIBC_STDIO_BUFSIZE" : 0 + } + + cdl_option CYGFUN_LIBC_STDIO_ungetc { + display "Support for ungetc()" + default_value 1 + description " + This option controls whether ungetc() is + supported. If not, then some space can be + saved, and speed is improved. Note that you + MUST have this defined if you want to use the + scanf() family of functions." + } + + cdl_option CYGPKG_LIBC_STDIO_OPEN { + display "Dynamic opening/closing of files" + requires CYGINT_ISO_MALLOC + default_value { 0 != CYGINT_ISO_MALLOC } + description " + fopen() and fclose() use dynamic memory + allocation routines to allocate memory for + new FILE structure pointers. If a malloc + implementation is available, this option + may be enabled to use + fopen() and fclose(). If disabled, only the + default console streams - stdin, stdout and + stderr - will be available." + } + + cdl_option CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE { + display "Default console device" + flavor data + default_value {"\"/dev/ttydiag\""} + description " + This option allows you to choose the + default console device. In the current + implementation, all these devices begin + with the prefix /dev/ and are followed by + the name of a device. The name of the device + depends on the device drivers you have + configured in your system. For example, + /dev/ttydiag could be the HAL diagnostic output + pseudo-device, or /dev/tty0 could be your + first serial driver, depending on your + configuration." + } + + cdl_component CYGPKG_LIBC_STDIO_FLOATING_POINT { + display "Floating point support" + flavor none + description " + This component allows floating point support + to be enabled in certain standard I/O + functions." + + cdl_option CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT { + display "printf() family" + requires CYGPKG_LIBM + default_value { 0 != CYGPKG_LIBM } + description " + This option enables the use of floating point + number output in the printf() family (i.e. + printf(), sprintf(), vprintf(), etc.) of + functions. A substantial amount of code space + can be saved if this option is disabled. If it + is disabled then floating point specifiers + (%e, %f, %g) are ignored, and nothing is + output." + } + + cdl_option CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT { + display "scanf() family" + requires CYGPKG_LIBM + requires CYGINT_ISO_STDLIB_STRCONV_FLOAT + default_value { 0 != CYGPKG_LIBM && + 0 != CYGINT_ISO_STDLIB_STRCONV_FLOAT } + description " + This option enables the use of floating point + number conversion in the scanf() family (i.e. + scanf(), sscanf(), vscanf(), etc.) of + functions. A substantial amount of code space + can be saved if this option is disabled. If it + is disabled then floating point specifiers + (%e, %f, %g) are ignored, and nothing is + converted." + } + } + + cdl_option CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS { + display "Thread safe I/O streams" + requires CYGPKG_KERNEL + default_value { 0 != CYGPKG_KERNEL } + description " + This option controls whether standard I/O streams + are thread-safe. Having this option set allows + the streams to be locked when accessed by + multiple threads simultaneously." + } + + +# ==================================================================== + + cdl_component CYGPKG_LIBC_STDIO_OPTIONS { + display "C library stdio functions build options" + flavor none + no_define + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_LIBC_STDIO_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the C library. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_LIBC_STDIO_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the C library. These flags are removed from + the set of global flags if present." + } + + cdl_option CYGPKG_LIBC_STDIO_TESTS { + display "C library stdio function tests" + flavor data + no_define + calculated { "tests/sprintf1 tests/sprintf2 tests/sscanf tests/stdiooutput" } + description " + This option specifies the set of tests for the C library + stdio functions." + } + } + +# ==================================================================== + + cdl_option CYGPKG_LIBC_STDIO_FILEIO { + display "Enable use of FILEIO package for IO operations." + active_if CYGPKG_IO_FILEIO + requires CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + calculated 1 + } +} + +# ==================================================================== +# EOF stdio.cdl diff --git a/packages/language/c/libc/stdio/current/include/io.hxx b/packages/language/c/libc/stdio/current/include/io.hxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/include/io.hxx @@ -0,0 +1,81 @@ +#ifndef CYGONCE_LIBC_STDIO_IO_HXX +#define CYGONCE_LIBC_STDIO_IO_HXX +//======================================================================== +// +// io.hxx +// +// Internal C library stdio io interface definitions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: +// Date: 2000-06-30 +// Purpose: +// Description: +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +//======================================================================== +// INCLUDES + +#include // Common project-wide type definitions +#include // Get assertion macros, as appropriate +#include // Cyg_ErrNo + +#ifdef CYGPKG_LIBC_STDIO_FILEIO +#include +#include +#include +#include +#else +#include // Device I/O support +#include // CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN +#endif + +//======================================================================== +// Stream handle type + +#ifdef CYGPKG_LIBC_STDIO_FILEIO +typedef int cyg_stdio_handle_t; +#define CYG_STDIO_HANDLE_NULL -1 +#else +typedef cyg_io_handle_t cyg_stdio_handle_t; +#define CYG_STDIO_HANDLE_NULL 0 +#endif + +//======================================================================== +#endif CYGONCE_LIBC_STDIO_IO_HXX multiple inclusion protection +// EOF io.hxx diff --git a/packages/language/c/libc/stdio/current/include/io.inl b/packages/language/c/libc/stdio/current/include/io.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/include/io.inl @@ -0,0 +1,246 @@ +#ifndef CYGONCE_LIBC_STDIO_IO_INL +#define CYGONCE_LIBC_STDIO_IO_INL +//======================================================================== +// +// io.inl +// +// Internal C library stdio io interface inlines +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: +// Date: 2000-06-30 +// Purpose: +// Description: +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +//======================================================================== +// INCLUDES + +#include + +//======================================================================== +// FileIO versions of IO functions + +#ifdef CYGPKG_LIBC_STDIO_FILEIO + +inline Cyg_ErrNo cyg_stdio_open( const char *filename, + const Cyg_StdioStream::OpenMode rw, + const cyg_bool binary, + const cyg_bool append, + cyg_stdio_handle_t *dev) +{ + mode_t mode = 0; + int fd; + + switch( rw ) + { + case Cyg_StdioStream::CYG_STREAM_WRITE: + mode = O_WRONLY|O_CREAT|O_TRUNC; + break; + case Cyg_StdioStream::CYG_STREAM_READ: + mode = O_RDONLY; + break; + case Cyg_StdioStream::CYG_STREAM_READWRITE: + mode = O_RDWR; + break; + } + + if( append ) + { + mode |= O_APPEND; + mode &= ~O_TRUNC; + } + + fd = open( filename, mode ); + + if( fd < 0 ) + return errno; + + *dev = fd; + return ENOERR; +} + +inline Cyg_ErrNo cyg_stdio_close( cyg_stdio_handle_t dev ) +{ + if( close( dev ) != ENOERR ) + return errno; + return ENOERR; +} + +inline Cyg_ErrNo cyg_stdio_read( cyg_stdio_handle_t dev, + void *buffer, cyg_uint32 *len ) +{ + if( dev != CYG_STDIO_HANDLE_NULL ) + { + ssize_t done = read( dev, buffer, *len ); + + if( done < 0 ) + { + *len = 0; + return errno; + } + + *len = done; + } + // If the device is NULL, just return EOF indication + else *len = 0; + + return ENOERR; +} + +inline Cyg_ErrNo cyg_stdio_write( cyg_stdio_handle_t dev, + const void *buffer, cyg_uint32 *len ) +{ + if( dev != CYG_STDIO_HANDLE_NULL ) + { + ssize_t done = write( dev, buffer, *len ); + + if( done < 0 ) + { + *len = 0; + return errno; + } + + *len = done; + } + // if the device is NULL, just absorb all writes. + + return ENOERR; +} + +inline Cyg_ErrNo cyg_stdio_lseek( cyg_stdio_handle_t dev, + off_t *pos, int whence ) +{ + off_t newpos = lseek( dev, *pos, whence ); + + if( newpos < 0 ) + return errno; + + *pos = newpos; + + return ENOERR; +} + +inline Cyg_ErrNo cyg_stdio_flush( cyg_stdio_handle_t dev ) +{ + int err = fsync( dev ); + + if( err < 0 ) + return errno; + + return ENOERR; +} + +inline cyg_bool cyg_stdio_interactive( cyg_stdio_handle_t dev ) +{ + struct stat buf; + int err; + + err = fstat( dev, &buf ); + + // If we get an error, assume interactive. + if( err < 0 ) + return true; + + if( S_ISCHR(buf.st_mode) ) + return true; + + return false; +} + + +#endif // CYGPKG_LIBC_STDIO_FILEIO + +//======================================================================== +// Direct IO versions of IO functions + +#ifndef CYGPKG_LIBC_STDIO_FILEIO + +inline Cyg_ErrNo cyg_stdio_open( const char *filename, + const Cyg_StdioStream::OpenMode rw, + const cyg_bool binary, + const cyg_bool append, + cyg_stdio_handle_t *dev) +{ + return cyg_io_lookup( filename, dev ); +} + +inline Cyg_ErrNo cyg_stdio_close( cyg_stdio_handle_t dev ) +{ + // Devices do not get closed + return ENOERR; +} + +inline Cyg_ErrNo cyg_stdio_read( cyg_stdio_handle_t dev, + void *buffer, cyg_uint32 *len ) +{ + return cyg_io_read( dev, buffer, len ); +} + +inline Cyg_ErrNo cyg_stdio_write( cyg_stdio_handle_t dev, + const void *buffer, cyg_uint32 *len ) +{ + return cyg_io_write( dev, buffer, len ); +} + +inline cyg_uint32 cyg_stdio_lseek( cyg_stdio_handle_t dev, + cyg_uint32 *pos, int whence ) +{ + // No seeking in raw devices, just return fake success + return ENOERR; +} + +inline Cyg_ErrNo cyg_stdio_flush( cyg_stdio_handle_t dev ) +{ + return cyg_io_get_config(dev, + CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN, + NULL, NULL); +} + +inline cyg_bool cyg_stdio_interactive( cyg_stdio_handle_t dev ) +{ + return true; +} + + +#endif // !CYGPKG_LIBC_STDIO_FILEIO + +//======================================================================== +#endif CYGONCE_LIBC_STDIO_IO_INL multiple inclusion protection +// EOF io.inl + diff --git a/packages/language/c/libc/stdio/current/include/stdio.h b/packages/language/c/libc/stdio/current/include/stdio.h new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/include/stdio.h @@ -0,0 +1,310 @@ +#ifndef CYGONCE_LIBC_STDIO_STDIO_H +#define CYGONCE_LIBC_STDIO_STDIO_H +//======================================================================== +// +// stdio.h +// +// ISO C standard I/O routines - with some POSIX 1003.1 extensions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-19 +// Purpose: ISO C standard I/O routines +// Description: +// Usage: Do not include this file directly - use #include +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // common type definitions and support +#include // va_list from compiler + +// CONSTANTS + +// Some of these values are odd to ensure that asserts have better effect +// should spurious values be passed to functions expecting these constants. + +// _IOFBF, _IOLBF, and _IONBF specify full, line or no buffering when used +// with setvbuf() - ISO C standard chap 7.9.1 + +#define _IOFBF (-2) +#define _IOLBF (-4) +#define _IONBF (-8) + +// EOF is a macro defined to any negative integer constant - ISO C standard +// chap. 7.9.1 +#define EOF (-1) + +// SEEK_CUR, SEEK_END and SEEK_SET are used with fseek() as position +// anchors - ISO C standard chap. 7.9.1 +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + + +// TYPE DEFINITIONS + +// A type capable of specifying uniquely every file position - ISO C +// standard chap 7.9.1 +typedef cyg_ucount32 fpos_t; + + +// FILE is just cast to an address here. It is uncast internally to the +// C library in stream.hxx as the C++ Cyg_StdioStream class. +// Optional run-time checking can be enabled to ensure that the cast is +// valid, using the standard assertion functionality. +// +// The array size is irrelevant other than being more than 8, and is present +// to stop references to FILEs being marked as able to be put in the small +// data section. We can't just mark it as in the ".data" section as on some +// targets it may actually be ".common". Maybe this doesn't matter? +// FIXME: This doesn't work if things are larger than 16 are put in sdata, +// e.g. on mips by specifying -G 32 +typedef CYG_ADDRESS FILE[16]; + +// EXTERNAL VARIABLES + +// Default file streams for input/output. These only need to be +// expressions, not l-values - ISO C standard chap. 7.9.1 +// +// cyg_libc_stdio_stdin/out/err aren't really files of course, +// but they are only named here so that we can take the address of +// them, in which case it doesn't matter what type they point to really +// +// CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS is used when initializing +// cyg_libc_stdio_stdin/out/err privately inside the C library + +#ifndef CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS +extern FILE cyg_libc_stdio_stdin, cyg_libc_stdio_stdout, + cyg_libc_stdio_stderr; + +#define stdin (&cyg_libc_stdio_stdin) +#define stdout (&cyg_libc_stdio_stdout) +#define stderr (&cyg_libc_stdio_stderr) +#endif + +// FUNCTION PROTOTYPES + +//======================================================================== + +// ISO C 7.9.5 File access functions + +externC int +fclose( FILE * /* stream */ ); + +externC int +fflush( FILE * /* stream */ ); + +externC FILE * +fopen( const char * /* filename */, const char * /* mode */ ); + +externC FILE * +freopen( const char * /* filename */, const char * /* mode */, + FILE * /* stream */ ); + +externC void +setbuf( FILE * /* stream */, char * /* buffer */ ); + +externC int +setvbuf( FILE * /* stream */, char * /* buffer */, int /* mode */, + size_t /* size */ ); + +//======================================================================== + +// ISO C 7.9.6 Formatted input/output functions + +externC int +fprintf( FILE * /* stream */, const char * /* format */, ... ); + +externC int +fscanf( FILE * /* stream */, const char * /* format */, ... ); + +externC int +printf( const char * /* format */, ... ); + +externC int +scanf( const char * /* format */, ... ); + +externC int +sprintf( char * /* str */, const char * /* format */, ... ); + +externC int +sscanf( const char * /* str */, const char * /* format */, ... ); + +externC int +vfprintf( FILE * /* stream */, const char * /* format */, + va_list /* args */ ); + +externC int +vprintf( const char * /* format */, va_list /* args */ ); + +externC int +vsprintf( char * /* str */, const char * /* format */, + va_list /* args */ ); + +//======================================================================== + +// ISO C 7.9.7 Character input/output functions + +externC int +fgetc( FILE * /* stream */ ); + +externC char * +fgets( char * /* str */, int /* length */, FILE * /* stream */ ); + +externC int +fputc( int /* c */, FILE * /* stream */ ); + +externC int +putc( int /* c */, FILE * /* stream */ ); + +externC int +putchar( int /* c */ ); + +externC int +fputs( const char * /* str */, FILE * /* stream */ ); + +externC char * +gets( char * ); + +externC int +getc( FILE * /* stream */ ); + +externC int +getchar( void ); + +externC int +puts( const char * /* str */ ); + +externC int +ungetc( int /* c */, FILE * /* stream */ ); + +// no function equivalent is required for getchar() or putchar(), so we can +// just #define them + +#define getchar() fgetc( stdin ) + +#define putchar(__c) fputc(__c, stdout) + +//======================================================================== + +// ISO C 7.9.8 Direct input/output functions + +externC size_t +fread( void * /* ptr */, size_t /* object_size */, + size_t /* num_objects */, FILE * /* stream */ ); + +externC size_t +fwrite( const void * /* ptr */, size_t /* object_size */, + size_t /* num_objects */, FILE * /* stream */ ); + +//======================================================================== + +// ISO C 7.9.9 File positioning functions + +externC int +fgetpos( FILE * /* stream */, fpos_t * /* pos */ ); + +externC int +fseek( FILE * /* stream */, long int /* offset */, int /* whence */ ); + +externC int +fsetpos( FILE * /* stream */, const fpos_t * /* pos */ ); + +externC long int +ftell( FILE * /* stream */ ); + +externC void +rewind( FILE * /* stream */ ); + +//======================================================================== + +// ISO C 7.9.10 Error-handling functions + +externC void +clearerr( FILE * /* stream */ ); + +externC int +feof( FILE * /* stream */ ); + +externC int +ferror( FILE * /* stream */ ); + +externC void +perror( const char * /* prefix_str */ ); + +//======================================================================== + +// Other non-ISO C functions + +externC int +fnprintf( FILE * /* stream */, size_t /* length */, + const char * /* format */, ... ); + +externC int +snprintf( char * /* str */, size_t /* length */, const char * /* format */, + ... ); + +externC int +vfnprintf( FILE * /* stream */, size_t /* length */, + const char * /* format */, va_list /* args */ ); + +externC int +vsnprintf( char * /* str */, size_t /* length */, + const char * /* format */, va_list /* args */ ); + +externC int +vscanf( const char * /* format */, va_list /* args */ ); + +externC int +vsscanf( const char * /* str */, const char * /* format */, + va_list /* args */ ); + +externC int +vfscanf( FILE * /* stream */, const char * /* format */, + va_list /* args */ ); + + +// INLINE FUNCTIONS + +#ifdef CYGIMP_LIBC_STDIO_INLINES +# include +#endif + +#endif // CYGONCE_LIBC_STDIO_STDIO_H multiple inclusion protection + +// EOF stdio.h diff --git a/packages/language/c/libc/stdio/current/include/stdio.inl b/packages/language/c/libc/stdio/current/include/stdio.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/include/stdio.inl @@ -0,0 +1,150 @@ +#ifndef CYGONCE_LIBC_STDIO_STDIO_INL +#define CYGONCE_LIBC_STDIO_STDIO_INL +//=========================================================================== +// +// stdio.inl +// +// ANSI standard I/O routines - inlined functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-19 +// Purpose: +// Description: +// Usage: Do not include this file directly - use #include +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // NULL and size_t from compiler +#include // va_list +#include // Just be sure it has been included +#include // Definition of error codes and errno +#include // Definition of strerror() for perror() +#include // INT_MAX + +// INLINE FUNCTION DEFINITIONS + +//=========================================================================== + +// 7.9.5 File access functions + +extern __inline__ void +setbuf( FILE *stream, char *buf ) +{ + if (buf == NULL) + setvbuf( stream, NULL, _IONBF, BUFSIZ ); + else + // NB: Should use full buffering by default ordinarily, but in + // the current system we're always connected to an interactive + // terminal, so use line buffering + setvbuf( stream, buf, _IOLBF, BUFSIZ ); + +} // setbuf() + +//=========================================================================== + +// 7.9.6 Formatted input/output functions + +extern __inline__ int +vfprintf( FILE *stream, const char *format, va_list arg ) +{ + return vfnprintf(stream, INT_MAX, format, arg); +} // vfprintf() + + +extern __inline__ int +vprintf( const char *format, va_list arg ) +{ + return vfnprintf(stdout, INT_MAX, format, arg); +} // vprintf() + + +extern __inline__ int +vsprintf( char *s, const char *format, va_list arg ) +{ + return vsnprintf(s, INT_MAX, format, arg); +} // vsprintf() + + +//=========================================================================== + +// 7.9.7 Character input/output functions + +extern __inline__ int +puts( const char *s ) +{ + int rc; + + rc = fputs( s, stdout ); + + if (rc >= 0) + rc = fputc('\n', stdout ); + + return rc; +} // puts() + + +//=========================================================================== + +// 7.9.10 Error-handling functions + +extern __inline__ void +perror( const char *s ) +{ + if (s && *s) + fprintf( stderr, "%s: %s\n", s, strerror(errno) ); + else + fputs( strerror(errno), stderr ); + +} // perror() + +//=========================================================================== + +// Other non-ANSI functions + +extern __inline__ int +vscanf( const char *format, va_list arg ) +{ + return vfscanf( stdin, format, arg ); +} // vscanf() + + +#endif // CYGONCE_LIBC_STDIO_STDIO_INL multiple inclusion protection + +// EOF stdio.inl diff --git a/packages/language/c/libc/stdio/current/include/stdiofiles.hxx b/packages/language/c/libc/stdio/current/include/stdiofiles.hxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/include/stdiofiles.hxx @@ -0,0 +1,108 @@ +#ifndef CYGONCE_LIBC_STDIO_STDIOFILES_HXX +#define CYGONCE_LIBC_STDIO_STDIOFILES_HXX +//======================================================================== +// +// stdiofiles.hxx +// +// ISO C library stdio central file access +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-19 +// Purpose: +// Description: +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // libc stdio configuration + +// INCLUDES + +#include // cyg_bool, cyg_ucount8, cyg_ucount16 +#include // Cyg_StdioStream + +#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS +# include // mutexes +#endif + +// CLASSES + +class Cyg_libc_stdio_files +{ + // List of open files - global for now + static + Cyg_StdioStream *files[FOPEN_MAX]; + +# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS + // lock for the above + static + Cyg_Mutex files_lock; +# endif + +public: + +# if FOPEN_MAX < 256 + typedef cyg_ucount8 fd_t; +# else + typedef cyg_ucount16 fd_t; +# endif + + static Cyg_StdioStream * + get_file_stream( fd_t fd ); + + static void + set_file_stream( fd_t fd, Cyg_StdioStream *stream ); + + + // the following functions lock(), trylock() and unlock() do nothing + // if we haven't got thread-safe streams + static cyg_bool + lock(void); + + static cyg_bool + trylock(void); + + static void + unlock(void); + +}; // class Cyg_libc_stdio_files + + +// Inline functions for this class +#include + +#endif // CYGONCE_LIBC_STDIO_STDIOFILES_HXX multiple inclusion protection + +// EOF stdiofiles.hxx diff --git a/packages/language/c/libc/stdio/current/include/stdiofiles.inl b/packages/language/c/libc/stdio/current/include/stdiofiles.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/include/stdiofiles.inl @@ -0,0 +1,117 @@ +#ifndef CYGONCE_LIBC_STDIO_STDIOFILES_INL +#define CYGONCE_LIBC_STDIO_STDIOFILES_INL +//======================================================================== +// +// stdiofiles.inl +// +// ISO C library stdio central file inlines +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-19 +// Purpose: +// Description: +// Usage: Do not include this file directly. Instead use: +// #include +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // libc stdio configuration + +// INCLUDES + +#include // cyg_bool +#include // Assert interface +#include // header for this file +#include // Cyg_StdioStream + +#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS +# include // mutexes +#endif + +// INLINE METHODS + +inline Cyg_StdioStream * +Cyg_libc_stdio_files::get_file_stream( fd_t fd ) +{ + CYG_PRECONDITION( (fd < FOPEN_MAX), + "Attempt to open larger file descriptor than FOPEN_MAX!" ); + + return files[fd]; + +} // Cyg_libc_stdio_files::get_file_stream() + +inline void +Cyg_libc_stdio_files::set_file_stream( fd_t fd, Cyg_StdioStream *stream ) +{ + CYG_PRECONDITION( (fd < FOPEN_MAX), + "Attempt to set larger file descriptor than FOPEN_MAX!" ); + + files[fd] = stream; + +} // Cyg_libc_stdio_files::set_file_stream() + + +inline cyg_bool +Cyg_libc_stdio_files::lock(void) +{ +# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS + return files_lock.lock(); +# else + return true; +# endif +} // Cyg_libc_stdio_files::lock() + +inline cyg_bool +Cyg_libc_stdio_files::trylock(void) +{ +# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS + return files_lock.trylock(); +# else + return true; +# endif +} // Cyg_libc_stdio_files::trylock() + +inline void +Cyg_libc_stdio_files::unlock(void) +{ +# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS + files_lock.unlock(); +# endif +} // Cyg_libc_stdio_files::unlock() + + +#endif // CYGONCE_LIBC_STDIO_STDIOFILES_INL multiple inclusion protection + +// EOF stdiofiles.inl diff --git a/packages/language/c/libc/stdio/current/include/stdiosupp.hxx b/packages/language/c/libc/stdio/current/include/stdiosupp.hxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/include/stdiosupp.hxx @@ -0,0 +1,74 @@ +#ifndef CYGONCE_LIBC_STDIO_STDIOSUPP_HXX +#define CYGONCE_LIBC_STDIO_STDIOSUPP_HXX +//======================================================================== +// +// stdiosupp.hxx +// +// Support for C library standard I/O routines +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-19 +// Purpose: +// Description: +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // common type definitions and support +#include // Main standard I/O header +#include // Cyg_StdioStream + +// FUNCTION PROTOTYPES + +//======================================================================== + +// Miscellaneous support functions + +externC cyg_stdio_handle_t +Cyg_libc_stdio_find_filename( const char *filename, + const Cyg_StdioStream::OpenMode rw, + const cyg_bool binary, + const cyg_bool append ); + +externC Cyg_ErrNo +cyg_libc_stdio_flush_all_but( Cyg_StdioStream *not_this_stream ); + +#endif // CYGONCE_LIBC_STDIOL_STDIOSUPP_HXX multiple inclusion protection + +// EOF stdiosupp.hxx diff --git a/packages/language/c/libc/stdio/current/include/stream.hxx b/packages/language/c/libc/stdio/current/include/stream.hxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/include/stream.hxx @@ -0,0 +1,310 @@ +#ifndef CYGONCE_LIBC_STDIO_STREAM_HXX +#define CYGONCE_LIBC_STDIO_STREAM_HXX +//======================================================================== +// +// stream.hxx +// +// Internal C library stdio stream interface definitions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-19 +// Purpose: +// Description: +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // Get assertion macros, as appropriate +#include // Cyg_ErrNo +#include // fpos_t and IOBUF defines +#include // Physical IO support +#include // Stdio stream file buffers + +#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS +#include +#include // Cyg_Mutex +#endif + +// TYPE DEFINITIONS + +class Cyg_StdioStream +{ + friend int setvbuf( FILE *, char *, int, size_t ); + +private: + + // error status for this file + Cyg_ErrNo error; + + + cyg_stdio_handle_t my_device; + +#ifdef CYGFUN_LIBC_STDIO_ungetc + cyg_uint8 unread_char_buf; +#endif + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + Cyg_StdioStreamBuffer io_buf; // read/write buffer +#endif + cyg_uint8 readbuf_char; // a one character emergency "buffer" + // only used when configured to not buffer + // (i.e. !CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO) + // or set at runtime to not buffer (i.e. + // buffering mode is _IONBF) + + // some flags indicating the state of the file. Some of it is internal + // state, which should not be public. Use bitfields to save + // space, which means using "unsigned int" rather than cyg_uintX + struct { + unsigned int at_eof : 1; // Have we reached eof? + + unsigned int opened_for_read : 1; // opened_for_read and + + unsigned int opened_for_write : 1; // opened_for_write can + // be set simultaneously + + unsigned int binary : 1; // opened for binary or + // text mode? + +#ifdef CYGFUN_LIBC_STDIO_ungetc + unsigned int unread_char_buf_in_use : 1; // unget buf in use? +#endif + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + unsigned int buffering : 1; // Is this file buffered? + + unsigned int line_buffering : 1; // If so, is it line + // buffered? If it is + // buffered, but NOT line + // buffered, it must be + // fully buffered + + unsigned int last_buffer_op_was_read : 1; // did we last read from + // the buffer. If not we + // must have written +#endif + unsigned int readbuf_char_in_use : 1; // is the above + // readbuf_char in use? + + } flags; + + // current position for reading/writing + fpos_t position; + +#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS + Cyg_Mutex stream_lock; // used for locking this stream +#endif // ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS + +#ifdef CYGDBG_USE_ASSERTS + // a value to check that this class is hopefully valid + cyg_ucount32 magic_validity_word; +#endif + +public: + // different modes when constructing (i.e. opening). + typedef enum { + CYG_STREAM_READ, + CYG_STREAM_WRITE, + CYG_STREAM_READWRITE + } OpenMode; + + // CONSTRUCTORS + + // This constructs the stream - effectively opens the file. This is + // used for static initialisation, and actually calls construct below + // + // dev is a valid Cyg_Device_Table_t, although it does not have to + // be a member of the device table object itself + // + // open_mode is one of CYG_STREAM_READ, CYG_STREAM_WRITE or + // CYG_STREAM_READWRITE + // + // append is true if the file position should be set at EOF on opening + // + // binary is true if this is a binary stream. Otherwise it is a text + // stream and character conversions (especially newline) may occur + // + // buffer_mode is one of _IONBF, _IOLBF, _IOFBF (from ) + // If buffer_mode is _IONBF, buffer_size should still be set to 0 + // and buffer_addr to NULL. If buffering is not configured, none + // of buffer_mode, buffer_size and buffer_addr have any effect + // + // buffer_size is the size of buffer to use + // + // buffer_addr is the address of a user supplied buffer. By default + // (when NULL) a system one is provided. + // + // The "return code" is set by assignment to the error member of this + // stream - use the get_error() method to check + + Cyg_StdioStream( cyg_stdio_handle_t dev, OpenMode open_mode, + cyg_bool append, cyg_bool binary, int buffer_mode, + cyg_ucount32 buffer_size=BUFSIZ, + cyg_uint8 *buffer_addr=NULL ); + + Cyg_StdioStream( OpenMode open_mode, + cyg_ucount32 buffer_size=BUFSIZ, + cyg_uint8 *buffer_addr=NULL ); + +private: + void initialize( cyg_stdio_handle_t dev, OpenMode open_mode, + cyg_bool append, cyg_bool binary, int buffer_mode, + cyg_ucount32 buffer_size=BUFSIZ, + cyg_uint8 *buffer_addr=NULL ); +public: + + // DESTRUCTOR + + ~Cyg_StdioStream(); + + + // MEMBER FUNCTIONS + + // Close the stream. This should be called before the destructor, + // so we can see and report any errors produced. + Cyg_ErrNo close(); + + // Refill read buffer from the stream - note this blocks until + // something arrives on the stream + Cyg_ErrNo + refill_read_buffer( void ); + + + // Read not more than buffer_length bytes from the read buffer into the + // user buffer. + // The number of bytes put into the user buffer is written + // into *bytes_read + Cyg_ErrNo + read( cyg_uint8 *user_buffer, cyg_ucount32 buffer_length, + cyg_ucount32 *bytes_read ); + + + // Read a single byte from the stream. Returns EAGAIN if no character + // available or EEOF if end of file (as well as setting the EOF state) + Cyg_ErrNo + read_byte( cyg_uint8 *c ); + + // Read a single byte from the stream, but don't remove it. Returns + // EAGAIN if no character available or EEOF if end of file (as well + // as setting the EOF state) + Cyg_ErrNo + peek_byte( cyg_uint8 *c ); + + + // Return a byte into the stream - basically the same as ungetc() + Cyg_ErrNo + unread_byte( cyg_uint8 c ); + + // the number of bytes available to read without needing to refill the + // buffer + cyg_ucount32 + bytes_available_to_read( void ); + + Cyg_ErrNo + write( const cyg_uint8 *buffer, cyg_ucount32 buffer_length, + cyg_ucount32 *bytes_written ); + + Cyg_ErrNo + write_byte( cyg_uint8 c ); + + + Cyg_ErrNo + flush_output( void ); + + Cyg_ErrNo + flush_output_unlocked( void ); + + // prevent multiple access in thread safe mode + + // lock_me() returns false if it couldn't be locked, which could + // happen if the file descriptor is bad + + cyg_bool + lock_me( void ); + + // trylock_me() returns false if it couldn't be locked, probably + // because it is already locked + cyg_bool + trylock_me( void ); + + void + unlock_me( void ); + + // get error status for this file + Cyg_ErrNo + get_error( void ); + + // set error status for this file. + void + set_error( Cyg_ErrNo errno_to_set ); + +public: + // are we at EOF? true means we are, false means no + cyg_bool + get_eof_state( void ); + +private: + + // Set whether we are at EOF. + void + set_eof_state( cyg_bool eof_to_set ); + +public: + // retrieve position + Cyg_ErrNo + get_position( fpos_t *pos ); + + // set absolute position. whence is SEEK_SET, SEEK_CUR, or SEEK_END + Cyg_ErrNo + set_position( fpos_t pos, int whence ); + + // Return my_device + cyg_stdio_handle_t get_dev() { return my_device; }; + + CYGDBG_DEFINE_CHECK_THIS +}; + +// INLINE FUNCTIONS + +#include + +#endif CYGONCE_LIBC_STDIO_STREAM_HXX multiple inclusion protection + +// EOF stream.hxx diff --git a/packages/language/c/libc/stdio/current/include/stream.inl b/packages/language/c/libc/stdio/current/include/stream.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/include/stream.inl @@ -0,0 +1,440 @@ +#ifndef CYGONCE_LIBC_STDIO_STREAM_INL +#define CYGONCE_LIBC_STDIO_STREAM_INL +//======================================================================== +// +// stream.inl +// +// Inline functions for internal C library stdio stream interface +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-19 +// Purpose: +// Description: +// Usage: Do not include this file - +// #include instead. +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // Error codes +#include // Just be sure that this really is + // included + +#include // I/O system inlines + +// FUNCTIONS + +#ifdef CYGDBG_USE_ASSERTS +inline cyg_bool +Cyg_StdioStream::check_this( cyg_assert_class_zeal zeal ) const +{ + // check that it has the magic word set meaning it is valid. + if ( magic_validity_word != 0x7b4321ce ) + return false; + return true; +} // check_this() + +#endif // ifdef CYGDBG_USE_ASSERTS + + + +// LOCKING FUNCTIONS + +// returns true on success +inline cyg_bool +Cyg_StdioStream::lock_me( void ) +{ + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + +#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS + return stream_lock.lock(); +#else + // otherwise it "worked" + return true; +#endif + +} // lock_me() + + +// returns true on success +inline cyg_bool +Cyg_StdioStream::trylock_me( void ) +{ + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + +#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS + return stream_lock.trylock(); +#else + // otherwise it "worked" + return true; +#endif + +} // lock_me() + + +inline void +Cyg_StdioStream::unlock_me( void ) +{ + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + +#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS + stream_lock.unlock(); +#endif +} // unlock_me() + + +// DESTRUCTOR + +inline Cyg_ErrNo +Cyg_StdioStream::close() +{ + Cyg_ErrNo err = ENOERR; + + if (!lock_me()) + return EBADF; + + if( my_device != CYG_STDIO_HANDLE_NULL ) + { + flush_output_unlocked(); + + err = cyg_stdio_close( my_device ); + + if( err == ENOERR ) + my_device = CYG_STDIO_HANDLE_NULL; + } + + unlock_me(); + + return err; +} // close() + +inline +Cyg_StdioStream::~Cyg_StdioStream() +{ + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + // Close the device if it has not already been closed. + if( my_device != CYG_STDIO_HANDLE_NULL ) + close(); + +#ifdef CYGDBG_USE_ASSERTS + magic_validity_word = 0xbadbad; +#endif +} // Cyg_StdioStream destructor + + +// MEMBER FUNCTIONS + + +// this is currently just a wrapper around write, but having this interface +// leaves scope for optimisations in future +inline Cyg_ErrNo +Cyg_StdioStream::write_byte( cyg_uint8 c ) +{ + cyg_ucount32 dummy_bytes_written; + Cyg_ErrNo err; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + err = write( &c, 1, &dummy_bytes_written ); + + CYG_ASSERT( (err!=ENOERR) || (dummy_bytes_written==1), + "Single byte not written, but no error returned!" ); + + return err; +} // write_byte() + + +inline Cyg_ErrNo +Cyg_StdioStream::unread_byte( cyg_uint8 c ) +{ + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + +#ifdef CYGFUN_LIBC_STDIO_ungetc + if (!lock_me()) + return EBADF; // assume file is now invalid + + if (flags.unread_char_buf_in_use) { + unlock_me(); + return ENOMEM; + } // if + + flags.unread_char_buf_in_use = true; + unread_char_buf = c; + + // can't be at EOF any more + flags.at_eof = false; + + if (position) // position is always 0 for certain devices + --position; + + unlock_me(); + + return ENOERR; + +#else // ifdef CYGFUN_LIBC_STDIO_ungetc + + return ENOSYS; +#endif // ifdef CYGFUN_LIBC_STDIO_ungetc +} // unread_byte() + + +inline cyg_ucount32 +Cyg_StdioStream::bytes_available_to_read( void ) +{ + cyg_ucount32 bytes=0; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + +#ifdef CYGFUN_LIBC_STDIO_ungetc + if (flags.unread_char_buf_in_use) + ++bytes; +#endif + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + + // either the last operation was a read, which attempted to read bytes + // into the buffer, or there are no bytes in the buffer + + if (flags.buffering) { + if (flags.last_buffer_op_was_read == true) + bytes += io_buf.get_buffer_space_used(); + } + else + +#endif + + if (flags.readbuf_char_in_use) + ++bytes; + + return bytes; +} // bytes_available_to_read() + + + +inline Cyg_ErrNo +Cyg_StdioStream::flush_output( void ) +{ + Cyg_ErrNo err; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if (!lock_me()) + return EBADF; // assume file is now invalid + + err = flush_output_unlocked(); + + unlock_me(); + + return err; +} // flush_output() + + +// get error status for this file +inline Cyg_ErrNo +Cyg_StdioStream::get_error( void ) +{ + Cyg_ErrNo err_temp; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if (!lock_me()) + return EBADF; // well, we've certainly got an error now! + + err_temp = error; + + unlock_me(); + + return err_temp; +} // get_error() + + +// set error status for this file +inline void +Cyg_StdioStream::set_error( Cyg_ErrNo errno_to_set ) +{ + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if (!lock_me()) + { + errno = EBADF; // best we can do - we can't trust error to be there + return; + } // if + + errno = error = errno_to_set; + + if ( EEOF == error ) + flags.at_eof = 1; + + unlock_me(); +} // set_error() + + +// are we at EOF? true means we are, false means no +inline cyg_bool +Cyg_StdioStream::get_eof_state( void ) +{ + cyg_bool eof_temp; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if (!lock_me()) + return false; // not much we can do here + + eof_temp = flags.at_eof; + + unlock_me(); + + return eof_temp; +} // get_eof_state() + + +// Set whether we are at EOF. +inline void +Cyg_StdioStream::set_eof_state( cyg_bool eof_to_set ) +{ + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if (!lock_me()) + return; // not much we can do here + + flags.at_eof = eof_to_set; + + unlock_me(); +} // set_eof_state() + + +// retrieve position +inline Cyg_ErrNo +Cyg_StdioStream::get_position( fpos_t *pos ) +{ + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if (!lock_me()) + return EBADF; // assume file is now invalid + + *pos = position; + + unlock_me(); + + return ENOERR; + +} // get_position() + + +// set absolute position +inline Cyg_ErrNo +Cyg_StdioStream::set_position( fpos_t pos, int whence ) +{ +#ifndef CYGPKG_LIBC_STDIO_FILEIO + // this is currently a workaround until we have real files + // this will be corrected when we decide the true filesystem interface + + Cyg_ErrNo err; + cyg_uint8 c; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if ((whence != SEEK_CUR) || pos < 0) + return ENOSYS; + + if (!lock_me()) + return EBADF; // assume file is now invalid + + // Drain read buffer + + for ( ; whence > 0 ; whence-- ) { + err = read_byte( &c ); + if (err == EAGAIN) + err=refill_read_buffer(); + + // if read_byte retured error, or refill_read_buffer returned error + if (err) { + unlock_me(); + return err; + } // if + } // for + + unlock_me(); + + return ENOERR; + +#else + + Cyg_ErrNo err; + off_t newpos = pos; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if (!lock_me()) + return EBADF; // assume file is now invalid + + err = cyg_stdio_lseek( my_device, &newpos, whence ); + + if( err == ENOERR ) + { + // Clean out the buffer. Flush output if any present, + // and clear any input out of input buffer and any ungot + // chars from unread buffer. + + err = flush_output_unlocked(); + io_buf.drain_buffer(); +#ifdef CYGFUN_LIBC_STDIO_ungetc + flags.unread_char_buf_in_use = false; +#endif + + // Clear EOF indicator. + flags.at_eof = false; + } + + if( err == ENOERR ) + position = newpos; + + unlock_me(); + + return err; +#endif + +} // set_position() + + +#endif CYGONCE_LIBC_STDIO_STREAM_INL multiple inclusion protection + +// EOF stream.inl diff --git a/packages/language/c/libc/stdio/current/include/streambuf.hxx b/packages/language/c/libc/stdio/current/include/streambuf.hxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/include/streambuf.hxx @@ -0,0 +1,155 @@ +#ifndef CYGONCE_LIBC_STDIO_STREAMBUF_HXX +#define CYGONCE_LIBC_STDIO_STREAMBUF_HXX +//=========================================================================== +// +// streambuf.hxx +// +// Internal C library stdio stream buffer interface definitions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-19 +// Purpose: +// Description: This file implements the buffer class used by Cyg_StdioStream +// for file buffers. It is simple, and not thread-safe - that +// is better done at a higher level for our purposes. +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// Include buffered I/O? +#if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO) + + +// INCLUDES + +#include // Common project-wide type definitions +#include // Cyg_ErrNo + + +// TYPE DEFINITIONS + + +class Cyg_StdioStreamBuffer +{ +private: + // Buffering data + +#if defined(CYGSEM_LIBC_STDIO_SETVBUF_MALLOC) + cyg_bool call_free; // should we free the old buffer if set_buffer is + // called? +#else + cyg_uint8 static_buffer[BUFSIZ]; // Static buffer used when we cannot + // use malloc()/free(). +#endif + + cyg_uint8 *buffer_bottom; + + cyg_ucount32 buffer_size; + + cyg_uint8 *buffer_top; + + cyg_uint8 *current_buffer_position; + +public: + + // CONSTRUCTORS + + // You can change the size, or even supply your own buffer, although + // this only has an effect with dynamic buffers. Otherwise it is + // silently ignored + Cyg_StdioStreamBuffer( cyg_ucount32 size=BUFSIZ, + cyg_uint8 *new_buffer=NULL ); + + + // DESTRUCTORS + + ~Cyg_StdioStreamBuffer(); + + // METHODS + + // Set up the buffer. As with the constructor, supplying a new_buffer + // only has an effect with dynamic buffers, although EINVAL is returned + // in that case. ENOMEM may also be returned + Cyg_ErrNo + set_buffer( cyg_ucount32 size=BUFSIZ, cyg_uint8 *new_buffer=NULL ); + + // Find out how much buffer space is in use + cyg_ucount32 + get_buffer_space_used( void ); + + + // What total size is the current buffer set to be. Can be -1 if the + // the buffer is invalid + cyg_count32 + get_buffer_size( void ); + + + // get buffer address to read from, and return the number of bytes + // available to read + cyg_ucount32 + get_buffer_addr_to_read( cyg_uint8 **buffer ); + + // when finished reading from said space, tell the buffer how much was + // actually read + void + set_bytes_read( cyg_ucount32 bytes ); + + // return address of buffer that can be used to write into, and its + // available capacity + cyg_ucount32 + get_buffer_addr_to_write( cyg_uint8 **buffer ); + + // when finished writing into said space, tell the buffer how much was + // actually written + void + set_bytes_written( cyg_ucount32 bytes ); + + // just empty the whole buffer contents + void + drain_buffer( void ); +}; // class Cyg_StdioStreamBuffer + +// INLINE FUNCTIONS + +#include + + +#endif // if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO) + +#endif CYGONCE_LIBC_STDIO_STREAMBUF_HXX multiple inclusion protection + +// EOF streambuf.hxx diff --git a/packages/language/c/libc/stdio/current/include/streambuf.inl b/packages/language/c/libc/stdio/current/include/streambuf.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/include/streambuf.inl @@ -0,0 +1,172 @@ +#ifndef CYGONCE_LIBC_STDIO_STREAMBUF_INL +#define CYGONCE_LIBC_STDIO_STREAMBUF_INL +//=========================================================================== +// +// streambuf.inl +// +// Internal C library stdio stream buffer inline functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-19 +// Purpose: +// Description: +// Usage: Do not include this file directly, instead +// #include +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// Include buffered I/O? +#if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO) + + +// INCLUDES + +#include // Common project-wide type definitions +#include // Assertion support +#include // Cyg_ErrNo +#include // fpos_t and iobuf defines +#include // free() +#include // header for this file, just in case + +// FUNCTIONS + +inline +Cyg_StdioStreamBuffer::Cyg_StdioStreamBuffer( cyg_ucount32 size=BUFSIZ, + cyg_uint8 *new_buffer=NULL ) : +#if defined(CYGSEM_LIBC_STDIO_SETVBUF_MALLOC) + call_free(false), + buffer_bottom( NULL ), + buffer_size(0), +#else + buffer_bottom( static_buffer ), + buffer_size(sizeof(static_buffer)), +#endif + buffer_top(NULL), + current_buffer_position(NULL) +{ + // NB Many of the above members in the initialisation list may seem + // unnecessary, but it is to ensure a defined state if e.g. the malloc + // in set_buffer() should fail + + (void)set_buffer(size, new_buffer); +} // Cyg_StdioStreamBuffer constructor + + +inline +Cyg_StdioStreamBuffer::~Cyg_StdioStreamBuffer() +{ +#ifdef CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF + if ((buffer_bottom != NULL) && call_free) + free( buffer_bottom ); +#endif +} // Cyg_StdioStreamBuffer destructor + + +inline cyg_ucount32 +Cyg_StdioStreamBuffer::get_buffer_space_used( void ) +{ + return (buffer_top - current_buffer_position); +} // get_buffer_space_used() + + +inline cyg_count32 +Cyg_StdioStreamBuffer::get_buffer_size( void ) +{ +#ifdef CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF + if (buffer_bottom==NULL) + return -1; +#endif + return buffer_size; +} // get_buffer_size() + + +inline cyg_ucount32 +Cyg_StdioStreamBuffer::get_buffer_addr_to_read( cyg_uint8 **buffer ) +{ + *buffer = current_buffer_position; + + return (buffer_top - current_buffer_position); +} // get_buffer_addr_to_read() + +inline void +Cyg_StdioStreamBuffer::set_bytes_read( cyg_ucount32 bytes ) +{ + cyg_uint8 *buffer_max = &buffer_bottom[ get_buffer_size() ]; + + current_buffer_position += bytes; + + CYG_ASSERT( (current_buffer_position <= buffer_top), + "read too many bytes from buffer" ); + + if (current_buffer_position == buffer_max) + current_buffer_position = buffer_top = &buffer_bottom[0]; + +} // set_bytes_read() + + +inline cyg_ucount32 +Cyg_StdioStreamBuffer::get_buffer_addr_to_write( cyg_uint8 **buffer ) +{ + cyg_uint8 *buffer_max = &buffer_bottom[ get_buffer_size() ]; + + *buffer = buffer_top; + + return (buffer_max - buffer_top); +} // get_buffer_addr_to_write() + + +inline void +Cyg_StdioStreamBuffer::set_bytes_written( cyg_ucount32 bytes ) +{ + buffer_top += bytes; + + CYG_ASSERT( (buffer_top <= &buffer_bottom[ get_buffer_size() ]), + "wrote too many bytes into buffer" ); +} // set_bytes_written() + + +inline void +Cyg_StdioStreamBuffer::drain_buffer( void ) +{ + buffer_top = current_buffer_position = &buffer_bottom[0]; +} // drain_buffer() + +#endif // if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO) + +#endif CYGONCE_LIBC_STDIO_STREAMBUF_INL multiple inclusion protection + +// EOF streambuf.inl diff --git a/packages/language/c/libc/stdio/current/src/common/fclose.cxx b/packages/language/c/libc/stdio/current/src/common/fclose.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/fclose.cxx @@ -0,0 +1,117 @@ +//=========================================================================== +// +// fclose.cxx +// +// Implementation of C library file close function as per ANSI 7.9.5.1 +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: Implements ISO C fclose() function +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + + +// We can't have fclose() without fopen() +#if defined(CYGPKG_LIBC_STDIO_OPEN) + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // Error codes +#include // header for fclose() +#include // free() +#include // C library files +#include // C library streams + +#include // I/O system inlines + +// FUNCTIONS + + +externC int +fclose( FILE *stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + int i; + Cyg_ErrNo err; + + Cyg_libc_stdio_files::lock(); + + // find the stream in the table + for (i=0; i < FOPEN_MAX; i++) + { + if (real_stream == Cyg_libc_stdio_files::get_file_stream(i)) + break; + } // for + + if (i == FOPEN_MAX) // didn't find it + { + errno = EBADF; + + return EOF; + } // if + + err = real_stream->close(); + + if( err != ENOERR ) + { + errno = err; + return EOF; + } + + // FIXME: should use delete? + // Explicitly call destructor - this flushes the output too + real_stream->~Cyg_StdioStream(); + + // and free it + free(real_stream); + + // and mark the stream available for use + Cyg_libc_stdio_files::set_file_stream(i, NULL); + + Cyg_libc_stdio_files::unlock(); + + return 0; + +} // fclose() + +#endif // if defined(CYGPKG_LIBC_STDIO_OPEN) + +// EOF fclose.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/fflush.cxx b/packages/language/c/libc/stdio/current/src/common/fflush.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/fflush.cxx @@ -0,0 +1,128 @@ +//======================================================================== +// +// fflush.cxx +// +// Implementation of C library file flush function as per ANSI 7.9.5.2 +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: Provides ISO C fflush() function +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // Error codes +#include // header for fflush() +#include // C library streams +#include // C library files +#include // support for stdio + +// FUNCTIONS + +// flush all but one stream +externC Cyg_ErrNo +cyg_libc_stdio_flush_all_but( Cyg_StdioStream *not_this_stream ) +{ + cyg_bool files_flushed[FOPEN_MAX] = { false }; // sets all to 0 + cyg_bool loop_again; + cyg_ucount32 i; + Cyg_ErrNo err=ENOERR; + Cyg_StdioStream *stream; + + do { + loop_again = false; + + for (i=0; (itrylock_me() ) { + err = stream->flush_output_unlocked(); + stream->unlock_me(); + files_flushed[i] = true; + } // if + else + loop_again = true; + } // else + } // if + } // for + } // do + while(loop_again && !err); + + return err; +} // cyg_libc_stdio_flush_all_but() + +externC int +fflush( FILE *stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + Cyg_ErrNo err; + + if (stream == NULL) { // tells us to flush ALL streams + err = cyg_libc_stdio_flush_all_but(NULL); + } // if + else { + err = real_stream->flush_output(); + } // else + + if (err) { + errno = err; + return EOF; + } // if + + return 0; + +} // fflush() + +// EOF fflush.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/fopen.cxx b/packages/language/c/libc/stdio/current/src/common/fopen.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/fopen.cxx @@ -0,0 +1,250 @@ +//=========================================================================== +// +// fopen.cxx +// +// Implementation of C library file open function as per ANSI 7.9.5.3 +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: Implements ISO C fopen() function +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + + +// Do we want fopen()? +#if defined(CYGPKG_LIBC_STDIO_OPEN) + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // Error codes +#include // header for fopen() +#include // malloc() +#include // strncmp() and strcmp() +#include // C library files +#include // C library streams + +#include // I/O system inlines + +// FUNCTIONS + +// process the mode string. Return true on error +static cyg_bool +process_mode( const char *mode, Cyg_StdioStream::OpenMode *rw, + cyg_bool *binary, cyg_bool *append ) +{ + *binary = *append = false; // default + + switch (mode[0]) { + case 'r': + *rw = Cyg_StdioStream::CYG_STREAM_READ; + break; + + case 'a': + *append = true; + case 'w': + *rw = Cyg_StdioStream::CYG_STREAM_WRITE; + break; + + default: + return true; + } // switch + + // ANSI says additional characters may follow the sequences, that we + // don't necessarily recognise so we just ignore them, and pretend that + // its the end of the string + + switch (mode[1]) { + case 'b': + *binary = true; + break; + case '+': + *rw = Cyg_StdioStream::CYG_STREAM_READWRITE; + break; + default: + return false; + } // switch + + switch (mode[2]) { + case 'b': + *binary = true; + break; + case '+': + *rw = Cyg_StdioStream::CYG_STREAM_READWRITE; + break; + default: + return false; + } // switch + + return false; +} // process_mode() + + +static FILE *fopen_inner( cyg_stdio_handle_t dev, + Cyg_StdioStream::OpenMode open_mode, + cyg_bool binary, + cyg_bool append) +{ + Cyg_StdioStream *curr_stream; + int i; + Cyg_ErrNo err; + int bufmode = _IOFBF; + cyg_ucount32 bufsize = BUFSIZ; + + Cyg_libc_stdio_files::lock(); + + // find an empty slot + for (i=0; i < FOPEN_MAX; i++) { + curr_stream = Cyg_libc_stdio_files::get_file_stream(i); + if (curr_stream == NULL) + break; + } // for + + if (i == FOPEN_MAX) { // didn't find an empty slot + errno = EMFILE; + cyg_stdio_close( dev ); + return NULL; + } // if + + // Decide the buffering mode. The default is fully buffered, but if + // this is an interactive stream then set it to non buffered. + if( (dev != CYG_STDIO_HANDLE_NULL) && + cyg_stdio_interactive( dev ) ) + bufmode = _IONBF, bufsize = 0; + + // Allocate it some memory and construct it. + curr_stream = new Cyg_StdioStream( dev, open_mode, append, binary, + bufmode, bufsize ); + + if (curr_stream == NULL) { + cyg_stdio_close( dev ); + errno = ENOMEM; + return NULL; + } // if + + + // it puts any error in its own error flag + if (( err=curr_stream->get_error() )) { + + Cyg_libc_stdio_files::unlock(); + + free( curr_stream ); + + cyg_stdio_close( dev ); + + errno = err; + + return NULL; + + } // if + + Cyg_libc_stdio_files::set_file_stream(i, curr_stream); + + Cyg_libc_stdio_files::unlock(); + + return (FILE *)(curr_stream); + +} // fopen_inner() + +externC FILE * +fopen( const char *filename, const char *mode ) +{ + cyg_stdio_handle_t dev; + Cyg_ErrNo err; + Cyg_StdioStream::OpenMode open_mode; + cyg_bool binary, append; + + // process_mode returns true on error + if (process_mode( mode, &open_mode, &binary, &append )) { + errno = EINVAL; + return NULL; + } // if + + err = cyg_stdio_open( filename, open_mode, binary, append, &dev ); + + // if not found + if (err != ENOERR) { + errno = ENOENT; + return NULL; + } // if + + return fopen_inner( dev, open_mode, binary, append ); + +} // fopen() + + +#endif // defined(CYGPKG_LIBC_STDIO_OPEN) + +#ifdef CYGPKG_LIBC_STDIO_FILEIO + +externC int fileno( FILE *stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + + return real_stream->get_dev(); +} + +externC FILE *fdopen( int fd, const char *mode ) +{ + Cyg_StdioStream::OpenMode open_mode; + cyg_bool binary, append; + FILE *f; + + // process_mode returns true on error + if (process_mode( mode, &open_mode, &binary, &append )) { + errno = EINVAL; + return NULL; + } // if + + f = fopen_inner( (cyg_stdio_handle_t)fd, open_mode, binary, append ); + + if( f == NULL ) + return f; + + // Do a null seek to initialize the file position. + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)f; + fpos_t pos = 0; + real_stream->set_position( pos, SEEK_CUR ); +} + +#endif // def CYGPKG_LIBC_STDIO_FILEIO + + +// EOF fopen.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/freopen.cxx b/packages/language/c/libc/stdio/current/src/common/freopen.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/freopen.cxx @@ -0,0 +1,70 @@ +//======================================================================== +// +// freopen.cxx +// +// Implementation of C library freopen() function +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: Provides ISO C freopen() function +// Description: Implementation of C library freopen() function as per +// ISO C standard chap. 7.9.5.4 +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// We only want freopen() if we have fopen() +#if defined(CYGPKG_LIBC_STDIO_OPEN) + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for freopen() + +// FUNCTIONS + + +externC FILE * +freopen( const char *, const char *, FILE * ) +{ + return NULL; // Returning NULL is valid! FIXME +} // freopen() + +#endif // defined(CYGPKG_LIBC_STDIO_OPEN) + +// EOF freopen.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/fseek.cxx b/packages/language/c/libc/stdio/current/src/common/fseek.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/fseek.cxx @@ -0,0 +1,158 @@ +//=========================================================================== +// +// fseek.cxx +// +// Implementation of C library file positioning functions as per ANSI 7.9.9 +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: +// Date: 2000-07-12 +// Purpose: Implements ISO C file positioning functions +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +#include // Common project-wide type definitions +#include // Assertion support +#include // Tracing support +#include // NULL and size_t from compiler +#include // Error codes +#include // header for fseek() etc. +#include // C library files +#include // C library streams + +//======================================================================== + +// ISO C 7.9.9 File positioning functions + +externC int +fgetpos( FILE * stream , fpos_t *pos ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + Cyg_ErrNo err; + int ret = 0; + + CYG_REPORT_FUNCNAME( "fgetpos" ); + + err = real_stream->get_position( pos ); + + if( err != ENOERR ) + { + errno = err; + ret = -1; + } + + CYG_REPORT_RETVAL( ret ); + return ret; +} + +externC int +fseek( FILE * stream , long int offset , int whence ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + Cyg_ErrNo err; + int ret = 0; + + CYG_REPORT_FUNCNAME( "fgetpos" ); + + err = real_stream->set_position( (fpos_t)offset, whence ); + + if( err != ENOERR ) + { + errno = err; + ret = -1; + } + + CYG_REPORT_RETVAL( ret ); + return ret; +} + +externC int +fsetpos( FILE * stream , const fpos_t * pos ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + Cyg_ErrNo err; + int ret = 0; + + CYG_REPORT_FUNCNAME( "fgetpos" ); + + err = real_stream->set_position( *pos, SEEK_SET ); + + if( err != ENOERR ) + { + errno = err; + ret = -1; + } + + CYG_REPORT_RETVAL( ret ); + return ret; +} + +externC long int +ftell( FILE * stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + Cyg_ErrNo err; + long int ret = 0; + fpos_t pos; + + CYG_REPORT_FUNCNAME( "ftell" ); + + err = real_stream->get_position( &pos ); + + if( err != ENOERR ) + { + errno = err; + ret = -1; + } + else ret = pos; + + CYG_REPORT_RETVAL( ret ); + return ret; +} + +externC void +rewind( FILE * stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + (void)fseek( stream, 0L, SEEK_SET ); + + real_stream->set_error( ENOERR ); +} + + +// EOF fseek.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/setvbuf.cxx b/packages/language/c/libc/stdio/current/src/common/setvbuf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/setvbuf.cxx @@ -0,0 +1,120 @@ +//=========================================================================== +// +// setvbuf.cxx +// +// Implementation of C library buffering setup as per ANSI 7.9.5.6 +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // Error codes +#include // header for setvbuf() +#include // C libray streams + +// FUNCTIONS + + +externC int +setvbuf( FILE *stream, char *buf, int mode, size_t size ) +{ +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + Cyg_ErrNo err; + +#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS + if ( !real_stream->lock_me() ) { + errno = EBADF; + return EBADF; + } // if +#endif + + err = real_stream->io_buf.set_buffer( (cyg_ucount32) size, + (cyg_uint8 *) buf ); + if (!err) { + switch (mode) { + case _IONBF: + CYG_ASSERT( (size == 0) && (buf == NULL), + "No buffering wanted but size/address specified!" ); + real_stream->flags.buffering = false; + real_stream->flags.line_buffering = false; + break; + case _IOLBF: + real_stream->flags.buffering = true; + real_stream->flags.line_buffering = true; + break; + case _IOFBF: + real_stream->flags.buffering = true; + real_stream->flags.line_buffering = false; + break; + default: + err = EINVAL; + break; + } // switch + } // if + +#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS + real_stream->unlock_me(); +#endif + + if (err) { + errno = err; + return err; + } // if + + return 0; + +#else // ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + + errno = ENOSUPP; + return ENOSUPP; + +#endif // ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + +} // setvbuf() + +// EOF setvbuf.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/snprintf.cxx b/packages/language/c/libc/stdio/current/src/common/snprintf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/snprintf.cxx @@ -0,0 +1,72 @@ +//=========================================================================== +// +// snprintf.cxx +// +// ANSI Stdio snprintf() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file + +// FUNCTIONS + +externC int +snprintf( char *s, size_t size, const char *format, ... ) +{ + int rc; // return code + va_list ap; // for variable args + + va_start(ap, format); // init specifying last non-var arg + + rc = vsnprintf(s, size, format, ap); + + va_end(ap); // end var args + + return rc; +} // snprintf() + +// EOF snprintf.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/sprintf.cxx b/packages/language/c/libc/stdio/current/src/common/sprintf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/sprintf.cxx @@ -0,0 +1,73 @@ +//=========================================================================== +// +// sprintf.cxx +// +// ANSI Stdio sprintf() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file +#include // INT_MAX + +// FUNCTIONS + +externC int +sprintf( char *s, const char *format, ... ) +{ + int rc; // return code + va_list ap; // for variable args + + va_start(ap, format); // init specifying last non-var arg + + rc = vsnprintf(s, INT_MAX, format, ap); + + va_end(ap); // end var args + + return rc; +} // sprintf() + +// EOF sprintf.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/sscanf.cxx b/packages/language/c/libc/stdio/current/src/common/sscanf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/sscanf.cxx @@ -0,0 +1,72 @@ +//=========================================================================== +// +// sscanf.cxx +// +// ANSI Stdio sscanf() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file + +// FUNCTIONS + +externC int +sscanf( const char *s, const char *format, ... ) +{ + int rc; // return code + va_list ap; // for variable args + + va_start(ap, format); // init specifying last non-var arg + + rc = vsscanf(s, format, ap); + + va_end(ap); // end var args + + return rc; +} // sscanf() + +// EOF sscanf.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/stderr.cxx b/packages/language/c/libc/stdio/current/src/common/stderr.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/stderr.cxx @@ -0,0 +1,91 @@ +//======================================================================== +// +// stderr.cxx +// +// Initialization of stderr stream for ISO C library +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: Initialization of stderr stream for ISO C library +// Description: We put all this in a separate file in the hope that if +// no-one uses stderr, then it is not included in the image +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// Don't let us get the stream definitions of stdin/out/err from stdio.h +// since we are going to break the type safety :-( +#define CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS + +// And we don't need the stdio inlines, which will otherwise complain if +// stdin/out/err are not available +#ifdef CYGIMP_LIBC_STDIO_INLINES +# undef CYGIMP_LIBC_STDIO_INLINES +#endif + +// INCLUDES + +#include // Common type definitions and support +#include // Cyg_StdioStream class +#include // C library files +#include // Cyg_libc_stdio_find_filename() + +// STATICS + +Cyg_StdioStream +cyg_libc_stdio_stderr CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC) = Cyg_StdioStream( + Cyg_libc_stdio_find_filename(CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE, + Cyg_StdioStream::CYG_STREAM_WRITE, false, false), + Cyg_StdioStream::CYG_STREAM_WRITE, false, false, _IONBF, 0, NULL ); + +// CLASSES + +// This is a dummy class just so we can execute arbitrary code when +// stderr is requested + +class cyg_libc_dummy_stderr_init_class { +public: + cyg_libc_dummy_stderr_init_class(void) { + Cyg_libc_stdio_files::set_file_stream(2, &cyg_libc_stdio_stderr); + } +}; + +// And here's an instance of the class just to make the code run +static cyg_libc_dummy_stderr_init_class cyg_libc_dummy_stderr_init + CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC); + +// EOF stderr.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/stdin.cxx b/packages/language/c/libc/stdio/current/src/common/stdin.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/stdin.cxx @@ -0,0 +1,91 @@ +//======================================================================== +// +// stdin.cxx +// +// Initialization of stdin stream for ISO C library +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: Initialization of stdin stream for ISO C library +// Description: We put all this in a separate file in the hope that if +// no-one uses stdin, then it is not included in the image +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// Don't let us get the stream definitions of stdin/out/err from stdio.h +// since we are going to break the type safety :-( +#define CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS + +// And we don't need the stdio inlines, which will otherwise complain if +// stdin/out/err are not available +#ifdef CYGIMP_LIBC_STDIO_INLINES +# undef CYGIMP_LIBC_STDIO_INLINES +#endif + +// INCLUDES + +#include // Common type definitions and support +#include // Cyg_StdioStream class +#include // C library files +#include // Cyg_libc_stdio_find_filename() + +// STATICS + +Cyg_StdioStream +cyg_libc_stdio_stdin CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC) = Cyg_StdioStream( + Cyg_libc_stdio_find_filename(CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE, + Cyg_StdioStream::CYG_STREAM_READ, false, false), + Cyg_StdioStream::CYG_STREAM_READ, false, false, _IOLBF ); + + +// CLASSES + +// This is a dummy class just so we can execute arbitrary code when +// stdin is requested + +class cyg_libc_dummy_stdin_init_class { +public: + cyg_libc_dummy_stdin_init_class(void) { + Cyg_libc_stdio_files::set_file_stream(0, &cyg_libc_stdio_stdin); + } +}; + +// And here's an instance of the class just to make the code run +static cyg_libc_dummy_stdin_init_class cyg_libc_dummy_stdin_init + CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC); +// EOF stdin.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/stdiofiles.cxx b/packages/language/c/libc/stdio/current/src/common/stdiofiles.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/stdiofiles.cxx @@ -0,0 +1,73 @@ +//======================================================================== +// +// stdiofiles.cxx +// +// ISO C library stdio central file data +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: Allocate storage for central file data object +// Description: This file allocates the actual objects used by the +// Cyg_libc_stdio_files class defined in +// +// Usage: +// +//####DESCRIPTIONEND#### +// +//========================================================================= + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include // NULL +#include // Cyg_StdioStream +#include // Class definition for + // Cyg_libc_stdio_files + +#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS +# include // CYGBLD_ATTRIB_INIT_PRI +# include // mutexes +#endif + + +// GLOBAL VARIABLES + +Cyg_StdioStream *Cyg_libc_stdio_files::files[FOPEN_MAX] = { NULL }; + +# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS +Cyg_Mutex Cyg_libc_stdio_files::files_lock + CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC); +# endif + +// EOF stdiofiles.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/stdioinlines.cxx b/packages/language/c/libc/stdio/current/src/common/stdioinlines.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/stdioinlines.cxx @@ -0,0 +1,155 @@ +//=========================================================================== +// +// stdioinlines.cxx +// +// ANSI standard I/O routines - real alternatives for inlined functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +// We don't want the inline versions of stdio functions defined here + +#ifdef CYGIMP_LIBC_STDIO_INLINES +#undef CYGIMP_LIBC_STDIO_INLINES +#endif + +#include // Common type definitions and support +#include // NULL and size_t from compiler +#include // va_list +#include // Header for this file +#include // Definition of error codes and errno +#include // Definition of strerror() for perror() +#include // INT_MAX + + +// FUNCTIONS + +//=========================================================================== + +// 7.9.5 File access functions + +externC void +setbuf( FILE *stream, char *buf ) +{ + if (buf == NULL) + setvbuf( stream, NULL, _IONBF, BUFSIZ ); + else + // NB: Should use full buffering by default ordinarily, but in + // the current system we're always connected to an interactive + // terminal, so use line buffering + setvbuf( stream, buf, _IOLBF, BUFSIZ ); + +} // setbuf() + +//=========================================================================== + +// 7.9.6 Formatted input/output functions + + +externC int +vfprintf( FILE *stream, const char *format, va_list arg ) +{ + return vfnprintf(stream, INT_MAX, format, arg); +} // vfprintf() + + +externC int +vprintf( const char *format, va_list arg) +{ + return vfnprintf( stdout, INT_MAX, format, arg ); +} // vprintf() + + +externC int +vsprintf( char *s, const char *format, va_list arg ) +{ + return vsnprintf(s, INT_MAX, format, arg); +} // vsprintf() + + +//=========================================================================== + +// 7.9.7 Character input/output functions + +externC int +puts( const char *s ) +{ + int rc; + + rc = fputs( s, stdout ); + + if (rc >= 0) + rc = fputc('\n', stdout ); + + return rc; +} // puts() + + +//=========================================================================== + +// 7.9.10 Error-handling functions + +externC void +perror( const char *s ) +{ + if (s && *s) + fprintf( stderr, "%s: %s\n", s, strerror(errno) ); + else + fputs( strerror(errno), stderr ); + +} // perror() + +//=========================================================================== + +// Other non-ANSI functions + +#ifdef CYGFUN_LIBC_STDIO_ungetc +externC int +vscanf( const char *format, va_list arg ) +{ + return vfscanf( stdin, format, arg ); +} // vscanf() +#endif + +// EOF stdioinlines.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/stdiosupp.cxx b/packages/language/c/libc/stdio/current/src/common/stdiosupp.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/stdiosupp.cxx @@ -0,0 +1,74 @@ +//=========================================================================== +// +// stdiosupp.cxx +// +// Helper C library functions for standard I/O +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // I/O system +#include // Header for this file + +#include // I/O system inlines + +//externC void cyg_io_init(void); + +cyg_stdio_handle_t +Cyg_libc_stdio_find_filename( const char *filename, + const Cyg_StdioStream::OpenMode rw, + const cyg_bool binary, + const cyg_bool append ) +{ + cyg_stdio_handle_t dev = CYG_STDIO_HANDLE_NULL; + + cyg_stdio_open(filename, rw, binary, append, &dev); + + return dev; +} // Cyg_libc_stdio_find_filename() + + +// EOF stdiosupp.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/stdout.cxx b/packages/language/c/libc/stdio/current/src/common/stdout.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/stdout.cxx @@ -0,0 +1,91 @@ +//======================================================================== +// +// stdout.cxx +// +// Initialization of stdout stream for ISO C library +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: Initialization of stdout stream for ISO C library +// Description: We put all this in a separate file in the hope that if +// no-one uses stdout, then it is not included in the image +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// Don't let us get the stream definitions of stdin/out/err from stdio.h +// since we are going to break the type safety :-( +#define CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS + +// And we don't need the stdio inlines, which will otherwise complain if +// stdin/out/err are not available +#ifdef CYGIMP_LIBC_STDIO_INLINES +# undef CYGIMP_LIBC_STDIO_INLINES +#endif + +// INCLUDES + +#include // Common type definitions and support +#include // Cyg_StdioStream class +#include // C library files +#include // Cyg_libc_stdio_find_filename() + +// STATICS + +Cyg_StdioStream +cyg_libc_stdio_stdout CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC) = Cyg_StdioStream( + Cyg_libc_stdio_find_filename(CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE, + Cyg_StdioStream::CYG_STREAM_WRITE, false, false), + Cyg_StdioStream::CYG_STREAM_WRITE, false, false, _IOLBF ); + +// CLASSES + +// This is a dummy class just so we can execute arbitrary code when +// stdout is requested + +class cyg_libc_dummy_stdout_init_class { +public: + cyg_libc_dummy_stdout_init_class(void) { + Cyg_libc_stdio_files::set_file_stream(1, &cyg_libc_stdio_stdout); + } +}; + +// And here's an instance of the class just to make the code run +static cyg_libc_dummy_stdout_init_class cyg_libc_dummy_stdout_init + CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC); + +// EOF stdout.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/stream.cxx b/packages/language/c/libc/stdio/current/src/common/stream.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/stream.cxx @@ -0,0 +1,688 @@ +//======================================================================== +// +// stream.cxx +// +// Implementations of internal C library stdio stream functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // Assertion infrastructure +#include // NULL and size_t from compiler +#include // Error codes +#include // memcpy() and memset() +#include // Header for this file +#include // Stdio support functions + + +#include // I/O system inlines + + +// FUNCTIONS + +Cyg_StdioStream::Cyg_StdioStream(cyg_stdio_handle_t dev, + OpenMode open_mode, + cyg_bool append, cyg_bool binary, + int buffer_mode, cyg_ucount32 buffer_size, + cyg_uint8 *buffer_addr ) +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + : io_buf( buffer_size, buffer_addr ) +#endif +{ + initialize( dev, open_mode, append, binary, buffer_mode, + buffer_size, buffer_addr); +} + +void Cyg_StdioStream::initialize(cyg_stdio_handle_t dev, + OpenMode open_mode, + cyg_bool append, cyg_bool binary, + int buffer_mode, cyg_ucount32 buffer_size, + cyg_uint8 *buffer_addr ) +{ + +#ifdef CYGDBG_USE_ASSERTS + magic_validity_word = 0xbadbad; +#endif + + my_device = dev; + + // Clear all flags + memset( &flags, 0, sizeof(flags) ); + + switch (open_mode) { + case CYG_STREAM_READ: + flags.opened_for_read = true; + break; + case CYG_STREAM_WRITE: + flags.opened_for_write = true; + break; + case CYG_STREAM_READWRITE: + flags.opened_for_read = true; + flags.opened_for_write = true; + break; + default: + error=EINVAL; + return; + } // switch + + + if (flags.opened_for_write) { +#if 0 + // FIXME: need some replacement for this + if (!my_device->write_blocking) { + error = EDEVNOSUPP; + return; + } // if +#endif +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + flags.last_buffer_op_was_read = false; +#endif + } // if + + + if (flags.opened_for_read) { +#if 0 + // FIXME: need some replacement for this + if (!my_device->read_blocking) { + error = EDEVNOSUPP; + return; + } // if +#endif + + // NB also if opened for read AND write, then say last op was read +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + flags.last_buffer_op_was_read = true; +#endif + } // if + + flags.binary = binary ? 1 : 0; + + error = ENOERR; + + // in due course we would do an equivalent to fseek(...,0, SEEK_END); + // when appending. for now, there's nothing, except set eof + + flags.at_eof = append ? 1 : 0; + + position = 0; + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + + switch (buffer_mode) { + case _IONBF: + CYG_ASSERT( (buffer_size == 0) && (buffer_addr == NULL), + "No buffering wanted but size/address specified!" ); + flags.buffering = flags.line_buffering = false; + break; + case _IOLBF: + flags.buffering = true; + flags.line_buffering = true; + break; + case _IOFBF: + flags.buffering = true; + flags.line_buffering = false; + break; + default: + error = EINVAL; + return; + } // switch + + // one way of checking the buffer was set up correctly + if (flags.buffering && io_buf.get_buffer_size()==-1) { + error = ENOMEM; + return; + } + +#endif + +#if 0 // FIXME - Need to set binary mode. + if (my_device->open) { + error = (*my_device->open)( my_device->cookie, + binary ? CYG_DEVICE_OPEN_MODE_RAW + : CYG_DEVICE_OPEN_MODE_TEXT ); + if (error != ENOERR) + return; // keep error code the same + } // if + +#endif + +#ifdef CYGDBG_USE_ASSERTS + magic_validity_word = 0x7b4321ce; +#endif + +} // Cyg_StdioStream constructor + + +Cyg_StdioStream::Cyg_StdioStream( OpenMode open_mode, + cyg_ucount32 buffer_size, + cyg_uint8 *buffer_addr ) +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + : io_buf( buffer_size, buffer_addr ) +#endif +{ + initialize( CYG_STDIO_HANDLE_NULL, open_mode, false, false, _IOFBF, + buffer_size, buffer_addr ); + + if( error != ENOERR ) + return; + + switch( open_mode ) + { + case CYG_STREAM_READ: + // Fix up the stream so it looks like the buffer contents has just + // been read in. +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + io_buf.set_bytes_written( buffer_size ); +#endif + break; + + case CYG_STREAM_WRITE: + // Fix up the stream so it looks like the buffer is ready to accept + // new data. + break; + + default: + error = EINVAL; + return; + } +} + + +Cyg_ErrNo +Cyg_StdioStream::refill_read_buffer( void ) +{ + Cyg_ErrNo read_err; + cyg_uint8 *buffer; + cyg_uint32 len; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if (!lock_me()) + return EBADF; // assume file is now invalid + + // first just check that we _can_ read this device! + if (!flags.opened_for_read) { + unlock_me(); + return EINVAL; + } + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + // If there is pending output to write, then this will check and + // write it + if (flags.buffering) { + read_err = flush_output_unlocked(); + + if (read_err != ENOERR) { + unlock_me(); + return read_err; + } // if + } // if +#endif + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + // we're now reading + flags.last_buffer_op_was_read = true; + + if (flags.buffering) { + len = io_buf.get_buffer_addr_to_write( (cyg_uint8**)&buffer ); + if (!len) { // no buffer space available + unlock_me(); + return ENOERR; // isn't an error, just needs user to read out data + } // if + } + else +#endif + + if (!flags.readbuf_char_in_use) { + len = 1; + buffer = &readbuf_char; + } + else { + // no buffer space available + unlock_me(); + return ENOERR; // isn't an error, just needs user to read out data + } // else + + read_err = cyg_stdio_read(my_device, buffer, &len); + + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + if (flags.buffering) + io_buf.set_bytes_written( len ); + else +#endif + flags.readbuf_char_in_use = len ? 1 : 0; + + unlock_me(); + + if (read_err == ENOERR) { + if (len == 0) + read_err = EAGAIN; + } // if + + return read_err; +} // refill_read_buffer() + + +Cyg_ErrNo +Cyg_StdioStream::read( cyg_uint8 *user_buffer, cyg_ucount32 buffer_length, + cyg_ucount32 *bytes_read ) +{ + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + *bytes_read = 0; + + if (!lock_me()) + return EBADF; // assume file is now invalid + + if (!flags.opened_for_read) { + unlock_me(); + return EINVAL; + } + +#ifdef CYGFUN_LIBC_STDIO_ungetc + if (flags.unread_char_buf_in_use && buffer_length) { + *user_buffer++ = unread_char_buf; + ++*bytes_read; + flags.unread_char_buf_in_use = false; + --buffer_length; + } // if + +#endif // ifdef CYGFUN_LIBC_STDIO_ungetc + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + if (flags.buffering) { + cyg_uint8 *buff_to_read_from; + cyg_ucount32 bytes_available; + Cyg_ErrNo err; + + // this should really only be called after refill_read_buffer, but + // just in case + err = flush_output_unlocked(); + if (ENOERR == err) + err = cyg_libc_stdio_flush_all_but(this); + + if (err != ENOERR) { + position += *bytes_read; + unlock_me(); + return err; + } + + // we're now reading + flags.last_buffer_op_was_read = true; + + bytes_available = io_buf.get_buffer_addr_to_read( + (cyg_uint8 **)&buff_to_read_from ); + + *bytes_read += (bytes_available < buffer_length) ? bytes_available + : buffer_length; + if (*bytes_read) { + memcpy( user_buffer, buff_to_read_from, *bytes_read ); + io_buf.set_bytes_read( *bytes_read ); + } // if + + } // if + else + +#endif + + if (flags.readbuf_char_in_use && buffer_length) { + *user_buffer = readbuf_char; + *bytes_read = 1; + flags.readbuf_char_in_use = false; + } + + position += *bytes_read; + + unlock_me(); + + return ENOERR; +} // read() + + +Cyg_ErrNo +Cyg_StdioStream::read_byte( cyg_uint8 *c ) +{ + Cyg_ErrNo err=ENOERR; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if (!lock_me()) + return EBADF; // assume file is now invalid + + if (!flags.opened_for_read) { + unlock_me(); + return EINVAL; + } + + // this should really only be called after refill_read_buffer, but just + // in case +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + if (flags.buffering) + err = flush_output_unlocked(); + if (ENOERR == err) + err = cyg_libc_stdio_flush_all_but(this); + + if (err != ENOERR) + return err; + + // we're now reading + flags.last_buffer_op_was_read = true; +#endif + +# ifdef CYGFUN_LIBC_STDIO_ungetc + if (flags.unread_char_buf_in_use) { + *c = unread_char_buf; + flags.unread_char_buf_in_use = false; + position++; + unlock_me(); + return ENOERR; + } // if +# endif // ifdef CYGFUN_LIBC_STDIO_ungetc + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + if (flags.buffering) { + cyg_uint8 *buff_to_read_from; + cyg_ucount32 bytes_available; + + bytes_available=io_buf.get_buffer_addr_to_read(&buff_to_read_from); + + if (bytes_available) { + *c = *buff_to_read_from; + io_buf.set_bytes_read(1); + position++; + } + else + err = EAGAIN; + } // if + else + +#endif + + + if (flags.readbuf_char_in_use) { + *c = readbuf_char; + flags.readbuf_char_in_use = false; + position++; + } + else + err = EAGAIN; + + unlock_me(); + + return err; +} // read_byte() + + +Cyg_ErrNo +Cyg_StdioStream::peek_byte( cyg_uint8 *c ) +{ + Cyg_ErrNo err=ENOERR; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if (!lock_me()) + return EBADF; // assume file is now invalid + + if (!flags.opened_for_read) { + unlock_me(); + return EINVAL; + } + + // this should really only be called after refill_read_buffer, but just + // in case +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + if (flags.buffering) + err = flush_output_unlocked(); + + if (err != ENOERR) + return err; + + // we're now reading + flags.last_buffer_op_was_read = true; +#endif + +# ifdef CYGFUN_LIBC_STDIO_ungetc + if (flags.unread_char_buf_in_use) { + *c = unread_char_buf; + unlock_me(); + return ENOERR; + } // if +# endif // ifdef CYGFUN_LIBC_STDIO_ungetc + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + if (flags.buffering) { + cyg_uint8 *buff_to_read_from; + cyg_ucount32 bytes_available; + + bytes_available=io_buf.get_buffer_addr_to_read(&buff_to_read_from); + + if (bytes_available) { + *c = *buff_to_read_from; + } + else + err = EAGAIN; + } // if + else + +#endif + + + if (flags.readbuf_char_in_use) { + *c = readbuf_char; + } + else + err = EAGAIN; + + unlock_me(); + + return err; +} // peek_byte() + + +Cyg_ErrNo +Cyg_StdioStream::flush_output_unlocked( void ) +{ +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + Cyg_ErrNo write_err=ENOERR; + cyg_uint8 *buffer; + cyg_uint32 len; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + if ( flags.last_buffer_op_was_read ) + return ENOERR; + + // first just check that we _can_ write to the device! + if ( !flags.opened_for_write ) + return EINVAL; + + // shortcut if nothing to do + if (io_buf.get_buffer_space_used() == 0) + return ENOERR; + + len = io_buf.get_buffer_addr_to_read( (cyg_uint8 **)&buffer ); + + CYG_ASSERT( len > 0, + "There should be data to read but there isn't!"); + + write_err = cyg_stdio_write(my_device, buffer, &len); + + // since we're doing a concerted flush, we tell the I/O layer to + // flush too, otherwise output may just sit there forever + if (!write_err) + cyg_stdio_flush( my_device ); + + // we've just read it all, so just wipe it out + io_buf.drain_buffer(); + + return write_err; + +#else // ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + return ENOERR; + +#endif // ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO +} // flush_output_unlocked() + + + +Cyg_ErrNo +Cyg_StdioStream::write( const cyg_uint8 *buffer, + cyg_ucount32 buffer_length, + cyg_ucount32 *bytes_written ) +{ + Cyg_ErrNo write_err = ENOERR; + + CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); + + *bytes_written = 0; + + if (!lock_me()) + return EBADF; // assume file is now invalid + + // first just check that we _can_ write to the device! + if ( !flags.opened_for_write ) { + unlock_me(); + return EINVAL; + } + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + if (flags.last_buffer_op_was_read == true) + io_buf.drain_buffer(); // nuke input bytes to prevent confusion + + flags.last_buffer_op_was_read = false; + + if (!flags.buffering) { +#endif + cyg_uint32 len = buffer_length; + + write_err = cyg_stdio_write(my_device, buffer, &len); + + *bytes_written = len; + +#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO + } // if + else { + cyg_ucount32 bytes_available; + cyg_ucount32 bytes_to_write; + cyg_ucount32 newline_pos; + cyg_uint8 *write_addr; + cyg_bool must_flush = false; + + while ( buffer_length > 0 ) { + bytes_available = + io_buf.get_buffer_addr_to_write( &write_addr ); + + // we need to flush if we've no room or the buffer has an up + // and coming newline + if ( !bytes_available || must_flush ) { + write_err = flush_output_unlocked(); + + // harmless even if there was an error + bytes_available = + io_buf.get_buffer_addr_to_write( &write_addr ); + + CYG_ASSERT( bytes_available > 0, + "Help! still no bytes available in " + "write buffer" ); + } // if + + if (write_err) { + unlock_me(); + return write_err; + } // if + + // choose the lower of the buffer available and the length + // to write + bytes_to_write=(bytes_available < buffer_length) + ? bytes_available + : buffer_length; + + // if we're line buffered, we may want want to flush if there's + // a newline character, so lets find out + + if (flags.line_buffering) { + for (newline_pos=0; + newline_pos // Configuration header + +// Include buffered I/O? +#if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO) + + +// INCLUDES + +#include // Common project-wide type definitions +#include // Assertion support +#include // Cyg_ErrNo +#include // malloc() and free() +#include // header for this file, just in case + +// FUNCTIONS + +Cyg_ErrNo +Cyg_StdioStreamBuffer::set_buffer( cyg_ucount32 size=BUFSIZ, + cyg_uint8 *new_buffer=NULL ) +{ + +#ifdef CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF + + // user-supplied buffer? + if (new_buffer != NULL) { + CYG_CHECK_DATA_PTR(new_buffer, "new_buffer not valid"); +#ifdef CYGSEM_LIBC_STDIO_SETVBUF_MALLOC + // first check if we were responsible for the old buffer + if (call_free) { + free(buffer_bottom); + call_free = false; + } +#endif + buffer_bottom = new_buffer; + } +#ifdef CYGSEM_LIBC_STDIO_SETVBUF_MALLOC + else if ( size != buffer_size ) { // as long as its different from + // what we've got now + cyg_uint8 *malloced_buf; + + malloced_buf = (cyg_uint8 * )malloc( size ); + if (malloced_buf == NULL) + return ENOMEM; + + // should the old buffer be freed? This waits till after we know + // whether the malloc succeeded + if (call_free) + free( buffer_bottom ); + + buffer_bottom = malloced_buf; + + call_free=true; + + } // else if +#else + // Here we have not been given a new buffer, but have been given + // a new buffer size. If possible, we just shrink what we already + // have. + else if( size > buffer_size ) + return EINVAL; +#endif + +#else // ifdef CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF + + // In this config we can't use a different buffer, or set a + // size greater than now. We can pretend to shrink it though + + // Note on the next line we compare it with the size of static_buffer + // and not the current size, as that's what is the limiting factor + if ( (new_buffer != NULL) || (size > sizeof(static_buffer)) ) + return EINVAL; + +#endif // ifdef CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF + + buffer_top = current_buffer_position = &buffer_bottom[0]; + buffer_size = size; + + return ENOERR; + +} // set_buffer() + + +#endif // if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO) + + +// EOF streambuf.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/ungetc.cxx b/packages/language/c/libc/stdio/current/src/common/ungetc.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/ungetc.cxx @@ -0,0 +1,85 @@ +//=========================================================================== +// +// ungetc.cxx +// +// ANSI Stdio ungetc() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file +#include // error codes +#include // Cyg_StdioStream + + +// FUNCTIONS + +externC int +ungetc( int c, FILE *stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + Cyg_ErrNo err; + cyg_uint8 real_c; + + if (c == EOF) + return EOF; + + real_c = (cyg_uint8) c; + + err = real_stream->unread_byte( real_c ); + + if (err) + { + errno = err; + return EOF; + } // if + + + return (int)real_c; + +} // ungetc() + +// EOF ungetc.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/vsnprintf.cxx b/packages/language/c/libc/stdio/current/src/common/vsnprintf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/vsnprintf.cxx @@ -0,0 +1,143 @@ +//=========================================================================== +// +// vsnprintf.cxx +// +// ANSI Stdio vsnprintf() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file +#include // error codes +#include // Device table +#include // Cyg_StdioStream + +#include // I/O system inlines + +#ifndef CYGPKG_LIBC_STDIO_FILEIO + +// FUNCTIONS + +static Cyg_ErrNo +str_write(cyg_stdio_handle_t handle, const void *buf, cyg_uint32 *len) +{ + cyg_devtab_entry_t *dev = (cyg_devtab_entry_t *)handle; + cyg_uint8 **str_p = (cyg_uint8 **)dev->priv; + cyg_ucount32 i; + + // I suspect most strings passed to vsnprintf will be relatively short, + // so we just take the simple approach rather than have the overhead + // of calling memcpy etc. + + // simply copy string until we run out of user space + + for (i = 0; i < *len; i++, (*str_p)++ ) + { + **str_p = *((cyg_uint8 *)buf + i); + } // for + + *len = i; + + return ENOERR; + +} // str_write() + +static DEVIO_TABLE(devio_table, + str_write, // write + NULL, // read + NULL, // select + NULL, // get_config + NULL); // set_config + +externC int +vsnprintf( char *s, size_t size, const char *format, va_list arg ) +{ + int rc; + // construct a fake device with the address of the string we've + // been passed as its private data. This way we can use the data + // directly + DEVTAB_ENTRY_NO_INIT(strdev, + "strdev", // Name + NULL, // Dependent name (layered device) + &devio_table, // I/O function table + NULL, // Init + NULL, // Lookup + &s); // private + Cyg_StdioStream my_stream( &strdev, Cyg_StdioStream::CYG_STREAM_WRITE, + false, false, _IONBF, 0, NULL ); + + rc = vfnprintf( (FILE *)&my_stream, size, format, arg ); + + // Null-terminate it, but note that s has been changed by str_write(), so + // that it now points to the end of the string + s[0] = '\0'; + + return rc; + +} // vsnprintf() + +#else + +externC int +vsnprintf( char *s, size_t size, const char *format, va_list arg ) +{ + int rc; + + Cyg_StdioStream my_stream( Cyg_StdioStream::CYG_STREAM_WRITE, + size, (cyg_uint8 *)s ); + + rc = vfnprintf( (FILE *)&my_stream, size, format, arg ); + + if( rc > 0 ) + s[rc] = '\0'; + + return rc; + +} // vsnprintf() + +#endif + +// EOF vsnprintf.cxx diff --git a/packages/language/c/libc/stdio/current/src/common/vsscanf.cxx b/packages/language/c/libc/stdio/current/src/common/vsscanf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/common/vsscanf.cxx @@ -0,0 +1,146 @@ +//=========================================================================== +// +// vsscanf.cxx +// +// ANSI Stdio vsscanf() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file +#include // error codes +#include // Device table +#include // Cyg_StdioStream + +#include // I/O system inlines + +#ifndef CYGPKG_LIBC_STDIO_FILEIO + +// FUNCTIONS + +static Cyg_ErrNo +str_read(cyg_stdio_handle_t handle, void *buf, cyg_uint32 *len) +{ + cyg_devtab_entry_t *dev = (cyg_devtab_entry_t *)handle; + cyg_uint8 *str_p = (cyg_uint8 *)dev->priv; + cyg_ucount32 i; + + // we set str_p to NULL further down when the string has finished being + // read + if (str_p == NULL) + { + *len = 0; + return ENOERR; + } // if + + // I suspect most strings passed to sprintf will be relatively short, + // so we just take the simple approach rather than have the overhead + // of calling memcpy etc. + + // copy string until run out of user space, or we reach its end + for (i = 0; i < *len ; ++i) + { + *((cyg_uint8 *)buf + i) = *str_p; + + if (*str_p++ == '\0') + { + str_p = NULL; + ++i; + break; + } // if + + } // for + + *len = i; + dev->priv = (void *)str_p; + + return ENOERR; + +} // str_read() + +static DEVIO_TABLE(devio_table, + NULL, // write + str_read, // read + NULL, // select + NULL, // get_config + NULL); // set_config + + +externC int +vsscanf( const char *s, const char *format, va_list arg ) +{ + // construct a fake device with the address of the string we've + // been passed as its private data. This way we can use the data + // directly + DEVTAB_ENTRY_NO_INIT(strdev, + "strdev", // Name + NULL, // Dependent name (layered device) + &devio_table, // I/O function table + NULL, // Init + NULL, // Lookup + (void *)s); // private + Cyg_StdioStream my_stream( &strdev, Cyg_StdioStream::CYG_STREAM_READ, + false, false, _IONBF, 0, NULL ); + + return vfscanf( (FILE *)&my_stream, format, arg ); + +} // vsscanf() + +#else + +externC int +vsscanf( const char *s, const char *format, va_list arg ) +{ + Cyg_StdioStream my_stream( Cyg_StdioStream::CYG_STREAM_READ, + strlen(s), (cyg_uint8 *)s ); + + return vfscanf( (FILE *)&my_stream, format, arg ); + +} // vsscanf() + +#endif + +// EOF vsscanf.cxx diff --git a/packages/language/c/libc/stdio/current/src/input/fgetc.cxx b/packages/language/c/libc/stdio/current/src/input/fgetc.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/input/fgetc.cxx @@ -0,0 +1,120 @@ +//=========================================================================== +// +// fgetc.cxx +// +// ISO C standard I/O get character functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: Provide the fgetc() function. Also provides the function +// version of getc() and getchar() +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // Standard eCos assertion support +#include // Standard eCos tracing support +#include // NULL and size_t from compiler +#include // header for this file +#include // error codes +#include // Cyg_StdioStream + +// FUNCTIONS + +externC int +fgetc( FILE *stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + cyg_ucount32 bytes_read; + Cyg_ErrNo err; + cyg_uint8 c; + + CYG_REPORT_FUNCNAMETYPE("fgetc", "returning char %d"); + CYG_REPORT_FUNCARG1XV( stream ); + + CYG_CHECK_DATA_PTR( stream, "stream is not a valid pointer" ); + + err = real_stream->read( &c, 1, &bytes_read ); + + // Why do we need this? Because the buffer might be empty. + if (!err && !bytes_read) { // if no err, but nothing to read, try again + err = real_stream->refill_read_buffer(); + if ( !err ) + err = real_stream->read( &c, 1, &bytes_read ); + } // if + + CYG_ASSERT( (ENOERR != err) || (1 == bytes_read), "Didn't read 1 byte!" ); + + if (err) + { + real_stream->set_error( err ); + errno = err; + CYG_REPORT_RETVAL(EOF); + return EOF; + } // if + + CYG_REPORT_RETVAL((int)c); + return (int)c; + +} // fgetc() + + +// Also define getc() even though it can be a macro. +// Undefine it first though +#undef getchar + +externC int +getchar( void ) +{ + return fgetc( stdin ); +} // getchar() + + +// EXPORTED SYMBOLS + +// Also define getc() even though it can be a macro. +// Undefine it first though +#undef getc + +externC int +getc( FILE * ) CYGBLD_ATTRIB_WEAK_ALIAS(fgetc); + +// EOF fgetc.cxx diff --git a/packages/language/c/libc/stdio/current/src/input/fgets.cxx b/packages/language/c/libc/stdio/current/src/input/fgets.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/input/fgets.cxx @@ -0,0 +1,89 @@ +//======================================================================== +// +// fgets.cxx +// +// ANSI Stdio fgets() function +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================= + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file +#include // error codes +#include // Cyg_StdioStream + +// FUNCTIONS + +externC char * +fgets( char *s, int n, FILE *stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + cyg_ucount32 bytes_read; + Cyg_ErrNo err; + + + err = real_stream->read( (cyg_uint8 *)s, n-1, &bytes_read ); + + if (!err && !bytes_read) { // if no err, but nothing to read, try again + err = real_stream->refill_read_buffer(); + if ( !err ) + err = real_stream->read( (cyg_uint8 *)s, n-1, &bytes_read ); + + } // if + + if (err) { + real_stream->set_error( err ); + errno = err; + return NULL; + } // if + + if (bytes_read > 0) + s[bytes_read]='\0'; // NULL terminate it + + return s; + +} // fgets() + +// EOF fgets.cxx diff --git a/packages/language/c/libc/stdio/current/src/input/fread.cxx b/packages/language/c/libc/stdio/current/src/input/fread.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/input/fread.cxx @@ -0,0 +1,101 @@ +//======================================================================== +// +// fread.cxx +// +// ANSI Stdio fread() function +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================= + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // Assertion support +#include // Tracing support +#include // NULL and size_t from compiler +#include // header for this file +#include // error codes +#include // Cyg_StdioStream + +// FUNCTIONS + +externC size_t +fread( void *ptr, size_t object_size, size_t num_objects, FILE *stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + cyg_ucount32 bytes_read; + Cyg_ErrNo err; + + + CYG_REPORT_FUNCNAMETYPE( "fread", "read %d objects" ); + CYG_REPORT_FUNCARG4( "ptr=%08x, object_size=%d, num_objects=%d, " + "stream=%08x", ptr, object_size, num_objects, + stream ); + + if ( (object_size==0) || (num_objects==0) ) { + CYG_REPORT_RETVAL(0); + return 0; + } // if + + err = real_stream->read( (cyg_uint8 *)ptr, object_size*num_objects, + &bytes_read ); + + if (!err && !bytes_read) { // if no err, but nothing to read, try again + err = real_stream->refill_read_buffer(); + if ( !err ) + err = real_stream->read( (cyg_uint8 *)ptr, object_size*num_objects, + &bytes_read ); + } // if + + if (err) { + real_stream->set_error( err ); + errno = err; + } // if + + // we return the number of _objects_ read. Simple division is + // sufficient as this returns the quotient rather than rounding + CYG_REPORT_RETVAL( bytes_read/object_size ); + return bytes_read/object_size; + +} // fread() + +// EOF fread.cxx diff --git a/packages/language/c/libc/stdio/current/src/input/fscanf.cxx b/packages/language/c/libc/stdio/current/src/input/fscanf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/input/fscanf.cxx @@ -0,0 +1,73 @@ +//=========================================================================== +// +// fscanf.cxx +// +// ANSI Stdio fscanf() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file +#include // INT_MAX + +// FUNCTIONS + +externC int +fscanf( FILE *stream, const char *format, ... ) +{ + int rc; // return code + va_list ap; // for variable args + + va_start(ap, format); // init specifying last non-var arg + + rc = vfscanf( stream, format, ap ); + + va_end(ap); // end var args + + return rc; +} // fscanf() + +// EOF fscanf.cxx diff --git a/packages/language/c/libc/stdio/current/src/input/gets.cxx b/packages/language/c/libc/stdio/current/src/input/gets.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/input/gets.cxx @@ -0,0 +1,97 @@ +//=========================================================================== +// +// gets.cxx +// +// ANSI Stdio gets() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1998-02-13 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file +#include // error codes +#include // UINT_MAX +#include // Cyg_StdioStream + +// FUNCTIONS + +externC char * +gets( char *s ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stdin; + cyg_ucount32 bytes_read; + Cyg_ErrNo err; + + + err = real_stream->read( (cyg_uint8 *)s, UINT_MAX, &bytes_read ); + + if (!err && !bytes_read) // if no err, but nothing to read, try again + { + real_stream->refill_read_buffer(); + err = real_stream->read( (cyg_uint8 *)s, UINT_MAX, &bytes_read ); + + } // if + + if (err) + { + real_stream->set_error( err ); + errno = err; + return NULL; + } // if + + if (bytes_read > 0) + { + // NULL terminate it + if (s[bytes_read-1] == '\n') + s[bytes_read-1] = '\0'; + else + s[bytes_read]='\0'; + } // if + + return s; + +} // gets() + +// EOF gets.cxx diff --git a/packages/language/c/libc/stdio/current/src/input/scanf.cxx b/packages/language/c/libc/stdio/current/src/input/scanf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/input/scanf.cxx @@ -0,0 +1,73 @@ +//=========================================================================== +// +// scanf.cxx +// +// ANSI Stdio scanf() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file + +// FUNCTIONS + + +externC int +scanf( const char *format, ... ) +{ + int rc; // return code + va_list ap; // for variable args + + va_start(ap, format); // init specifying last non-var arg + + rc = vfscanf( stdin, format, ap ); + + va_end(ap); // end var args + + return rc; +} // scanf() + +// EOF scanf.cxx diff --git a/packages/language/c/libc/stdio/current/src/input/vfscanf.cxx b/packages/language/c/libc/stdio/current/src/input/vfscanf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/input/vfscanf.cxx @@ -0,0 +1,964 @@ +//======================================================================== +// +// vfscanf.cxx +// +// I/O routines for vfscanf() for use with ANSI C library +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== +// +// This code is based on original code with the following copyright: +// +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + + +// CONFIGURATION + +#include // Configuration header + +// We have to have ungetc for this to work +#if defined(CYGFUN_LIBC_STDIO_ungetc) + + +// INCLUDES + +#include // Common type definitions and support +#include // Variable argument definitions +#include // Standard header for all stdio files +#include // isspace() and isupper() +#include // standard utility functions e.g. strtol +#include // C library streams + +#ifdef CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + +#include + +# define MAXFRACT DBL_DIG +# define MAXEXP DBL_MAX_10_EXP + +# define BUF (MAXEXP+MAXFRACT+3) /* 3 = sign + decimal point + NUL */ + +#else // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + +# define BUF 40 + +#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + +/* + * Flags used during conversion. + */ + +#define LONG 0x01 /* l: long or double */ +#define LONGDBL 0x02 /* L: long double; unimplemented */ +#define SHORT 0x04 /* h: short */ +#define SUPPRESS 0x08 /* suppress assignment */ +#define POINTER 0x10 /* weird %p pointer (`fake hex') */ +#define NOSKIP 0x20 /* do not skip blanks */ + +/* + * The following are used in numeric conversions only: + * SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point; + * SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral. + */ + +#define SIGNOK 0x40 /* +/- is (still) legal */ +#define NDIGITS 0x80 /* no digits detected */ + +#define DPTOK 0x100 /* (float) decimal point is still legal */ +#define EXPOK 0x200 /* (float) exponent (e+3, etc) still + legal */ + +#define PFXOK 0x100 /* 0x prefix is (still) legal */ +#define NZDIGITS 0x200 /* no zero digits detected */ + +/* + * Conversion types. + */ + +#define CT_CHAR 0 /* %c conversion */ +#define CT_CCL 1 /* %[...] conversion */ +#define CT_STRING 2 /* %s conversion */ +#define CT_INT 3 /* integer, i.e., strtol or strtoul */ +#define CT_FLOAT 4 /* floating, i.e., strtod */ + +#if 0 +#define u_char unsigned char +#endif +#define u_char char +#define u_long unsigned long + +typedef unsigned long (*strtoul_t)(const char *, char **endptr, int base); + +static u_char * +__sccl (char *tab, u_char *fmt); + + +/* + * vfscanf + */ + +#define _CAST_VOID + +#define CURR_POS (file->peek_byte( (cyg_uint8 *)&curr_byte),&curr_byte ) + +#define INC_CURR_POS ( file->read_byte( (cyg_uint8 *)&curr_byte ) ) + +#define MOVE_CURR_POS(x) (file->set_position( (x), SEEK_CUR )) + +#define SPACE_LEFT (file->bytes_available_to_read()) + +#define REFILL (file->refill_read_buffer()) + +#define BufferEmpty ( !SPACE_LEFT && \ + (REFILL, (!SPACE_LEFT)) ) + +externC int +vfscanf (FILE *fp, const char *fmt0, va_list ap) +{ + u_char *fmt = (u_char *) fmt0; + int c; /* character from format, or conversion */ + size_t width; /* field width, or 0 */ + char *p; /* points into all kinds of strings */ + int n; /* handy integer */ + int flags; /* flags as defined above */ + char *p0; /* saves original value of p when necessary */ + int nassigned; /* number of fields assigned */ + int nread; /* number of characters consumed from fp */ + int base = 0; /* base argument to strtol/strtoul */ + + strtoul_t ccfn = NULL; /* conversion function (strtol/strtoul) */ + char ccltab[256]; /* character class table for %[...] */ + char buf[BUF]; /* buffer for numeric conversions */ + + Cyg_StdioStream *file = (Cyg_StdioStream *)fp; + char curr_byte; + + short *sp; + int *ip; + float *flp; + long double *ldp; + double *dp; + long *lp; + + /* `basefix' is used to avoid `if' tests in the integer scanner */ + static const short basefix[17] = + {10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + + nassigned = 0; + nread = 0; + for (;;) + { + c = *fmt++; + if (c == 0) + return nassigned; + if (isspace (c)) + { + for (;;) + { + if (BufferEmpty) + return nassigned; + if (!isspace (*CURR_POS)) + break; + nread++, INC_CURR_POS; + } + continue; + } + if (c != '%') + goto literal; + width = 0; + flags = 0; + + /* + * switch on the format. continue if done; break once format + * type is derived. + */ + +again: + c = *fmt++; + + switch (c) + { + case '%': +literal: + if (BufferEmpty) + goto input_failure; + if (*CURR_POS != c) + goto match_failure; + INC_CURR_POS; + nread++; + continue; + + case '*': + flags |= SUPPRESS; + goto again; + case 'l': + flags |= LONG; + goto again; + case 'L': + flags |= LONGDBL; + goto again; + case 'h': + flags |= SHORT; + goto again; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + width = width * 10 + c - '0'; + goto again; + + /* + * Conversions. Those marked `compat' are for + * 4.[123]BSD compatibility. + * + * (According to ANSI, E and X formats are supposed to + * the same as e and x. Sorry about that.) + */ + + case 'D': /* compat */ + flags |= LONG; + /* FALLTHROUGH */ + case 'd': + c = CT_INT; + ccfn = (strtoul_t)strtol; + base = 10; + break; + + case 'i': + c = CT_INT; + ccfn = (strtoul_t)strtol; + base = 0; + break; + + case 'O': /* compat */ + flags |= LONG; + /* FALLTHROUGH */ + case 'o': + c = CT_INT; + ccfn = strtoul; + base = 8; + break; + + case 'u': + c = CT_INT; + ccfn = strtoul; + base = 10; + break; + + case 'X': /* compat XXX */ + case 'x': + flags |= PFXOK; /* enable 0x prefixing */ + c = CT_INT; + ccfn = strtoul; + base = 16; + break; + + case 'E': /* compat XXX */ + case 'G': /* compat XXX */ +/* ANSI says that E,G and X behave the same way as e,g,x */ + /* FALLTHROUGH */ + case 'e': + case 'f': + case 'g': + c = CT_FLOAT; + break; + + case 's': + c = CT_STRING; + break; + + case '[': + fmt = __sccl (ccltab, fmt); + flags |= NOSKIP; + c = CT_CCL; + break; + + case 'c': + flags |= NOSKIP; + c = CT_CHAR; + break; + + case 'p': /* pointer format is like hex */ + flags |= POINTER | PFXOK; + c = CT_INT; + ccfn = strtoul; + base = 16; + break; + + case 'n': + if (flags & SUPPRESS) /* ??? */ + continue; + if (flags & SHORT) + { + sp = va_arg (ap, short *); + *sp = nread; + } + else if (flags & LONG) + { + lp = va_arg (ap, long *); + *lp = nread; + } + else + { + ip = va_arg (ap, int *); + *ip = nread; + } + continue; + + /* + * Disgusting backwards compatibility hacks. XXX + */ + case '\0': /* compat */ + return EOF; + + default: /* compat */ + if (isupper (c)) + flags |= LONG; + c = CT_INT; + ccfn = (strtoul_t)strtol; + base = 10; + break; + } + + /* + * We have a conversion that requires input. + */ + if (BufferEmpty) + goto input_failure; + + /* + * Consume leading white space, except for formats that + * suppress this. + */ + if ((flags & NOSKIP) == 0) + { + while (isspace (*CURR_POS)) + { + nread++; + INC_CURR_POS; + if (SPACE_LEFT == 0) +#ifndef REDHAT_NEC + if (REFILL) +#endif + goto input_failure; + } + /* + * Note that there is at least one character in the + * buffer, so conversions that do not set NOSKIP ca + * no longer result in an input failure. + */ + } + + /* + * Do the conversion. + */ + switch (c) + { + + case CT_CHAR: + /* scan arbitrary characters (sets NOSKIP) */ + if (width == 0) + width = 1; + if (flags & SUPPRESS) + { + size_t sum = 0; + + for (;;) + { + if ((n = SPACE_LEFT) < (signed)width) + { + sum += n; + width -= n; + MOVE_CURR_POS(n-1); + INC_CURR_POS; +#ifndef REDHAT_NEC + if (REFILL) + { +#endif + if (sum == 0) + goto input_failure; + break; +#ifndef REDHAT_NEC + } +#endif + } + else + { + sum += width; + MOVE_CURR_POS(width - 1); + INC_CURR_POS; + break; + } + } + nread += sum; + } + else + { + /* Kludge city for the moment */ + char *dest = va_arg (ap, char *); + int n = width; + if (SPACE_LEFT == 0) +#ifndef REDHAT_NEC + if (REFILL) +#endif + goto input_failure; + + while (n && !BufferEmpty) + { + *dest++ = *CURR_POS; + INC_CURR_POS; + n--; + nread++; + } + nassigned++; + } + break; + + case CT_CCL: + /* scan a (nonempty) character class (sets NOSKIP) */ + if (width == 0) + width = ~0; /* `infinity' */ + /* take only those things in the class */ + if (flags & SUPPRESS) + { + n = 0; + while (ccltab[*CURR_POS]) + { + n++, INC_CURR_POS; + if (--width == 0) + break; + if (BufferEmpty) + { + if (n == 0) + goto input_failure; + break; + } + } + if (n == 0) + goto match_failure; + } + else + { + p0 = p = va_arg (ap, char *); + while (ccltab[*CURR_POS]) + { + *p++ = *CURR_POS; + INC_CURR_POS; + if (--width == 0) + break; + if (BufferEmpty) + { + if (p == p0) + goto input_failure; + break; + } + } + n = p - p0; + if (n == 0) + goto match_failure; + *p = 0; + nassigned++; + } + nread += n; + break; + + case CT_STRING: + /* like CCL, but zero-length string OK, & no NOSKIP */ + if (width == 0) + width = ~0; + if (flags & SUPPRESS) + { + n = 0; + while (!isspace (*CURR_POS)) + { + n++, INC_CURR_POS; + if (--width == 0) + break; + if (BufferEmpty) + break; + } + nread += n; + } + else + { + p0 = p = va_arg (ap, char *); + while (!isspace (*CURR_POS)) + { + *p++ = *CURR_POS; + INC_CURR_POS; + if (--width == 0) + break; + if (BufferEmpty) + break; + } + *p = 0; + nread += p - p0; + nassigned++; + } + continue; + + case CT_INT: + /* scan an integer as if by strtol/strtoul */ +#ifdef hardway + if (width == 0 || width > sizeof (buf) - 1) + width = sizeof (buf) - 1; +#else + /* size_t is unsigned, hence this optimisation */ + if (--width > sizeof (buf) - 2) + width = sizeof (buf) - 2; + width++; +#endif + flags |= SIGNOK | NDIGITS | NZDIGITS; + for (p = buf; width; width--) + { + c = *CURR_POS; + /* + * Switch on the character; `goto ok' if we + * accept it as a part of number. + */ + switch (c) + { + /* + * The digit 0 is always legal, but is special. + * For %i conversions, if no digits (zero or nonzero) + * have been scanned (only signs), we will have base==0 + * In that case, we should set it to 8 and enable 0x + * prefixing. Also, if we have not scanned zero digits + * before this, do not turn off prefixing (someone else + * will turn it off if we have scanned any nonzero + * digits). + */ + case '0': + if (base == 0) + { + base = 8; + flags |= PFXOK; + } + if (flags & NZDIGITS) + flags &= ~(SIGNOK | NZDIGITS | NDIGITS); + else + flags &= ~(SIGNOK | PFXOK | NDIGITS); + goto ok; + + /* 1 through 7 always legal */ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + base = basefix[base]; + flags &= ~(SIGNOK | PFXOK | NDIGITS); + goto ok; + + /* digits 8 and 9 ok iff decimal or hex */ + case '8': + case '9': + base = basefix[base]; + if (base <= 8) + break; /* not legal here */ + flags &= ~(SIGNOK | PFXOK | NDIGITS); + goto ok; + + /* letters ok iff hex */ + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + /* no need to fix base here */ + if (base <= 10) + break; /* not legal here */ + flags &= ~(SIGNOK | PFXOK | NDIGITS); + goto ok; + + /* sign ok only as first character */ + case '+': + case '-': + if (flags & SIGNOK) + { + flags &= ~SIGNOK; + goto ok; + } + break; + + /* x ok iff flag still set & 2nd char */ + case 'x': + case 'X': + if (flags & PFXOK && p == buf + 1) + { + base = 16;/* if %i */ + flags &= ~PFXOK; + goto ok; + } + break; + } + + /* + * If we got here, c is not a legal character + * for a number. Stop accumulating digits. + */ + break; + ok: + /* + * c is legal: store it and look at the next. + */ + *p++ = c; + INC_CURR_POS; + if (SPACE_LEFT == 0) +#ifndef REDHAT_NEC + if (REFILL) +#endif + break; /* EOF */ + } + /* + * If we had only a sign, it is no good; push back the sign. + * If the number ends in `x', it was [sign] '0' 'x', so push + * back the x and treat it as [sign] '0'. + */ + if (flags & NDIGITS) + { + if (p > buf) + _CAST_VOID ungetc (*(u_char *)-- p, fp); + goto match_failure; + } + c = ((u_char *) p)[-1]; + if (c == 'x' || c == 'X') + { + --p; + /*(void)*/ ungetc (c, fp); + } + if ((flags & SUPPRESS) == 0) + { + u_long res; + + *p = 0; + res = (*ccfn) (buf, (char **) NULL, base); + if (flags & POINTER) + *(va_arg (ap, char **)) = (char *) (CYG_ADDRESS) res; + else if (flags & SHORT) + { + sp = va_arg (ap, short *); + *sp = res; + } + else if (flags & LONG) + { + lp = va_arg (ap, long *); + *lp = res; + } + else + { + ip = va_arg (ap, int *); + *ip = res; + } + nassigned++; + } + nread += p - buf; + break; + + case CT_FLOAT: + /* scan a floating point number as if by strtod */ + +#ifdef hardway + if (width == 0 || width > sizeof (buf) - 1) + width = sizeof (buf) - 1; +#else + /* size_t is unsigned, hence this optimisation */ + if (--width > sizeof (buf) - 2) + width = sizeof (buf) - 2; + width++; +#endif // ifdef hardway + + flags |= SIGNOK | NDIGITS | DPTOK | EXPOK; + for (p = buf; width; width--) + { + c = *CURR_POS; + /* + * This code mimicks the integer conversion + * code, but is much simpler. + */ + switch (c) + { + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + flags &= ~(SIGNOK | NDIGITS); + goto fok; + + case '+': + case '-': + if (flags & SIGNOK) + { + flags &= ~SIGNOK; + goto fok; + } + break; + case '.': + if (flags & DPTOK) + { + flags &= ~(SIGNOK | DPTOK); + goto fok; + } + break; + case 'e': + case 'E': + /* no exponent without some digits */ + if ((flags & (NDIGITS | EXPOK)) == EXPOK) + { + flags = + (flags & ~(EXPOK | DPTOK)) | + SIGNOK | NDIGITS; + goto fok; + } + break; + } + break; + fok: + *p++ = c; + INC_CURR_POS; + if (SPACE_LEFT == 0) +#ifndef REDHAT_NEC + if (REFILL) +#endif + break; /* EOF */ + } + /* + * If no digits, might be missing exponent digits + * (just give back the exponent) or might be missing + * regular digits, but had sign and/or decimal point. + */ + if (flags & NDIGITS) + { + if (flags & EXPOK) + { + /* no digits at all */ + while (p > buf) + ungetc (*(u_char *)-- p, fp); + goto match_failure; + } + /* just a bad exponent (e and maybe sign) */ + c = *(u_char *)-- p; + if (c != 'e' && c != 'E') + { + _CAST_VOID ungetc (c, fp); /* sign */ + c = *(u_char *)-- p; + } + _CAST_VOID ungetc (c, fp); + } + if ((flags & SUPPRESS) == 0) + { + double res; + + *p = 0; +#ifdef CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + res = atof (buf); +#else + res = 0.0; +#endif + if (flags & LONG) + { + dp = va_arg (ap, double *); + *dp = res; + } + else if (flags & LONGDBL) + { + ldp = va_arg (ap, long double *); + *ldp = res; + } + else + { + flp = va_arg (ap, float *); + *flp = res; + } + nassigned++; + } + nread += p - buf; + break; + } + } + +input_failure: + return nassigned ? nassigned : -1; +match_failure: + return nassigned; +} // vfscanf() + +/* + * Fill in the given table from the scanset at the given format + * (just after `['). Return a pointer to the character past the + * closing `]'. The table has a 1 wherever characters should be + * considered part of the scanset. + */ + +/*static*/ +u_char * +__sccl (char *tab, u_char *fmt) +{ + int c, n, v; + + /* first `clear' the whole table */ + c = *fmt++; /* first char hat => negated scanset */ + if (c == '^') + { + v = 1; /* default => accept */ + c = *fmt++; /* get new first char */ + } + else + v = 0; /* default => reject */ + /* should probably use memset here */ + for (n = 0; n < 256; n++) + tab[n] = v; + if (c == 0) + return fmt - 1; /* format ended before closing ] */ + + /* + * Now set the entries corresponding to the actual scanset to the + * opposite of the above. + * + * The first character may be ']' (or '-') without being special; the + * last character may be '-'. + */ + + v = 1 - v; + for (;;) + { + tab[c] = v; /* take character c */ + doswitch: + n = *fmt++; /* and examine the next */ + switch (n) + { + + case 0: /* format ended too soon */ + return fmt - 1; + + case '-': + /* + * A scanset of the form [01+-] is defined as `the digit 0, the + * digit 1, the character +, the character -', but the effect + * of a scanset such as [a-zA-Z0-9] is implementation defined. + * The V7 Unix scanf treats `a-z' as `the letters a through z', + * but treats `a-a' as `the letter a, the character -, and the + * letter a'. + * + * For compatibility, the `-' is not considerd to define a + * range if the character following it is either a close + * bracket (required by ANSI) or is not numerically greater + * than the character we just stored in the table (c). + */ + n = *fmt; + if (n == ']' || n < c) + { + c = '-'; + break; /* resume the for(;;) */ + } + fmt++; + do + { /* fill in the range */ + tab[++c] = v; + } + while (c < n); +#if 1 /* XXX another disgusting compatibility hack */ + /* + * Alas, the V7 Unix scanf also treats formats such + * as [a-c-e] as `the letters a through e'. This too + * is permitted by the standard.... + */ + goto doswitch; +#else + c = *fmt++; + if (c == 0) + return fmt - 1; + if (c == ']') + return fmt; +#endif + + break; + + + case ']': /* end of scanset */ + return fmt; + + default: /* just another character */ + c = n; + break; + } + } + /* NOTREACHED */ +} // __sccl() + +#endif // if defined(CYGFUN_LIBC_STDIO_ungetc) + +// EOF vfscanf.cxx diff --git a/packages/language/c/libc/stdio/current/src/output/fnprintf.cxx b/packages/language/c/libc/stdio/current/src/output/fnprintf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/output/fnprintf.cxx @@ -0,0 +1,72 @@ +//=========================================================================== +// +// fnprintf.cxx +// +// ANSI Stdio fnprintf() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file + +// FUNCTIONS + +externC int +fnprintf( FILE *stream, size_t size, const char *format, ... ) +{ + int rc; // return code + va_list ap; // for variable args + + va_start(ap, format); // init specifying last non-var arg + + rc = vfnprintf(stream, size, format, ap); + + va_end(ap); // end var args + + return rc; +} // fnprintf() + +// EOF fnprintf.cxx diff --git a/packages/language/c/libc/stdio/current/src/output/fprintf.cxx b/packages/language/c/libc/stdio/current/src/output/fprintf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/output/fprintf.cxx @@ -0,0 +1,73 @@ +//=========================================================================== +// +// fprintf.cxx +// +// ANSI Stdio fprintf() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file +#include // INT_MAX + +// FUNCTIONS + +externC int +fprintf( FILE *stream, const char *format, ... ) +{ + int rc; // return code + va_list ap; // for variable args + + va_start(ap, format); // init specifying last non-var arg + + rc = vfnprintf(stream, INT_MAX, format, ap); + + va_end(ap); // end var args + + return rc; +} // fprintf() + +// EOF fprintf.cxx diff --git a/packages/language/c/libc/stdio/current/src/output/fputc.cxx b/packages/language/c/libc/stdio/current/src/output/fputc.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/output/fputc.cxx @@ -0,0 +1,107 @@ +//=========================================================================== +// +// fputc.cxx +// +// ISO Standard I/O character output functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: Provide the fputc() function. Also provides the function +// versions of putc() and putchar() +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // Standard eCos assertion support +#include // Standard eCos tracing support +#include // NULL and size_t from compiler +#include // header for this file +#include // error codes +#include // Cyg_StdioStream + +// FUNCTIONS + +externC int +fputc( int c, FILE *stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + Cyg_ErrNo err; + cyg_uint8 real_c = (cyg_uint8) c; + + CYG_REPORT_FUNCNAMETYPE("fputc", "wrote char %d"); + CYG_REPORT_FUNCARG2( "c = %d, stream=%08x", c, stream ); + + CYG_CHECK_DATA_PTR( stream, "stream is not a valid pointer" ); + + err = real_stream->write_byte( real_c ); + + if (err) + { + real_stream->set_error( err ); + errno = err; + CYG_REPORT_RETVAL(EOF); + return EOF; + } // if + + CYG_REPORT_RETVAL((int)real_c); + return (int)real_c; + +} // fputc() + + +// Also define putchar() even though it can be a macro. +// Undefine the macro first though +#undef putchar + +externC int +putchar( int c ) +{ + return fputc( c, stdout ); +} // putchar() + +// Also define putc() even though it can be a macro. +// Undefine the macro first though +#undef putc + +externC int +putc( int, FILE * ) CYGBLD_ATTRIB_WEAK_ALIAS(fputc); + +// EOF fputc.cxx diff --git a/packages/language/c/libc/stdio/current/src/output/fputs.cxx b/packages/language/c/libc/stdio/current/src/output/fputs.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/output/fputs.cxx @@ -0,0 +1,81 @@ +//======================================================================== +// +// fputs.cxx +// +// ANSI Stdio fputs() function +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file +#include // error codes +#include // Cyg_StdioStream +#include // strlen() + +// FUNCTIONS + +externC int +fputs( const char *s, FILE *stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + cyg_ucount32 size = strlen(s); + cyg_ucount32 written; + Cyg_ErrNo err; + + err = real_stream->write( (cyg_uint8 *)s, size, &written ); + + if (err) { + real_stream->set_error( err ); + errno = err; + return EOF; + } // if + + + return written; + +} // fputs() + +// EOF fputs.cxx diff --git a/packages/language/c/libc/stdio/current/src/output/fwrite.cxx b/packages/language/c/libc/stdio/current/src/output/fwrite.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/output/fwrite.cxx @@ -0,0 +1,94 @@ +//======================================================================== +// +// fwrite.cxx +// +// ANSI Stdio fwrite() function +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // Assertion support +#include // Tracing support +#include // NULL and size_t from compiler +#include // header for this file +#include // error codes +#include // Cyg_StdioStream + +// FUNCTIONS + +externC size_t +fwrite( const void *ptr, size_t object_size, size_t num_objects, + FILE *stream ) +{ + Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream; + cyg_ucount32 written; + Cyg_ErrNo err; + + CYG_REPORT_FUNCNAMETYPE( "fwrite", "wrote %d objects" ); + CYG_REPORT_FUNCARG4( "ptr=%08x, object_size=%d, num_objects=%d, " + "stream=%08x", ptr, object_size, num_objects, + stream ); + + if ( (object_size==0) || (num_objects==0) ) { + CYG_REPORT_RETVAL(0); + return 0; + } // if + + err = real_stream->write( (cyg_uint8 *)ptr, num_objects*object_size, + &written ); + + if (err) { + real_stream->set_error( err ); + errno = err; + } // if + + // we return the number of _objects_ written. Simple division is + // sufficient as this returns the quotient rather than rounding + + CYG_REPORT_RETVAL( written/object_size ); + return written/object_size; +} // fwrite() + +// EOF fwrite.cxx diff --git a/packages/language/c/libc/stdio/current/src/output/printf.cxx b/packages/language/c/libc/stdio/current/src/output/printf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/output/printf.cxx @@ -0,0 +1,73 @@ +//=========================================================================== +// +// printf.cxx +// +// ANSI Stdio printf() function +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common project-wide type definitions +#include // NULL and size_t from compiler +#include // header for this file +#include // INT_MAX + +// FUNCTIONS + +externC int +printf( const char *format, ... ) +{ + int rc; // return code + va_list ap; // for variable args + + va_start(ap, format); // init specifying last non-var arg + + rc = vfnprintf(stdout, INT_MAX, format, ap); + + va_end(ap); // end var args + + return rc; +} // printf() + +// EOF printf.cxx diff --git a/packages/language/c/libc/stdio/current/src/output/vfnprintf.cxx b/packages/language/c/libc/stdio/current/src/output/vfnprintf.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/src/output/vfnprintf.cxx @@ -0,0 +1,920 @@ +//=========================================================================== +// +// vfnprintf.c +// +// I/O routines for vfnprintf() for use with ANSI C library +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== +// +// This code is based on original code with the following copyright: +// +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // Variable argument definitions +#include // Standard header for all stdio files +#include // memchr() and strlen() functions +#include // C library streams + +#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + +# include // for DBL_DIG etc. below +# include // for modf() +# include // Cyg_libm_ieee_double_shape_type + +# define MAXFRACT DBL_DIG +# define MAXEXP DBL_MAX_10_EXP + +# define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */ +# define DEFPREC 6 + +static int +cvt( double, int, int, char *, int, char *, char * ); + +#else // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + +# define BUF 40 + +#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + +/* + * Actual printf innards. + * + * This code is large and complicated... + */ + + + +/* + * Macros for converting digits to letters and vice versa + */ +#define to_digit(c) ((c) - '0') +#define is_digit(c) ((unsigned)to_digit(c) <= 9) +#define to_char(n) ((n) + '0') + +/* + * Flags used during conversion. + */ +#define ALT 0x001 /* alternate form */ +#define HEXPREFIX 0x002 /* add 0x or 0X prefix */ +#define LADJUST 0x004 /* left adjustment */ +#define LONGDBL 0x008 /* long double; unimplemented */ +#define LONGINT 0x010 /* long integer */ +#define QUADINT 0x020 /* quad integer */ +#define SHORTINT 0x040 /* short integer */ +#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */ +#define FPT 0x100 /* Floating point number */ + +static int +__mbtowc(char *pwc, const char *s, size_t n) +{ + if (s == NULL) + return 0; + if (n == 0) + return -1; + if (pwc) + *pwc = (char) *s; + return (*s != '\0'); +} + +externC int +vfnprintf ( FILE *stream, size_t n, const char *format, va_list arg) +{ + char *fmt; /* format string */ + int ch; /* character from fmt */ + int x, y; /* handy integers (short term usage) */ + char *cp; /* handy char pointer (short term usage) */ + int flags; /* flags as above */ + int ret; /* return value accumulator */ + int width; /* width from format (%8d), or 0 */ + int prec; /* precision from format (%.3d), or -1 */ + char sign; /* sign prefix (' ', '+', '-', or \0) */ + char wc; + +#define quad_t long long +#define u_quad_t unsigned long long + + u_quad_t _uquad; /* integer arguments %[diouxX] */ + enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */ + int dprec; /* a copy of prec if [diouxX], 0 otherwise */ + int fieldsz; /* field size expanded by sign, etc */ + int realsz; /* field size expanded by dprec */ + int size; /* size of converted field or string */ + char *xdigs; /* digits for [xX] conversion */ +#define NIOV 8 + char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ + char ox[2]; /* space for 0x hex-prefix */ +#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + char softsign; /* temporary negative sign for floats */ + double _double; /* double precision arguments %[eEfgG] */ + int fpprec; /* `extra' floating precision in [eEfgG] */ +#endif + + /* + * Choose PADSIZE to trade efficiency vs. size. If larger printf + * fields occur frequently, increase PADSIZE and make the initialisers + * below longer. + */ +#define PADSIZE 16 /* pad chunk size */ + static char blanks[PADSIZE] = + {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}; + static char zeroes[PADSIZE] = + {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + + /* + * BEWARE, these `goto error' on error, and PAD uses `n'. + */ +#define PRINT(ptr, len) \ +CYG_MACRO_START \ + cyg_ucount32 length = MIN( (cyg_ucount32) len, n - ret - 1); \ + if (((Cyg_StdioStream *)stream)->write( (const cyg_uint8 *)ptr, \ + length, &length )) \ + goto error; \ + if (length < (cyg_ucount32)len) { \ + ret += length; \ + goto done; \ + } \ +CYG_MACRO_END + + +#define PAD(howmany, with) \ +CYG_MACRO_START \ + if ((x = (howmany)) > 0) { \ + while (x > PADSIZE) { \ + PRINT(with, PADSIZE); \ + x -= PADSIZE; \ + } \ + PRINT(with, x); \ + } \ +CYG_MACRO_END + + /* + * To extend shorts properly, we need both signed and unsigned + * argument extraction methods. + */ + +#define SARG() \ + (flags&QUADINT ? va_arg(arg, cyg_int64) : \ + flags&LONGINT ? va_arg(arg, cyg_int32) : \ + flags&SHORTINT ? (long)va_arg(arg, cyg_int32) : \ + (long)va_arg(arg, cyg_int32)) +#define UARG() \ + (flags&QUADINT ? va_arg(arg, cyg_uint64) : \ + flags&LONGINT ? va_arg(arg, cyg_uint32) : \ + flags&SHORTINT ? (unsigned long)va_arg(arg, cyg_uint32) : \ + (unsigned long)va_arg(arg, cyg_uint32)) + + + xdigs = NULL; // stop compiler whinging + fmt = (char *)format; + ret = 0; + + /* + * Scan the format for conversions (`%' character). + */ + for (;;) { + cp = (char *)fmt; + while ((x = __mbtowc(&wc, fmt, 1)) > 0) { + fmt += x; + if (wc == '%') { + fmt--; + break; + } + } + if ((y = fmt - cp) != 0) { + PRINT(cp, y); + ret += y; + } + if ((x <= 0) || (ret >= (int)n)) // @@@ this check with n isn't good enough + goto done; + fmt++; /* skip over '%' */ + + flags = 0; + dprec = 0; +#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + fpprec = 0; +#endif + width = 0; + prec = -1; + sign = '\0'; + +rflag: ch = *fmt++; +reswitch: switch (ch) { + case ' ': + /* + * ``If the space and + flags both appear, the space + * flag will be ignored.'' + * -- ANSI X3J11 + */ + if (!sign) + sign = ' '; + goto rflag; + case '#': + flags |= ALT; + goto rflag; + case '*': + /* + * ``A negative field width argument is taken as a + * - flag followed by a positive field width.'' + * -- ANSI X3J11 + * They don't exclude field widths read from args. + */ + if ((width = va_arg(arg, int)) >= 0) + goto rflag; + width = -width; + /* FALLTHROUGH */ + case '-': + flags |= LADJUST; + goto rflag; + case '+': + sign = '+'; + goto rflag; + case '.': + if ((ch = *fmt++) == '*') { + x = va_arg(arg, int); + prec = x < 0 ? -1 : x; + goto rflag; + } + x = 0; + while (is_digit(ch)) { + x = 10 * x + to_digit(ch); + ch = *fmt++; + } + prec = x < 0 ? -1 : x; + goto reswitch; + case '0': + /* + * ``Note that 0 is taken as a flag, not as the + * beginning of a field width.'' + * -- ANSI X3J11 + */ + flags |= ZEROPAD; + goto rflag; + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + x = 0; + do { + x = 10 * x + to_digit(ch); + ch = *fmt++; + } while (is_digit(ch)); + width = x; + goto reswitch; +#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + case 'L': + flags |= LONGDBL; + goto rflag; +#endif + case 'h': + flags |= SHORTINT; + goto rflag; + case 'l': + if (*fmt == 'l') { + fmt++; + flags |= QUADINT; + } else { + flags |= LONGINT; + } + goto rflag; + case 'q': + flags |= QUADINT; + goto rflag; + case 'c': + *(cp = buf) = va_arg(arg, int); + size = 1; + sign = '\0'; + break; + case 'D': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'd': + case 'i': + _uquad = SARG(); +#ifndef _NO_LONGLONG + if ((quad_t)_uquad < 0) +#else + if ((long) _uquad < 0) +#endif + { + + _uquad = -_uquad; + sign = '-'; + } + base = DEC; + goto number; + +#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': + _double = va_arg(arg, double); + /* + * don't do unrealistic precision; just pad it with + * zeroes later, so buffer size stays rational. + */ + if (prec > MAXFRACT) { + if ((ch != 'g' && ch != 'G') || (flags&ALT)) + fpprec = prec - MAXFRACT; + prec = MAXFRACT; + } else if (prec == -1) + prec = DEFPREC; + /* + * cvt may have to round up before the "start" of + * its buffer, i.e. ``intf("%.2f", (double)9.999);''; + * if the first character is still NUL, it did. + * softsign avoids negative 0 if _double < 0 but + * no significant digits will be shown. + */ + cp = buf; + *cp = '\0'; + size = cvt(_double, prec, flags, &softsign, ch, + cp, buf + sizeof(buf)); + if (softsign) + sign = '-'; + if (*cp == '\0') + cp++; + break; +#else + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': + // Output nothing at all + (void) va_arg(arg, double); // take off arg anyway + cp = ""; + size = 0; + sign = '\0'; + break; + + +#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + + case 'n': +#ifndef _NO_LONGLONG + if (flags & QUADINT) + *va_arg(arg, quad_t *) = ret; + else +#endif + if (flags & LONGINT) + *va_arg(arg, long *) = ret; + else if (flags & SHORTINT) + *va_arg(arg, short *) = ret; + else + *va_arg(arg, int *) = ret; + continue; /* no output */ + case 'O': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'o': + _uquad = UARG(); + base = OCT; + goto nosign; + case 'p': + /* + * ``The argument shall be a pointer to void. The + * value of the pointer is converted to a sequence + * of printable characters, in an implementation- + * defined manner.'' + * -- ANSI X3J11 + */ + /* NOSTRICT */ + _uquad = (unsigned long)va_arg(arg, void *); + base = HEX; + xdigs = "0123456789abcdef"; + flags |= HEXPREFIX; + ch = 'x'; + goto nosign; + case 's': + if ((cp = va_arg(arg, char *)) == NULL) + cp = "(null)"; + if (prec >= 0) { + /* + * can't use strlen; can only look for the + * NUL in the first `prec' characters, and + * strlen() will go further. + */ + char *p = (char *)memchr(cp, 0, prec); + + if (p != NULL) { + size = p - cp; + if (size > prec) + size = prec; + } else + size = prec; + } else + size = strlen(cp); + sign = '\0'; + break; + case 'U': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'u': + _uquad = UARG(); + base = DEC; + goto nosign; + case 'X': + xdigs = "0123456789ABCDEF"; + goto hex; + case 'x': + xdigs = "0123456789abcdef"; +hex: _uquad = UARG(); + base = HEX; + /* leading 0x/X only if non-zero */ + if (flags & ALT && _uquad != 0) + flags |= HEXPREFIX; + + /* unsigned conversions */ +nosign: sign = '\0'; + /* + * ``... diouXx conversions ... if a precision is + * specified, the 0 flag will be ignored.'' + * -- ANSI X3J11 + */ +number: if ((dprec = prec) >= 0) + flags &= ~ZEROPAD; + + /* + * ``The result of converting a zero value with an + * explicit precision of zero is no characters.'' + * -- ANSI X3J11 + */ + cp = buf + BUF; + if (_uquad != 0 || prec != 0) { + /* + * Unsigned mod is hard, and unsigned mod + * by a constant is easier than that by + * a variable; hence this switch. + */ + switch (base) { + case OCT: + do { + *--cp = to_char(_uquad & 7); + _uquad >>= 3; + } while (_uquad); + /* handle octal leading 0 */ + if (flags & ALT && *cp != '0') + *--cp = '0'; + break; + + case DEC: + /* many numbers are 1 digit */ + while (_uquad >= 10) { + *--cp = to_char(_uquad % 10); + _uquad /= 10; + } + *--cp = to_char(_uquad); + break; + + case HEX: + do { + *--cp = xdigs[_uquad & 15]; + _uquad >>= 4; + } while (_uquad); + break; + + default: + cp = "bug in vfprintf: bad base"; + size = strlen(cp); + goto skipsize; + } + } + size = buf + BUF - cp; + skipsize: + break; + default: /* "%?" prints ?, unless ? is NUL */ + if (ch == '\0') + goto done; + /* pretend it was %c with argument ch */ + cp = buf; + *cp = ch; + size = 1; + sign = '\0'; + break; + } + + /* + * All reasonable formats wind up here. At this point, `cp' + * points to a string which (if not flags&LADJUST) should be + * padded out to `width' places. If flags&ZEROPAD, it should + * first be prefixed by any sign or other prefix; otherwise, + * it should be blank padded before the prefix is emitted. + * After any left-hand padding and prefixing, emit zeroes + * required by a decimal [diouxX] precision, then print the + * string proper, then emit zeroes required by any leftover + * floating precision; finally, if LADJUST, pad with blanks. + * + * Compute actual size, so we know how much to pad. + * fieldsz excludes decimal prec; realsz includes it. + */ +#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + fieldsz = size + fpprec; +#else + fieldsz = size; +#endif + if (sign) + fieldsz++; + else if (flags & HEXPREFIX) + fieldsz+= 2; + realsz = dprec > fieldsz ? dprec : fieldsz; + + /* right-adjusting blank padding */ + if ((flags & (LADJUST|ZEROPAD)) == 0) { + if (width - realsz > 0) { + PAD(width - realsz, blanks); + ret += width - realsz; + } + } + + /* prefix */ + if (sign) { + PRINT(&sign, 1); + ret++; + } else if (flags & HEXPREFIX) { + ox[0] = '0'; + ox[1] = ch; + PRINT(ox, 2); + ret += 2; + } + + /* right-adjusting zero padding */ + if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) { + if (width - realsz > 0) { + PAD(width - realsz, zeroes); + ret += width - realsz; + } + } + + if (dprec - fieldsz > 0) { + /* leading zeroes from decimal precision */ + PAD(dprec - fieldsz, zeroes); + ret += dprec - fieldsz; + } + + /* the string or number proper */ + PRINT(cp, size); + ret += size; + +#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + /* trailing f.p. zeroes */ + PAD(fpprec, zeroes); + ret += fpprec; +#endif + + /* left-adjusting padding (always blank) */ + if (flags & LADJUST) { + if (width - realsz > 0) { + PAD(width - realsz, blanks); + ret += width - realsz; + } + } + + } +done: +error: + return (((Cyg_StdioStream *) stream)->get_error() ? EOF : ret); + /* NOTREACHED */ +} + + +#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + +static char * +round(double fract, int *exp, char *start, char *end, char ch, char *signp) +{ + double tmp; + + if (fract) + (void)modf(fract * 10, &tmp); + else + tmp = to_digit(ch); + if (tmp > 4) + for (;; --end) { + if (*end == '.') + --end; + if (++*end <= '9') + break; + *end = '0'; + if (end == start) { + if (exp) { /* e/E; increment exponent */ + *end = '1'; + ++*exp; + } + else { /* f; add extra digit */ + *--end = '1'; + --start; + } + break; + } + } + /* ``"%.3f", (double)-0.0004'' gives you a negative 0. */ + else if (*signp == '-') + for (;; --end) { + if (*end == '.') + --end; + if (*end != '0') + break; + if (end == start) + *signp = 0; + } + return (start); +} // round() + + +static char * +exponent(char *p, int exp, int fmtch) +{ + char *t; + char expbuf[MAXEXP]; + + *p++ = fmtch; + if (exp < 0) { + exp = -exp; + *p++ = '-'; + } + else + *p++ = '+'; + t = expbuf + MAXEXP; + if (exp > 9) { + do { + *--t = to_char(exp % 10); + } while ((exp /= 10) > 9); + *--t = to_char(exp); + for (; t < expbuf + MAXEXP; *p++ = *t++); + } + else { + *p++ = '0'; + *p++ = to_char(exp); + } + return (p); +} // exponent() + + +static int +cvt(double number, int prec, int flags, char *signp, int fmtch, char *startp, + char *endp) +{ + char *p, *t; + double fract; + int dotrim, expcnt, gformat; + double integer, tmp; + Cyg_libm_ieee_double_shape_type ieeefp; + + dotrim = expcnt = gformat = 0; + ieeefp.value = number; + if ( ieeefp.number.sign ){ // this checks for <0.0 and -0.0 + number = -number; + *signp = '-'; + } else + *signp = 0; + + fract = modf(number, &integer); + + /* get an extra slot for rounding. */ + t = ++startp; + + /* + * get integer portion of number; put into the end of the buffer; the + * .01 is added for modf(356.0 / 10, &integer) returning .59999999... + */ + for (p = endp - 1; integer; ++expcnt) { + tmp = modf(integer / 10, &integer); + *p-- = to_char((int)((tmp + .01) * 10)); + } + switch (fmtch) { + case 'f': + /* reverse integer into beginning of buffer */ + if (expcnt) + for (; ++p < endp; *t++ = *p); + else + *t++ = '0'; + /* + * if precision required or alternate flag set, add in a + * decimal point. + */ + if (prec || flags&ALT) + *t++ = '.'; + /* if requires more precision and some fraction left */ + if (fract) { + if (prec) + do { + fract = modf(fract * 10, &tmp); + *t++ = to_char((int)tmp); + } while (--prec && fract); + if (fract) + startp = round(fract, (int *)NULL, startp, + t - 1, (char)0, signp); + } + for (; prec--; *t++ = '0'); + break; + case 'e': + case 'E': +eformat: if (expcnt) { + *t++ = *++p; + if (prec || flags&ALT) + *t++ = '.'; + /* if requires more precision and some integer left */ + for (; prec && ++p < endp; --prec) + *t++ = *p; + /* + * if done precision and more of the integer component, + * round using it; adjust fract so we don't re-round + * later. + */ + if (!prec && ++p < endp) { + fract = 0; + startp = round((double)0, &expcnt, startp, + t - 1, *p, signp); + } + /* adjust expcnt for digit in front of decimal */ + --expcnt; + } + /* until first fractional digit, decrement exponent */ + else if (fract) { + /* adjust expcnt for digit in front of decimal */ + for (expcnt = -1;; --expcnt) { + fract = modf(fract * 10, &tmp); + if (tmp) + break; + } + *t++ = to_char((int)tmp); + if (prec || flags&ALT) + *t++ = '.'; + } + else { + *t++ = '0'; + if (prec || flags&ALT) + *t++ = '.'; + } + /* if requires more precision and some fraction left */ + if (fract) { + if (prec) + do { + fract = modf(fract * 10, &tmp); + *t++ = to_char((int)tmp); + } while (--prec && fract); + if (fract) + startp = round(fract, &expcnt, startp, + t - 1, (char)0, signp); + } + /* if requires more precision */ + for (; prec--; *t++ = '0'); + + /* unless alternate flag, trim any g/G format trailing 0's */ + if (gformat && !(flags&ALT)) { + while (t > startp && *--t == '0'); + if (*t == '.') + --t; + ++t; + } + t = exponent(t, expcnt, fmtch); + break; + case 'g': + case 'G': + /* a precision of 0 is treated as a precision of 1. */ + if (!prec) + ++prec; + /* + * ``The style used depends on the value converted; style e + * will be used only if the exponent resulting from the + * conversion is less than -4 or greater than the precision.'' + * -- ANSI X3J11 + */ + if (expcnt > prec || (!expcnt && fract && fract < .0001)) { + /* + * g/G format counts "significant digits, not digits of + * precision; for the e/E format, this just causes an + * off-by-one problem, i.e. g/G considers the digit + * before the decimal point significant and e/E doesn't + * count it as precision. + */ + --prec; + fmtch -= 2; /* G->E, g->e */ + gformat = 1; + goto eformat; + } + /* + * reverse integer into beginning of buffer, + * note, decrement precision + */ + if (expcnt) + for (; ++p < endp; *t++ = *p, --prec); + else + *t++ = '0'; + /* + * if precision required or alternate flag set, add in a + * decimal point. If no digits yet, add in leading 0. + */ + if (prec || flags&ALT) { + dotrim = 1; + *t++ = '.'; + } + else + dotrim = 0; + /* if requires more precision and some fraction left */ + if (fract) { + if (prec) { + do { + fract = modf(fract * 10, &tmp); + *t++ = to_char((int)tmp); + } while(!tmp); + while (--prec && fract) { + fract = modf(fract * 10, &tmp); + *t++ = to_char((int)tmp); + } + } + if (fract) + startp = round(fract, (int *)NULL, startp, + t - 1, (char)0, signp); + } + /* alternate format, adds 0's for precision, else trim 0's */ + if (flags&ALT) + for (; prec--; *t++ = '0'); + else if (dotrim) { + while (t > startp && *--t == '0'); + if (*t != '.') + ++t; + } + } + return (t - startp); +} // cvt() + +#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + +// EOF vfnprintf.cxx diff --git a/packages/language/c/libc/stdio/current/tests/sprintf1.c b/packages/language/c/libc/stdio/current/tests/sprintf1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/tests/sprintf1.c @@ -0,0 +1,584 @@ +//================================================================= +// +// sprintf1.c +// +// Testcase for C library sprintf() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-20 +// Description: Contains testcode for C library sprintf() function +// +// +//####DESCRIPTIONEND#### + + +// CONFIGURATION + +#include // Configuration header + + +// INCLUDES + +#include +#include + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + + +static void test(CYG_ADDRWORD data) +{ + static char x[500]; + static char y[500]; + int ret; + int tmp; + int *ptr; + + + // Check 1 + ret = sprintf(x, "%d", 20); + CYG_TEST_PASS_FAIL(my_strcmp(x, "20")==0, "%d test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%d test return code"); + + // Check 2 + my_strcpy(y, "Pigs noses. Get 'em while there 'ot"); + ret = sprintf(x, "%s", y); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%s test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%s test return code"); + + // Check 3 + ret = sprintf(x, "||%7d||", 2378); + CYG_TEST_PASS_FAIL(my_strcmp(x, "|| 2378||")==0, "padding test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "padding test return code"); + + // Check 4 + ret = sprintf(x, "%x", 3573); + CYG_TEST_PASS_FAIL(my_strcmp(x, "df5")==0, "hex conversion (lowercase)"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "hex conv (lowercase) return code"); + + // Check 5 + ret = sprintf(x, "%X", 3573); + CYG_TEST_PASS_FAIL(my_strcmp(x, "DF5")==0, "hex conversion (uppercase)"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "hex conv (upperbase ) return code"); + + // Check 6 + ret = sprintf(x, "%c", 65); + CYG_TEST_PASS_FAIL(my_strcmp(x, "A")==0, "%c test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%c test return code"); + + // Check 7 + ret = sprintf(x, "%o",4628); + CYG_TEST_PASS_FAIL(my_strcmp(x, "11024")==0, "octal conversion"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "octal conversion return code"); + + // Check 8 + ret = sprintf(x, "%u", (unsigned int) 4738); + CYG_TEST_PASS_FAIL(my_strcmp(x, "4738")==0, "%u test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%u test return code"); + + // Check 9 + ptr = &tmp; + ret = sprintf(x, "1234567x%n||", ptr); + CYG_TEST_PASS_FAIL(tmp==8, "%n test"); + CYG_TEST_PASS_FAIL(ret==10, "%n test return code"); + + // Check 10 + ret = sprintf(x, "%%"); + CYG_TEST_PASS_FAIL(my_strcmp(x, "%")==0, "%% test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%% test return code"); + + // Check 11 + ret = sprintf(x, "%ld", (long)1<<30); + CYG_TEST_PASS_FAIL(my_strcmp(x, "1073741824")==0, "%ld test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%ld test return code"); + + // Check 12 + ret = sprintf(x, "%lu", (unsigned long)(1<<31) + 100); + CYG_TEST_PASS_FAIL(my_strcmp(x, "2147483748")==0, "%lu test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%lu test return code"); + + // Check 13 + ret = sprintf(x, "%x", 0x789a); + CYG_TEST_PASS_FAIL(my_strcmp(x, "789a")==0, "%x test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%x test return code"); + + // Check 14 + ret = sprintf(x, "%X", 0x789ab2); + CYG_TEST_PASS_FAIL(my_strcmp(x, "789AB2")==0, "%X test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%x test return code"); + + // Check 15 + ret = sprintf(x, "%08x", 0xdea2f2); + CYG_TEST_PASS_FAIL(my_strcmp(x, "00dea2f2")==0, "%0x test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%0x test return code"); + + // Check 16 + ret = sprintf(x, "%09X", 0x12fa1c); + CYG_TEST_PASS_FAIL(my_strcmp(x, "00012FA1C")==0, "%0X test"); + CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%0X test return code"); + + // Check 17 + ptr=&tmp; + ret = sprintf(x, "%p", (void *)ptr); + // just check _something_ was returned + CYG_TEST_PASS_FAIL((ret==my_strlen(x)) && (ret > 0), + "%p test return code"); + +#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + + CYG_TEST_INFO("Starting floating point specific tests"); + + // Check 18 + ret = sprintf(x, "%f", 2.5); + my_strcpy( y, "2.500000" ); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "simple %f test #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "simple %f test #1 return code"); + + // Check 19 + ret = sprintf(x, "hello %f world", 1.234); + my_strcpy( y, "hello 1.234000 world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "simple %f test #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "simple %f test #2 return code"); + + // Check 20 + ret = sprintf(x, "hello%fworld", 2.3456781); + my_strcpy( y, "hello2.345678world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "simple %f test #3"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "simple %f test #3 return code"); + + // Check 21 + ret = sprintf(x, "%s%f%d%s", "testing", -0.591, 3, "123"); + my_strcpy( y, "testing-0.5910003123"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%f mixed with others"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y),"%f mixed with others return code"); + + // Check 22 + ret = sprintf(x, "%s%f%d%s", "testing", -0.591, 3, "123"); + my_strcpy( y, "testing-0.5910003123"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%f mixed with others"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y),"%f mixed with others return code"); + + // Check 23 + ret = sprintf(x, "hello%fworld", 2.3456786); + my_strcpy( y, "hello2.345679world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "rounding test #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "rounding test #1 return code"); + + // Check 24 + ret = sprintf(x, "hello%fworld", -2.3456786); + my_strcpy( y, "hello-2.345679world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "rounding test #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "rounding test #2 return code"); + + // Check 25 + ret = sprintf(x, "hello%+fworld", -6.54321); + my_strcpy( y, "hello-6.543210world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "+ modifier #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "+ modifier #1 return code"); + + // Check 26 + ret = sprintf(x, "hello%+fworld", 6.54321); + my_strcpy( y, "hello+6.543210world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "+ modifier #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "+ modifier #2 return code"); + + // Check 27 + ret = sprintf(x, "hello%5fworld", 6.5); + my_strcpy( y, "hello6.500000world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width modifier #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "width modifier #1 return code"); + + // Check 28 + ret = sprintf(x, "hello%2fworld", 4.3); + my_strcpy( y, "hello4.300000world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width modifier #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "width modifier #2 return code"); + + // Check 29 + ret = sprintf(x, "hello%2.1fworld", 5.6); + my_strcpy( y, "hello5.6world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width and precision modifier #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "width and precision modifier #1 return code"); + + // Check 30 + ret = sprintf(x, "hello%5.1fworld", 6.7); + my_strcpy( y, "hello 6.7world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width and precision modifier #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "width and precision modifier #2 return code"); + + // Check 31 + ret = sprintf(x, "hello%3.1fworld", 7.8); + my_strcpy( y, "hello7.8world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width and precision modifier #3"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "width and precision modifier #3 return code"); + + // Check 32 + ret = sprintf(x, "hello%3.2fworld", 7.8); + my_strcpy( y, "hello7.80world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width and precision modifier #4"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "width and precision modifier #4 return code"); + + // Check 33 + ret = sprintf(x, "hello%05.1fworld", 6.5); + my_strcpy( y, "hello006.5world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0 modifier #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0 modifier #1 return code"); + + // Check 34 + ret = sprintf(x, "hello%03.0fworld", 6.2); + my_strcpy( y, "hello006world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0 modifier #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0 modifier #2 return code"); + + // Check 35 + ret = sprintf(x, "hello%05.*fworld",2, 7.5); + my_strcpy( y, "hello07.50world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0 modifier plus *"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "0 modifier plus * return code"); + + // Check 36 + ret = sprintf(x, "hello%03.1fworld",-1.232); + my_strcpy( y, "hello-1.2world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "-ve number with 0 modifier #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "-ve number with 0 modifier #1 return code"); + + // Check 37 + ret = sprintf(x, "hello%04.1fworld",-1.232); + my_strcpy( y, "hello-1.2world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "-ve number with 0 modifier #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "-ve number with 0 modifier #2 return code"); + + // Check 38 + ret = sprintf(x, "hello%05.1fworld",-1.232); + my_strcpy( y, "hello-01.2world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "-ve number with 0 modifier #3"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "-ve number with 0 modifier #3 return code"); + + // Check 39 + ret = sprintf(x, "hello%fworld",0.0); + my_strcpy( y, "hello0.000000world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0.0 test #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0.0 test #1 return code"); + + // Check 40 + ret = sprintf(x, "hello%1.0fworld",0.0); + my_strcpy( y, "hello0world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0.0 test #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0.0 test #2 return code"); + + // Check 41 + ret = sprintf(x, "hello%1.1fworld",0.0); + my_strcpy( y, "hello0.0world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0.0 test #3"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0.0 test #3 return code"); + + // Check 42 + ret = sprintf(x, "hello%5.1fworld",0.0); + my_strcpy( y, "hello 0.0world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0.0 test #4"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0.0 test #4 return code"); + + // Check 43 + ret = sprintf(x, "hello%fworld",-0.0); + my_strcpy( y, "hello-0.000000world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "-0.0 test #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "-0.0 test #1 return code"); + + // Check 44 + ret = sprintf(x, "hello%fworld",0.234); + my_strcpy( y, "hello0.234000world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "number less than 1 #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "number less than 1 #1 return code"); + + // Check 45 + ret = sprintf(x, "hello%02fworld",-0.234); + my_strcpy( y, "hello-0.234000world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "number less than 1 #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "number less than 1 #2 return code"); + + // Check 46 + ret = sprintf(x, "hello%02.2fworld",-0.234); + my_strcpy( y, "hello-0.23world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "number less than 1 #3"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "number less than 1 #3 return code"); + + // Check 47 + ret = sprintf(x, "hello%06.2fworld",-0.234); + my_strcpy( y, "hello-00.23world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "number less than 1 #4"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "number less than 1 #4 return code"); + + // Check 48 + ret = sprintf(x, "hello%-6.2fworld",2.345); + my_strcpy( y, "hello2.35 world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "left justification #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "left justification #1 return code"); + + // Check 49 + ret = sprintf(x, "hello%-6.2fworld",2.345); + my_strcpy( y, "hello2.35 world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "left justification #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "left justification #2 return code"); + + // Check 50 + ret = sprintf(x, "hello%-3.2fworld",2.345); + my_strcpy( y, "hello2.35world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "left justification #3"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "left justification #3 return code"); + + // Check 51 + ret = sprintf(x, "hello%#1.0fworld",2.12); + my_strcpy( y, "hello2.world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "# modifier #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "# modifier #1 return code"); + + // Check 52 + ret = sprintf(x, "hello%#1.2fworld",2.0); + my_strcpy( y, "hello2.00world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "# modifier #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "# modifier #2 return code"); + + // Check 53 + ret = sprintf(x, "hello%eworld",2.3456); + my_strcpy( y, "hello2.345600e+00world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%e #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%e #1 return code"); + + // Check 54 + ret = sprintf(x, "hello%4.3eworld",-2.3456e-1); + my_strcpy( y, "hello-2.346e-01world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%e #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%e #2 return code"); + + // Check 55 + ret = sprintf(x, "hello%4.2eworld",2.56e2); + my_strcpy( y, "hello2.56e+02world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%e #3"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%e #3 return code"); + + // Check 56 + ret = sprintf(x, "hello%09.2eworld",2.56e2); + my_strcpy( y, "hello02.56e+02world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%e #4"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%e #4 return code"); + + // Check 57 + ret = sprintf(x, "hello%09.2Eworld",4.23e19); + my_strcpy( y, "hello04.23E+19world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%e #5"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%e #5 return code"); + + // Check 58 + ret = sprintf(x, "hello%gworld",4.0); + my_strcpy( y, "hello4world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #1 return code"); + + // Check 59 + ret = sprintf(x, "hello%gworld",4.56); + my_strcpy( y, "hello4.56world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #2 return code"); + + // Check 60 + ret = sprintf(x, "hello%5.2gworld",4.56); + my_strcpy( y, "hello 4.6world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #3"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #3 return code"); + + // Check 61 + ret = sprintf(x, "hello%gworld",0.002); + my_strcpy( y, "hello0.002world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #4"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #4 return code"); + + // Check 62 + ret = sprintf(x, "hello%06.1gworld",0.0026); + my_strcpy( y, "hello00.003world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #5"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #5 return code"); + + // Check 63 + ret = sprintf(x, "hello%06gworld",0.000026); + my_strcpy( y, "hello2.6e-05world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #5"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #5 return code"); + + // Check 64 + ret = sprintf(x, "hello%06Gworld",0.000037); + my_strcpy( y, "hello3.7E-05world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #6"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #6 return code"); + + // Check 65 + ret = sprintf(x, "hello%08Gworld",-123456.0); + my_strcpy( y, "hello-0123456world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #7"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #7 return code"); + + // Check 66 + ret = sprintf(x, "hello%07gworld",-1234567.0); + my_strcpy( y, "hello-1.23457e+06world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #8"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #8 return code"); + + // Check 67 + ret = sprintf(x, "hello%013Gworld",-1234567.0); + my_strcpy( y, "hello-01.23457E+06world"); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #9"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #9 return code"); + + +#else + CYG_TEST_PASS("Floating point tests skipped - not configured"); +#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + + // Long string tests + ret = sprintf(x, "This is a very long string so I hope this works as " + "otherwise I would be very, very, sad. The cat sat on the " + "hat, and the mat sat on the rat. Quick brown fax, etc.etc. " + "blah, blah and all that jazz. Isn't he finished yet? My " + "old man's a dustman, why do I have to think up this " + "drivel, isn't that what summer students are for, if " + "anything that seems thinking up mindless drivel seems to " + "be their occupation in life. Yoof of today, eh? What, " + "what? %s So there.", + "And this is a middly bit."); + my_strcpy(y, "This is a very long string so I hope this works as " + "otherwise I would be very, very, sad. The cat sat on the " + "hat, and the mat sat on the rat. Quick brown fax, etc.etc. " + "blah, blah and all that jazz. Isn't he finished yet? My " + "old man's a dustman, why do I have to think up this " + "drivel, isn't that what summer students are for, if " + "anything that seems thinking up mindless drivel seems to " + "be their occupation in life. Yoof of today, eh? What, " + "what? And this is a middly bit. So there."); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "long (480 char) string output #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "long (480 char) string output #1 return code"); + + ret = sprintf(x, "Boo! This %s So there.", + "is a very long string so I hope this works as " + "otherwise I would be very, very, sad. The cat sat on the " + "hat, and the mat sat on the rat. Quick brown fax, etc.etc. " + "blah, blah and all that jazz. Isn't he finished yet? My " + "old man's a dustman, why do I have to think up this " + "drivel, isn't that what summer students are for, if " + "anything that seems thinking up mindless drivel seems to " + "be their occupation in life. Yoof of today, eh? What, " + "what? And this is a middly bit."); + my_strcpy(y, "Boo! This is a very long string so I hope this works as " + "otherwise I would be very, very, sad. The cat sat on the " + "hat, and the mat sat on the rat. Quick brown fax, etc.etc. " + "blah, blah and all that jazz. Isn't he finished yet? My " + "old man's a dustman, why do I have to think up this " + "drivel, isn't that what summer students are for, if " + "anything that seems thinking up mindless drivel seems to " + "be their occupation in life. Yoof of today, eh? What, " + "what? And this is a middly bit. So there."); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "long (485 char) string output #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(y), + "long (485 char) string output #2 return code"); + + + + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "sprintf() function"); + +} // test() + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "sprintf() function"); + CYG_TEST_INFO("These test individual features separately"); + + test(0); + + return 0; +} // main() + +// EOF sprintf1.c diff --git a/packages/language/c/libc/stdio/current/tests/sprintf2.c b/packages/language/c/libc/stdio/current/tests/sprintf2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/tests/sprintf2.c @@ -0,0 +1,187 @@ +//================================================================= +// +// sprintf2.c +// +// Testcase for C library sprintf() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-20 +// Description: Contains testcode for C library sprintf() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include +#include + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int +my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int +my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char * +my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + + +static void +test( CYG_ADDRWORD data ) +{ + static char x[200]; + static char y[200]; + static char z[200]; + int ret; + int tmp; + int *ptr; + + // Check 1 + my_strcpy(x, "I'm afraid the shield generator"); + ptr = &tmp; + ret = sprintf(y, "%s%n will be quite operational - %5d%%%c%05X", x, + ptr, 13, '5', 0x89ab); + my_strcpy( z, "I'm afraid the shield generator will be " + "quite operational - 13%5089AB" ); + CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "%s%n%d%%%c%0X test"); + + CYG_TEST_PASS_FAIL(ret == my_strlen(z), + "%s%n%d%%%c%0X test return code" ); + + CYG_TEST_PASS_FAIL(tmp==31, "%n test"); + + // Check 2 + ret = sprintf(y, "|%5d|%10s|%03d|%c|%o|", 2, "times", 6, '=', 10 ); + my_strcpy(z, "| 2| times|006|=|12|"); + + CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "|%5d|%10s|%03d|%c|%o| test"); + + CYG_TEST_PASS_FAIL(ret == my_strlen(z), + "|%5d|%10s|%03d|%c|%o| test return code" ); + + // Check 3 + ret = snprintf(y, 19, "print up to here >< and not this bit" ); + my_strcpy(z, "print up to here >"); + CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "simple snprintf test #1"); + CYG_TEST_PASS_FAIL(ret == my_strlen(z), + "simple snprintf test #1 return code" ); + + // Check 4 + ret = snprintf(y, 31, "print a bit of this number: %05d nyer", 1234); + my_strcpy(z, "print a bit of this number: 01"); + CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "simple snprintf test #2"); + CYG_TEST_PASS_FAIL(ret == my_strlen(z), + "simple snprintf test #2 return code" ); + +#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + + CYG_TEST_INFO("Starting floating point specific tests"); + + // Check 5 + ret = sprintf(y, "|%5f|%10s|%03d|%c|%+-5.2G|%010.3G|", + 2.0, "times", 6, '=', 12.0, -2.3451e-6 ); + my_strcpy(z, "|2.000000| times|006|=|+12 |-02.35E-06|"); + + CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, + "|%5f|%10s|%03d|%c|%+-5.2G|%010.3G| test"); + + CYG_TEST_PASS_FAIL(ret == my_strlen(z), + "|%5f|%10s|%03d|%c|%+-5.2G|%010.3G| test " + "return code" ); + + // Check 6 + ret = snprintf(y, 20, "bit of this: %g double", 6.431e8); + my_strcpy(z, "bit of this: 6.431e"); + CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, + "snprintf double test #1"); + + CYG_TEST_PASS_FAIL(ret == my_strlen(z), + "snprintf double test #1 return code"); + +#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ + " for C library sprintf() function"); + +} // test() + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C " + "library sprintf() function"); + CYG_TEST_INFO("These test combinations of sprintf() features"); + + test(0); + + return 0; +} // main() + +// EOF sprintf2.c diff --git a/packages/language/c/libc/stdio/current/tests/sscanf.c b/packages/language/c/libc/stdio/current/tests/sscanf.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/tests/sscanf.c @@ -0,0 +1,307 @@ +//================================================================= +// +// sscanf.c +// +// Testcase for C library sscanf() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-20 +// Description: Contains testcode for C library sscanf() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include +#include + +// HOW TO START TESTS + +#if defined(CYGFUN_LIBC_STDIO_ungetc) + +# define START_TEST( test ) test(0) + +#else + +# define START_TEST( test ) CYG_EMPTY_STATEMENT + +#endif + + +// FUNCTIONS + +#if defined(CYGFUN_LIBC_STDIO_ungetc) + +// Functions to avoid having to use libc strings + +static int +my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0') + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char * +my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +static void +test( CYG_ADDRWORD data ) +{ + static char x[300]; + static char y[300]; + char z[20]; + int ret; + int int_test, int_test2, int_test3, int_test4; + + // Check 1 + my_strcpy(x, "20"); + ret = sscanf(x, "%d", &int_test); + CYG_TEST_PASS_FAIL(int_test==20, "%d test"); + CYG_TEST_PASS_FAIL(ret == 1, "%d test return code"); + + // Check 2 + my_strcpy(y, "PigsNoses"); + ret = sscanf(y, "%s", x); + CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%s test"); + CYG_TEST_PASS_FAIL(ret == 1, "%s test return code"); + + // Check 3 + my_strcpy(x, "FE8C"); + ret = sscanf(x, "%X", &int_test); + CYG_TEST_PASS_FAIL(int_test == 65164, "hex read leading zeroes"); + CYG_TEST_PASS_FAIL(ret == 1, "hex read leading zeroes return code"); + + // Check 4 + my_strcpy(x, "000053Ba"); + ret = sscanf(x, "%x", &int_test); + CYG_TEST_PASS_FAIL(int_test == 21434, "hex read leading zeroes"); + CYG_TEST_PASS_FAIL(ret == 1, "hex read leading zeros return code"); + + // Check 5 + my_strcpy(x, "53Ba"); + ret = sscanf(x, "%3x", &int_test); + CYG_TEST_PASS_FAIL(int_test == 1339, "hex read constrained width"); + CYG_TEST_PASS_FAIL(ret == 1, "hex read constrained width return code"); + + // Check 6 + my_strcpy(x, "get the first char test"); + ret = sscanf(x, "%c", &y[0]); + CYG_TEST_PASS_FAIL(y[0] == 'g', "%c test"); + CYG_TEST_PASS_FAIL(ret == 1, "%c test return code"); + + // Check 7 + my_strcpy(x, "-5"); + ret = sscanf(x, "%d", &int_test); + CYG_TEST_PASS_FAIL(int_test == -5, "negative integer"); + CYG_TEST_PASS_FAIL(ret == 1, "negative integer return code"); + + // Check 8 + my_strcpy(x, "53"); + ret = sscanf(x, "%o", &int_test); + CYG_TEST_PASS_FAIL(int_test == 43, "%o test"); + CYG_TEST_PASS_FAIL(ret == 1, "%o test return code"); + + // Check 9 + int_test=10; + my_strcpy(x, "-5 0"); + ret = sscanf(x, "%*d %d", &int_test); + CYG_TEST_PASS_FAIL(int_test == 0, "assignment suppression"); + CYG_TEST_PASS_FAIL(ret == 1, "assignment suppression return code"); + + // Check 10 + int_test=0; + my_strcpy(x, "052"); + ret = sscanf(x, "%i", &int_test); + CYG_TEST_PASS_FAIL(int_test == 42, "octal with %i"); + CYG_TEST_PASS_FAIL(ret == 1, "octal with %i return code"); + + // Check 10 + int_test=0; + my_strcpy(x, "0x05f"); + ret = sscanf(x, "%i", &int_test); + CYG_TEST_PASS_FAIL(int_test == 95, "hex with %i"); + CYG_TEST_PASS_FAIL(ret == 1, "hex with %i return code"); + + // Check 11 + int_test=0; + my_strcpy(x, "+023456"); + ret = sscanf(x, "%u", &int_test); + CYG_TEST_PASS_FAIL(int_test == 23456, "unsigned int with %u"); + CYG_TEST_PASS_FAIL(ret == 1, "unsigned int with %u return code"); + + // Check 12 + my_strcpy(x, "aString 2747 D"); + ret = sscanf(x, "%s %d %c", y, &int_test, z); + CYG_TEST_PASS_FAIL( (my_strcmp(y, "aString")==0) && + (int_test == 2747) && + (z[0] == 'D'), "A few combinations #1"); + CYG_TEST_PASS_FAIL(ret == 3, "Combinations #1 return code"); + + + // Check 13 + my_strcpy(x, "-6 52 awurble 2747 xxx"); + ret = sscanf(x, "%d %u %s %2d %n %c", + &int_test, &int_test2, y, &int_test3, &int_test4, z); + CYG_TEST_PASS_FAIL( (int_test == -6) && (int_test2 == 52) && + (my_strcmp(y, "awurble")==0) && + (int_test3 == 27) && + (int_test4 == 16) && + (z[0] == '4'), "A few combinations #2"); + CYG_TEST_PASS_FAIL(ret == 5, "Combinations #2 return code"); + + +#ifdef CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + +// How much _relative_ error do we allow? +#define FLT_TOLERANCE 1.0e-3 + +#define MY_FABS(x) ((x) < 0.0 ? -(x) : (x)) + + CYG_TEST_INFO("Starting floating point specific tests"); + + { + float flt_test, wanted; + + // Check 14 + my_strcpy(x, "2.5"); + wanted = 2.5; + ret = sscanf(x, "%f", &flt_test); + CYG_TEST_PASS_FAIL( MY_FABS(flt_test - wanted) < + MY_FABS(wanted * FLT_TOLERANCE), + "Simple %f test #1" ); + CYG_TEST_PASS_FAIL( ret == 1, "Simple %f test #1 return code" ); + + + // Check 15 + my_strcpy(x, "-23.472345"); + wanted = -23.472345; + ret = sscanf(x, "%f", &flt_test); + CYG_TEST_PASS_FAIL( MY_FABS(flt_test - wanted) < + MY_FABS(wanted * FLT_TOLERANCE), + "Simple %f test #2" ); + CYG_TEST_PASS_FAIL( ret == 1, "Simple %f test #2 return code" ); + + // Check 16 + my_strcpy(x, "0.0"); + ret = sscanf(x, "%f", &flt_test); + CYG_TEST_PASS_FAIL( flt_test==0.0, "Simple %f test 0.0" ); + CYG_TEST_PASS_FAIL( ret == 1, "Simple %f test 0.0 return code" ); + + + // Check 17 + my_strcpy(x, "-2.6334e00"); + wanted = -2.6334; + ret = sscanf(x, "%e", &flt_test); + CYG_TEST_PASS_FAIL( MY_FABS(flt_test - wanted) < + MY_FABS(wanted * FLT_TOLERANCE), + "Simple %e test #1" ); + CYG_TEST_PASS_FAIL( ret == 1, "Simple %e test #1 return code" ); + + + // Check 18 + my_strcpy(x, "-2.56789e-06"); + wanted = -2.56789e-06; + ret = sscanf(x, "%e", &flt_test); + CYG_TEST_PASS_FAIL( MY_FABS(flt_test-wanted) < + MY_FABS(wanted * FLT_TOLERANCE), + "Simple %e test #2" ); + CYG_TEST_PASS_FAIL( ret == 1, "Simple %e test #2 return code" ); + + + // Check 19 + my_strcpy(x, "-2.12389e-06"); + wanted = -2.12389e-06; + ret = sscanf(x, "%g", &flt_test); + CYG_TEST_PASS_FAIL( MY_FABS(flt_test-wanted) < + MY_FABS(wanted * FLT_TOLERANCE), + "Simple %g test #1" ); + CYG_TEST_PASS_FAIL( ret == 1, "Simple %g test #1 return code" ); + + // Check 20 + my_strcpy(x, "1.3423345"); + wanted = 1.342335; + ret = sscanf(x, "%g", &flt_test); + CYG_TEST_PASS_FAIL( MY_FABS(flt_test-wanted) < + MY_FABS(wanted * FLT_TOLERANCE), + "Simple %g test #2" ); + CYG_TEST_PASS_FAIL( ret == 1, "Simple %g test #2 return code" ); + + + } // compound + +#else + CYG_TEST_PASS("Floating point tests skipped - not configured"); +#endif // ifdef CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "sscanf() function"); + +} // test() + +#endif // defined(CYGFUN_LIBC_STDIO_ungetc) + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "sscanf() function"); + + START_TEST( test ); + + CYG_TEST_NA("Testing is not applicable to this configuration"); +} // main() + + +// EOF sscanf.c diff --git a/packages/language/c/libc/stdio/current/tests/stdiooutput.c b/packages/language/c/libc/stdio/current/tests/stdiooutput.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdio/current/tests/stdiooutput.c @@ -0,0 +1,199 @@ +//================================================================= +// +// stdiooutput.c +// +// Testcase for miscellaneous C library output functions +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-20 +// Description: Contains testcode for C library stdio output +// functions +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // All the stdio functions +#include // errno +#include // Testcase API + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + int i; + + + // Check 1 + CYG_TEST_INFO("Expect: Hello printf world 42!"); + printf("Hello printf %s %d!\n", "world", 42); + + // Check 2 + CYG_TEST_INFO("Expect: This is fprintf 0x07f!"); + fprintf(stdout, "This is fprintf 0x%03x!\n", 0x7f); + + // Check 3 + CYG_TEST_INFO("Expect: char tests"); + fputc( 'c', stderr ); + putc( 'h', stdout ); + putchar( 'a' ); + fputc( 'r', stdout ); + putchar( ' ' ); + fflush(stdout); + putc( 't', stderr ); + fputc( 'e', stdout ); + putchar( 's' ); + fflush( NULL ); + putc( 't', stderr ); + fputc( 's', stderr ); + putchar( '\n' ); + + // Check 4 + CYG_TEST_INFO("Expect: puts test"); + puts("puts test"); + + // Check 5 + CYG_TEST_INFO("Expect: fputs test"); + fputs( "fputs test\n", stdout ); + + // Check 6 + CYG_TEST_INFO("Expect: fwrite test"); + fwrite( "fwrite test\n", 6, 2, stderr ); + + // Check 7 + CYG_TEST_INFO("Expect: wibble: No error"); + errno = ENOERR; + perror( "wibble" ); + + // Check 8 + CYG_TEST_INFO("Expect: Long string test!\nSitting on the side of the " + "highway waiting to catch speeding drivers, a State " + "Police Officer sees a car puttering along at 22 MPH. " + "He thinks to himself, \"This driver is just as " + "dangerous as a speeder!\" So he turns on his lights " + "and pulls the driver over. Approaching the car, " + "he notices that there are five old ladies-two in " + "the front seat and three in the back-wide eyed and " + "white as ghosts. The driver, obviously confused, says " + "to him, \"Officer, I don't understand, I was doing " + "exactly the speed limit! What seems to be the " + "problem?\" \"Ma'am,\" the officer replies, \"you " + "weren't speeding, but you should know that driving " + "slower than the speed limit can also be a danger to " + "other drivers.\" \"Slower than the speed limit? No " + "sir, I was doing the speed limit exactly...Twenty-two " + "miles an hour!\" the old woman says a bit proudly. " + "The State Police officer, trying to contain a " + "chuckle explains to her that \"22\" was the route " + "number, not the speed limit. A bit embarrassed, the " + "woman grinned and thanked the officer for pointing " + "out her error. \"But before I let you go, Ma'am, I " + "have to ask... Is everyone in this car OK? These " + "women seem awfully shaken and they haven't muttered a " + "single peep this whole time,\" the officer asks. \"Oh, " + "they'll be all right in a minute officer. We just got " + "off Route 119\"."); + + printf("Long string test!\nSitting on the side of the " + "highway waiting to catch speeding drivers, a State " + "Police Officer sees a car puttering along at %d MPH. " + "He thinks to himself, \"This driver is just as " + "dangerous as a speeder!\" So he turns on his lights " + "and pulls the driver over. Approaching the car, " + "he notices that there are five old ladies-two in " + "the front seat and three in the back-wide eyed and " + "white as ghosts. The driver, obviously confused, says " + "to him, \"Officer, I don't understand, I was doing " + "exactly the speed limit! What seems to be the " + "problem?\" \"Ma'am,\" the officer replies, \"you " + "weren't speeding, but you should know that driving " + "slower than the speed limit can also be a danger to " + "other drivers.\" \"Slower than the speed limit? No " + "sir, I was doing the speed limit exactly...Twenty-two " + "miles an hour!\" the old woman says a bit proudly. " + "The State Police officer, trying to contain a " + "chuckle explains to her that \"%d\" was the route " + "number, not the speed limit. A bit embarrassed, the " + "%coman grinned and thanked the officer for pointing " + "out her error. \"But before I let you go, Ma'am, I " + "have to ask... Is everyone in this car OK? These " + "women seem awfully shaken and they haven't muttered a " + "single peep this whole time,\" the officer asks. \"Oh, " + "they'll be all right in a minute officer. We just got " + "off Route %d\".\n", 22, 22, 'w', 119); + + // Check 9 + CYG_TEST_INFO("Expect: Another puts test, just for fun"); + puts("Another puts test, just for fun"); + + // Check 10 + CYG_TEST_INFO("Expect: more fputs testing"); + fputs( "more fputs testing\n", stderr ); + + // Check 11 + CYG_TEST_INFO("Expect all the numbers from 1 to 100 in 5 columns"); + for (i=1; i<101; ++i) { + + printf("%5d ", i); + if (i%5 == 0) + fputc( '\n', stdout); + + } // for + + CYG_TEST_PASS("Stdio output tests completed"); + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ + " for C library stdio output functions"); + +} // test() + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C " + "library stdio output functions"); + CYG_TEST_INFO("The output of these tests needs to be manually " + "verified."); + + test(0); + + return 0; + +} // main() + +// EOF stdiooutput.c diff --git a/packages/language/c/libc/stdlib/current/ChangeLog b/packages/language/c/libc/stdlib/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/ChangeLog @@ -0,0 +1,59 @@ +2000-08-03 Jonathan Larmour + + * src/getenv.cxx: Revert nickg's change of 2000-06-07. environ is + meant to be determined by the startup environment (normally in + CYGPKG_LIBC_STARTUP), not getenv. + +2000-07-27 Jonathan Larmour + + * cdl/stdlib.cdl: Require CYGINT_ISO_CTYPE because we need the iswhite() + etc. funs + +2000-07-04 Jonathan Larmour + + * cdl/stdlib.cdl: Remove all parts of malloc implementation and + move to new separate package CYGPKG_MEMALLOC + + * src/malloc.cxx, tests/malloc1.c, tests/malloc2.c, tests/malloc3.c, + tests/realloc.c: remove - moved to CYGPKG_MEMALLOC + +2000-06-07 Nick Garnett + + * tests/realloc.c: Include correct pkgconf file. + + * src/getenv.cxx: Removed externC from definition of environ, so + that is actually gets defined. + +2000-05-02 Jonathan Larmour + + * New package + Separated original libc out into separate packages on functional + boundaries. + Header files are now managed by isoinfra package + Plenty of cleanups done, but no major functionality changes + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/stdlib/current/ChangeLog.libc b/packages/language/c/libc/stdlib/current/ChangeLog.libc new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/ChangeLog.libc @@ -0,0 +1,2727 @@ +This ChangeLog file is now obsolete. This is the original ChangeLog from when +libc was one large package, before being separated. It is included for +historical reasons. + +2000-04-05 Jesper Skov + + * src/time/settime.cxx: + * src/time/time.cxx: + Wallclock moved to io/. + +2000-03-28 John Dallaway + + * cdl/string.cdl, + cdl/stdlib.cdl, + cdl/stdio.cdl, + cdl/libc.cdl: + + Adjust documentation URLs. + +2000-03-27 Jesper Skov + + * src/clibincl/stream.inl (check_this): Use cyb_bool instead of bool. + +2000-03-06 Jesper Skov + + * tests/time/strftime.c (test): Adjust test to match below change. + +2000-03-02 Jonathan Larmour + + * src/time/strftime.cxx (do_format): Make sure %m counts from + 1..12 rather than 0..11. Fix for case 103300 + +2000-02-29 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: Correctly use 'n' parameter to + restrict length. Credit due to Andrew Lunn here as well. + Resolves 103057-CR-1 + + * tests/stdio/sprintf2.c (test): + Add snprintf tests to verify the correct behaviour of restricting + output length + +2000-02-10 Jesper Skov + + * tests/signal/signal2.c (main): + Also reclaim DATA_TLB_MISS vector if available. + +2000-01-31 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-28 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-19 Hugo Tyson + + * cdl/*.cdl: Add descriptions to a number of options &c which were + lacking same, also tidied up other typos as noticed en passant. + +1999-11-11 Bart Veer + + * cdl/string.cdl: + Switch to a single boolean configuration option for code size vs. + speed optimization. + +1999-11-03 John Dallaway + + * cdl/libc.cdl: Define tests. + +1999-10-19 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: We can now remove Berkeley + advertising clause + * src/stdlib/div.cxx: ditto + * src/stdlib/ldiv.cxx: ditto + * src/stdlib/strtol.cxx: ditto + * src/stdlib/strtoul.cxx: ditto + * src/string/strtok.cxx: ditto + +1999-10-19 John Dallaway + + * cdl/libc.cdl: + + Define CDL options for package-specific CFLAGS. + +1999-10-08 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_THREAD_PRIORITY): Change + default to 10 to keep test farm happy + * cdl/startup.cdl: Likewise + +1999-10-07 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Specify radio buttons using CDL interfaces. + +1999-10-06 Jonathan Larmour + + * cdl/stdio.cdl: Change default to /dev/ttydiag as per 1999-10-01 + change below + * cdl/startup.cdl: Add new form CDL for the startup changes as + per 1999-10-05 + +1999-10-05 Jonathan Larmour + + * include/libc.h: Add CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM to allow + the user to supply their own stack. + Rename CYGNUM_LIBC_MAIN_STACK_SIZE to + CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE and reparent under + CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + Add CYGNUM_LIBC_MAIN_THREAD_PRIORITY to provide main() thread + priority + + * src/support/mainthread.cxx: Add support for user-supplied stack + Allow user to specify thread priority + + These changes fix CR 101069 + +1999-10-01 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE): Change + default to /dev/ttydiag to get correct console-like behaviour + Also don't preclude use if haldiag package isn't included + (case 102065) + +1999-09-15 Jesper Skov + + * tests/signal/signal2.c (cause_fpe): Try both float and integer + division by zero. + +1999-09-10 Jesper Skov + + * src/stdlib/malloc.cxx (cyg_libc_get_malloc_pool): Added for + stress_threads test. + +1999-09-07 Jesper Skov + PRs 20243, 20433 + * tests/signal/signal2.c: Disabled test3 on ARM. + +1999-09-02 Hugo Tyson + + * include/assert.h: Make the sense of NDEBUG correct; it is "set" + when NOT debugging. Fix for CR 101983-CR-1 + See Stroustrup, "The C++ Programming Language." + +1999-08-18 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): Set buffer size 0 when not + buffering + Fix for case 101868 + +1999-08-17 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Implement radio buttons using "FIXME radio" hack in + description field for now. + +1999-08-12 John Dallaway + + * cdl/stdlib.cdl: + Take advantage of MACRONAME_ENUMVAL macros output by CDL. + +1999-08-06 Jonathan Larmour + + * tests/stdio/sprintf2.c (test): Don't rely on 2.345 being exactly + representable in binary as a difference of 1 ulp will make it round + the wrong way. + +1999-07-16 Jonathan Larmour + + * src/stdio/input/fgetc.cxx: + Include outline versions of getc() (actually just a symbol alias for + fgetc() ) and getchar() + Some minor clean-ups + Add tracing/assertions + + * src/stdio/input/fputc.cxx: + Likewise (except applied to putc() and putchar()) + + * src/stdio/common/stdioinlines.cxx (_puts): + Call fputc() not _fputc() + + * src/clibincl/stdiosupp.hxx: + Remove now obsolete prototypes for _fgetc() and _fputc() + + * include/stdio.h: + Don't bother with getc()/putc() macros any more, just call + them as functions + Include protos for getc(), putc(), getchar() and putchar() functions + +1999-06-21 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for SH EDK7708. + +1999-06-11 Jonathan Larmour + + * include/stdio.h: Make FILEs array types so they won't be + given $gp relocations on MIPS targets + +1999-05-27 Jesper Skov + + * tests/time/ctime.c: Fixed compiler warning. + +1999-05-25 Jonathan Larmour + + * tests/signal/signal2.c (main): + Update CYGPKG_HAL_TX39 -> CYGPKG_HAL_MIPS_TX39 due to recent MIPS + HAL changes + Fix for PR 20116 + +1999-04-30 Jesper Skov + PR 19945/19946 workaround + * tests/signal/signal2.c: Disabled test 3 for PowerPC sim. + +1999-04-19 Jonathan Larmour + + * include/time.inl: + Ensure all calls to cyg_libc_time_year_is_leap() are with the full + year, and not the direct contents of a struct tm, which are (year-1900) + +1999-04-19 Jesper Skov + PR 19308, 19410, 19528 + * tests/time/clock.c (test): Also disable data cache which may + affect timing when tracing/assertions are enabled. + +1999-04-15 Jonathan Larmour + + * src/clibincl/stdiosupp.hxx: + Add prototype for new cyg_libc_stdio_flush_all_but() function + + * src/clibincl/stream.hxx: + Don't include stdiosupp.hxx any more to prevent circular dependency, + therefore manually provide _setvbuf prototype + Make sure pkgconf/kernel.h is included before mutex.hxx + + * src/clibincl/stream.inl (Cyg_StdioStream::set_error()): + Add missing unlock_me() + + * src/stdio/common/fflush.cxx: + Separate most of code for fflush(NULL) into separate + cyg_libc_stdio_flush_all_but() function, which has the extra + capability of omitting one stream + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Add missing clibincl/stdiosupp.hxx include + + * src/stdio/common/stream.cxx (Cyg_StdioStream::read()): + When reading, ensure we flush all output streams + + * src/stdio/common/stream.cxx (Cyg_StdioStream::flush_output_unlocked): + Flush the device as well + +1999-04-15 Jonathan Larmour + + * src/stdio/common/streambuf.cxx (set_buffer): + * src/stdio/common/stdioinlines.cxx (_setbuf): + * src/clibincl/streambuf.inl: + * src/clibincl/streambuf.hxx: + * src/clibincl/stream.hxx (class Cyg_StdioStream): + * include/pkgconf/libc.h: + * include/stdio.inl (setbuf): + Fix dumb typo: BUFSIZE -> BUFSIZ + This fixes PR19837 + +1999-04-15 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx (_setbuf): + * include/stdio.inl (setbuf): + Use _IONBF when buf==NULL, and _IOLBF otherwise. + Fix for PR 19836 + +1999-04-15 John Dallaway + + * include/pkgconf/libc.h: Tidy display string capitalization. + +1999-04-12 Jonathan Larmour + + * include/pkgconf/libc.h: + Clarify CDL description of CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE + + * tests/signal/signal2.c: Try harder to generate an exception by + accessing a misaligned address + Don't handle SIGTRAP any more + Part of fix for PRs 19731/19607 + +1999-04-07 Jesper Skov + PR 19667 + * src/support/mainthread.cxx: + Changed to use the new Cyg_Thread constructor. + +1999-04-07 Hugo Tyson + + * tests/signal/signal2.c (main): Use new macro + HAL_VSR_SET_TO_ECOS_HANDLER if defined, to wrest control from + CygMon, for example, by reinstalling eCos' default VSRs for + exceptions that we are provoking. + +1999-03-29 Jonathan Larmour + + * src/signal/siginit.cxx: Include stdlib.h for exit() + Fix for PR 19720 + +1999-03-29 Jonathan Larmour + + * tests/time/clock.c (test): Disable instruction cache + Hopefully fixes PR 19308 + +1999-03-29 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for PPC as it cannot + trap division by zero. + +1999-03-26 Jonathan Larmour + + * src/support/main.cxx (main): Invoke cyg_user_start() if no kernel + Only sensible thing to do in our default main in a non-kernel config + +1999-03-25 Jonathan Larmour + + * tests/time/time.c: + Increase MAX_TIMEOUT since the sparclite gets very close to overrunning + it even when working. + Should return -1 iff CYGSEM_LIBC_TIME_TIME_WORKING isn't defined + Cosmetic changes + +1999-03-25 Hugo Tyson + + * tests/time/time.c (test): Take into account setting of + CYGSEM_LIBC_TIME_SETTIME_WORKING ie. does cyg_libc_time_settime() + work? If not, check that it returns an error. + This was exposed by the random combo in PR#19479. + +1999-03-23 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 to + CYGIMP_... + + Add another rand implementation CYGIMP_LIBC_RAND_SIMPLE1 which is + the default + + Part of fix for PR 19562 + + * include/sys/cstartup.h: + Tidy and remove unnecessary dependencies + + * src/stdlib/rand.cxx: + Rename algorithms from CYGSEM_... to CYGIMP_... + Add new "simple1" algorithm + + * tests/ctype/ctype.c: + Tidy + + * tests/stdlib/rand3.c: + Fix so that 0..RAND_MAX is split evenly over buckets, which it wasn't + before + Deal with case of RAND_MAX not being divisible by NUM_BUCKETS + exactly + Increase TEST_LENGTH to 200000 to provide more representative sample + Add CYG_TEST_INFO output to help ensure it doesn't time out + Tidy + + * tests/stdlib/rand4.c: + Only fail if more than _two_ thirds (rather than one third) match. + This is because half would match for a perfectly random distribution + This is the rest of the fix for PR 19562 + Cosmetic changes + +1999-03-22 Hugo Tyson + + * src/support/mainthread.cxx (CYGNUM_LIBC_MAIN_STACK_SIZE): + Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of + CYGNUM_HAL_MINIMUM_STACK_SIZE. + +1999-03-22 Jonathan Larmour + + * tests/PKGconf.mak: Add -Wno-format when building strftime otherwise + it generates warnings for things that we do want to test (null + string, and %y format) + +1999-03-19 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Put brackets back round negative number since sdf says the config + tool is fixed now (PR 19537) + + Add new CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 + options for different rand() algorithms in a so far failed attempt + to fix PR 19562 + + * src/stdlib/rand.cxx: + Add new optional algorithm from Knuth vol.2 + + * tests/stdlib/rand4.c: + Some tidies + Don't run test when using simplest algorithm + + * tests/signal/signal2.c (main): + Don't try to make an FPE on tx39 - its possible to detect but requires + too much HAL work to be sensible + +1999-03-18 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Use HAL_ENABLE_INTERRUPTS() rather than kernel to enable interrupts + +1999-03-18 Mark Galassi + + * tests/PKGconf.mak (TESTS): added rand4 compilation. + + * tests/stdlib/rand4.c: added this test for periodicity in the + least significant bit of rand(). + +1999-03-18 Jonathan Larmour + + * include/pkgconf/libc.h: Remove CYGFUN_LIBC_TIME_POSIX dependency + on CYGPKG_LIBC_STDIO + + * src/stdlib/itoa.cxx: + New file to convert integers to ascii + + * include/stdlib.h: + Add proto for new cyg_libc_itoa() function + + * include/time.inl: + Rework __asctime_r() to use memcpy() and cyg_libc_itoa() rather than + sprintf() + + * src/PKGconf.mak: + Build stdlib/itoa.cxx + + The above changes fix PR 19448 + +1999-03-17 Jonathan Larmour + + * include/time.h: Add #define of __time_t_defined to placate newlib + if it is used by accident. This is just a temporary workaround though. + +1999-03-16 Gary Thomas + + * src/PKGconf.mak: Add compile option to step around ARM compiler bug. + +1999-03-16 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Don't use parentheses for now + + * src/stdio/common/stream.cxx (refill_read_buffer): + Silence bogus compiler warning + +1999-03-16 Jesper Skov + + * tests/signal/signal2.c (main): Enable SIGSEGV test for + i386/Linux. + + +1999-03-15 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Only enable interrupts if they were disabled + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: + Add FIX ME line as a reminder that the workaround there can go away + in future + + * include/pkgconf/libc.h: + Add proper define for CYGSEM_LIBC_EXIT_CALLS_FFLUSH + Put brackets round negative CYGNUM_LIBC_TIME_DST_DEFAULT_STATE define + Fix run time typo + + * include/time.inl (__localtime_r): + Include sys/timeutil.h before this to get + cyg_libc_time_normalize_structtm() + +1999-03-12 Gary Thomas + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: Remove 'const' from char arrays since + this fails [silently] on ARM when -fwritable-strings (PR19440) + +1999-03-12 Jesper Skov + + * tests/signal/signal2.c (main): Compiler warnings fix was + slightly broken. + +1999-03-12 Jesper Skov + PR 19473 + * tests/signal/signal2.c (main): + Disabling SIGTRAP handling on i386/Linux is not a good idea. +1999-03-11 Jesper Skov + PR 19473 + * tests/signal/signal2.c: + Added compiler warnings fix. + Added N/A handling for i386/Linux. + +1999-03-10 Gary Thomas + + * include/pkgconf/libc.h: Force "haldiag" device to be present. + 'asctime' and friends need 'stdio' as well. + + * include/time.inl: Fix syntax error on difftime() declaration. + +1999-03-08 Gary Thomas + + * src/clibincl/stream.hxx: needed for this file. + + * src/stdio/common/vsscanf.cxx (str_read): Fix problem with string + pointer [created by merge with new I/O package]. + +1999-03-05 John Dallaway + + * include/pkgconf/libc.h: + Add legal values for CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET + and CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET. + +1999-03-05 Jonathan Larmour + + * include/time.inl (cyg_libc_time_year_is_leap): + Fix bug with modulo year 400 + Fix typo in asctime_r macro + Fix gmtime_r, and mktime as a result of testing + + * tests/time/asctime.c, tests/time/ctime.c, tests/time/gmtime.c, + tests/time/gmtime.c, tests/time/localtime.c, tests/time/mktime.c, + tests/time/strftime.c, tests/time/time.c: + New tests + + * tests/PKGconf.mak: + Build above new tests + + * include/pkgconf/libc.h: + Add reminder FIX ME about extra config option + + * src/time/strftime.cxx: + Fix %w and %Y parameters as a result of testing + + * src/time/timeutil.cxx: + Fix cyg_libc_time_normalize_structtm() as a result of testing + of mktime() + + * tests/time/clock.c: + Reformat, remove obsolete bits and tidy + + * include/time.h: + Add Cyg_libc_time_dst type and new functions + cyg_libc_time_setzoneoffsets(), cyg_libc_time_setdst(), + cyg_libc_time_getzoneoffsets(), cyg_libc_time_settime() + + * include/time.inl: + Implement the above functions. This allows us to adjust for timezone + diffences and set the time. + Change localtime() to adjust for STD/DST + Change mktime() to adjust for STD/DST + + * include/libc.h: + Add new config options CYGSEM_LIBC_TIME_SETTIME_WORKING + and component CYGPKG_LIBC_TIME_ZONES containing options + CYGNUM_LIBC_TIME_DST_DEFAULT_STATE, + CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET, + CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET + + * src/strftime.cxx: + Adjust handling of %Z to _not_ deal with STD/DST + + * src/time/settime.cxx: + New file to implement cyg_libc_time_settime() + + * src/PKGconf.mak: + Build settime.cxx + + * src/time/timeutil.cxx: + Supply outline versions of cyg_libc_time_setzoneoffsets(), + cyg_libc_time_setdst(), and cyg_libc_time_getzoneoffsets() + Add variables for STD/DST state + Some minor comment changes + + * include/errno.h: + Use CYGBLD_ATTRIB_CONST instead of __attribute__((const)) directly + + * include/signal.h: + Change format of function comment headers + + * include/signal.inl: + Restrict errno.h inclusion to when its actually used + Fix a spelling typo + + * include/stdlib.h: + Add CYGBLD_ATTRIB_CONST to abs, div, labs, ldiv + + * include/stdlib.inl: + Reformat and tidy + Include new versions of div and ldiv which are more portable and + are cleanly rewritten so aren't covered by the BSD licence, which + is now removed + + * src/stdlib/div.cxx, src/stdlib/ldiv.cxx: + Non-inline, non-BSD and portable versions of the new versions of div + and ldiv from stdlib.inl + + * include/time.h: + Much reformatting, tidying and improving comments + Change CLOCKS_PER_SEC from 1000 to 1000000 + Add new functions asctime_r, ctime_r, gmtime_r, localtime_r, clock, + difftime, mktime, time, asctime, ctime, gmtime, localtime, strftime + Include new time.inl file + + * include/pkgconf/libc.h: + Add new options CYGSEM_LIBC_TIME_CLOCK_WORKING, + CYGSEM_LIBC_TIME_TIME_WORKING, CYGFUN_LIBC_TIME_POSIX, + CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL, CYGIMP_LIBC_TIME_ASCTIME_INLINE, + CYGIMP_LIBC_TIME_CTIME_INLINE, CYGIMP_LIBC_TIME_DIFFTIME_INLINE, + CYGIMP_LIBC_TIME_GMTIME_INLINE, CYGIMP_LIBC_TIME_LOCALTIME_INLINE, + CYGIMP_LIBC_TIME_MKTIME_INLINE, CYGIMP_LIBC_TIME_ASCTIME_R_INLINE, + CYGIMP_LIBC_TIME_CTIME_R_INLINE, CYGIMP_LIBC_TIME_GMTIME_R_INLINE, + and CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE + + * time/asctime.cxx, time/asctime_r.cxx, time/clock.cxx, time/ctime.cxx, + time/ctime_r.cxx, time/difftime.cxx, time/gmtime.cxx, + time/gmtime_r.cxx, time/localtime.cxx, time/localtime_r.cxx, + time/mktime.cxx, time/strftime.cxx, time/time.cxx, time/timeutil.cxx, + include/time.inl: + New files to implement the new time functions. Many of them simply + provide the outline definitions, but the real body of the function + comes from time.inl + + * src/PKGconf.mak: + Build new .cxx files + + * src/clibincl/stdlibsupp.hxx: + Remove _div and _ldiv prototypes since they're no longer needed + + * src/clibincl/timesupp.hxx: + Delete as its now obsolete + + * src/time/clock.cxx: + Use new CYGSEM_LIBC_TIME_CLOCK_WORKING option to control whether it + just returns (clock_t)-1 or not. + Much reformatting and tidying + Change real imlpementation from _clock to __clock + Use CYGBLD_ATTRIB_WEAK_ALIAS now + + * tests/stdlib/div.c, tests/stdlib/ldiv.c: + Add some extra tests for handling of negative numbers + Reformat and tidy a bit, including removing the test for CYGPKG_LIBC + since its now always defined if the test is to be compiled + + * tests/time/clock.c: + Remove duplication CYG_TEST_INFO line + Check if unimplemented using "(clock_t)-1" and not just "-1" + +1999-03-04 Jonathan Larmour + + * src/stdlib/system.cxx: + Make sure system() is a weak alias for __system() + + * include/pkgconf/libc.h: Rework CDL description for + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE and change its default to + "/dev/haldiag" + + * src/stdio/common/stream.cxx: + Check that dev is valid when passed to stream constructor + + * src/stdio/common/stdiosupp.cxx: + Tidy + + * src/support/mainthread.cxx: Make this depend on + CYGSEM_LIBC_STARTUP_MAIN_THREAD rather than just CYGPKG_KERNEL + +1999-03-04 Gary Thomas + + Merged in changes from 'ecos-new_devs-19990216-branch' + + (1999-02-24 Jonathan Larmour ) + + * src/stdio/common/stream.cxx: + Add "fix me" comments and remove a couple of commented out lines + + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Revert to using pointer to string for private data, not just string. + This preserves the state across multiple calls + + (1999-02-24 Gary Thomas ) + + * src/stdio/common/vsscanf.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/stream.cxx: + * src/stdio/common/stdiosupp.cxx: + * src/stdio/common/fopen.cxx: + * src/clibincl/stream.inl: + * src/clibincl/stream.hxx: + * src/clibincl/stdiosupp.hxx: + * include/pkgconf/libc.h: Changes for new I/O system. + +1999-03-03 Jonathan Larmour + + * tests/stdlib/atexit.c: Forgot to config atexit test for + CYGFUN_LIBC_ATEXIT option + + * include/pkgconf/libc.h: + Require CYGVAR_KERNEL_THREADS_DATA for CYGSEM_LIBC_PER_THREAD_STRTOK + This fixes PR 19362 + Require CYGPKG_KERNEL for thread safe streams + Also don't need "requires CYGPKG_KERNEL" for per-thread rand and errno + if we already require a finer granularity kernel option + +1999-02-25 Jonathan Larmour + + * include/pkgconf/libc.h: Fix CYGNUM_LIBC_MAIN_STACK_SIZE by changing + CYGPKG_LIBC_STARTUP_MAIN_THREAD -> CYGSEM_LIBC_STARTUP_MAIN_THREAD + Fix for PR 19304 + +1999-02-23 Jonathan Larmour + + * src/stdlib/system.cxx: Add to implement trivial system() call + * include/stdlib.h: Add system() prototype + * src/PKGconf.mak: Build system.cxx + + * tests/ctype/ctype.c, tests/i18n/setlocale.c, tests/setjmp/setjmp.c, + tests/signal/signal1.c, tests/signal/signal2.c, + tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdio/stdiooutput.c, tests/stdlib/atexit.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/getenv.c, tests/stdlib/labs.c, + tests/stdlib/ldiv.c, tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/realloc.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + Use CYG_TEST_NA() macro for non-applicable test configurations + +1999-02-20 Jonathan Larmour + + * include/signal.h: + * include/signal.inl: + * src/signal/raise.cxx: + * src/signal/siginit.cxx: + * src/signal/signal.cxx: + * tests/signal/signal1.c + * tests/signal/signal2.c: + New files to implement ISO standard signals + + * src/PKGconf.mak (TESTS): + * tests/PKGconf.mak (TESTS): + Update to build new files above + + * include/stdlib.h: + * src/clibincl/stdlibsupp.hxx: + Comment and QA changes (including giving better names to some types) + + * include/libc.h: + Add new configuration options for signals + Add new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + Add a note to CYGNUM_LIBC_MAIN_STACK_SIZE option that it may be + overriden by HAL + Add new CYGFUN_LIBC_ATEXIT option and move ...ATEXIT_HANDLERS under + it + Add new CYGSEM_LIBC_EXIT_CALLS_FFLUSH option + Require CYGSEM_LIBC_STARTUP_MAIN_THREAD for "Invoke default static + constructors" option + + * src/stdlib/atexit.cxx: + Support above CYGFUN_LIBC_ATEXIT and QA changes + + * src/stdlib/exit.cxx: + Support for above new libc.h options, and some QA changes + + * src/support/cstartup.cxx: + Add support for new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + + * src/support/mainthread.cxx: + Override main stack size if the HAL has a minimum + + * src/string/strncpy.cxx: + Use improved algorithm for aligned copies - imported from newlib + QA changes + + * src/stdlib/abort.cxx: + Support raise(SIGABRT), and some QA + + * include/errno.h: + Add const attribute + + * tests/stdlib/abs.c: + QA improvements + +1999-02-04 Jesper Skov + + * src/support/cstartup.cxx: Only define cyg_libc_main_thread when + the kernel is around. + +1999-02-01 Jesper Skov + + * tests/time/clock.c: Joined the two test/NOP checks into + one. + Increased tolerance in attempt to fix PRs 18737,18787,18846. + Fixed typo. + +1999-01-28 Jonathan Larmour + + * src/string/strtok.cxx: + * src/stdlib/rand.cxx: + Include if we use kernel header files + +1999-01-25 Jonathan Larmour + + * tests/stdio/sscanf.c (test): + CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT should be + CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + Fix for PR 18786 + + * src/string/strtok.cxx: + * src/stdio/common/stdiofiles.cxx: + * src/errno/errno.cxx: + * src/stdlib/rand.cxx: + Give mutex protection objects a libc constructor priority + + * src/support/invokemain.cxx: + Add prototype for cyg_hal_invoke_constructors() + + * src/support/mainthread.cxx: + Give cyg_libc_dummy_constructor_obj a libc constructor priority, + and make its class have a public constructor + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/stdin.cxx: + Give cyg_libc_stdio_stdin/out/err static objects a libc constructor + priority + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + * src/clibincl/stream.hxx (class Cyg_StdioStream): + Remove private copy constructor. Needed to make prioritised + static constructors work. Fix for PR 18898 + +1999-01-22 Jonathan Larmour + + * src/errno/errno.cxx: + Include pkgconf/kernel.h otherwise it fails with per-thread errno + enabled + + * include/pkgconf/libc.h: + Enable per-thread errno by default since that is what POSIX would + want + + * tests/time/clock.c (test): + Placate compiler by initializing clock_first/second/third anyway, + even though they won't be in practice. This is only a test program + so adding an extra instruction doesn't matter. + + * src/i18n/locale.cxx (_setlocale): + Placate compiler, since it is dumb, by nesting, not serializing, if's + This is an idempotent change, but screws up the formatting :-(. + + * src/string/strpbrk.cxx (_strpbrk): + Change while loop to do loop to placate compiler. It'll even save an + instruction too (wow!) + +1999-01-22 John Dallaway + + * include/pkgconf/libc.h: + Add closing curly brace to CYGPKG_LIBC_STRING_STRTOK definition + +1999-01-21 Jonathan Larmour + + * include/errno.h: + Tidy up and add to header description + Change cyg_get_errno_p() to cyg_libc_get_errno_p() + Remove ifdef CYGPKG_LIBC + + * include/sys/file_if.h: + Remove - move contents to stdio.h + + * include/stdio.h: + Tidy up header description + Move FILE typedef here from sys/file_if.h + SEEK_SET, SEEK_CUR, SEEK_END defined to 0, 1, 2 respectively + for backwards compatibility with old UNIX + Change definitions of stdin/out/err to be addresses of FILE + globals - even though they're actually Cyg_StdioStream it'll work + + * include/pkgconf/libc.h: + Make CYGPRI_LIBC_WEAK et al macros depend on new ones in infra + Reorganise trace options under the individual components they are + associated with. + Reorganise thread-safety options under the individual components + they are associated with. + Add new CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS option + Misc. reformatting + Remove dependency on pkgconf/kernel.h - Configuration Tool will + generate check macros anyway. + Remove CYGPKG_LIBC_TRACE, CYGFUN_LIBC_strtok, CYGPKG_LIBC_RAND + options + Tidy up description header + + * src/clibincl/clibdata.hxx: + * src/clibincl/clibdata.inl: + * src/support/clibdata.cxx: + Remove and instead rely on each component to initialise its own data + + * src/clibincl/stdiofiles.hxx, src/clibincl/stdiofiles.inl: + New files to contain global file list and lock (if applicable). + Implemented as class with member access functions + + * src/errno/errno.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Rename cyg_get_errno_p() to cyg_libc_get_errno_p() + + * src/stdio/common/fclose.cxx: + * src/stdio/common/fflush.cxx: + * src/stdio/common/fopen.cxx: + * src/stdio/common/freopen.cxx: + Remove ifdef CYGPKG_LIBC + Use new global file access method from stdiofiles.hxx + Tidy up description header + Use new CYGBLD_ATTRIB_WEAK_ALIAS + Access errno "normally" rather than clibdata way + + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx + * src/stdio/common/stderr.cxx: + New files. Implement Cyg_StdioStream objects for each stream. In + separate self-contained files so using one doesn't bring in the + others + + * src/stdio/common/stdiofiles.cxx: + New file. Implements global files array and lock + + * src/stdlib/_exit.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Use infra CYGBLD* macros + + * src/stdlib/malloc.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Add pkgconf/kernel.h now that pkgconf/libc.h doesn't have it + Use infra CYGBLD* macros + Make pool visible externally with weak attribute and new name + cyg_libc_malloc_memorypool + + * src/stdlib/rand.cxx: + * src/stdlib/strtok.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Use infra CYGBLD* macros + + * src/support/cstartup.cxx: + Split into smaller files to make selective linking work better, + fix i386 port problem and make GDB happy + + * src/support/environ.cxx: + * src/support/invokemain.cxx: + * src/support/main.cxx: + * src/support/mainthread.cxx: + New files from bits of the old cstartup.cxx + Add support for CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG + + * src/PKGconf.mak: + Update to reflect file additions/deletion + + * tests/stdlib/rand1.c: + * tests/stdlib/rand2.c: + * tests/stdlib/rand3.c: + * tests/stdlib/srand.c: + Make conform to coding standards + Remove ifdef CYGPKG_LIBC_RAND + Tidy up description header + + * tests/string/strtok.c: + Make conform to coding standards + Remove ifdef CYGFUN_LIBC_strtok + Tidy up description header + +1999-01-15 Mark Galassi + + * tests/stdlib/getenv.c (main): added tests for the case in which + the user does not supply environ and in which the user supplies a + NULL environ. + +1999-01-15 Jesper Skov + + * src/support/cstartup.cxx: Added workaround for weak aliasing + problem in i386 gcc. + + +1999-01-15 Gary Thomas + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_STACK_SIZE): + (CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE): Change defaults to be + more reasonable on small systems. + +1999-01-04 Jonathan Larmour + + * src/support/clibdata.cxx: + Minor bug with environ not being initialised correctly by + default + +1998-12-24 Bart Veer + + * src/clibincl/stream.inl (Cyg_StdioStream): + check_this() member functions should now be const + +1998-12-22 Jonathan Larmour + + * src/string/memchr.cxx (_memchr): + treat search value parameter to memchr as an unsigned byte, + not a signed int - copied fix from newlib PR 18471 + +1998-12-21 Jonathan Larmour + + * tests/stdlib/realloc.c: + * tests/stdlib/malloc3.c: + * tests/stdlib/malloc2.c: + Warning cleanup + +1998-12-14 Jonathan Larmour + + * tests/stdlib/malloc2.c, tests/stdlib/malloc3.c, + tests/stdlib/realloc.c: + Only run these tests when we have a coalescing memory allocator + +1998-12-14 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Only check buffer init success if buffering + + * src/stdio/common/streambuf.cxx (set_buffer): + Check for diff of requested size against buffer_size, not + get_buffer_size(), since this may return -1, which won't be + equal to size, and will cause malloc to be called + +1998-12-01 Jesper Skov + + * tests/stdlib/getenv.c (main): Don't declare variables when they + are not used. + +Thu Nov 26 17:59:12 1998 Jonathan Larmour + + * tests/string/strncpy1.c: + Fix off-by-one error since it called my_strcmp() and not + my_strncmp(), which meant in included the trailing NULL when it + shouldn't have. + +1998-11-26 Jesper Skov + + * src/stdlib/qsort.cxx (_qsort): + * src/stdlib/rand.cxx (_srand): + Changed CYG_REPORT_FUNCNAMETYPE to CYG_REPORT_FUNCNAME in void + functions. + +Mon Oct 26 18:49:00 1998 Jonathan Larmour + + * src/support/cstartup.cxx (cyg_libc_dummy_main): + Silence compiler warning with cast of char * to CYG_ADDRWORD + +Wed Oct 28 17:31:21 1998 Jonathan Larmour + + * src/time/clock.cxx (_clock): + Reorder scaling expression as it was both incorrect and risked + overflow. + Fix for PR 18076 + +Mon Oct 19 14:40:06 1998 Jonathan Larmour + + * include/stdio.h (EOF): + Change from -64 to (-1), to allow broken code to work :-/ + Also change other negative defines to be within parentheses + +1998-10-19 Mark Galassi + + * include/pkgconf/libc.h: updated the doc URL + +Thu Oct 15 21:33:44 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Only include kernel thread headers when we're in thread-safe mode + + * src/time/clock.cxx: + Only include kernel clock headers if there's a kernel with the + right functionality available + + * tests/time/clock.c: + Remove unnecessary inclusion of + + Above changes are required for PR 17229 + +Wed Oct 14 16:38:55 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise inclusion of clibincl/stdiosupp.hxx and + clibincl/stream.hxx. Tidying up PR 17502 + +Wed Oct 14 14:08:56 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGPKG_LIBC_STRING_OPTIMISATIONS to + CYGPKG_LIBC_STRING_OPTIMIZATIONS to make it truely merkin. + +Tue Oct 13 19:34:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_ARGUMENTS): + Add a default argv[0] of "" as many programs assume argc>0 + The standard allows argv[0] to be "" if the program name + is not available + +1998-09-26 Bart Veer + + * src/clibincl/stdiosupp.hxx: + PR 17502: this header file now does nothing if the stdio option + is disabled completely. This is the same behaviour is + clibincl/stream.hxx, although arguably the #ifdef protection + should happen wherever the header file is #include'd rather than + in the header file itself. + + * src/clibincl/clibdata.hxx: + PR 17502: this header file still #include's internal stdio-related + header files and references the FILE structure, even if stdio is + disabled. There were some #ifdef's for CYGPKG_LIBC_STDIO already. + One more has been added for _fopen() and _fclose(). + +1998-09-25 Bart Veer + + * src/clibincl/streambuf.inl (Cyg_StdioStreamBuffer): + PR 17487: Reorder the calls to initialize member fields, to + eliminate a compiler warning. + +Fri Sep 25 19:04:29 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/string/strtok.cxx, + src/time/clock.cxx: + Only define tracing variable and tracing level macro when + the relevant tracing level config options are set. Otherwise + keep the tracing level fixed at 0 + Fix for PR 17476 + + * include/pkgconf/libc.h: + Define trace levels only if parent CYGPKG_LIBC_TRACE is defined + for consistency with Configuration Tool + + +Fri Sep 25 17:24:45 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Make definition of vscanf() dependent on CYGFUN_LIBC_STDIO_ungetc + otherwise _vfscanf() won't be compiled. This therefore would + cause a link fail iff selective linking is not enabled. + Fix for PR 17455 + +Fri Sep 25 17:23:17 1998 Jonathan Larmour + + * src/stdlib/rand.cxx: + Make compilation dependent on CYGPKG_LIBC_RAND + Fix for PR 17473 + + * tests/stdlib/srand.c: + Make definition of dummy test pass conditional on CYGPKG_LIBC_RAND + not being defined, as well as CYGPKG_LIBC + Caused compilation failure when testing PR 17473 fix + +Mon Sep 21 17:11:04 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Make sscanf test conditional on CYGFUN_LIBC_STDIO_ungetc since + _vfscanf() only gets compiled if this is defined + Fix for PR 17346 + +1998-09-20 Mark Galassi + + * include/pkgconf/libc.h: updated CDL doc strings. + +Fri Sep 18 22:18:47 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_errno_p): + Rather than this function only being available in thread-safe mode, + instead make what it returns be either the per-thread errno, or + global errno depending on the configuration. + Include (conditionally) to support this change + +Wed Sep 16 11:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove "fix me" comment which I forgot to remove before + +Tue Sep 15 19:27:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Updated descriptions and a few other minor things after review. + Notably though, the NDEBUG config option has been removed + +1998-09-15 Bart Veer + + * include/pkgconf/libc.h: + PR 17201: removed dependency on CYGPKG_KERNEL in the option + CYGNUM_LIBC_MAIN_STACK_SIZE, since the actual dependencies cannot + be expressed sensibly in the current system. + +1998-09-11 Bart Veer + + * include/pkgconf/libc.h: + Sorting out dependencies for error package. + +1998-09-10 Mark Galassi + + * include/pkgconf/libc.h: started adding doc fields to the + cdl_package data, as a pilot for now. + +Wed Sep 9 17:41:23 1998 Hugo Tyson + + * include/pkgconf/libc.h: + Add option CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE to explicitly + control whether the empty delete functions (currently) in + kernel/.../common/delete.cxx are enabled; controls code bloat, see + the comments in delete.cxx. + +Fri Sep 4 16:43:38 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add a default CYG_TEST_PASS() to make sure the test infra doesn't + complain. + Also remove the unused string functionsa + +Fri Sep 4 15:43:48 1998 Hugo Tyson + + * src/stdlib/exit.cxx (__libc_exit): + * src/stdlib/_exit.cxx (__libc__exit): + * src/stdlib/malloc.cxx (_free): + * src/stdlib/abort.cxx (abort): + * src/support/cstartup.cxx (invoke_main): + Tracing system asserted cos it was being called incorrectly; these + are void functions so you shouldn't give a type to the function + reporting call. + +Fri Sep 4 15:03:10 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Fix CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE description to refer to + the table.cxx file, not table.h + +Fri Sep 4 14:38:52 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add description for CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE since + Proven won't be making any changes to the device driver + implementation after all. + Fix for PR 17148 + + * src/clibincl/stream.inl (set_position): + Remove "fix me" line. It is obvious that this will have to change + with a filesystem interface + Fix for PR 17147 + + * src/stdio/common/freopen.cxx: + Remove "fix me" - I know about this issue + Fix for PR 17145 + + * src/stdio/common/stream.cxx (read): + Remove "fix me" and change to use memcpy + Fix for PR 17144 + +Fri Sep 4 14:36:47 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Actually add it this time! + +Fri Sep 4 13:48:13 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add new tests for misc stdio output functions + + * tests/PKGconf.mak: + Build stdiooutput.c test + +Fri Sep 4 12:52:10 1998 Jonathan Larmour + + * src/clibincl/stream.inl (write_byte): + Remove bogus assert + + * tests/stdlib/getenv.c (main): + Check whether str is NULL before doing a strcmp() + + * tests/stdio/sprintf2.c (main): + Reformat to 76 columns + +Fri Sep 4 02:10:54 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/stdio/common/stream.cxx: + Add new peek_byte method to Cyg_StdioStream + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix up buffer access to work with new peek_byte method above + Fix for PR 16954 + +Thu Sep 3 19:40:11 1998 Jonathan Larmour + + * tests/stdlib/rand1.c, tests/stdlib/rand2.c, + tests/stdlib/rand3.c: + Add extra check for CYGPKG_LIBC_RAND to decide whether the test + is applicable or not + + * tests/stdlib/rand2.c (test): + Use CYGNUM_LIBC_RAND_SEED for default seed, not 1 + + * tests/string/strtok.c: + Add extra check for CYGFUN_LIBC_strtok to decide whether the + test is applicable or not + +Wed Sep 2 19:11:40 1998 Jonathan Larmour + + * src/stdio/input/fread.cxx, src/stdio/output/fwrite.cxx: + Add fread() and fwrite() functions + + * src/PKGconf.mak: + Build fread.cxx and fwrite.cxx from above + + * src/stdio/common/stream.cxx: + Reformat to 76 columns + In write(), move initialisation of *bytes_written to start + In read(), move initialisation of *bytes_read to start + + * include/stdio.h: + Reformat to 76 columns + + Replace all references to the ANSI + standard to instead by the ISO C standard + + Add commented argument names for "documentation" + + Add fread() and fwrite() prototypes + + * src/clibincl/stdiosupp.hxx: + Copy the above changes from stdio.h, and add _fread() and _fwrite() + prototypes + + * src/stdio/output/fputs.cxx, src/stdio/input/fgets.cxx: + Reformat to 76 columns + +Wed Sep 2 15:41:15 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Reformat to 76 columns + +Wed Sep 2 14:46:18 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Use trylock_me() instead of lock_me(), and loop to prevent + deadlocks + + * src/clibincl/stream.hxx, src/clibincl/stream.inl: + Add trylock_me() method + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/fflush.cxx: + Reformat to 76 columns + +Wed Sep 2 12:24:27 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change 0x7fff to 0x7fffffff. Oops! + give main stack size option a legal_values field + Undefine tracing by default + Add some more description in the header + +Tue Sep 1 20:02:07 1998 Jonathan Larmour + + * tests/i18n/setlocale.c (cyg_package_start): + Fix typo - extra "x" for no reason at all! :-) + +Tue Sep 1 19:44:58 1998 Jonathan Larmour + + * src/i18n/locale.cxx: + Fix bug in find_locale_data() that miscalculated size of + all_locales + + Make find_locale_data() match the locale "" and add some + other things in _setlocale() to ensure that "C" gets returned + when the default locale "" is passed. + + Only check the locale pointer when it is non-NULL + + * tests/i18n/setlocale.c: + New tests for setlocale() + + * tests/PKGconf.mak: + Update to build setlocale.c test + + * src/support/cstartup.cxx: + Don't actually call system default main() "main" otherwise GDB + gets confused and thinks its the entry point. Instead make a weak + alias and call the real function something different. + +Tue Sep 1 18:31:42 1998 Jonathan Larmour + + * src/i18n/locale.cxx (_setlocale): + Fix tracing macro name and remove "str maybe used before + initialised" warning + + * tests/stdlib/qsort.c: + Correct file description header + +Tue Sep 1 17:04:32 1998 Jonathan Larmour + + * include/locale.h, src/clibincl/i18nsupp.hxx, src/i18n/locale.cxx: + New files to add support for locales as defined by the ISO C + standard. i.e. setlocale() and localeconv() functions and some + other bits + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAX_LOCALE_NAME_SIZE config option for locale + support + + * src/PKGconf.mak: + build locale.cxx + + * include/errno.h, src/clibincl/ctypesupp.hxx: + Tidy up to 76 columns + +Tue Sep 1 00:24:22 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Move environment-related options from stdlib into new + CYGPKG_LIBC_STARTUP component. Also add options for main()'s + arguments (CYGPKG_LIBC_ARGUMENTS), main()'s default stack size + (CYGNUM_LIBC_MAIN_STACK_SIZE), number of atexit handlers + (CYGNUM_LIBC_ATEXIT_HANDLERS), and whether _exit() stops the + system (CYGSEM_LIBC_EXIT_STOPS_SYSTEM). + + * src/clibincl/stdlibsupp.hxx: + Fix a few comment bugs, and add new + cyg_libc_invoke_atexit_handlers() function prototype + + * src/stdlib/_exit.cxx, src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Implement exit(), atexit() and _exit() correctly now. Also + includes cyg_libc_invoke_atexit_handlers() in atexit.cxx. Now + we get the correct behaviour of atexit(), and exit() invokes the + atexit handlers and fflushs all the stdio streams. Add plenty of + tracing of asserts too. + + * src/support/cstartup.cxx: + Make main_thread object an exported global. Allow user-settable + arguments. Add MUCH more tracing and asserts. Improve comments. + Tidy up to 76 columns + + * tests/stdlib/atexit.c: + Add simple test for atexit() and it calling registered functions + + * tests/PKGconf.mak: + Build atexit.c test + +Mon Aug 31 18:54:48 1998 Jonathan Larmour + + * src/stdlib/getenv.cxx, tests/stdlib/getenv.c: + Add support for getenv(), and some tests to ensure it works + + * src/PKGconf.mak, tests/PKGconf.mak: + Update to include getenv.cxx and getenv.c test + + * src/clibincl/clibdata.hxx: + remove prototype for environ - we expect files needing it to + define it themselves + + * src/support/clibdata.cxx: + Tidy up to 76 columns and add definition of char **environ, but + with a configurable initialiser (see libc.h below) + + * tests/stdlib/abs.c (main): + Tidy up to 76 columns + + * src/stdlib/malloc.cxx: + Tidy up to 76 columns and remove warning for undefined _memcpy() + by changing to memcpy(), and casting away signedness + + * include/pkgconf/libc.h: + Add CYGPKG_LIBC_ENVIRONMENT and CYGDAT_LIBC_DEFAULT_ENVIRONMENT + configuration options + + * include/pkgconf/libc.h, src/clibincl/clibdata.hxx: + Tidy up to 76 columns + + * include/stdlib.h: + Add getenv() prototype and tidy up to 76 columns + + * src/clibincl/stdlibsupp.hxx: + Add _getenv() prototype + +Mon Aug 31 13:37:08 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Add realloc() + + * tests/stdlib/realloc.c: + Add this file to test new realloc() functionality + + * tests/PKGconf.mak: + Build realloc test + + * tests/stdlib/malloc3.c (main), tests/stdlib/malloc2.c (main), + tests/stdlib/malloc1.c (main): + Conditionalise local vars to prevent warnings + + * tests/stdlib/malloc3.c (fill_with_data): + Move '{' into "verb" line + + * include/pkgconf/libc.h: + Require infra tracing support to allow tracing + + * include/stdlib.h: + Add realloc() + + * src/clibincl/stdlibsupp.hxx: + Update the commented argument names from stdlib.h, including realloc() + +1998-08-28 Bart Veer + + * include/pkgconf/libc.h: + * src/clibincl/clibdata.hxx, src/time/clock.cxx: + + Updated for new kernel configuration option symbol names + +Fri Aug 28 19:18:25 1998 Hugo Tyson + + Changed the entry below to sat "tx39" instead of "mn10300". + It's been a long week. + +Fri Aug 28 18:59:20 1998 Hugo Tyson + + * src/support/cstartup.cxx: Add a weakly named main to allow the + default configuration to link on the tx39 which has no + scalextric linking yet. The static Cyg_Thread main_thread object + below continues to exist, though unreferenced, so all its + descendants must exist too. + +Fri Aug 28 08:54:29 1998 Jonathan Larmour + + * include/stdlib.h: + Add commented argument names Add exit(), and atexit(). And move + these along with abort() and _exit() to a new section. + + * src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Add trivial versions of atexit() and exit() + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAIN_STACK_SIZE config option + + * include/sys/cstartup.h, src/support/cstartup.cxx, src/PKGconf.mak: + New files to provide a new function cyg_iso_c_support(), which + invokes main "correctly". + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/srand.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcoll2.c, tests/string/strcpy1.c, + tests/string/strcpy2.c, tests/string/strcspn.c, + tests/string/strlen.c, tests/string/strncat1.c, + tests/string/strncat2.c, tests/string/strncpy1.c, + tests/string/strncpy2.c, tests/string/strpbrk.c, + tests/string/strrchr.c, tests/string/strspn.c, + tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, + tests/time/clock.c: + + Modify all tests to use new startup mechanism, and cyg_iso_c_start() + +Fri Aug 28 00:29:38 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Add #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO around all accesses to + flags.last_buffer_op_was_read. Fix for PR 16997 + +Thu Aug 27 01:12:42 1998 Jonathan Larmour + + * include/sys/file_if.h: + Fix comments and remove cyg_get_file_star() + +Wed Aug 26 20:24:32 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove #define CYGPKG_LIBC is that is meant to live in + after all + +Wed Aug 26 19:39:23 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + More fixes to CDL stuff to make it work better, and look better on + the screen + +Tue Aug 25 20:21:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Make some fixes after running the ConfigTool + +Tue Aug 25 16:46:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_STDIO_BUFSIZE): + Fix typo of CYGNUM_LIBC_STDIO_BUFSIZE + +Tue Aug 25 15:10:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Tidy up CDL stuff a bit more, prior to checking it actually works. + +Tue Aug 25 11:38:52 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c (main): + Prevent calls to CYG_TEST_STILL_ALIVE for now + +Tue Aug 25 05:39:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change cosmetic paragraph alignment. + +Tue Aug 25 03:11:34 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Make stderr initialise with buffer size 0. + For PR 16955 + +Mon Aug 24 17:38:46 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + First pass at CDL-ifying the C library configuration. Currently + deliberately disabled as there a few outstanding issues. + +Mon Aug 24 16:14:22 1998 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx (_vfnprintf): + clear up warning for unused argument + + * tests/stdlib/malloc2.c (NUM_ITERATIONS): + Lower to 100 from 50000 so it won't take too long under the simulator + +Thu Aug 20 17:48:43 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Remove now unnecessary inclusion of kernel/ktypes.h + +Wed Aug 19 19:19:14 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, + tests/stdio/sscanf.c, tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, + tests/stdlib/strtoul.c, tests/string/strtok.c, + tests/time/clock.c: + Add parameters to "main()" to silence warnings + +Wed Aug 19 18:52:59 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx (refill_read_buffer): + Put conditional error check into same #ifdef and if as what was being + checked in the first place! + +Wed Aug 19 18:49:19 1998 Jonathan Larmour + + * src/clibincl/stream.inl: + Reorder Cyg_StdioStream::check_this() to be first to silence + warnings + +Tue Aug 18 16:10:03 1998 Jonathan Larmour + + * ecc/language/c/libc/current/src/clibincl/clibdata.hxx, + ecc/language/c/libc/current/src/errno/errno.cxx, + ecc/language/c/libc/current/src/stdio/common/fopen.cxx, + ecc/language/c/libc/current/src/stdlib/rand.cxx, + ecc/language/c/libc/current/src/string/strtok.cxx: + Rename CYGIMP_LIBC_INTERNAL_DATA_PREAMBLE, + CYGIMP_LIBC_INTERNAL_DATA_ALLOC_CHECK_PREAMBLE, + CYGVAR_LIBC_INTERNAL_DATA, and + CYGIMP_LIBC_INTERNAL_DATA_CHECK to all have CYGPRI_ prefix instead + as recommended by the config name rules + + +Tue Aug 18 14:31:19 1998 Jonathan Larmour + + * src/stdio/common/setvbuf.cxx (_setvbuf): + Rename variable names in assert line, otherwise doesn't build + with asserts on! + +Sun Aug 16 18:15:12 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix some bugs, although there are some left to fix still. Unrelated + to the rest of the checkins, so I will check the partial fix in now. + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx: + Add parameters to constructor to allow more things to be done at + construction time. + + Now we have "new", remove separate "construct" method + + Add more documentation on constructor + + As requested by code review, where possible, move boolean flags + into separate packed bitfield structure for space efficiency + + Make readbuf_char be usable all the time rather than when configured + not to be buffering, as it is also needed for non-buffered mode i.e. + _IONBF + + * src/stdio/common/fopen.cxx: + Change to use new method of construction from above, using new + + Use thread-specific data, rather than global. And so change errnos + to access errno entry specifically + + Make process_mode() check for append mode too + + Reformat for coding standards to have { in same line as "verb" + + * src/stdio/common/setvbuf.cxx: + + Change to cope with different way of dealing with buffering policy + flags etc. in Cyg_StdioStream + + * src/stdio/common/vsnprintf.cxx, src/stdio/common/vsscanf.cxx, + src/support/clibdata.cxx: + Change construction of streams to use new parameters added above, + and change to use _IONBF mode for string stdio functions, + otherwise its a waste of memory. And use _IONBF for stderr as the + ISO standard tells us to! + + Reformat for coding standards to have { in same line as "verb" + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Change constructor so that it can be set with default size and + dynamic buffer (if applicable) + + Fix minor bug in destructor - should only call free when allocated + dynamically + + Change get_buffer_size to return -1 if the buffer was not allowed + to be set up + + * src/stdio/common/streambuf.cxx: + Remove unnecessary stdio.h include and add extra comment to whether + to free bit in set_buffer() + + * src/stdio/common/freopen.cxx: + Change @@@ to standard fix me string + + * src/stdio/output/fputc.cxx: + Remove unnecessary "written" variable + +Thu Aug 13 15:37:28 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: + Included use of "fix me" line to ensure this is discussed before + release + + * include/stdlib.h, src/stdlib/abort.cxx, src/PKGconf.mak: + Add abort.cxx to implement abort(), albeit naively + +Thu Jul 30 18:03:09 1998 Jonathan Larmour + + * src/stdio/common/vsscanf.cxx (_vsscanf), + src/stdio/common/vsnprintf.cxx (_vsnprintf): + Fix initialiser of pseudo string device table that didn't get updated + when the table changed (Bad proven, no biscuit). + + * src/clibincl/stream.inl (~Cyg_StdioStream): + Move invalidation of magic_validity_word to after unlock_me(), + otherwise it always fails! + +Tue Jul 28 21:29:53 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Shorten over-long lines + +Tue Jul 28 20:28:23 1998 Jonathan Larmour + + * src/clibincl/stream.hxx (class Cyg_StdioStream), + src/clibincl/stream.inl, src/stdio/common/stream.cxx: + Clarify some comments and get the CYGDBG_DEFINE_CHECK_THIS and + CYG_ASSERTCLASS stuff going + + * src/clibincl/stream.inl: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 15:31:06 1998 Jonathan Larmour + + * src/clibincl/streambuf.inl, src/stdio/common/streambuf.cxx: + Move set_buffer() from streambuf.inl to new file streambuf.cxx + + * src/PKGconf.mak (COMPILE): + Build new file streambuf.cxx + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + Add METHODS comment + + * src/stdio/common/stream.cxx: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 00:26:36 1998 Jonathan Larmour + + * include/stdlib.inl, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/div.cxx, + src/stdlib/ldiv.cxx, src/stdlib/qsort.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/string/strtok.cxx: + + Include proper Berkeley license inline in the file, rather than + referring to an external file + + * doc/COPYING.UCB: + Remove, now that it isn't referred to any more + +Mon Jul 27 23:34:26 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl, include/errno.h, + include/stdio.h, include/stdio.inl, include/stdlib.h, + include/stdlib.inl, include/string.h, include/string.inl, + include/time.h, include/sys/file_if.h, src/PKGconf.mak, + src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/stdiosupp.hxx, + src/clibincl/stream.hxx, src/clibincl/streambuf.hxx, + src/clibincl/streambuf.inl, src/clibincl/stringsupp.hxx, + src/clibincl/timesupp.hxx, src/ctype/isalnum.cxx, + src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, + src/ctype/islower.cxx, src/ctype/isprint.cxx, + src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, + src/ctype/tolower.cxx, src/ctype/toupper.cxx, + src/errno/errno.cxx, src/stdio/common/snprintf.cxx, + src/stdio/common/sprintf.cxx, src/stdio/common/sscanf.cxx, + src/stdio/common/stdioinlines.cxx, src/stdio/common/stream.cxx, + src/stdio/common/ungetc.cxx, src/stdio/common/vsnprintf.cxx, + src/stdio/common/vsscanf.cxx, src/stdio/input/fgetc.cxx, + src/stdio/input/fgets.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/gets.cxx, src/stdio/input/scanf.cxx, + src/stdio/output/fnprintf.cxx, src/stdio/output/fprintf.cxx, + src/stdio/output/fputc.cxx, src/stdio/output/fputs.cxx, + src/stdio/output/printf.cxx, src/stdlib/_exit.cxx, + src/stdlib/abs.cxx, src/stdlib/atof.cxx, src/stdlib/atoi.cxx, + src/stdlib/atol.cxx, src/stdlib/div.cxx, src/stdlib/labs.cxx, + src/stdlib/ldiv.cxx, src/stdlib/rand.cxx, src/stdlib/strtod.cxx, + src/string/memchr.cxx, src/string/memcmp.cxx, + src/string/memmove.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, + src/string/strcoll.cxx, src/string/strcpy.cxx, + src/string/strcspn.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx, src/string/strpbrk.cxx, + src/string/strrchr.cxx, src/string/strspn.cxx, + src/string/strstr.cxx, src/string/strsuppt.cxx, + src/string/strtok.cxx, src/string/strxfrm.cxx, + src/support/clibdata.cxx, src/time/clock.cxx: + Untabify + +Mon Jul 27 23:14:18 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/stdlib/malloc.cxx, src/stdlib/qsort.cxx, + tests/ctype/ctype.c, tests/stdlib/rand3.c, tests/stdlib/malloc3.c: + Remove all mentions of "register" in variable declarations. Also + untabify where needed + + * src/stdlib/bsearch.cxx: + Untabify this too + + +Mon Jul 27 22:18:51 1998 Jonathan Larmour + + * src/stdio/output/fputc.cxx (_fputc): + Replace call to stream write() with call to write_byte() + + * src/clibincl/stream.inl (write_byte): + Add asserts for stream write() returning odd values for how much has + been written + + (bytes_available_to_read): + Remove "register" def for variable declaration + +Mon Jul 27 22:06:22 1998 Jonathan Larmour + + * src/stdio/common/stdiosupp.cxx: + Remove #if 0'd cyg_get_file_star() and unnecessary pseudo string + device definition + +Mon Jul 27 21:57:25 1998 Jonathan Larmour + + * include/pkgconf/libc.h, src/support/clibdata.cxx: + Change CYGXXX_LIBC_STDIO_DEFAULT_CONSOLE to + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE + +Mon Jul 27 21:49:23 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/setjmpsupp.hxx, + src/clibincl/stdiosupp.hxx, src/clibincl/stdlibsupp.hxx, + src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl, + src/clibincl/stringsupp.hxx, src/clibincl/timesupp.hxx: + + Change CYGONCE_LIBC_*_{HXX,INL} to CYGONCE_LIBC_CLIBINCL_*_{HXX,INL} + +Mon Jul 27 21:34:05 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change #define XXXXX 1 to #define XXXXX where applicable as per code + review + + Also remove obsolete CYGIMP_LIBC_THREAD_START_SUSPENDS_SELF + +Mon Jul 27 19:42:27 1998 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): + Use #ifdef, not #if for config options + +Mon Jul 27 15:01:51 BST 1998 Chris Provenzano + + * src/stdio/common/stream.cxx, src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx: + Fixes to compile with the new Cyg_IORB field names. + +Thu Jul 9 03:40:21 1998 Jonathan Larmour + + * tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Adjust starting of tests to possibly start scheduler since + strtol/stroul rely on errno, which may be a per-thread variable + +Thu Jul 9 03:06:25 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx, src/stdio/common/setvbuf.cxx: + Consolidate read and write buffers into single buffer, as it should + have been all along + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Add drain_buffer() method to speed up the case when we want the + buffer completely emptied + +Tue Jul 7 21:26:33 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Add a couple of new tests that check that very long strings work too + +Wed Jul 1 19:52:39 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/streambuf.hxx: + Do not permit copy constructors + + * src/clibincl/stream.inl, src/stdio/common/fclose.cxx: + Make sure we use #ifdef and not #if + + * src/clibincl/streambuf.inl: + Use member initialisation list rather than explicit initialisation to + reduce warnings + +Wed Jul 1 19:17:55 1998 Jonathan Larmour + + * include/pkgconf/libc.h and all files using config options: + Rename configuration defines to make them more standard + +Thu Jun 25 20:09:30 1998 Jonathan Larmour + + * src/string/strcat.cxx: + Add parentheses on check to silence warning + (Verified by proven) + +Thu Jun 25 19:30:01 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Make sure that the malloc pool is initialised before other things + can use it. This is done with the hot new constructor ordering + feature. + +Thu Jun 25 18:27:03 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Remove bogus ifdef if floating point is _not_ wanted + +Thu Jun 25 17:31:42 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Fix argument checking to allow first argument of NULL + +Thu Jun 25 04:18:50 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_strtok_last_p): + Remove bogus assertion + + * src/stdlib/malloc.cxx: + Got sense of alignment check assertion the wrong way round, so negate + it + +Thu Jun 25 03:56:35 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: + Fix argument checking assertions with legitimate nulls here too + +Thu Jun 25 03:46:32 1998 Jonathan Larmour + + * src/stdlib/strtoul.cxx, src/stdlib/strtol.cxx: + Fix argument checking assertions to cope with legitimate nulls + +Wed Jun 24 09:01:45 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Remove extraneous info messages + +Wed Jun 24 05:59:17 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c: + + Change large automatic arrays to static arrays to prevent overuse + of a potentially small stack + +Wed Jun 24 05:45:28 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/string/strtok.c, tests/time/clock.c: + + Increase thread stack size from 4K to 32K as in some cases it was + too small. + + +Tue Jun 23 20:12:31 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Add extra tests, including floating point conversion testing + +Tue Jun 23 17:01:06 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Make sure this is only compiled if CYGFUN_LIBC_strtok is defined + +Tue Jun 23 06:10:13 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + add some comments - that's all + + * src/stdio/common/stream.cxx: + fix case in refill_read_buffer() for what to do when there's nothing + left. Now return EAGAIN + + * src/stdio/common/vsscanf.cxx, src/stdio/input/vfscanf.cxx: + Get sscanf working properly and passing tests. Also make sure it + ignores FP when its not configured + + * src/stdlib/atof.cxx: + Only compile at all if strtod() is present + + +Mon Jun 22 19:13:42 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise strtok_last and rand_seed better + +Mon Jun 22 14:14:12 1998 Jonathan Larmour + + * tests/stdlib/malloc3.c: + Add test for checking that mallocing and freeing repeatedly works + + * tests/PKGconf.mak: + Update to reflect addition of the above + +Mon Jun 22 13:09:33 BST 1998 Chris Provenzano + + * src/stdio/common/fopen.cxx + * src/stdio/common/stream.cxx + * src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx + Include cyg/devs/common/iorb.h instead of iorb.hxx + + * src/stdio/common/stream.cxx + Use read_blocking and write_blocking instead of just read and + write when accessing devices through the virtual device table. + +Sun Jun 21 18:19:13 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Propagate change of return code handling for puts from stdio.inl + into here + + * src/stdio/output/fputc.cxx: + make sure the right type is used for output - byte not int + + * src/support/clibdata.cxx: + Fix #define config mistook. #endif was in wrong place + +Sun Jun 21 16:11:04 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Allow explicit construction to get around a bug when + dynamically allocating per-thread structure + +Sun Jun 21 16:02:51 1998 Jonathan Larmour + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, tests/stdlib/qsort.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + + Update tests to "do the right thing" with all configuration settings + + +Sun Jun 21 04:54:14 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + I have to be careful not to use setjmp() in a way not exactly + defined by the standard, so make sure I do, and add a comment + documenting these ways. + + Also ensure this test does the right thing in all configurations + +Sun Jun 21 04:38:15 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add extra checks for invalid configurations + Also make default for thread safety OFF + + * src/clibincl/clibdata.inl: + Adjust indentation + + * src/stdio/output/vfnprintf.cxx: + Make printf of -0.0 floating point do the right thing + +Sun Jun 21 04:28:00 1998 Jonathan Larmour + + * src/stdio/common/snprintf.cxx, src/stdio/common/sprintf.cxx, + src/stdio/common/sscanf.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/scanf.cxx, src/stdio/output/fnprintf.cxx, + src/stdio/output/fprintf.cxx, src/stdio/output/printf.cxx: + + Had to remove inline functions with varargs. Which means separating + out each function from stdioinlines.cxx into a separate file, as they + no longer belong there. So all the above files were created. + + * include/stdio.inl, src/PKGconf.mak, + src/stdio/common/stdioinlines.cxx: + Changed to take account of the above + + +Sun Jun 21 03:58:42 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c: + Update with floating-point tests. Also make sure they DTRT in all + configurations + +Fri Jun 19 19:33:06 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + accidentally initialised stdin/out/err twice + +Fri Jun 19 19:09:29 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Another typo + +Fri Jun 19 18:59:07 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Missing #endif typo + +Fri Jun 19 18:51:42 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Fix initialisation of static data members. Unsure how it worked at + all before! + +Fri Jun 19 18:01:01 1998 Jonathan Larmour + + * include/stdio.inl: + puts should check whether fputs returns non-negative, rather than + non-zero + +Fri Jun 19 17:22:52 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl: + Make inclusion of get_errno_p conditional on thread-safety + +Wed Jun 17 10:55:32 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Add weak alias of vfscanf() to _vfscanf() + +Wed Jun 17 09:10:41 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Initialise err to silence compiler warning + +Wed Jun 17 08:59:20 1998 Jonathan Larmour + + * Most important is the addition of floating point support in + src/stdio/output/vfnprintf.cxx and src/stdio/input/vfscanf.cxx. This + also required the addition of atof() and strtod() in stdlib which is + definitely no bad thing! Other than that... + + * Fix a whole bunch of stuff I messed up first time round. Also the + sprintf and sscanf tests are included again. + +Tue Jun 16 16:38:02 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Typo with not putting comment character at the beginning. Sigh. + +Tue Jun 16 14:53:09 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Forgot to (temporarily) remove fputs test for now + +Mon Jun 15 20:40:03 1998 Jonathan Larmour + + Everything to do with stdio has almost completely changed, so there's + not much point documenting individual changes. + +Mon Jun 15 18:36:01 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c: + Stop it moaning quite as much when it fails by making it exit sooner + + * tests/time/clock.c : + This isn't a compound testcase + +Thu Jun 11 17:59:13 1998 Jonathan Larmour + + * include/assert.h + Reverse sense of NDEBUG ifdef, that was left in accidentally due + to testing + +Thu Jun 11 04:58:08 1998 Jonathan Larmour + + * include/errno.h, include/string.h, src/clibincl/stringsupp.hxx: + Modify as I've now added an "error" package which defines the error + codes and strerror() + + * src/errno/strerror.cxx: + Moved to new error package and thus deleted + +Wed Jun 10 18:37:37 1998 Jonathan Larmour + + * include/assert.h: + create this header and add assert() function + +Wed Jun 10 16:23:57 1998 Jonathan Larmour + + * include/stdlib.h, src/clibincl/stdlibsupp.hxx, src/stdlib/malloc.cxx: + Add malloc(), calloc() and free() functions + + * include/pkgconf/libc.h: + Add malloc memory pool size option + + * tests/stdlib/malloc1.c, tests/stdlib/malloc2.c: + new tests for malloc + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for new files + +Wed Jun 10 15:06:16 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + Add another test + +Tue Jun 9 18:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add some setjmp config's and a macro for the noreturn attribute + + * include/setjmp.h, include/setjmp.inl, src/clibincl/setjmpsupp.hxx, + src/setjmp/longjmp.cxx, tests/setjmp/setjmp.c: + Added to implement and test setjmp() and longjmp() + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for newly added files + +Thu Jun 4 01:29:18 1998 Jonathan Larmour + + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, src/string/strcpy.cxx, + src/string/strlen.cxx, src/string/strncat.cxx, + src/string/strncmp.cxx, src/string/strncpy.cxx: + Rename CYGIMP_LIBC_PREFER_SMALL_TO_FAST to + CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST + + Also use slower but smaller version when __OPTIMIZE_SIZE__ is + defined (which comes from using gcc -Os) + +Fri May 29 16:15:04 1998 Jonathan Larmour + + * include/ctype.inl, src/ctype/isxdigit.cxx: + Fix bug that numerals aren't considered hex digits + + * include/time.h: + Change clock_t and time_t to be signed so that they can accept -1, as + required by other libc functions + + * src/clibincl/clibdata.hxx: + Fix typo that CYGIMP_LIBC_THREAD_SUPPORT should be ..._SAFETY + Also fix macro to allocate thread-specific data to not set variables + in a different stack-frame + + * tests/ctype/ctype.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/stdlib/qsort.c: + make ctr unsigned to prevent warnings + + * tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/string/strrchr.c: + Fix off by one error + + * tests/string/strspn.c: + Fix case-sensitivity problem, and off-by-one error + + * tests/string/strxfrm1.c: + Remove bogus bit of test that doesn't apply to strxfrm, and fix typo + + +Fri May 22 16:33:04 1998 Jonathan Larmour + + * src/PKGconf.mak + Remove CXXFLAGS line now that its redundant + + * tests/everything! + Do a blitz change of all tests - break some of them down into + different files, add new tests, standardize format, fix bugs, + update for recent header file changes and much more! + +Wed May 20 17:50:04 1998 Jonathan Larmour + + * tests/PKGconf.mak: + interim checkin for different dir structure for Bart + +Fri May 15 20:30:46 1998 Jonathan Larmour + + * Tidy up some loose ends I forgot: rename src/include directory to + src/clibincl. And add clibdata.inl and timesupp.hxx in there. + +Thu May 14 19:56:32 1998 Jonathan Larmour + + * Basically everything has changed in the C library. Files have + been moved, renamed, deleted and reworked. This is a major + revision, and now starts from this new baseline rather than doing + incremental changes. + +Fri Apr 17 18:43:02 1998 Jonathan Larmour + + * src/ECCconf.mak: + added for new build system (actually Bart did this, but didn't + update this ChangeLog) + +Fri Apr 17 15:03:25 1998 Hugo Tyson + + * src/stdio/device/sim.cxx: + Make it build with CYG_EMPTY_STATEMENT; the unadorned one is being + removed. + +Thu Apr 16 00:24:24 1998 Jonathan Larmour + + * All source files: + replace ECCIMP_LIBC_* conditional ifdef with CYGIMP_LIBC_* + + * include/eccconf/libc.h: + improve comments and reorder a bit + +Wed Apr 8 14:35:20 1998 Jonathan Larmour + + * Makefile.am, src/Makefile.am, tests/Makefile.am, configure.in: + many changes to integrate build structure from release tree + + * src/ctype/Makefile.am, src/ctype/Makefile.in, src/errno/Makefile.am, + src/errno/Makefile.in, src/stdio/Makefile.am, src/stdio/Makefile.in, + src/stdio/common/Makefile.am, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.am, src/stdio/device/Makefile.in, + src/stdio/output/Makefile.am, src/stdio/output/Makefile.in, + src/stdio/input/Makefile.am, src/stdio/input/Makefile.in, + src/stdlib/Makefile.am, src/stdlib/Makefile.in, + src/string/Makefile.am, src/string/Makefile.in, + src/support/Makefile.am, src/support/Makefile.in, + src/time/Makefile.am, src/time/Makefile.in: + Remove as they are now redundant with above changes + + * include/Makefile.am: + Add to support above changes + + * include/eccconf/libc.h: + Change include file for configuration from kernel to system + + * src/include/kerndiag.hxx, src/stdio/device/kerndiag.cxx, + src/time/clockfn.cxx: + Change kernel include file to eccconf/kernel.h + + * src/include/strngdev.h: + remove unnecessary kernel include + + * Makefile.in, aclocal.m4, configure, src/Makefile.in, + tests/Makefile.in, include/Makefile.in: + regenerate + +Mon Apr 6 20:55:07 1998 Jonathan Larmour + + * src/stdlib/abs.cxx, src/stdlib/atoi.cxx, src/stdlib/atol.cxx, + src/stdlib/div.cxx, src/stdlib/labs.cxx, src/stdlib/ldiv.cxx: + Separated out functions from stdlib.cxx into separate files + + * src/stdlib/stdlib.cxx: + removed to be replaced by above files + + * Makefile.am, src/stdlib/Makefile.am: + modified to support building above and not building stdlib.cxx + + * src/support/tsd.cxx: + Remove unnecessary header file includes + + * Makefile.in, src/stdlib/Makefile.in: + regenerated + +Mon Apr 6 19:19:42 1998 Jonathan Larmour + + * src/support/tsd.cxx, include/eccconf/libc.h: + remove lame hack for tx39 compiler now that its fixed + + * src/include/sim.hxx: + define constants as static to placate compiler + +Thu Apr 2 21:01:21 1998 Jonathan Larmour + + * src/ctype/ctype.cxx: + deleted and separated out into below files + + * src/ctype/isalnum.cxx, src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, src/ctype/islower.cxx, + src/ctype/isprint.cxx, src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, src/ctype/tolower.cxx, + src/ctype/toupper.cxx: + Separated out individual ctype functions from ctype.cxx into separate + files + + * Makefile.am, src/ctype/Makefile.am: + modified to reflect above deletion/additions + + * Makefile.in, src/ctype/Makefile.in: + regenerated + +Thu Apr 2 19:08:26 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: optimise using prefix increments + +Thu Apr 2 15:18:15 1998 Jonathan Larmour + + * src/string/strchr.cxx: optimise setting of mask a little + +Thu Mar 26 14:07:01 1998 Jonathan Larmour + + * src/support/tsd.cxx: fixed some typos + +Thu Mar 26 11:58:47 1998 Jonathan Larmour + + * include/eccconf/libc.h, src/support/tsd.cxx: + Implement workaround for tx39 compiler bug. + + * src/include/strsuppt.hxx: + remove prototypes for _memcpy() and _memset() as they are now in the + kernel + +Wed Mar 25 18:31:53 1998 Jonathan Larmour + + * Makefile.am, src/string/Makefile.am: memcpy() and memset() are + now in the kernel so remove them from build + * include/string.h: add a comment to say as much + * Makefile.in, src/string/Makefile.in: regenerate + +Wed Mar 25 15:30:42 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx, src/include/file_if.inl: + Change _exit workaround to not cause a compiler optimisation + problem. Now just references _exit rather than calls it. + +Wed Mar 25 14:59:49 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fix bug causing tests to fail completely + for this function + +Wed Mar 25 12:55:53 1998 Jonathan Larmour + + * src/include/sim.hxx: add types to constants (oops!) + * Makefile.am: link src/stdio/device/sim.cxx + * Makefile.in: regenerated + +Wed Mar 25 04:14:30 1998 Jonathan Larmour + + * src/include/file_if.hxx, src/include/file_if.inl, + src/include/kerndiag.hxx, src/include/sim.hxx, + src/include/stdio_if.hxx, src/include/strngdev.hxx, + src/include/tsd.hxx, src/stdio/common/clearerr.cxx, + src/stdio/common/clearerr.cxx, src/stdio/common/feof.cxx, + src/stdio/common/ferror.cxx, src/stdio/common/file_if.cxx, + src/stdio/common/vsprintf.cxx, + src/stdio/device/kerndiag.cxx, src/stdio/device/sim.cxx, + src/stdio/device/strngdev.cxx, src/stdio/output/fputc.cxx, + src/stdio/output/fputs.cxx, src/stdio/output/puts.cxx, + src/stdio/output/vfnprintf.cxx, src/support/tsd.cxx: + Modified to support buffered reads including renaming + _EccInternalFileStruct to __EccStdioStream which is what affects + most of these files + * src/include/file_if.inl, src/stdio/common/file_if.cxx: added for + the above reason + * src/stdio/common/sscanf.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/input/Makefile.am: added to provide sscanf() functionality + * include/ctype.h, include/stdio.h, include/stdlib.h, + include/string.h, include/eccconf/libc.h, src/ctype/ctype.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/stdio/common/stdio.cxx: + rename *_INLINES macros with prefix CYG rather than ECC + * include/errno.h, src/errno/errno.cxx, src/errno/strerror.cxx: + rename ErrNo to _ErrNo and add EAGAIN and EWOULDBLOCK error codes + * configure.in, Makefile.am, src/stdio/Makefile.am, + src/stdio/input/Makefile.am: add support for building + file_if.cxx sscanf.cxx and vfscanf.cxx + * src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/input/Makefile.in, configure, Makefile.in: regenerated + +Tue Mar 24 19:51:40 1998 Jonathan Larmour + + * src/time/clockfn.cxx, src/time/clock.cxx: + Renamed clock.cxx to clockfn.cxx (preserving CVS history) + * Makefile.am, src/time/Makefile.am: updated to reflect name change + * Makefile.in, src/time/Makefile.in: regenerated + +Tue Mar 24 16:28:06 1998 Jonathan Larmour + + * include/ctype.inl: Swap around definitions to get right order so + inlining works + +Tue Mar 24 14:43:05 1998 Jonathan Larmour + + * include/ctype.h, include/stdio.h, include/stdlib.h, include/string.h: + modify to only conditionally include inlines + * src/ctype/ctype.cxx, src/stdio/common/stdio.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/ctype/Makefile.am: Add to provide real linkable alternatives + to inline functions + * Makefile.am, configure.in, src/Makefile.am, + src/stdio/common/Makefile.am, src/stdlib/Makefile.am, + src/string/Makefile.am: modified to support previous additions + * include/eccconf/libc.h: redefine inline macro to add extern inline, + and add conditional defines for inline functions. Also rename + space vs. speed macro to have CYG instead of ECC prefix + * include/stdio.inl: fix comment typo + * src/stdlib/qsort.cxx: fix to define inline functions properly + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/memcpy.cxx, + src/string/memset.cxx, src/string/strcat.cxx, src/string/strchr.cxx, + src/string/strcmp.cxx, src/string/strcpy.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx + * Makefile.in, configure, src/Makefile.in, src/ctype/Makefile.in, + src/stdio/common/Makefile.in, src/stdlib/Makefile.in, + src/string/Makefile.in: regenerate + + +Mon Mar 23 19:19:49 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: added to support temporary _exit + * include/stdlib.h, include/stdlib.inl: added support for _exit and + added abs(), labs(), div() and ldiv() functions + * src/include/file_if.hxx: added support for _exit kludge + * src/stdlib/qsort.cxx: Added Berkeley copyright message + * src/time/clock.cxx: Include correct kernel config header as + CYG_CONFIGURATION rather than + * Makefile.am src/stdlib/Makefile.am: added support for _exit + * Makefile.in, src/stdlib/Makefile.in: regenerated + +Mon Mar 23 14:41:07 1998 Jonathan Larmour + + * Replace ECCPKG_ANSI_LIBC with CYGPKG_ANSI_LIBC in all source files + +Mon Mar 23 14:28:44 1998 Jonathan Larmour + + * include/string.inl: add file to provide strcoll() + * include/string.h: include string.inl + * ctype.h: include ctype.inl (oops!) + * include/stdlib.h: include stdlib.inl (oops!) + +Mon Mar 23 13:30:38 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl: added to provide ANSI ctype + functionality + * include/stdlib.h, include/stdlib.inl, src/include/stdlibbsp.hxx, + src/stdlib/Makefile.am, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/stdlib/srand.cxx, + src/stdlib/strtol.cxx, src/stdlib/strtoul.cxx: Added to provide + many stdlib functions + * src/include/tsd.hxx: modified to support rand() random number + seed, and added some comments + * configure.in, Makefile.am, src/Makefile.am: modified to support + addition of above new sources + * include/eccconf/libc.h: Add extra helpful comments, and #include + kernel config file + * src/time/clock.cxx: #include clock.inl and fix to call + get_resolution() properly now + * Makefile.in, configure, src/Makefile.in, src/errno/Makefile.in, + src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.in, src/stdio/output/Makefile.in, + src/stdlib/Makefile.in, src/strings/Makefile.in, + src/support/Makefile.in, src/time/Makefile.in, + tests/Makefile.in: regenerated + + +Sun Mar 22 21:29:25 1998 Jonathan Larmour + + * include/time.h, src/include/timesupp.hxx, src/time/clock.cxx, + src/time/Makefile.am: added to provide clock() function + * src/Makefile.am: modified to try to build in src/time directory + * include/eccconf/libc.h: added and is now the main configuration + file for this package + * acconfig.h, include/libcconf.h.in, include/stamp-h.in: removed + due to usage of libc.h above instead + * Almost all *.h, *.hxx and *.cxx: replaced LIBC_CONFIG_HEADER + defined include with simple + * configure.in: remove AM_CONFIG_HEADER of libcconf.h and + LIBC_CONFIG_HEADER definition. Also remove usage of builtin + memcpy() etc. from gcc, and generate src/time/Makefile + * Makefile.am: link in src/time/clock.o + * src/include/file_if.hxx, src/include/sim.hxx: use config header + to decide whether C library is to be used + * Makefile.in, aclocal.m4, configure, src/Makefile.in: regenerated + +Fri Mar 20 18:08:10 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fixed bug with ignoring terminating NULL + +1998-03-20 Chris Tarpy + + * configure: - regenerated + * Makefile.am: - Support added for libc testcases + * Makefile.in: regenerated + * configure.in: set c compiler, descend test dir + * tests/Makefile.in: added + * tests/Makefile.am: added + * tests/tcdiag.cxx : added + + +Thu Mar 19 11:41:56 1998 Jonathan Larmour + + * Initial check-in of everything + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/stdlib/current/cdl/stdlib.cdl b/packages/language/c/libc/stdlib/current/cdl/stdlib.cdl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/cdl/stdlib.cdl @@ -0,0 +1,274 @@ +# ==================================================================== +# +# stdlib.cdl +# +# C library stdlib related configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jlarmour +# Contributors: +# Date: 2000-04-14 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_LIBC_STDLIB { + display "ISO C library general utility functions" + description " + This package provides general utility functions in + as specified by the ISO C standard - ISO/IEC 9899:1990." + doc redirect/the-iso-standard-c-and-math-libraries.html + include_dir cyg/libc/stdlib + parent CYGPKG_LIBC + requires CYGPKG_ISOINFRA + implements CYGINT_ISO_STDLIB_STRCONV + implements CYGINT_ISO_STDLIB_ENVIRON + implements CYGINT_ISO_STDLIB_SYSTEM + implements CYGINT_ISO_BSEARCH + implements CYGINT_ISO_QSORT + implements CYGINT_ISO_ABS + implements CYGINT_ISO_DIV + requires CYGINT_ISO_CTYPE + + compile abs.cxx atox.cxx bsearch.cxx \ + div.cxx getenv.cxx qsort.cxx \ + rand.cxx strtod.cxx strtol.cxx \ + strtoul.cxx system.cxx + +# ==================================================================== + + cdl_component CYGIMP_LIBC_STDLIB_INLINES { + display "Inline versions of functions" + flavor none + no_define + description " + This option chooses whether some of the + particularly simple standard utility functions + from are available as inline + functions. This may improve performance, and as + the functions are small, may even improve code + size." + + cdl_option CYGIMP_LIBC_STDLIB_INLINE_ABS { + display "abs() / labs()" + default_value 1 + no_define + requires { CYGBLD_ISO_STDLIB_ABS_HEADER == \ + "" } + } + + cdl_option CYGIMP_LIBC_STDLIB_INLINE_DIV { + display "div() / ldiv()" + default_value 1 + no_define + requires { CYGBLD_ISO_STDLIB_DIV_HEADER == \ + "" } + } + + cdl_option CYGIMP_LIBC_STDLIB_INLINE_ATOX { + display "atof() / atoi() / atol()" + default_value 1 + no_define + requires { CYGBLD_ISO_STDLIB_STRCONV_HEADER == \ + "" } + } + } + + cdl_component CYGPKG_LIBC_RAND { + display "Random number generation" + flavor none + description " + These options control the behaviour of the + functions rand(), srand() and rand_r()" + + cdl_option CYGSEM_LIBC_PER_THREAD_RAND { + display "Per-thread random seed" + requires CYGVAR_KERNEL_THREADS_DATA + default_value 0 + description " + This option controls whether the pseudo-random + number generation functions rand() and srand() + have their state recorded on a per-thread + basis rather than global. If this option is + disabled, some per-thread space can be saved. + Note there is also a POSIX-standard rand_r() + function to achieve a similar effect with user + support. Enabling this option will use one slot + of kernel per-thread data. You should ensure you + have enough slots configured for all your + per-thread data." + } + + cdl_option CYGNUM_LIBC_RAND_SEED { + display "Random number seed" + flavor data + legal_values 0 to 0x7fffffff + default_value 1 + description " + This selects the initial random number seed for + rand()'s pseudo-random number generator. For + strict ISO standard compliance, this should be 1, + as per section 7.10.2.2 of the standard." + } + + cdl_option CYGNUM_LIBC_RAND_TRACE_LEVEL { + display "Tracing level" + flavor data + legal_values 0 to 1 + default_value 0 + description " + Trace verbosity level for debugging the rand(), + srand() and rand_r() functions. Increase this + value to get additional trace output." + } + + cdl_option CYGIMP_LIBC_RAND_SIMPLEST { + display "Simplest implementation" + flavor bool + default_value 0 + implements CYGINT_ISO_RAND + description " + This provides a very simple implementation of rand() + that does not perform well with randomness in the + lower significant bits. However it is exceptionally + fast. It uses the sample algorithm from the ISO C + standard itself." + } + + cdl_option CYGIMP_LIBC_RAND_SIMPLE1 { + display "Simple implementation #1" + flavor bool + default_value 1 + implements CYGINT_ISO_RAND + description " + This provides a very simple implementation of rand() + based on the simplest implementation above. However + it does try to work around the lack of randomness + in the lower significant bits, at the expense of a + little speed." + } + + cdl_option CYGIMP_LIBC_RAND_KNUTH1 { + display "Knuth implementation #1" + flavor bool + default_value 0 + implements CYGINT_ISO_RAND + description " + This implements a slightly more complex algorithm + published in Donald E. Knuth's Art of Computer + Programming Vol.2 section 3.6 (p.185 in the 3rd ed.). + This produces better random numbers than the + simplest approach but is slower." + } + } + + cdl_option CYGFUN_LIBC_strtod { + display "Provides strtod()" + requires CYGPKG_LIBM + default_value { 0 != CYGPKG_LIBM } + implements CYGINT_ISO_STDLIB_STRCONV_FLOAT + description " + This option allows use of the utility function + strtod() (and consequently atof()) to convert + from string to double precision floating point + numbers. Disabling this option removes the + dependency on the math library package." + } + + cdl_option CYGNUM_LIBC_BSEARCH_TRACE_LEVEL { + display "bsearch() tracing level" + flavor data + legal_values 0 to 1 + default_value 0 + description " + Trace verbosity level for debugging the + binary search function bsearch(). Increase this + value to get additional trace output." + } + + cdl_option CYGNUM_LIBC_QSORT_TRACE_LEVEL { + display "qsort() tracing level" + flavor data + legal_values 0 to 1 + default_value 0 + description " + Trace verbosity level for debugging the + quicksort function qsort(). Increase this value + to get additional trace output." + } + + +# ==================================================================== + + cdl_component CYGPKG_LIBC_STDLIB_OPTIONS { + display "C library stdlib build options" + flavor none + no_define + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_LIBC_STDLIB_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building this package. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_LIBC_STDLIB_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building this package. These flags are removed from + the set of global flags if present." + } + + cdl_option CYGPKG_LIBC_STDLIB_TESTS { + display "C library stdlib tests" + flavor data + no_define + calculated { "tests/abs tests/atoi tests/atol tests/bsearch tests/div tests/getenv tests/labs tests/ldiv tests/qsort tests/rand1 tests/rand2 tests/rand3 tests/rand4 tests/srand tests/strtol tests/strtoul" } + description " + This option specifies the set of tests for this package." + } + } +} + +# ==================================================================== +# EOF stdlib.cdl diff --git a/packages/language/c/libc/stdlib/current/include/abs.inl b/packages/language/c/libc/stdlib/current/include/abs.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/include/abs.inl @@ -0,0 +1,105 @@ +#ifndef CYGONCE_LIBC_STDLIB_ABS_INL +#define CYGONCE_LIBC_STDLIB_ABS_INL +/*=========================================================================== +// +// abs.inl +// +// Inline implementations for the ISO standard utility functions +// abs() and labs() defined in section 7.10 of the standard +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-28 +// Purpose: +// Description: +// Usage: Do not include this file directly - include instead +// +//####DESCRIPTIONEND#### +// +//=========================================================================*/ + +/* INCLUDES */ + +#include /* Tracing support */ + +/* FUNCTION PROTOTYPES */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int +abs( int /* val */ ) __attribute__((__const__)); + +extern long +labs( long /* val */ ) __attribute__((__const__)); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* INLINE FUNCTIONS */ + +#ifndef CYGPRI_LIBC_STDLIB_ABS_INLINE +# define CYGPRI_LIBC_STDLIB_ABS_INLINE extern __inline__ +#endif + +CYGPRI_LIBC_STDLIB_ABS_INLINE int +abs( int __j ) +{ + int __retval; + + CYG_REPORT_FUNCNAMETYPE( "abs", "returning %d" ); + + __retval = (__j<0) ? -__j : __j; + + CYG_REPORT_RETVAL( __retval ); + + return __retval; +} /* abs() */ + +CYGPRI_LIBC_STDLIB_ABS_INLINE long +labs( long __j ) +{ + long __retval; + + CYG_REPORT_FUNCNAMETYPE( "abs", "returning %ld" ); + + __retval = (__j<0) ? -__j : __j; + + CYG_REPORT_RETVAL( __retval ); + + return __retval; +} /* labs() */ + + +#endif /* CYGONCE_LIBC_STDLIB_ABS_INL multiple inclusion protection */ + +/* EOF abs.inl */ diff --git a/packages/language/c/libc/stdlib/current/include/atox.inl b/packages/language/c/libc/stdlib/current/include/atox.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/include/atox.inl @@ -0,0 +1,153 @@ +#ifndef CYGONCE_LIBC_STDLIB_ATOX_INL +#define CYGONCE_LIBC_STDLIB_ATOX_INL +/*=========================================================================== +// +// atox.inl +// +// Inline implementations for the ISO standard utility functions +// atoi(), atol() and atof() defined in section 7.10 of the standard +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-28 +// Purpose: +// Description: +// Usage: Do not include this file directly - include instead +// +//####DESCRIPTIONEND#### +// +//=========================================================================*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +/* INCLUDES */ + +#include /* NULL */ +#include /* Tracing support */ + +/* FUNCTION PROTOTYPES */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CYGFUN_LIBC_strtod +extern double +atof( const char * /* double_str */ ); +#endif + +extern int +atoi( const char * /* int_str */ ); + +extern long +atol( const char * /* long_str */ ); + +#ifdef CYGFUN_LIBC_strtod +extern double +strtod( const char * /* double_str */, char ** /* endptr */ ); +#endif + +extern long +strtol( const char * /* long_str */, char ** /* endptr */, + int /* base */ ); + +extern unsigned long +strtoul( const char * /* ulong_str */, char ** /* endptr */, + int /* base */ ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* INLINE FUNCTIONS */ + +/* 7.10.1 String conversion functions */ + +#ifndef CYGPRI_LIBC_STDLIB_ATOX_INLINE +# define CYGPRI_LIBC_STDLIB_ATOX_INLINE extern __inline__ +#endif + + +#ifdef CYGFUN_LIBC_strtod +CYGPRI_LIBC_STDLIB_ATOX_INLINE double +atof( const char *__nptr ) +{ + double __retval; + + CYG_REPORT_FUNCNAMETYPE( "atof", "returning %f" ); + + CYG_CHECK_DATA_PTR( __nptr, "__nptr is an invalid pointer!" ); + + __retval = strtod( __nptr, (char **)NULL ); + + CYG_REPORT_RETVAL( __retval ); + + return __retval; +} /* atof() */ +#endif + +CYGPRI_LIBC_STDLIB_ATOX_INLINE int +atoi( const char *__nptr ) +{ + int __retval; + + CYG_REPORT_FUNCNAMETYPE( "atoi", "returning %d" ); + + CYG_CHECK_DATA_PTR( __nptr, "__nptr is an invalid pointer!" ); + + __retval = (int)strtol( __nptr, (char **)NULL, 10 ); + + CYG_REPORT_RETVAL( __retval ); + + return __retval; +} /* atoi() */ + + +CYGPRI_LIBC_STDLIB_ATOX_INLINE long +atol( const char *__nptr ) +{ + long __retval; + + CYG_REPORT_FUNCNAMETYPE( "atol", "returning %ld" ); + + CYG_CHECK_DATA_PTR( __nptr, "__nptr is an invalid pointer!" ); + + __retval = strtol( __nptr, (char **)NULL, 10 ); + + CYG_REPORT_RETVAL( __retval ); + + return __retval; +} /* atol() */ + +#endif /* CYGONCE_LIBC_STDLIB_ATOX_INL multiple inclusion protection */ + +/* EOF atox.inl */ diff --git a/packages/language/c/libc/stdlib/current/include/div.inl b/packages/language/c/libc/stdlib/current/include/div.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/include/div.inl @@ -0,0 +1,209 @@ +#ifndef CYGONCE_LIBC_STDLIB_DIV_INL +#define CYGONCE_LIBC_STDLIB_DIV_INL +/*=========================================================================== +// +// div.inl +// +// Inline implementations for the ISO standard utility functions +// div() and ldiv() +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-28 +// Purpose: +// Description: +// Usage: Do not include this file directly - include instead +// +//####DESCRIPTIONEND#### +// +//=========================================================================*/ + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Assertion support +#include // Tracing support + +/* TYPE DEFINITIONS */ + +/* return type of the div() function */ + +typedef struct { + int quot; /* quotient */ + int rem; /* remainder */ +} div_t; + + +/* return type of the ldiv() function */ + +typedef struct { + long quot; /* quotient */ + long rem; /* remainder */ +} ldiv_t; + +/* FUNCTION PROTOTYPES */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern div_t +div( int /* numerator */, int /* denominator */ ) __attribute__((__const__)); + +extern ldiv_t +ldiv( long /* numerator */, long /* denominator */ ) __attribute__((__const__)); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* FUNCTIONS */ + +#ifndef CYGPRI_LIBC_STDLIB_DIV_INLINE +# define CYGPRI_LIBC_STDLIB_DIV_INLINE extern __inline__ +#endif + +CYGPRI_LIBC_STDLIB_DIV_INLINE div_t +div( int __numer, int __denom ) +{ + div_t __ret; + + CYG_REPORT_FUNCNAMETYPE( "div", "quotient: %d"); + CYG_REPORT_FUNCARG2DV( __numer, __denom ); + // FIXME: what if they want it handled with SIGFPE? Should have option + CYG_PRECONDITION(__denom != 0, "division by zero attempted!"); + + __ret.quot = __numer / __denom; + __ret.rem = __numer % __denom; + + // But the modulo is implementation-defined for -ve numbers (ISO C 6.3.5) + // and we are required to "round" to zero (ISO C 7.10.6.2) + // + // The cases we have to deal with are inexact division of: + // a) + div + + // b) + div - + // c) - div + + // d) - div - + // + // a) can never go wrong and the quotient and remainder are always positive + // b) only goes wrong if the negative quotient has been "rounded" to + // -infinity - if so then the remainder will be negative when it + // should be positive or zero + // c) only goes wrong if the negative quotient has been "rounded" to + // -infinity - if so then the remainder will be positive when it + // should be negative or zero + // d) only goes wrong if the positive quotient has been rounded to + // +infinity - if so then the remainder will be positive when it + // should be negative or zero + // + // So the correct sign of the remainder corresponds to the sign of the + // numerator. Which means we can say that the result needs adjusting + // iff the sign of the numerator is different from the sign of the + // remainder. + // + // You may be interested to know that the Berkeley version of div() + // would get this wrong for e.g. (c) and (d) on some targets. + // e.g. for (-5)/4 it could leave the result as -2R3 + + if ((__ret.rem < 0) && (__numer > 0)) { + ++__ret.quot; + __ret.rem -= __denom; + } else if ((__ret.rem > 0) && (__numer < 0)) { + --__ret.quot; + __ret.rem += __denom; + } // else + + CYG_REPORT_RETVAL( __ret.quot ); + + return __ret; +} // div() + +CYGPRI_LIBC_STDLIB_DIV_INLINE ldiv_t +ldiv( long __numer, long __denom ) +{ + ldiv_t __ret; + + CYG_REPORT_FUNCNAMETYPE( "ldiv", "quotient: %d"); + CYG_REPORT_FUNCARG2DV( __numer, __denom ); + // FIXME: what if they want it handled with SIGFPE? Should have option + CYG_PRECONDITION(__denom != 0, "division by zero attempted!"); + + __ret.quot = __numer / __denom; + __ret.rem = __numer % __denom; + + // But the modulo is implementation-defined for -ve numbers (ISO C 6.3.5) + // and we are required to "round" to zero (ISO C 7.10.6.2) + // + // The cases we have to deal with are inexact division of: + // a) + div + + // b) + div - + // c) - div + + // d) - div - + // + // a) can never go wrong and the quotient and remainder are always positive + // b) only goes wrong if the negative quotient has been "rounded" to + // -infinity - if so then the remainder will be negative when it + // should be positive or zero + // c) only goes wrong if the negative quotient has been "rounded" to + // -infinity - if so then the remainder will be positive when it + // should be negative or zero + // d) only goes wrong if the positive quotient has been rounded to + // +infinity - if so then the remainder will be positive when it + // should be negative or zero + // + // So the correct sign of the remainder corresponds to the sign of the + // numerator. Which means we can say that the result needs adjusting + // iff the sign of the numerator is different from the sign of the + // remainder. + // + // You may be interested to know that the Berkeley version of ldiv() + // would get this wrong for e.g. (c) and (d) on some targets. + // e.g. for (-5)/4 it could leave the result as -2R3 + + if ((__ret.rem < 0) && (__numer > 0)) { + ++__ret.quot; + __ret.rem -= __denom; + } else if ((__ret.rem > 0) && (__numer < 0)) { + --__ret.quot; + __ret.rem += __denom; + } // else + + CYG_REPORT_RETVAL( __ret.quot ); + + return __ret; +} // ldiv() + + +#endif // CYGONCE_LIBC_STDLIB_DIV_INL multiple inclusion protection + +// EOF div.inl diff --git a/packages/language/c/libc/stdlib/current/src/abs.cxx b/packages/language/c/libc/stdlib/current/src/abs.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/src/abs.cxx @@ -0,0 +1,55 @@ +//=========================================================================== +// +// abs.cxx +// +// ISO C standard abs()/labs() utility functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-28 +// Purpose: +// Description: Real alternative for inline implementation of the ISO +// standard abs()/labs() utility functions defined in +// section 7.10.6.1 of the standard +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// We don't want the inline versions of abs/labs defined here + +#define CYGPRI_LIBC_STDLIB_ABS_INLINE + +/* This means that including abs.inl will make the outline functions */ + +#include + +// EOF abs.cxx diff --git a/packages/language/c/libc/stdlib/current/src/atox.cxx b/packages/language/c/libc/stdlib/current/src/atox.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/src/atox.cxx @@ -0,0 +1,55 @@ +//=========================================================================== +// +// atox.cxx +// +// ISO C standard atoi(), atol() and atof() utility functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-28 +// Purpose: +// Description: Real alternative for inline implementation of the ISO +// standard atoi(), atol() and atof() utility functions defined +// in sections 7.10.1.1, 7.10.1.2 and 7.10.1.3 of the standard +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// We don't want the inline versions of atoi(), atol() and atof() defined here + +#define CYGPRI_LIBC_STDLIB_ATOX_INLINE + +/* This means that including atox.inl will make the outline functions */ + +#include + +// EOF atox.cxx diff --git a/packages/language/c/libc/stdlib/current/src/bsearch.cxx b/packages/language/c/libc/stdlib/current/src/bsearch.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/src/bsearch.cxx @@ -0,0 +1,123 @@ +//=========================================================================== +// +// bsearch.cxx +// +// ANSI standard binary search function defined in section 7.10.5.1 +// of the standard +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // Tracing support +#include // Assertion support +#include // Header for all stdlib functions + // (like this one) + +// TRACING + +# if defined(CYGDBG_USE_TRACING) && \ + defined(CYGNUM_LIBC_BSEARCH_TRACE_LEVEL) +static int bsearch_trace = CYGNUM_LIBC_BSEARCH_TRACE_LEVEL; +# define TL1 (0 < bsearch_trace) +# else +# define TL1 (0) +# endif + + +// FUNCTIONS + +externC void * +bsearch( const void *key, const void *base, size_t nmemb, size_t size, + __bsearch_comparison_fn_t compar ) +{ + CYG_REPORT_FUNCNAMETYPE( "bsearch", "returning %08x" ); + + CYG_REPORT_FUNCARG5( "key=%08x, base=%08x, nmemb=%d, size=%d, " + "compar=%08x", key, base, nmemb, size, compar ); + + CYG_CHECK_DATA_PTR( key, "key is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( base, "base is not a valid pointer!" ); + CYG_CHECK_FUNC_PTR( compar, "compar is not a valid function pointer!" ); + + CYG_ADDRESS current; + size_t lower = 0; + size_t upper = nmemb; + size_t index; + int result; + + if (nmemb == 0 || size == 0) + { + CYG_TRACE2( TL1, "Warning! either nmemb (%d) or size (%d) is 0", + nmemb, size ); + CYG_REPORT_RETVAL( NULL ); + return NULL; + } // if + + while (lower < upper) + { + index = (lower + upper) / 2; + current = (CYG_ADDRESS) (((char *) base) + (index * size)); + + CYG_TRACE2( TL1, "About to call comparison function with " + "key=%08x, current=%08x", key, current ); + result = compar (key, (void *) current); + CYG_TRACE1( TL1, "Comparison function returned %d", result ); + + if (result < 0) + upper = index; + else if (result > 0) + lower = index + 1; + else + { + CYG_REPORT_RETVAL( current ); + return (void *)current; + } // else + } // while + + CYG_REPORT_RETVAL( NULL ); + return NULL; +} // bsearch() + +// EOF bsearch.cxx diff --git a/packages/language/c/libc/stdlib/current/src/div.cxx b/packages/language/c/libc/stdlib/current/src/div.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/src/div.cxx @@ -0,0 +1,56 @@ +//=========================================================================== +// +// div.cxx +// +// ISO C implementation for div()/ldiv() utility functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-28 +// Description: Real alternative for inline implementation of the ISO +// standard div()/ldiv() utility functions defined in +// section 7.10.6.2 of the standard +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== +// + +// We don't want the inline versions of div/ldiv defined here + +#define CYGPRI_LIBC_STDLIB_DIV_INLINE + +/* This means that including div.inl will make the outline functions */ + +#include + +// EOF div.cxx diff --git a/packages/language/c/libc/stdlib/current/src/getenv.cxx b/packages/language/c/libc/stdlib/current/src/getenv.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/src/getenv.cxx @@ -0,0 +1,127 @@ +//======================================================================== +// +// getenv.cxx +// +// Implementation of the ISO C standard getenv() function +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // Tracing support +#include // Tracing support +#include // Main header for stdlib functions +#include // strchr(), strlen() and strncmp() + + +// VARIABLES + +externC char **environ; // standard definition of environ + +// FUNCTIONS + +extern char * +getenv( const char *name ) +{ + // This function assumes the POSIX 1003.1 layout of the environment + // in the environ variable, i.e. extern char **environ is a pointer + // to an array of character pointers to the environment strings + // (POSIX 3.1.2.2 and 2.6). + // + // getenv() searches the environment list for a string of the form + // "name=value" (POSIX 4.6.1). The strings must have this form + // (POSIX 2.6) + + CYG_REPORT_FUNCNAMETYPE( "getenv", "returning %08x" ); + + CYG_PRECONDITION( name != NULL, "getenv() called with NULL string!" ); + + CYG_REPORT_FUNCARG1( "name=%s", name ); + + CYG_PRECONDITION( environ != NULL, + "environ not set i.e. environ == NULL" ); + + CYG_CHECK_DATA_PTR( environ, "environ isn't a valid pointer!" ); + + CYG_CHECK_DATA_PTR( name, "name isn't a valid pointer!" ); + + // check name doesn't contain '=' + CYG_PRECONDITION( strchr(name, '=') == NULL, + "name contains '='!" ); + + char **env_str_p; + cyg_ucount32 len = strlen( name ); + + for (env_str_p = environ; *env_str_p != NULL; ++env_str_p ) { + + CYG_CHECK_DATA_PTR( env_str_p, + "current environment string isn't valid!" ); + + CYG_CHECK_DATA_PTR( *env_str_p, + "current environment string isn't valid!" ); + + // do we have a match? + if ( !strncmp(*env_str_p, name, len) ) { + // but it could be just a prefix i.e. we could have + // matched MYNAMEFRED when we're looking for just MYNAME, so: + + if ( (*env_str_p)[len] == '=' ) { + // we got a match + CYG_REPORT_RETVAL( *env_str_p + len + 1 ); + + return (*env_str_p + len + 1); + } // if + } // if + + // check the next pointer isn't NULL, as we're about to dereference + // it + CYG_ASSERT( env_str_p+1 != NULL, + "environment contains a NULL pointer!" ); + } // for + + CYG_REPORT_RETVAL( NULL ); + return NULL; +} // getenv() + +// EOF getenv.cxx diff --git a/packages/language/c/libc/stdlib/current/src/qsort.cxx b/packages/language/c/libc/stdlib/current/src/qsort.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/src/qsort.cxx @@ -0,0 +1,275 @@ +//=========================================================================== +// +// qsort.cxx +// +// ANSI standard sorting function defined in section 7.10.5.2 +// of the standard +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== +// +// This code is based on original code with the following copyright: +// +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // Tracing support +#include // Assertion support +#include // Header for all stdlib functions + // (like this one) + +// TRACING + +# if defined(CYGDBG_USE_TRACING) && defined(CYGNUM_LIBC_QSORT_TRACE_LEVEL) +static int qsort_trace = CYGNUM_LIBC_QSORT_TRACE_LEVEL; +# define TL1 (0 < qsort_trace) +# else +# define TL1 (0) +# endif + + +// FUNCTION PROTOTYPES + +static __inline__ char *med3(char *, char *, char *, __qsort_comparison_fn_t); +static __inline__ void swapfunc(char *, char *, int, int); + + +// MACRO FUNCTIONS + +#define min(a, b) ((a) < (b) ? (a) : (b)) + +// +// Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". +// + +#define swapcode(TYPE, parmi, parmj, n) do { \ + long i = (n) / sizeof (TYPE); \ + TYPE *pi = (TYPE *) (parmi); \ + TYPE *pj = (TYPE *) (parmj); \ + do { \ + TYPE t = *pi; \ + *pi++ = *pj; \ + *pj++ = t; \ + } while (--i > 0); \ +} while (0) + +#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ + es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; + + +#define swap(a, b) \ + if (swaptype == 0) { \ + long t = *(long *)(a); \ + *(long *)(a) = *(long *)(b); \ + *(long *)(b) = t; \ + } else \ + swapfunc(a, b, size, swaptype) + +#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) + + +// FUNCTIONS + +// Debug wrapper for comparison function +static __inline__ int +cmp_wrapper( __qsort_comparison_fn_t cmp, void *x, void *y ) +{ + int retval; + CYG_TRACE3( TL1, "Calling comparison function address %08x with args " + "( %08x, %08x )", cmp, x, y ); + retval = cmp(x, y); + + CYG_TRACE1( TL1, "Comparison function returned %d", retval ); + + return retval; +} // cmp_wrapper() + +static __inline__ void +swapfunc( char *a, char *b, int n, int swaptype) +{ + if(swaptype <= 1) + swapcode(long, a, b, n); + else + swapcode(char, a, b, n); +} // swapfunc() + + +static __inline__ char * +med3( char *a, char *b, char *c, __qsort_comparison_fn_t cmp ) +{ + return cmp_wrapper(cmp, a, b) < 0 ? + (cmp_wrapper(cmp, b, c) < 0 ? b : (cmp_wrapper(cmp, a, c) < 0 ? c : a )) + :(cmp_wrapper(cmp, b, c) > 0 ? b : (cmp_wrapper(cmp, a, c) < 0 ? a : c )); +} // med3() + + +void +qsort( void *base, size_t nmemb, size_t size, __qsort_comparison_fn_t compar ) +{ + char *pa, *pb, *pc, *pd, *pl, *pm, *pn; + int d, r, swaptype, swap_cnt; + + CYG_REPORT_FUNCNAME( "qsort" ); + CYG_REPORT_FUNCARG4( "base=%08x, nmemb=%d, size=%d, compar=%08x", + base, nmemb, size, compar ); + + CYG_CHECK_DATA_PTR( base, "base is not a valid pointer!" ); + CYG_CHECK_FUNC_PTR( compar, "compar is not a valid function pointer!" ); + +loop: + SWAPINIT(base, size); + swap_cnt = 0; + if (nmemb < 7) { + for (pm = (char *) base + size; + pm < (char *) base + nmemb * size; + pm += size) + for (pl = pm; pl > (char *) base && cmp_wrapper( compar, pl - size, pl) > 0; + pl -= size) + swap(pl, pl - size); + { + CYG_REPORT_RETURN(); + return; + } // for + } // if + pm = (char *) base + (nmemb / 2) * size; + if (nmemb > 7) { + pl = (char *) base; + pn = (char *) base + (nmemb - 1) * size; + if (nmemb > 40) { + d = (nmemb / 8) * size; + pl = med3(pl, pl + d, pl + 2 * d, compar); + pm = med3(pm - d, pm, pm + d, compar); + pn = med3(pn - 2 * d, pn - d, pn, compar); + } // if + pm = med3(pl, pm, pn, compar); + } // if + swap( (char *)base, pm ); + pa = pb = (char *) base + size; + + pc = pd = (char *) base + (nmemb - 1) * size; + for (;;) { + while (pb <= pc && (r = cmp_wrapper( compar, pb, base)) <= 0) { + if (r == 0) { + swap_cnt = 1; + swap(pa, pb); + pa += size; + } // if + pb += size; + } // while + while (pb <= pc && (r = cmp_wrapper( compar, pc, base)) >= 0) { + if (r == 0) { + swap_cnt = 1; + swap(pc, pd); + pd -= size; + } // if + pc -= size; + } // while + if (pb > pc) + break; + swap(pb, pc); + swap_cnt = 1; + pb += size; + pc -= size; + } // for + if (swap_cnt == 0) { // Switch to insertion sort + for (pm = (char *) base + size; + pm < (char *) base + nmemb * size; + pm += size) + for (pl = pm; pl > (char *) base && cmp_wrapper( compar, pl - size, pl) > 0; + pl -= size) + swap(pl, pl - size); + { + CYG_REPORT_RETURN(); + return; + } // for + } //if + + pn = (char *) base + nmemb * size; + r = min(pa - (char *)base, pb - pa); + vecswap((char *)base, pb - r, r); + r = min( (unsigned)(pd - pc), pn - pd - size ); + vecswap(pb, pn - r, r); + if ((unsigned)(r = pb - pa) > size) + qsort(base, r / size, size, compar); + if ((unsigned)(r = pd - pc) > size) { + // Iterate rather than recurse to save stack space + base = pn - r; + nmemb = r / size; + goto loop; + } // if +/* qsort(pn - r, r / size, size, compar);*/ + + CYG_REPORT_RETURN(); +} // qsort() + +// EOF qsort.cxx diff --git a/packages/language/c/libc/stdlib/current/src/rand.cxx b/packages/language/c/libc/stdlib/current/src/rand.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/src/rand.cxx @@ -0,0 +1,242 @@ +//=========================================================================== +// +// rand.cxx +// +// ISO and POSIX 1003.1 standard random number generation functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: Provides ISO C rand() and srand() functions, along with +// POSIX 1003.1 rand_r() function +// Description: This implements rand() and srand() of section 7.10.2.1 of +// the ISO C standard. Also rand_r() defined in section 8.3.8 +// of the POSIX 1003.1 standard +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // Tracing support +#include // Assertion support +#include // Header for all stdlib functions + // (like this one) + +#ifdef CYGSEM_LIBC_PER_THREAD_RAND +# include // kernel configuration +# include // per-thread data +# include // per-thread data +# include // mutexes +#endif + +// TRACE + +#if defined(CYGDBG_USE_TRACING) && defined(CYGNUM_LIBC_RAND_TRACE_LEVEL) +static int rand_trace = CYGNUM_LIBC_RAND_TRACE_LEVEL; +# define TL1 (0 < rand_trace) +#else +# define TL1 (0) +#endif + + +// STATICS + +#ifdef CYGSEM_LIBC_PER_THREAD_RAND +static cyg_ucount32 rand_data_index=CYGNUM_KERNEL_THREADS_DATA_MAX; +static Cyg_Mutex rand_data_mutex CYGBLD_ATTRIB_INIT_PRIORITY(CYG_INIT_LIBC); +#else +static unsigned int cyg_libc_rand_seed = CYGNUM_LIBC_RAND_SEED; +#endif + +// FUNCTIONS + +int +rand( void ) +{ + unsigned int *seed_p; + int retval; + + CYG_REPORT_FUNCNAMETYPE( "rand", "returning %d" ); + + // get seed for this thread (if relevant ) +#ifdef CYGSEM_LIBC_PER_THREAD_RAND + Cyg_Thread *self = Cyg_Thread::self(); + + // Get a per-thread data slot if we haven't got one already + // Do a simple test before locking and retrying test, as this is a + // rare situation + if (CYGNUM_KERNEL_THREADS_DATA_MAX==rand_data_index) { + rand_data_mutex.lock(); + if (CYGNUM_KERNEL_THREADS_DATA_MAX==rand_data_index) { + + // the kernel just throws an assert if this doesn't work + // FIXME: Should use real CDL to pre-allocate a slot at compile + // time to ensure there are enough slots + rand_data_index = self->new_data_index(); + + // Initialize seed + self->set_data(rand_data_index, CYGNUM_LIBC_RAND_SEED); + } + rand_data_mutex.unlock(); + } // if + + // we have a valid index now + + seed_p = (unsigned int *)self->get_data_ptr(rand_data_index); +#else + seed_p = &cyg_libc_rand_seed; +#endif + + CYG_TRACE2( TL1, "Retrieved seed address %08x containing %d", + seed_p, *seed_p ); + CYG_CHECK_DATA_PTR( seed_p, "Help! Returned address of seed is invalid!" ); + + retval = rand_r( seed_p ); + + CYG_REPORT_RETVAL( retval ); + + return retval; + +} // rand() + + +int +rand_r( unsigned int *seed ) +{ + int retval; + + CYG_REPORT_FUNCNAMETYPE( "rand_r", "returning %d" ); + + CYG_CHECK_DATA_PTR( seed, "pointer to seed invalid!" ); + +#if defined(CYGIMP_LIBC_RAND_SIMPLEST) + + // This algorithm sucks in the lower bits + + *seed = (*seed * 1103515245) + 12345; // permutate seed + + retval = (int)( *seed & RAND_MAX ); + +#elif defined(CYGIMP_LIBC_RAND_SIMPLE1) + + // The above algorithm sucks in the lower bits, so we shave them off + // and repeat a couple of times to make it up + + unsigned int s=*seed; + unsigned int uret; + + s = (s * 1103515245) + 12345; // permutate seed + // Only use top 11 bits + uret = s & 0xffe00000; + + s = (s * 1103515245) + 12345; // permutate seed + // Only use top 14 bits + uret += (s & 0xfffc0000) >> 11; + + s = (s * 1103515245) + 12345; // permutate seed + // Only use top 7 bits + uret += (s & 0xfe000000) >> (11+14); + + retval = (int)(uret & RAND_MAX); + *seed = s; + +#elif defined(CYGIMP_LIBC_RAND_KNUTH1) + +// This is the code supplied in Knuth Vol 2 section 3.6 p.185 bottom + +#define MM 2147483647 // a Mersenne prime +#define AA 48271 // this does well in the spectral test +#define QQ 44488 // (long)(MM/AA) +#define RR 3399 // MM % AA; it is important that RRnew_data_index(); + + } + rand_data_mutex.unlock(); + } // if + + // we have a valid index now + + self->set_data(rand_data_index, (CYG_ADDRWORD) seed); +#else + cyg_libc_rand_seed = seed; +#endif + + CYG_REPORT_RETURN(); + +} // srand() + +// EOF rand.cxx diff --git a/packages/language/c/libc/stdlib/current/src/strtod.cxx b/packages/language/c/libc/stdlib/current/src/strtod.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/src/strtod.cxx @@ -0,0 +1,254 @@ +//=========================================================================== +// +// strtod.cxx +// +// ISO String to double-precision floating point conversion +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// Include strtod()? +#if defined(CYGFUN_LIBC_strtod) + +// INCLUDES + +#include // Common type definitions and support +#include // Tracing support +#include // Assertion support +#include // NULL, wchar_t and size_t from compiler +#include // Main header for stdlib functions +#include // isspace() and isdigit() +#include // DBL_MIN_10_EXP and DBL_MAX_10_EXP +#include // HUGE_VAL +#include // errno + +// CONSTANTS + +#define MAXE (DBL_MAX_10_EXP) +#define MINE (DBL_MIN_10_EXP) + +// flags +#define SIGN 0x01 +#define ESIGN 0x02 +#define DECP 0x04 + + +// MACROS + +#define Ise(c) ((c == 'e') || (c == 'E') || (c == 'd') || (c == 'D')) +#define Issign(c) ((c == '-') || (c == '+')) +#define Val(c) ((c - '0')) + + +// FUNCTIONS + +/* + * [atw] multiply 64 bit accumulator by 10 and add digit. + * The KA/CA way to do this should be to use + * a 64-bit integer internally and use "adjust" to + * convert it to float at the end of processing. + */ +static int +ten_mul(double *acc, int digit) +{ + /* [atw] Crude, but effective (at least on a KB)... + */ + *acc *= 10; + *acc += digit; + + return 0; /* no overflow */ +} // ten_mul() + + +/* + * compute 10**x by successive squaring. + */ + +static const double +exp10(unsigned x) +{ + static double powtab[] = {1.0, + 10.0, + 100.0, + 1000.0, + 10000.0}; + + if (x < (sizeof(powtab)/sizeof(double))) + return powtab[x]; + else if (x & 1) + return 10.0 * exp10(x-1); + else + return exp10(x/2) * exp10(x/2); +} // exp10() + + +/* + * return (*acc) scaled by 10**dexp. + */ + +static double +adjust(double *acc, int dexp, int sign) + /* *acc the 64 bit accumulator */ + /* dexp decimal exponent */ + /* sign sign flag */ +{ + double r; + + if (dexp > MAXE) + { + errno = ERANGE; + return (sign) ? -HUGE_VAL : HUGE_VAL; + } + else if (dexp < MINE) + { + errno = ERANGE; + return 0.0; + } + + r = *acc; + if (sign) + r = -r; + if (dexp==0) + return r; + + if (dexp < 0) + return r / exp10(abs(dexp)); + else + return r * exp10(dexp); +} // adjust() + + +externC double +strtod( const char *nptr, char **endptr ) +{ + const char *start=nptr; + double accum = 0.0; + int flags = 0; + int texp = 0; + int e = 0; + int conv_done = 0; + + double retval; + + CYG_REPORT_FUNCNAMETYPE( "strtod", "returning %f" ); + + CYG_CHECK_DATA_PTR( nptr, "nptr is an invalid pointer!" ); + + // endptr is allowed to be NULL, but if it isn't, we check it + if (endptr != NULL) + CYG_CHECK_DATA_PTR( endptr, "endptr is an invalid pointer!" ); + + while(isspace(*nptr)) nptr++; + if(*nptr == '\0') + { /* just leading spaces */ + if(endptr != NULL) *endptr = (char *)start; + return 0.0; + } + + + if(Issign(*nptr)) + { + if(*nptr == '-') flags = SIGN; + if(*++nptr == '\0') + { /* "+|-" : should be an error ? */ + if(endptr != NULL) *endptr = (char *)start; + return 0.0; + } + } + + for(; (isdigit(*nptr) || (*nptr == '.')); nptr++) + { + conv_done = 1; + if(*nptr == '.') + flags |= DECP; + else + { + if( ten_mul(&accum, Val(*nptr)) ) texp++; + if(flags & DECP) texp--; + } + } + + if(Ise(*nptr)) + { + conv_done = 1; + if(*++nptr != '\0') /* skip e|E|d|D */ + { /* ! ([nptr]xxx[.[yyy]]e) */ + + while(isspace(*nptr)) nptr++; /* Ansi allows spaces after e */ + if(*nptr != '\0') + { /* ! ([nptr]xxx[.[yyy]]e[space]) */ + + if(Issign(*nptr)) + if(*nptr++ == '-') flags |= ESIGN; + + if(*nptr != '\0') + { /* ! ([nptr]xxx[.[yyy]]e[nptr]) -- error?? */ + + for(; isdigit(*nptr); nptr++) + if (e < MAXE) /* prevent from grossly overflowing */ + e = e*10 + Val(*nptr); + + /* dont care what comes after this */ + if(flags & ESIGN) + texp -= e; + else + texp += e; + } + } + } + } + + if(endptr != NULL) + *endptr = (char *)((conv_done) ? nptr : start); + + retval = adjust(&accum, (int)texp, (int)(flags & SIGN)); + + + CYG_REPORT_RETVAL( retval ); + + return retval; +} // strtod() + + +#endif // if defined(CYGFUN_LIBC_strtod) + +// EOF strtod.cxx diff --git a/packages/language/c/libc/stdlib/current/src/strtol.cxx b/packages/language/c/libc/stdlib/current/src/strtol.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/src/strtol.cxx @@ -0,0 +1,194 @@ +//=========================================================================== +// +// strtol.cxx +// +// ISO standard string to long int conversion function defined in +// section 7.10.1.5 of the standard +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== +// +// This code is based on original code with the following copyright: +// +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // Tracing support +#include // Assertion support +#include // Definition of LONG_MIN and LONG_MAX +#include // Definition of many ctype functions +#include // Error code definitions +#include // Header for all stdlib functions + // (like this one) + + +// FUNCTIONS + +// +// Convert a string to a long integer. +// +// Ignores `locale' stuff. Assumes that the upper and lower case +// alphabets and digits are each contiguous. +// + +long +strtol( const char *nptr, char **endptr, int base ) +{ + const char *s = nptr; + unsigned long acc; + int c; + unsigned long cutoff; + int neg = 0, any, cutlim; + + CYG_REPORT_FUNCNAMETYPE( "strtol", "returning long %d" ); + CYG_REPORT_FUNCARG3( "nptr=%08x, endptr=%08x, base=%d", + nptr, endptr, base ); + CYG_CHECK_DATA_PTR( nptr, "nptr is not a valid pointer!" ); + + if (endptr != NULL) + CYG_CHECK_DATA_PTR( endptr, "endptr is not a valid pointer!" ); + + // + // Skip white space and pick up leading +/- sign if any. + // If base is 0, allow 0x for hex and 0 for octal, else + // assume decimal; if base is already 16, allow 0x. + // + + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + // + // Compute the cutoff value between legal numbers and illegal + // numbers. That is the largest legal value, divided by the + // base. An input number that is greater than this value, if + // followed by a legal input character, is too big. One that + // is equal to this value may be valid or not; the limit + // between valid and invalid numbers is then based on the last + // digit. For instance, if the range for longs is + // [-2147483648..2147483647] and the input base is 10, + // cutoff will be set to 214748364 and cutlim to either + // 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + // a value > 214748364, or equal but the next digit is > 7 (or 8), + // the number is too big, and we will return a range error. + // + // Set any if any `digits' consumed; make it negative to indicate + // overflow. + // + + cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; + cutlim = cutoff % (unsigned long)base; + cutoff /= (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = neg ? LONG_MIN : LONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + + CYG_REPORT_RETVAL ( acc ); + + return acc; +} // strtol() + +// EOF strtol.cxx diff --git a/packages/language/c/libc/stdlib/current/src/strtoul.cxx b/packages/language/c/libc/stdlib/current/src/strtoul.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/src/strtoul.cxx @@ -0,0 +1,170 @@ +//=========================================================================== +// +// strtoul.cxx +// +// ISO standard string to long int conversion function defined in +// section 7.10.1.6 of the standard +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== +// +// This code is based on original code with the following copyright: +// +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions and support +#include // Tracing support +#include // Assertion support +#include // Definition of ULONG_MAX +#include // Definition of many ctype functions +#include // Error code definitions +#include // Header for all stdlib functions + // (like this one) + + +// FUNCTIONS + +// +// Convert a string to an unsigned long integer. +// +// Ignores `locale' stuff. Assumes that the upper and lower case +// alphabets and digits are each contiguous. +// + +unsigned long +strtoul( const char *nptr, char **endptr, int base ) +{ + const char *s = nptr; + unsigned long acc; + int c; + unsigned long cutoff; + int neg = 0, any, cutlim; + + CYG_REPORT_FUNCNAMETYPE( "strtoul", "returning long %d" ); + CYG_REPORT_FUNCARG3( "nptr=%08x, endptr=%08x, base=%d", + nptr, endptr, base ); + CYG_CHECK_DATA_PTR( nptr, "nptr is not a valid pointer!" ); + + if (endptr != NULL) + CYG_CHECK_DATA_PTR( endptr, "endptr is not a valid pointer!" ); + // + // See strtol for comments as to the logic used. + // + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; + cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = ULONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + + CYG_REPORT_RETVAL( acc ); + + return acc; +} // strtoul() + +// EOF strtoul.cxx diff --git a/packages/language/c/libc/stdlib/current/src/system.cxx b/packages/language/c/libc/stdlib/current/src/system.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/src/system.cxx @@ -0,0 +1,60 @@ +//======================================================================== +// +// system.cxx +// +// Implementation of ISO C system() function from section 7.10.4.5 +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Purpose: This file implements the ISO C system() function +// Description: This file provides a trivial implementation of the +// system() function from ISO C section 7.10.4.5. It +// simply exists to show that a command processor is +// not available +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// INCLUDES + +#include // Header for this file + +// FUNCTIONS + +extern "C" int +system( const char * ) +{ + return 0; +} // system() + +// EOF system.cxx diff --git a/packages/language/c/libc/stdlib/current/tests/abs.c b/packages/language/c/libc/stdlib/current/tests/abs.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/abs.c @@ -0,0 +1,93 @@ +//================================================================= +// +// abs.c +// +// Testcase for C library abs() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library abs() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include +#include + +// FUNCTIONS + +int +main( int argc, char *argv[] ) +{ + int x; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C " + "library abs() function"); + + // Check 1 + x = 5; + CYG_TEST_PASS_FAIL( abs(x) == 5, "abs(5)"); + + // Check 2 + x = -5; + CYG_TEST_PASS_FAIL( abs(x) == 5, "abs(-5)"); + + // Check 3 + x = 12345; + CYG_TEST_PASS_FAIL( abs(x) == 12345, "abs(12345)"); + + // Check 4 + x = -23456; + CYG_TEST_PASS_FAIL( abs(x) == 23456, "abs(-23456"); + + // Check 5 + x = 0; + CYG_TEST_PASS_FAIL( abs(x) == 0, "abs(0)"); + + // Check 6 + x = INT_MAX; + CYG_TEST_PASS_FAIL( abs(x) == INT_MAX, "abs(INT_MAX)"); + + // Check 7 + x = -INT_MAX; + CYG_TEST_PASS_FAIL( abs(x) == INT_MAX, "abs(-INT_MAX)"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C " + "library abs() function"); + +} // main() + +// EOF abs.c diff --git a/packages/language/c/libc/stdlib/current/tests/atoi.c b/packages/language/c/libc/stdlib/current/tests/atoi.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/atoi.c @@ -0,0 +1,101 @@ +//================================================================= +// +// atoi.c +// +// Testcase for C library atoi() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library atoi() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// FUNCTIONS + +static char * +my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +static void +test( CYG_ADDRWORD data ) +{ + char x[30]; + + // Check 1 + my_strcpy(x, "20"); + CYG_TEST_PASS_FAIL( atoi(x) == 20, "atoi(20)"); + + // Check 2 + my_strcpy(x, "1972"); + CYG_TEST_PASS_FAIL( atoi(x) == 1972, "atoi(1972)"); + + // Check 3 + my_strcpy(x, "-9876"); + CYG_TEST_PASS_FAIL( atoi(x) == -9876, "atoi(-9876)"); + + // Check 4 + my_strcpy(x, " -9876xxx"); + CYG_TEST_PASS_FAIL( atoi(x) == -9876, "atoi( -9876xxx)"); + + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "atoi() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "atoi() function"); + + test(0); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); +} // main() + +// EOF atoi.c diff --git a/packages/language/c/libc/stdlib/current/tests/atol.c b/packages/language/c/libc/stdlib/current/tests/atol.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/atol.c @@ -0,0 +1,99 @@ +//================================================================= +// +// atol.c +// +// Testcase for C library atol() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library atol() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// FUNCTIONS + +static char * +my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +static void +test( CYG_ADDRWORD data ) +{ + char x[30]; + + // Check 1 + my_strcpy(x, "20"); + CYG_TEST_PASS_FAIL( atol(x) == 20, "atol(20)"); + + // Check 2 + my_strcpy(x, "1972"); + CYG_TEST_PASS_FAIL( atol(x) == 1972, "atol(1972)"); + + // Check 3 + my_strcpy(x, "-98765"); + CYG_TEST_PASS_FAIL( atol(x) == -98765, "atol(-98765)"); + + // Check 4 + my_strcpy(x, " -98765xxx"); + CYG_TEST_PASS_FAIL( atol(x) == -98765, "atol( -98765xxx)"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "atol() function"); +} // test() + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "atol() function"); + + test(0); + + CYG_TEST_NA("Testing is not applicable to this configuration"); +} // main() + +// EOF atol.c diff --git a/packages/language/c/libc/stdlib/current/tests/bsearch.c b/packages/language/c/libc/stdlib/current/tests/bsearch.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/bsearch.c @@ -0,0 +1,122 @@ +//================================================================= +// +// bsearch.c +// +// Testcase for C library bsearch() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library bsearch() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +static int +Compar( const void *int1, const void *int2 ) +{ + if ( *(int*)int1 < *(int*)int2 ) + return -1; + else if ( *(int*)int1 == *(int*)int2 ) + return 0; + else + return 1; +} // Compar() + +int +main( int argc, char *argv[] ) +{ + int key; + int *result; + int i_array[] = {1, 5, 8, 35, 84, 258, 1022, 1022, 5300, 7372, 9029}; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "bsearch() function"); + + // Test 1 + key = 8; + result = bsearch(&key, i_array, sizeof(i_array)/sizeof(i_array[0]), + sizeof(i_array[0]), &Compar); + CYG_TEST_PASS_FAIL( (result!=NULL) && (*result == 8), + "bsearch() something in the middle"); + + // Test 2 + key = 5300; + result = bsearch(&key, i_array, sizeof(i_array)/sizeof(i_array[0]), + sizeof(i_array[0]), &Compar); + CYG_TEST_PASS_FAIL( (result!=NULL) && (*result == 5300), + "bsearch() something else in the middle"); + + // Test 3 + key = 1; + result = bsearch(&key, i_array, sizeof(i_array)/sizeof(i_array[0]), + sizeof(i_array[0]), &Compar); + CYG_TEST_PASS_FAIL( (result!=NULL) && (*result == 1), + "bsearch() first element"); + + // Test 4 + key = 9029; + result = bsearch(&key, i_array, sizeof(i_array)/sizeof(i_array[0]), + sizeof(i_array[0]), &Compar); + CYG_TEST_PASS_FAIL( (result!=NULL) && (*result == 9029), + "bsearch() last element"); + + // Test 5 + key = 1022; + result = bsearch(&key, i_array, sizeof(i_array)/sizeof(i_array[0]), + sizeof(i_array[0]), &Compar); + CYG_TEST_PASS_FAIL( (result!=NULL) && (*result == 1022), + "bsearch() duplicate element"); + + // Test 6 + key = 2; + result = bsearch(&key, i_array, sizeof(i_array)/sizeof(i_array[0]), + sizeof(i_array[0]), &Compar); + CYG_TEST_PASS_FAIL( result==NULL, "bsearch() nonexistent element"); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "bsearch() function"); + +} // main() + + +// EOF bsearch.c diff --git a/packages/language/c/libc/stdlib/current/tests/div.c b/packages/language/c/libc/stdlib/current/tests/div.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/div.c @@ -0,0 +1,109 @@ +//================================================================= +// +// div.c +// +// Testcase for C library div() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library div() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// FUNCTIONS + +int +main( int argc, char *argv[] ) +{ + int num, denom; + div_t result; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "div() function"); + + num = 10232; + denom = 43; + result = div(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==237) && (result.rem==41), + "div( 10232, 43 )"); + + num = 4232; + denom = 2000; + result = div(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==2) && (result.rem==232), + "div( 4232, 2000 )"); + + + num = 20; + denom = 20; + result = div(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==1) && (result.rem==0), + "div( 20, 20 )"); + + num = -5; + denom = 4; + result = div(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==-1) && (result.rem==-1), + "div( -5, 4 )"); + + num = 5; + denom = -4; + result = div(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==-1) && (result.rem==1), + "div( 5, -4 )"); + + num = -5; + denom = -3; + result = div(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==1) && (result.rem==-2), + "div( -5, -3 )"); + + num = -7; + denom = -7; + result = div(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==1) && (result.rem==0), + "div( -7, -7 )"); + + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "div() function"); + +} // main() + +// EOF div.c diff --git a/packages/language/c/libc/stdlib/current/tests/getenv.c b/packages/language/c/libc/stdlib/current/tests/getenv.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/getenv.c @@ -0,0 +1,134 @@ +//================================================================= +// +// getenv.c +// +// Testcase for C library getenv() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library getenv() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include // Main header for stdlib functions +#include // Testcase API + +// GLOBALS + +extern char **environ; // Standard environment definition + +// FUNCTIONS + +static int +my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + +int +main( int argc, char *argv[] ) +{ + char *str; + + char *env1[] = { NULL }; + char *env2[] = { "WIBBLE=fred", NULL }; + char *env3[] = { "PATH=/usr/local/bin:/usr/bin", + "HOME=/home/fred", + "TEST=1234=5678", + "home=hatstand", + NULL }; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C " + "library getenv() function"); + + + // Check 1 + str = getenv("ThisIsAVeryUnlikelyName"); + CYG_TEST_PASS_FAIL( str==NULL, "Simple getenv() default environ" ); + + // Check 2 + environ = (char **)&env1; + str = getenv("wibble"); + CYG_TEST_PASS_FAIL( str==NULL, "Simple getenv() with empty environ" ); + + // Check 3 + environ = (char **)&env2; + str = getenv("WIBBLE"); + CYG_TEST_PASS_FAIL( (str != NULL) && !my_strcmp(str, "fred"), + "Simple getenv()" ); + + // Check 4 + str = getenv("wibble"); + CYG_TEST_PASS_FAIL( str==NULL, + "Simple getenv() for something not in the " + "environment" ); + + // Check 5 + environ = (char **)&env3; + str = getenv("PATH"); + CYG_TEST_PASS_FAIL( (str!= NULL) && + !my_strcmp(str,"/usr/local/bin:/usr/bin"), + "Multiple string environment" ); + + // Check 6 + str = getenv("PATh"); + CYG_TEST_PASS_FAIL( str==NULL, "getenv() for something not in the " + "environment for multiple string environment" ); + + // Check 7 + str = getenv("home"); + CYG_TEST_PASS_FAIL( (str != NULL) && !my_strcmp(str, "hatstand"), + "Case-sensitive environment names" ); + + // Check 8 + str = getenv("TEST"); + CYG_TEST_PASS_FAIL( (str != NULL) && !my_strcmp(str, "1234=5678"), + "environment value containing '='" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C " + "library getenv() function"); + +} // main() + +// EOF getenv.c diff --git a/packages/language/c/libc/stdlib/current/tests/labs.c b/packages/language/c/libc/stdlib/current/tests/labs.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/labs.c @@ -0,0 +1,89 @@ +//================================================================= +// +// labs.c +// +// Testcase for C library labs() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library labs() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// FUNCTIONS + +int +main( int argc, char *argv[] ) +{ + int x; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "labs() function"); + + // Check 1 + x = 5; + CYG_TEST_PASS_FAIL( labs(x) == 5, "labs(5)"); + + // Check 2 + x = -5; + CYG_TEST_PASS_FAIL( labs(x) == 5, "labs(-5)"); + + // Check 3 + x = 12345; + CYG_TEST_PASS_FAIL( labs(x) == 12345, "labs(12345)"); + + // Check 4 + x = -23456; + CYG_TEST_PASS_FAIL( labs(x) == 23456, "labs(-23456"); + + // Check 5 + x = 3456789; + CYG_TEST_PASS_FAIL( labs(x) == 3456789, "labs(3456789"); + + // Check 6 + x = -23456789; + CYG_TEST_PASS_FAIL( labs(x) == 23456789, "labs(-23456789"); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "labs() function"); +} // main() + +// EOF labs.c diff --git a/packages/language/c/libc/stdlib/current/tests/ldiv.c b/packages/language/c/libc/stdlib/current/tests/ldiv.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/ldiv.c @@ -0,0 +1,120 @@ +//================================================================= +// +// ldiv.c +// +// Testcase for C library ldiv() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library ldiv() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +int +main( int argc, char *argv[] ) +{ + long num, denom; + ldiv_t result; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "ldiv() function"); + + num = 10232; + denom = 43; + result = ldiv(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==237) && (result.rem==41), + "ldiv( 10232, 43 )"); + + num = 4232; + denom = 2000; + result = ldiv(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==2) && (result.rem==232), + "ldiv( 4232, 2000 )"); + + num = 20; + denom = 20; + result = ldiv(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==1) && (result.rem==0), + "ldiv( 20, 20 )"); + + num = -5; + denom = 4; + result = ldiv(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==-1) && (result.rem==-1), + "ldiv( -5, 4 )"); + + num = 5; + denom = -4; + result = ldiv(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==-1) && (result.rem==1), + "ldiv( 5, -4 )"); + + num = -5; + denom = -3; + result = ldiv(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==1) && (result.rem==-2), + "ldiv( -5, -3 )"); + + num = -7; + denom = -7; + result = ldiv(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==1) && (result.rem==0), + "ldiv( -7, -7 )"); + + num = 90123456; + denom = 12345678; + result = ldiv(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==7) && (result.rem==3703710), + "ldiv( 90123456, 12345678 )"); + + num = 90123456; + denom = 123; + result = ldiv(num, denom); + CYG_TEST_PASS_FAIL( (result.quot==732711) && (result.rem==3), + "ldiv( 90123456, 123 )"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "ldiv() function"); + +} // main() + +// EOF ldiv.c diff --git a/packages/language/c/libc/stdlib/current/tests/qsort.c b/packages/language/c/libc/stdlib/current/tests/qsort.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/qsort.c @@ -0,0 +1,96 @@ +//================================================================= +// +// qsort.c +// +// Testcase for C library qsort() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library qsort() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + + +static int +Compar( const void *int1, const void *int2 ) +{ + if ( *(int*)int1 < *(int*)int2 ) + return -1; + else if ( *(int*)int1 == *(int*)int2 ) + return 0; + else + return 1; +} // Compar() + +int +main( int argc, char *argv[] ) +{ + unsigned int ctr; + int fail=0; + int i_array_sorted[] = {1, 5, 8, 35, 84, 258, 1022, 5300, 7372, 9029}; + int i_array_unsorted[] = {258, 8, 7372, 1, 5, 9029, 1022, 35, 5300, 84}; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "qsort() function"); + + qsort(i_array_unsorted, + sizeof(i_array_unsorted) / sizeof(i_array_unsorted[0]), + sizeof(int), &Compar); + + for (ctr = 0; + ctr < (sizeof(i_array_unsorted) / sizeof(i_array_unsorted[0])); + ++ctr) + { + if (i_array_sorted[ctr] != i_array_unsorted[ctr]) + ++fail; + } // for + + CYG_TEST_PASS_FAIL( fail == 0, "qsort() sorts correctly" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "qsort() function"); + +} // main() + +// EOF qsort.c diff --git a/packages/language/c/libc/stdlib/current/tests/rand1.c b/packages/language/c/libc/stdlib/current/tests/rand1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/rand1.c @@ -0,0 +1,91 @@ +//================================================================= +// +// rand1.c +// +// Testcase for C library rand() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library rand() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// CONSTANTS + +// This is the max allowable hits, where a hit is an element +// of a random array being the same as index+1 or index+2 +#define TOLERANCE 2 + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + int ctr; + static int array[1024]; + int hits=0; + + for (ctr=0; ctr<1024; ctr++) + array[ctr] = rand(); + + for (ctr=0; ctr< 1021; ctr++) + if ((array[ctr]==array[ctr+1]) || + (array[ctr]==array[ctr+2]) || + (array[ctr]==array[ctr+3])) + hits++; + + CYG_TEST_PASS_FAIL(hits <= TOLERANCE, + "Simple test for rand() repetition"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for " + "C library rand() function"); +} // test() + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "rand() function"); + + test(0); + + CYG_TEST_NA("Testing is not applicable to this configuration"); +} // main() + +// EOF rand1.c diff --git a/packages/language/c/libc/stdlib/current/tests/rand2.c b/packages/language/c/libc/stdlib/current/tests/rand2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/rand2.c @@ -0,0 +1,98 @@ +//================================================================= +// +// rand2.c +// +// Testcase for C library rand() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library rand() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include // CYGNUM_LIBC_RAND_SEED +#include +#include + + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + static int rand_data1[100]; + static int rand_data2[100]; + int count; + int fail=0; + + // Test that rand starts with the seed as CYGNUM_LIBC_RAND_SEED + + for ( count=0; count < 100; ++count ) { + rand_data1[count] = rand(); + } // for + + // set seed to CYGNUM_LIBC_RAND_SEED + srand(CYGNUM_LIBC_RAND_SEED); + + for ( count=0; count < 100; ++count ) { + rand_data2[count] = rand(); + } // for + + for ( count=0; count < 100; ++count ) { + if (rand_data1[count] != rand_data2[count]) + ++fail; + } // for + + CYG_TEST_PASS_FAIL(fail==0, "rand() has seed initialised to " + "CYGNUM_LIBC_RAND_SEED"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C " + "library rand() function"); +} // test() + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C " + "library rand() function"); + + test(0); + + CYG_TEST_NA("Testing is not applicable to this configuration"); +} // main() + + +// EOF rand2.c diff --git a/packages/language/c/libc/stdlib/current/tests/rand3.c b/packages/language/c/libc/stdlib/current/tests/rand3.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/rand3.c @@ -0,0 +1,138 @@ +//================================================================= +// +// rand3.c +// +// Testcase for C library rand() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library rand() function. This tests +// that random numbers are distributed well between 0 and +// RAND_MAX +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// CONSTANTS + +#define NUM_BUCKETS 1000 // how many categories to define +#define TEST_LENGTH 200000 // how many samples to take - careful + // when reducing this since it also reduces + // BUCKET_DIFF_TOLERANCE below. If you reduce + // it too low, BUCKET_DIFF_TOLERANCE will need + // a fudge factor + +#define BUCKET_SIZE (RAND_MAX / NUM_BUCKETS) // number space allocated + // to bucket from 0..RAND_MAX +#define NUM_PER_BUCKET (TEST_LENGTH/NUM_BUCKETS) // Expected number that went + // into each bucket at end + +// how much the buckets can vary at the end. +#define BUCKET_DIFF_TOLERANCE (NUM_PER_BUCKET/4) // allowed to vary 25% + + + +// FUNCTIONS + +static __inline__ int +my_abs(int i) +{ + return (i < 0) ? -i : i; +} // my_abs() + +int +main(int argc, char *argv[]) +{ + // divide the space from 0..RAND_MAX into NUM_BUCKETS categories *BUT* + // RAND_MAX / NUM_BUCKETS may not divide exactly so we leave space for + // the bits left over, in case there are any! So we add 1. + + static cyg_uint8 rand_bucket[NUM_BUCKETS+1]; + cyg_ucount32 count; // loop variable + int r; // temp for rand() variable + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "rand() function"); + + CYG_TEST_INFO("This test tests the distribution of random numbers and"); + CYG_TEST_INFO("may take some time"); + + for ( count=0; count < TEST_LENGTH; ++count ) { + r = rand(); + ++rand_bucket[ r / BUCKET_SIZE ]; + if ((count%10000)==0) + CYG_TEST_STILL_ALIVE(count, "Still testing..."); + } // for + + for ( count=0; count < NUM_BUCKETS; ++count ) { + cyg_ucount32 diff; + + diff = my_abs( rand_bucket[count] - NUM_PER_BUCKET ); + if ( diff > BUCKET_DIFF_TOLERANCE ) + break; + } // for + + // if the previous loop completed, we may want to check the "extra" + // bucket (see the comment at the top) that may have some bits in if + // RAND_MAX doesn't split into NUM_BUCKETS evenly. The number of random + // digits that fell into that bucket would be expected to be proportional + // to the ratio of the remainder of (RAND_MAX % NUM_BUCKETS) to + // NUM_BUCKETS. + if (count == NUM_BUCKETS) { + cyg_ucount32 rem; + cyg_ucount32 last_bucket_expected; + cyg_ucount32 diff; + + rem = RAND_MAX % NUM_BUCKETS; + + last_bucket_expected = (rem * NUM_PER_BUCKET) / BUCKET_SIZE; + + diff = my_abs(last_bucket_expected - rand_bucket[count]); + CYG_TEST_PASS_FAIL(diff <= BUCKET_DIFF_TOLERANCE, + "Upper bound fencepost test"); + } + CYG_TEST_PASS_FAIL( (count >= NUM_BUCKETS), + "even distribution of rand()"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for " + "C library rand() function"); +} // main() + + +// EOF rand3.c diff --git a/packages/language/c/libc/stdlib/current/tests/rand4.c b/packages/language/c/libc/stdlib/current/tests/rand4.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/rand4.c @@ -0,0 +1,111 @@ +//================================================================= +// +// rand4.c +// +// Testcase for C library rand() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): rosalia +// Contributors: jlarmour +// Date: 2000-04-30 +// Description: Contains testcode for C library rand() function. This tests +// that random numbers do not have periodicity in the lower +// bit +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include +#include + +// CONSTANTS + +#define TEST_LENGTH 100000 // how many samples to take + +// DEFINES + +#define TEST_VALID (!defined(CYGIMP_LIBC_RAND_SIMPLEST)) + +// FUNCTIONS + +int +main(int argc, char *argv[]) +{ +#if TEST_VALID + int i; + int r, prev, prevprev; + int how_many_periodics = 0; +#endif + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "rand() function"); + + CYG_TEST_INFO("This test tests the distribution of random numbers and"); + CYG_TEST_INFO("may take some time"); + +#if TEST_VALID + r = rand() % 2; + prev = r; + r = rand() % 2; + for (i = 0; i < TEST_LENGTH; ++i) { + prevprev = prev; + prev = r; + r = rand() % 2; + if (r == prevprev) { + ++how_many_periodics; + } + if (how_many_periodics > (2*TEST_LENGTH)/3) { + break; + } + } + + CYG_TEST_PASS_FAIL( (how_many_periodics <= (2*TEST_LENGTH)/3), + "periodicity of rand() in lowest bit"); + +#else + + // TODO: should be an _expected_ fail i.e. XFAIL + CYG_TEST_NA("Chosen rand algorithm is known to fail this test"); + +#endif + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for " + "C library rand() function"); +} // main() + + +// EOF rand4.c diff --git a/packages/language/c/libc/stdlib/current/tests/srand.c b/packages/language/c/libc/stdlib/current/tests/srand.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/srand.c @@ -0,0 +1,121 @@ +//================================================================= +// +// srand.c +// +// Testcase for C library srand() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library srand() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// CONSTANTS + +// Max cross correlation value of two sequences of +// different seed +#define X_CORREL 10 + +// size of arrays to use for testing +#define TEST_SIZE 1024 + + +// FUNCTIONS + +static void +test( CYG_ADDRWORD data ) +{ + int ctr; + static int array_1[TEST_SIZE]; + static int array_2[TEST_SIZE]; + static int array_3[TEST_SIZE]; + int hits; + int fail; + + + srand(3); + for (ctr=0; ctr +#include +#include +#include + + +// FUNCTIONS + +static char * +my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +static void +test( CYG_ADDRWORD data ) +{ + char x[30]; + long z; + char *endptr; + + my_strcpy(x, "20"); + CYG_TEST_PASS_FAIL( strtol(x, (char**)NULL, 10) == 20, + "Simple strtol(20 ,...)" ); + + my_strcpy(x, "1972100"); + CYG_TEST_PASS_FAIL( strtol(x, (char**)NULL, 10) == 1972100, + "Simple strtol(1972100, ..." ); + + my_strcpy(x, "0xFFEE"); + z = strtol(x, (char**)NULL, 16); + CYG_TEST_PASS_FAIL(z == 65518, "Hex base strtol()"); + + my_strcpy(x, "100111011"); + z = strtol(x, (char**)NULL, 2); + CYG_TEST_PASS_FAIL(z == 315, "Binary base strtol()"); + + my_strcpy(x, "10372"); + z = strtol(x, (char**)NULL, 8); + CYG_TEST_PASS_FAIL(z == 4346, "Octal base strtol()" ); + + my_strcpy(x, "317823"); + z = strtol(x, (char**)NULL, 8); + CYG_TEST_PASS_FAIL(z == 207, "Partial string" ); + + my_strcpy(x, " 53ab823"); + z = strtol(x, &endptr, 10); + CYG_TEST_PASS_FAIL((z == 53) && (endptr==&x[3]), "Correct end pointer" ); + + my_strcpy(x, "-479"); + z = strtol(x, (char**)NULL, 10); + CYG_TEST_PASS_FAIL(z == -479, "Negative string"); + + my_strcpy(x, "+4796"); + z = strtol(x, (char**)NULL, 10); + CYG_TEST_PASS_FAIL(z == 4796, "Positive string"); + + my_strcpy(x, ""); + z = strtol(x, (char**)NULL, 10); + CYG_TEST_PASS_FAIL(z == 0, "Empty string"); + + my_strcpy(x, ""); + z = strtol(x, &endptr, 10); + CYG_TEST_PASS_FAIL((z == 0) && (endptr==x), + "Empty string sets endptr correctly"); + + my_strcpy(x, " "); + z = strtol(x, &endptr, 10); + CYG_TEST_PASS_FAIL((z == 0) && (endptr==x), + "White space only string sets endptr correctly"); + + my_strcpy(x, "0XFFEE"); + z = strtol(x, (char**)NULL, 0); + CYG_TEST_PASS_FAIL(z == 65518, "Base 0 but hex"); + + my_strcpy(x, "\t 0629"); + z = strtol(x, (char**)NULL, 0); + CYG_TEST_PASS_FAIL(z == 50, "Base 0 but octal"); + + my_strcpy(x, "42"); + z = strtol(x, (char**)NULL, 0); + CYG_TEST_PASS_FAIL(z == 42, "Base 0 but decimal"); + + my_strcpy(x, "hello"); + z = strtol(x, &endptr, 0); + CYG_TEST_PASS_FAIL((z == 0) && (endptr==x), + "endptr set correctly on conversion failure"); + + my_strcpy(x, "z2f"); + z = strtol(x, (char**)NULL, 36); + CYG_TEST_PASS_FAIL(z == 45447, "Base==36"); + + my_strcpy(x, "h547324"); + z = strtol(x, (char**)NULL, 10); + CYG_TEST_PASS_FAIL(z == 0, "No valid number string"); + + my_strcpy(x, "545425876654547324"); + z = strtol(x, (char**)NULL, 10); + CYG_TEST_PASS_FAIL( (z == LONG_MAX) && (errno == ERANGE), + "Number out of range"); + + my_strcpy(x, "-545425876654547324"); + z = strtol(x, (char**)NULL, 10); + CYG_TEST_PASS_FAIL( (z == LONG_MIN) && (errno == ERANGE), + "Number out of range"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strtol() function"); +} // test() + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strtol() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + test(0); + + CYG_TEST_NA("Testing is not applicable to this configuration"); +} // main() + +// EOF strtol.c diff --git a/packages/language/c/libc/stdlib/current/tests/strtoul.c b/packages/language/c/libc/stdlib/current/tests/strtoul.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/stdlib/current/tests/strtoul.c @@ -0,0 +1,170 @@ +//================================================================= +// +// strtoul.c +// +// Testcase for C library strtoul() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strtoul() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include +#include +#include + + +// FUNCTIONS + +static char * +my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +static void +test( CYG_ADDRWORD data ) +{ + char x[30]; + unsigned long z; + char *endptr; + + my_strcpy(x, "20"); + CYG_TEST_PASS_FAIL( strtoul(x, (char**)NULL, 10) == 20, + "Simple strtoul(20 ,...)" ); + + my_strcpy(x, "1972100"); + CYG_TEST_PASS_FAIL( strtoul(x, (char**)NULL, 10) == 1972100, + "Simple strtoul(1972100, ..." ); + + my_strcpy(x, "0xFFEE"); + z = strtoul(x, (char**)NULL, 16); + CYG_TEST_PASS_FAIL(z == 65518, "Hex base strtoul()"); + + my_strcpy(x, "100111011"); + z = strtoul(x, (char**)NULL, 2); + CYG_TEST_PASS_FAIL(z == 315, "Binary base strtoul()"); + + my_strcpy(x, "10372"); + z = strtoul(x, (char**)NULL, 8); + CYG_TEST_PASS_FAIL(z == 4346, "Octal base strtoul()" ); + + my_strcpy(x, "317823"); + z = strtoul(x, (char**)NULL, 8); + CYG_TEST_PASS_FAIL(z == 207, "Partial string" ); + + my_strcpy(x, " 53ab823"); + z = strtoul(x, &endptr, 10); + CYG_TEST_PASS_FAIL( (z == 53) && (endptr==&x[3]), "Correct end pointer" ); + + my_strcpy(x, "-479"); + z = strtoul(x, (char**)NULL, 0); + CYG_TEST_PASS_FAIL( (z == (unsigned long) -479), + "Negative string"); + + my_strcpy(x, "+4796"); + z = strtoul(x, (char**)NULL, 10); + CYG_TEST_PASS_FAIL(z == 4796, "Positive string"); + + my_strcpy(x, ""); + z = strtoul(x, (char**)NULL, 10); + CYG_TEST_PASS_FAIL(z == 0, "Empty string"); + + my_strcpy(x, ""); + z = strtoul(x, &endptr, 10); + CYG_TEST_PASS_FAIL( (z == 0) && (endptr==x), + "Empty string sets endptr correctly"); + + my_strcpy(x, " "); + z = strtoul(x, &endptr, 10); + CYG_TEST_PASS_FAIL( (z == 0) && (endptr==x), + "White space only string sets endptr correctly"); + + my_strcpy(x, "0XFFEE"); + z = strtoul(x, (char**)NULL, 0); + CYG_TEST_PASS_FAIL(z == 65518, "Base 0 but hex"); + + my_strcpy(x, "\t 0629"); + z = strtoul(x, (char**)NULL, 0); + CYG_TEST_PASS_FAIL(z == 50, "Base 0 but octal"); + + my_strcpy(x, "42"); + z = strtoul(x, (char**)NULL, 0); + CYG_TEST_PASS_FAIL(z == 42, "Base 0 but decimal"); + + my_strcpy(x, "hello"); + z = strtoul(x, &endptr, 0); + CYG_TEST_PASS_FAIL((z == 0) && (endptr==x), + "endptr set correctly on conversion failure"); + + my_strcpy(x, "z2f"); + z = strtoul(x, (char**)NULL, 36); + CYG_TEST_PASS_FAIL(z == 45447, "Base==36"); + + my_strcpy(x, "h547324"); + z = strtoul(x, (char**)NULL, 10); + CYG_TEST_PASS_FAIL(z == 0, "No valid number string"); + + my_strcpy(x, "545425876654547324"); + z = strtoul(x, (char**)NULL, 10); + CYG_TEST_PASS_FAIL( (z == ULONG_MAX) && (errno == ERANGE), + "Number out of range"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strtoul() function"); +} // test() + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strtoul() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + test(0); + + CYG_TEST_NA("Testing is not applicable to this configuration"); +} // main() + +// EOF strtoul.c diff --git a/packages/language/c/libc/string/current/ChangeLog b/packages/language/c/libc/string/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/ChangeLog @@ -0,0 +1,37 @@ +2000-05-20 Jonathan Larmour + + * src/strtok.cxx: Remove aliases + +2000-05-02 Jonathan Larmour + + * New package + Separated original libc out into separate packages on functional + boundaries. + Header files are now managed by isoinfra package + Plenty of cleanups done, but no major functionality changes + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/string/current/ChangeLog.libc b/packages/language/c/libc/string/current/ChangeLog.libc new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/ChangeLog.libc @@ -0,0 +1,2727 @@ +This ChangeLog file is now obsolete. This is the original ChangeLog from when +libc was one large package, before being separated. It is included for +historical reasons. + +2000-04-05 Jesper Skov + + * src/time/settime.cxx: + * src/time/time.cxx: + Wallclock moved to io/. + +2000-03-28 John Dallaway + + * cdl/string.cdl, + cdl/stdlib.cdl, + cdl/stdio.cdl, + cdl/libc.cdl: + + Adjust documentation URLs. + +2000-03-27 Jesper Skov + + * src/clibincl/stream.inl (check_this): Use cyb_bool instead of bool. + +2000-03-06 Jesper Skov + + * tests/time/strftime.c (test): Adjust test to match below change. + +2000-03-02 Jonathan Larmour + + * src/time/strftime.cxx (do_format): Make sure %m counts from + 1..12 rather than 0..11. Fix for case 103300 + +2000-02-29 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: Correctly use 'n' parameter to + restrict length. Credit due to Andrew Lunn here as well. + Resolves 103057-CR-1 + + * tests/stdio/sprintf2.c (test): + Add snprintf tests to verify the correct behaviour of restricting + output length + +2000-02-10 Jesper Skov + + * tests/signal/signal2.c (main): + Also reclaim DATA_TLB_MISS vector if available. + +2000-01-31 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-28 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-19 Hugo Tyson + + * cdl/*.cdl: Add descriptions to a number of options &c which were + lacking same, also tidied up other typos as noticed en passant. + +1999-11-11 Bart Veer + + * cdl/string.cdl: + Switch to a single boolean configuration option for code size vs. + speed optimization. + +1999-11-03 John Dallaway + + * cdl/libc.cdl: Define tests. + +1999-10-19 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: We can now remove Berkeley + advertising clause + * src/stdlib/div.cxx: ditto + * src/stdlib/ldiv.cxx: ditto + * src/stdlib/strtol.cxx: ditto + * src/stdlib/strtoul.cxx: ditto + * src/string/strtok.cxx: ditto + +1999-10-19 John Dallaway + + * cdl/libc.cdl: + + Define CDL options for package-specific CFLAGS. + +1999-10-08 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_THREAD_PRIORITY): Change + default to 10 to keep test farm happy + * cdl/startup.cdl: Likewise + +1999-10-07 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Specify radio buttons using CDL interfaces. + +1999-10-06 Jonathan Larmour + + * cdl/stdio.cdl: Change default to /dev/ttydiag as per 1999-10-01 + change below + * cdl/startup.cdl: Add new form CDL for the startup changes as + per 1999-10-05 + +1999-10-05 Jonathan Larmour + + * include/libc.h: Add CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM to allow + the user to supply their own stack. + Rename CYGNUM_LIBC_MAIN_STACK_SIZE to + CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE and reparent under + CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + Add CYGNUM_LIBC_MAIN_THREAD_PRIORITY to provide main() thread + priority + + * src/support/mainthread.cxx: Add support for user-supplied stack + Allow user to specify thread priority + + These changes fix CR 101069 + +1999-10-01 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE): Change + default to /dev/ttydiag to get correct console-like behaviour + Also don't preclude use if haldiag package isn't included + (case 102065) + +1999-09-15 Jesper Skov + + * tests/signal/signal2.c (cause_fpe): Try both float and integer + division by zero. + +1999-09-10 Jesper Skov + + * src/stdlib/malloc.cxx (cyg_libc_get_malloc_pool): Added for + stress_threads test. + +1999-09-07 Jesper Skov + PRs 20243, 20433 + * tests/signal/signal2.c: Disabled test3 on ARM. + +1999-09-02 Hugo Tyson + + * include/assert.h: Make the sense of NDEBUG correct; it is "set" + when NOT debugging. Fix for CR 101983-CR-1 + See Stroustrup, "The C++ Programming Language." + +1999-08-18 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): Set buffer size 0 when not + buffering + Fix for case 101868 + +1999-08-17 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Implement radio buttons using "FIXME radio" hack in + description field for now. + +1999-08-12 John Dallaway + + * cdl/stdlib.cdl: + Take advantage of MACRONAME_ENUMVAL macros output by CDL. + +1999-08-06 Jonathan Larmour + + * tests/stdio/sprintf2.c (test): Don't rely on 2.345 being exactly + representable in binary as a difference of 1 ulp will make it round + the wrong way. + +1999-07-16 Jonathan Larmour + + * src/stdio/input/fgetc.cxx: + Include outline versions of getc() (actually just a symbol alias for + fgetc() ) and getchar() + Some minor clean-ups + Add tracing/assertions + + * src/stdio/input/fputc.cxx: + Likewise (except applied to putc() and putchar()) + + * src/stdio/common/stdioinlines.cxx (_puts): + Call fputc() not _fputc() + + * src/clibincl/stdiosupp.hxx: + Remove now obsolete prototypes for _fgetc() and _fputc() + + * include/stdio.h: + Don't bother with getc()/putc() macros any more, just call + them as functions + Include protos for getc(), putc(), getchar() and putchar() functions + +1999-06-21 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for SH EDK7708. + +1999-06-11 Jonathan Larmour + + * include/stdio.h: Make FILEs array types so they won't be + given $gp relocations on MIPS targets + +1999-05-27 Jesper Skov + + * tests/time/ctime.c: Fixed compiler warning. + +1999-05-25 Jonathan Larmour + + * tests/signal/signal2.c (main): + Update CYGPKG_HAL_TX39 -> CYGPKG_HAL_MIPS_TX39 due to recent MIPS + HAL changes + Fix for PR 20116 + +1999-04-30 Jesper Skov + PR 19945/19946 workaround + * tests/signal/signal2.c: Disabled test 3 for PowerPC sim. + +1999-04-19 Jonathan Larmour + + * include/time.inl: + Ensure all calls to cyg_libc_time_year_is_leap() are with the full + year, and not the direct contents of a struct tm, which are (year-1900) + +1999-04-19 Jesper Skov + PR 19308, 19410, 19528 + * tests/time/clock.c (test): Also disable data cache which may + affect timing when tracing/assertions are enabled. + +1999-04-15 Jonathan Larmour + + * src/clibincl/stdiosupp.hxx: + Add prototype for new cyg_libc_stdio_flush_all_but() function + + * src/clibincl/stream.hxx: + Don't include stdiosupp.hxx any more to prevent circular dependency, + therefore manually provide _setvbuf prototype + Make sure pkgconf/kernel.h is included before mutex.hxx + + * src/clibincl/stream.inl (Cyg_StdioStream::set_error()): + Add missing unlock_me() + + * src/stdio/common/fflush.cxx: + Separate most of code for fflush(NULL) into separate + cyg_libc_stdio_flush_all_but() function, which has the extra + capability of omitting one stream + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Add missing clibincl/stdiosupp.hxx include + + * src/stdio/common/stream.cxx (Cyg_StdioStream::read()): + When reading, ensure we flush all output streams + + * src/stdio/common/stream.cxx (Cyg_StdioStream::flush_output_unlocked): + Flush the device as well + +1999-04-15 Jonathan Larmour + + * src/stdio/common/streambuf.cxx (set_buffer): + * src/stdio/common/stdioinlines.cxx (_setbuf): + * src/clibincl/streambuf.inl: + * src/clibincl/streambuf.hxx: + * src/clibincl/stream.hxx (class Cyg_StdioStream): + * include/pkgconf/libc.h: + * include/stdio.inl (setbuf): + Fix dumb typo: BUFSIZE -> BUFSIZ + This fixes PR19837 + +1999-04-15 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx (_setbuf): + * include/stdio.inl (setbuf): + Use _IONBF when buf==NULL, and _IOLBF otherwise. + Fix for PR 19836 + +1999-04-15 John Dallaway + + * include/pkgconf/libc.h: Tidy display string capitalization. + +1999-04-12 Jonathan Larmour + + * include/pkgconf/libc.h: + Clarify CDL description of CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE + + * tests/signal/signal2.c: Try harder to generate an exception by + accessing a misaligned address + Don't handle SIGTRAP any more + Part of fix for PRs 19731/19607 + +1999-04-07 Jesper Skov + PR 19667 + * src/support/mainthread.cxx: + Changed to use the new Cyg_Thread constructor. + +1999-04-07 Hugo Tyson + + * tests/signal/signal2.c (main): Use new macro + HAL_VSR_SET_TO_ECOS_HANDLER if defined, to wrest control from + CygMon, for example, by reinstalling eCos' default VSRs for + exceptions that we are provoking. + +1999-03-29 Jonathan Larmour + + * src/signal/siginit.cxx: Include stdlib.h for exit() + Fix for PR 19720 + +1999-03-29 Jonathan Larmour + + * tests/time/clock.c (test): Disable instruction cache + Hopefully fixes PR 19308 + +1999-03-29 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for PPC as it cannot + trap division by zero. + +1999-03-26 Jonathan Larmour + + * src/support/main.cxx (main): Invoke cyg_user_start() if no kernel + Only sensible thing to do in our default main in a non-kernel config + +1999-03-25 Jonathan Larmour + + * tests/time/time.c: + Increase MAX_TIMEOUT since the sparclite gets very close to overrunning + it even when working. + Should return -1 iff CYGSEM_LIBC_TIME_TIME_WORKING isn't defined + Cosmetic changes + +1999-03-25 Hugo Tyson + + * tests/time/time.c (test): Take into account setting of + CYGSEM_LIBC_TIME_SETTIME_WORKING ie. does cyg_libc_time_settime() + work? If not, check that it returns an error. + This was exposed by the random combo in PR#19479. + +1999-03-23 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 to + CYGIMP_... + + Add another rand implementation CYGIMP_LIBC_RAND_SIMPLE1 which is + the default + + Part of fix for PR 19562 + + * include/sys/cstartup.h: + Tidy and remove unnecessary dependencies + + * src/stdlib/rand.cxx: + Rename algorithms from CYGSEM_... to CYGIMP_... + Add new "simple1" algorithm + + * tests/ctype/ctype.c: + Tidy + + * tests/stdlib/rand3.c: + Fix so that 0..RAND_MAX is split evenly over buckets, which it wasn't + before + Deal with case of RAND_MAX not being divisible by NUM_BUCKETS + exactly + Increase TEST_LENGTH to 200000 to provide more representative sample + Add CYG_TEST_INFO output to help ensure it doesn't time out + Tidy + + * tests/stdlib/rand4.c: + Only fail if more than _two_ thirds (rather than one third) match. + This is because half would match for a perfectly random distribution + This is the rest of the fix for PR 19562 + Cosmetic changes + +1999-03-22 Hugo Tyson + + * src/support/mainthread.cxx (CYGNUM_LIBC_MAIN_STACK_SIZE): + Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of + CYGNUM_HAL_MINIMUM_STACK_SIZE. + +1999-03-22 Jonathan Larmour + + * tests/PKGconf.mak: Add -Wno-format when building strftime otherwise + it generates warnings for things that we do want to test (null + string, and %y format) + +1999-03-19 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Put brackets back round negative number since sdf says the config + tool is fixed now (PR 19537) + + Add new CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 + options for different rand() algorithms in a so far failed attempt + to fix PR 19562 + + * src/stdlib/rand.cxx: + Add new optional algorithm from Knuth vol.2 + + * tests/stdlib/rand4.c: + Some tidies + Don't run test when using simplest algorithm + + * tests/signal/signal2.c (main): + Don't try to make an FPE on tx39 - its possible to detect but requires + too much HAL work to be sensible + +1999-03-18 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Use HAL_ENABLE_INTERRUPTS() rather than kernel to enable interrupts + +1999-03-18 Mark Galassi + + * tests/PKGconf.mak (TESTS): added rand4 compilation. + + * tests/stdlib/rand4.c: added this test for periodicity in the + least significant bit of rand(). + +1999-03-18 Jonathan Larmour + + * include/pkgconf/libc.h: Remove CYGFUN_LIBC_TIME_POSIX dependency + on CYGPKG_LIBC_STDIO + + * src/stdlib/itoa.cxx: + New file to convert integers to ascii + + * include/stdlib.h: + Add proto for new cyg_libc_itoa() function + + * include/time.inl: + Rework __asctime_r() to use memcpy() and cyg_libc_itoa() rather than + sprintf() + + * src/PKGconf.mak: + Build stdlib/itoa.cxx + + The above changes fix PR 19448 + +1999-03-17 Jonathan Larmour + + * include/time.h: Add #define of __time_t_defined to placate newlib + if it is used by accident. This is just a temporary workaround though. + +1999-03-16 Gary Thomas + + * src/PKGconf.mak: Add compile option to step around ARM compiler bug. + +1999-03-16 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Don't use parentheses for now + + * src/stdio/common/stream.cxx (refill_read_buffer): + Silence bogus compiler warning + +1999-03-16 Jesper Skov + + * tests/signal/signal2.c (main): Enable SIGSEGV test for + i386/Linux. + + +1999-03-15 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Only enable interrupts if they were disabled + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: + Add FIX ME line as a reminder that the workaround there can go away + in future + + * include/pkgconf/libc.h: + Add proper define for CYGSEM_LIBC_EXIT_CALLS_FFLUSH + Put brackets round negative CYGNUM_LIBC_TIME_DST_DEFAULT_STATE define + Fix run time typo + + * include/time.inl (__localtime_r): + Include sys/timeutil.h before this to get + cyg_libc_time_normalize_structtm() + +1999-03-12 Gary Thomas + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: Remove 'const' from char arrays since + this fails [silently] on ARM when -fwritable-strings (PR19440) + +1999-03-12 Jesper Skov + + * tests/signal/signal2.c (main): Compiler warnings fix was + slightly broken. + +1999-03-12 Jesper Skov + PR 19473 + * tests/signal/signal2.c (main): + Disabling SIGTRAP handling on i386/Linux is not a good idea. +1999-03-11 Jesper Skov + PR 19473 + * tests/signal/signal2.c: + Added compiler warnings fix. + Added N/A handling for i386/Linux. + +1999-03-10 Gary Thomas + + * include/pkgconf/libc.h: Force "haldiag" device to be present. + 'asctime' and friends need 'stdio' as well. + + * include/time.inl: Fix syntax error on difftime() declaration. + +1999-03-08 Gary Thomas + + * src/clibincl/stream.hxx: needed for this file. + + * src/stdio/common/vsscanf.cxx (str_read): Fix problem with string + pointer [created by merge with new I/O package]. + +1999-03-05 John Dallaway + + * include/pkgconf/libc.h: + Add legal values for CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET + and CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET. + +1999-03-05 Jonathan Larmour + + * include/time.inl (cyg_libc_time_year_is_leap): + Fix bug with modulo year 400 + Fix typo in asctime_r macro + Fix gmtime_r, and mktime as a result of testing + + * tests/time/asctime.c, tests/time/ctime.c, tests/time/gmtime.c, + tests/time/gmtime.c, tests/time/localtime.c, tests/time/mktime.c, + tests/time/strftime.c, tests/time/time.c: + New tests + + * tests/PKGconf.mak: + Build above new tests + + * include/pkgconf/libc.h: + Add reminder FIX ME about extra config option + + * src/time/strftime.cxx: + Fix %w and %Y parameters as a result of testing + + * src/time/timeutil.cxx: + Fix cyg_libc_time_normalize_structtm() as a result of testing + of mktime() + + * tests/time/clock.c: + Reformat, remove obsolete bits and tidy + + * include/time.h: + Add Cyg_libc_time_dst type and new functions + cyg_libc_time_setzoneoffsets(), cyg_libc_time_setdst(), + cyg_libc_time_getzoneoffsets(), cyg_libc_time_settime() + + * include/time.inl: + Implement the above functions. This allows us to adjust for timezone + diffences and set the time. + Change localtime() to adjust for STD/DST + Change mktime() to adjust for STD/DST + + * include/libc.h: + Add new config options CYGSEM_LIBC_TIME_SETTIME_WORKING + and component CYGPKG_LIBC_TIME_ZONES containing options + CYGNUM_LIBC_TIME_DST_DEFAULT_STATE, + CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET, + CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET + + * src/strftime.cxx: + Adjust handling of %Z to _not_ deal with STD/DST + + * src/time/settime.cxx: + New file to implement cyg_libc_time_settime() + + * src/PKGconf.mak: + Build settime.cxx + + * src/time/timeutil.cxx: + Supply outline versions of cyg_libc_time_setzoneoffsets(), + cyg_libc_time_setdst(), and cyg_libc_time_getzoneoffsets() + Add variables for STD/DST state + Some minor comment changes + + * include/errno.h: + Use CYGBLD_ATTRIB_CONST instead of __attribute__((const)) directly + + * include/signal.h: + Change format of function comment headers + + * include/signal.inl: + Restrict errno.h inclusion to when its actually used + Fix a spelling typo + + * include/stdlib.h: + Add CYGBLD_ATTRIB_CONST to abs, div, labs, ldiv + + * include/stdlib.inl: + Reformat and tidy + Include new versions of div and ldiv which are more portable and + are cleanly rewritten so aren't covered by the BSD licence, which + is now removed + + * src/stdlib/div.cxx, src/stdlib/ldiv.cxx: + Non-inline, non-BSD and portable versions of the new versions of div + and ldiv from stdlib.inl + + * include/time.h: + Much reformatting, tidying and improving comments + Change CLOCKS_PER_SEC from 1000 to 1000000 + Add new functions asctime_r, ctime_r, gmtime_r, localtime_r, clock, + difftime, mktime, time, asctime, ctime, gmtime, localtime, strftime + Include new time.inl file + + * include/pkgconf/libc.h: + Add new options CYGSEM_LIBC_TIME_CLOCK_WORKING, + CYGSEM_LIBC_TIME_TIME_WORKING, CYGFUN_LIBC_TIME_POSIX, + CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL, CYGIMP_LIBC_TIME_ASCTIME_INLINE, + CYGIMP_LIBC_TIME_CTIME_INLINE, CYGIMP_LIBC_TIME_DIFFTIME_INLINE, + CYGIMP_LIBC_TIME_GMTIME_INLINE, CYGIMP_LIBC_TIME_LOCALTIME_INLINE, + CYGIMP_LIBC_TIME_MKTIME_INLINE, CYGIMP_LIBC_TIME_ASCTIME_R_INLINE, + CYGIMP_LIBC_TIME_CTIME_R_INLINE, CYGIMP_LIBC_TIME_GMTIME_R_INLINE, + and CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE + + * time/asctime.cxx, time/asctime_r.cxx, time/clock.cxx, time/ctime.cxx, + time/ctime_r.cxx, time/difftime.cxx, time/gmtime.cxx, + time/gmtime_r.cxx, time/localtime.cxx, time/localtime_r.cxx, + time/mktime.cxx, time/strftime.cxx, time/time.cxx, time/timeutil.cxx, + include/time.inl: + New files to implement the new time functions. Many of them simply + provide the outline definitions, but the real body of the function + comes from time.inl + + * src/PKGconf.mak: + Build new .cxx files + + * src/clibincl/stdlibsupp.hxx: + Remove _div and _ldiv prototypes since they're no longer needed + + * src/clibincl/timesupp.hxx: + Delete as its now obsolete + + * src/time/clock.cxx: + Use new CYGSEM_LIBC_TIME_CLOCK_WORKING option to control whether it + just returns (clock_t)-1 or not. + Much reformatting and tidying + Change real imlpementation from _clock to __clock + Use CYGBLD_ATTRIB_WEAK_ALIAS now + + * tests/stdlib/div.c, tests/stdlib/ldiv.c: + Add some extra tests for handling of negative numbers + Reformat and tidy a bit, including removing the test for CYGPKG_LIBC + since its now always defined if the test is to be compiled + + * tests/time/clock.c: + Remove duplication CYG_TEST_INFO line + Check if unimplemented using "(clock_t)-1" and not just "-1" + +1999-03-04 Jonathan Larmour + + * src/stdlib/system.cxx: + Make sure system() is a weak alias for __system() + + * include/pkgconf/libc.h: Rework CDL description for + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE and change its default to + "/dev/haldiag" + + * src/stdio/common/stream.cxx: + Check that dev is valid when passed to stream constructor + + * src/stdio/common/stdiosupp.cxx: + Tidy + + * src/support/mainthread.cxx: Make this depend on + CYGSEM_LIBC_STARTUP_MAIN_THREAD rather than just CYGPKG_KERNEL + +1999-03-04 Gary Thomas + + Merged in changes from 'ecos-new_devs-19990216-branch' + + (1999-02-24 Jonathan Larmour ) + + * src/stdio/common/stream.cxx: + Add "fix me" comments and remove a couple of commented out lines + + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Revert to using pointer to string for private data, not just string. + This preserves the state across multiple calls + + (1999-02-24 Gary Thomas ) + + * src/stdio/common/vsscanf.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/stream.cxx: + * src/stdio/common/stdiosupp.cxx: + * src/stdio/common/fopen.cxx: + * src/clibincl/stream.inl: + * src/clibincl/stream.hxx: + * src/clibincl/stdiosupp.hxx: + * include/pkgconf/libc.h: Changes for new I/O system. + +1999-03-03 Jonathan Larmour + + * tests/stdlib/atexit.c: Forgot to config atexit test for + CYGFUN_LIBC_ATEXIT option + + * include/pkgconf/libc.h: + Require CYGVAR_KERNEL_THREADS_DATA for CYGSEM_LIBC_PER_THREAD_STRTOK + This fixes PR 19362 + Require CYGPKG_KERNEL for thread safe streams + Also don't need "requires CYGPKG_KERNEL" for per-thread rand and errno + if we already require a finer granularity kernel option + +1999-02-25 Jonathan Larmour + + * include/pkgconf/libc.h: Fix CYGNUM_LIBC_MAIN_STACK_SIZE by changing + CYGPKG_LIBC_STARTUP_MAIN_THREAD -> CYGSEM_LIBC_STARTUP_MAIN_THREAD + Fix for PR 19304 + +1999-02-23 Jonathan Larmour + + * src/stdlib/system.cxx: Add to implement trivial system() call + * include/stdlib.h: Add system() prototype + * src/PKGconf.mak: Build system.cxx + + * tests/ctype/ctype.c, tests/i18n/setlocale.c, tests/setjmp/setjmp.c, + tests/signal/signal1.c, tests/signal/signal2.c, + tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdio/stdiooutput.c, tests/stdlib/atexit.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/getenv.c, tests/stdlib/labs.c, + tests/stdlib/ldiv.c, tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/realloc.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + Use CYG_TEST_NA() macro for non-applicable test configurations + +1999-02-20 Jonathan Larmour + + * include/signal.h: + * include/signal.inl: + * src/signal/raise.cxx: + * src/signal/siginit.cxx: + * src/signal/signal.cxx: + * tests/signal/signal1.c + * tests/signal/signal2.c: + New files to implement ISO standard signals + + * src/PKGconf.mak (TESTS): + * tests/PKGconf.mak (TESTS): + Update to build new files above + + * include/stdlib.h: + * src/clibincl/stdlibsupp.hxx: + Comment and QA changes (including giving better names to some types) + + * include/libc.h: + Add new configuration options for signals + Add new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + Add a note to CYGNUM_LIBC_MAIN_STACK_SIZE option that it may be + overriden by HAL + Add new CYGFUN_LIBC_ATEXIT option and move ...ATEXIT_HANDLERS under + it + Add new CYGSEM_LIBC_EXIT_CALLS_FFLUSH option + Require CYGSEM_LIBC_STARTUP_MAIN_THREAD for "Invoke default static + constructors" option + + * src/stdlib/atexit.cxx: + Support above CYGFUN_LIBC_ATEXIT and QA changes + + * src/stdlib/exit.cxx: + Support for above new libc.h options, and some QA changes + + * src/support/cstartup.cxx: + Add support for new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + + * src/support/mainthread.cxx: + Override main stack size if the HAL has a minimum + + * src/string/strncpy.cxx: + Use improved algorithm for aligned copies - imported from newlib + QA changes + + * src/stdlib/abort.cxx: + Support raise(SIGABRT), and some QA + + * include/errno.h: + Add const attribute + + * tests/stdlib/abs.c: + QA improvements + +1999-02-04 Jesper Skov + + * src/support/cstartup.cxx: Only define cyg_libc_main_thread when + the kernel is around. + +1999-02-01 Jesper Skov + + * tests/time/clock.c: Joined the two test/NOP checks into + one. + Increased tolerance in attempt to fix PRs 18737,18787,18846. + Fixed typo. + +1999-01-28 Jonathan Larmour + + * src/string/strtok.cxx: + * src/stdlib/rand.cxx: + Include if we use kernel header files + +1999-01-25 Jonathan Larmour + + * tests/stdio/sscanf.c (test): + CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT should be + CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + Fix for PR 18786 + + * src/string/strtok.cxx: + * src/stdio/common/stdiofiles.cxx: + * src/errno/errno.cxx: + * src/stdlib/rand.cxx: + Give mutex protection objects a libc constructor priority + + * src/support/invokemain.cxx: + Add prototype for cyg_hal_invoke_constructors() + + * src/support/mainthread.cxx: + Give cyg_libc_dummy_constructor_obj a libc constructor priority, + and make its class have a public constructor + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/stdin.cxx: + Give cyg_libc_stdio_stdin/out/err static objects a libc constructor + priority + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + * src/clibincl/stream.hxx (class Cyg_StdioStream): + Remove private copy constructor. Needed to make prioritised + static constructors work. Fix for PR 18898 + +1999-01-22 Jonathan Larmour + + * src/errno/errno.cxx: + Include pkgconf/kernel.h otherwise it fails with per-thread errno + enabled + + * include/pkgconf/libc.h: + Enable per-thread errno by default since that is what POSIX would + want + + * tests/time/clock.c (test): + Placate compiler by initializing clock_first/second/third anyway, + even though they won't be in practice. This is only a test program + so adding an extra instruction doesn't matter. + + * src/i18n/locale.cxx (_setlocale): + Placate compiler, since it is dumb, by nesting, not serializing, if's + This is an idempotent change, but screws up the formatting :-(. + + * src/string/strpbrk.cxx (_strpbrk): + Change while loop to do loop to placate compiler. It'll even save an + instruction too (wow!) + +1999-01-22 John Dallaway + + * include/pkgconf/libc.h: + Add closing curly brace to CYGPKG_LIBC_STRING_STRTOK definition + +1999-01-21 Jonathan Larmour + + * include/errno.h: + Tidy up and add to header description + Change cyg_get_errno_p() to cyg_libc_get_errno_p() + Remove ifdef CYGPKG_LIBC + + * include/sys/file_if.h: + Remove - move contents to stdio.h + + * include/stdio.h: + Tidy up header description + Move FILE typedef here from sys/file_if.h + SEEK_SET, SEEK_CUR, SEEK_END defined to 0, 1, 2 respectively + for backwards compatibility with old UNIX + Change definitions of stdin/out/err to be addresses of FILE + globals - even though they're actually Cyg_StdioStream it'll work + + * include/pkgconf/libc.h: + Make CYGPRI_LIBC_WEAK et al macros depend on new ones in infra + Reorganise trace options under the individual components they are + associated with. + Reorganise thread-safety options under the individual components + they are associated with. + Add new CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS option + Misc. reformatting + Remove dependency on pkgconf/kernel.h - Configuration Tool will + generate check macros anyway. + Remove CYGPKG_LIBC_TRACE, CYGFUN_LIBC_strtok, CYGPKG_LIBC_RAND + options + Tidy up description header + + * src/clibincl/clibdata.hxx: + * src/clibincl/clibdata.inl: + * src/support/clibdata.cxx: + Remove and instead rely on each component to initialise its own data + + * src/clibincl/stdiofiles.hxx, src/clibincl/stdiofiles.inl: + New files to contain global file list and lock (if applicable). + Implemented as class with member access functions + + * src/errno/errno.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Rename cyg_get_errno_p() to cyg_libc_get_errno_p() + + * src/stdio/common/fclose.cxx: + * src/stdio/common/fflush.cxx: + * src/stdio/common/fopen.cxx: + * src/stdio/common/freopen.cxx: + Remove ifdef CYGPKG_LIBC + Use new global file access method from stdiofiles.hxx + Tidy up description header + Use new CYGBLD_ATTRIB_WEAK_ALIAS + Access errno "normally" rather than clibdata way + + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx + * src/stdio/common/stderr.cxx: + New files. Implement Cyg_StdioStream objects for each stream. In + separate self-contained files so using one doesn't bring in the + others + + * src/stdio/common/stdiofiles.cxx: + New file. Implements global files array and lock + + * src/stdlib/_exit.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Use infra CYGBLD* macros + + * src/stdlib/malloc.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Add pkgconf/kernel.h now that pkgconf/libc.h doesn't have it + Use infra CYGBLD* macros + Make pool visible externally with weak attribute and new name + cyg_libc_malloc_memorypool + + * src/stdlib/rand.cxx: + * src/stdlib/strtok.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Use infra CYGBLD* macros + + * src/support/cstartup.cxx: + Split into smaller files to make selective linking work better, + fix i386 port problem and make GDB happy + + * src/support/environ.cxx: + * src/support/invokemain.cxx: + * src/support/main.cxx: + * src/support/mainthread.cxx: + New files from bits of the old cstartup.cxx + Add support for CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG + + * src/PKGconf.mak: + Update to reflect file additions/deletion + + * tests/stdlib/rand1.c: + * tests/stdlib/rand2.c: + * tests/stdlib/rand3.c: + * tests/stdlib/srand.c: + Make conform to coding standards + Remove ifdef CYGPKG_LIBC_RAND + Tidy up description header + + * tests/string/strtok.c: + Make conform to coding standards + Remove ifdef CYGFUN_LIBC_strtok + Tidy up description header + +1999-01-15 Mark Galassi + + * tests/stdlib/getenv.c (main): added tests for the case in which + the user does not supply environ and in which the user supplies a + NULL environ. + +1999-01-15 Jesper Skov + + * src/support/cstartup.cxx: Added workaround for weak aliasing + problem in i386 gcc. + + +1999-01-15 Gary Thomas + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_STACK_SIZE): + (CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE): Change defaults to be + more reasonable on small systems. + +1999-01-04 Jonathan Larmour + + * src/support/clibdata.cxx: + Minor bug with environ not being initialised correctly by + default + +1998-12-24 Bart Veer + + * src/clibincl/stream.inl (Cyg_StdioStream): + check_this() member functions should now be const + +1998-12-22 Jonathan Larmour + + * src/string/memchr.cxx (_memchr): + treat search value parameter to memchr as an unsigned byte, + not a signed int - copied fix from newlib PR 18471 + +1998-12-21 Jonathan Larmour + + * tests/stdlib/realloc.c: + * tests/stdlib/malloc3.c: + * tests/stdlib/malloc2.c: + Warning cleanup + +1998-12-14 Jonathan Larmour + + * tests/stdlib/malloc2.c, tests/stdlib/malloc3.c, + tests/stdlib/realloc.c: + Only run these tests when we have a coalescing memory allocator + +1998-12-14 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Only check buffer init success if buffering + + * src/stdio/common/streambuf.cxx (set_buffer): + Check for diff of requested size against buffer_size, not + get_buffer_size(), since this may return -1, which won't be + equal to size, and will cause malloc to be called + +1998-12-01 Jesper Skov + + * tests/stdlib/getenv.c (main): Don't declare variables when they + are not used. + +Thu Nov 26 17:59:12 1998 Jonathan Larmour + + * tests/string/strncpy1.c: + Fix off-by-one error since it called my_strcmp() and not + my_strncmp(), which meant in included the trailing NULL when it + shouldn't have. + +1998-11-26 Jesper Skov + + * src/stdlib/qsort.cxx (_qsort): + * src/stdlib/rand.cxx (_srand): + Changed CYG_REPORT_FUNCNAMETYPE to CYG_REPORT_FUNCNAME in void + functions. + +Mon Oct 26 18:49:00 1998 Jonathan Larmour + + * src/support/cstartup.cxx (cyg_libc_dummy_main): + Silence compiler warning with cast of char * to CYG_ADDRWORD + +Wed Oct 28 17:31:21 1998 Jonathan Larmour + + * src/time/clock.cxx (_clock): + Reorder scaling expression as it was both incorrect and risked + overflow. + Fix for PR 18076 + +Mon Oct 19 14:40:06 1998 Jonathan Larmour + + * include/stdio.h (EOF): + Change from -64 to (-1), to allow broken code to work :-/ + Also change other negative defines to be within parentheses + +1998-10-19 Mark Galassi + + * include/pkgconf/libc.h: updated the doc URL + +Thu Oct 15 21:33:44 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Only include kernel thread headers when we're in thread-safe mode + + * src/time/clock.cxx: + Only include kernel clock headers if there's a kernel with the + right functionality available + + * tests/time/clock.c: + Remove unnecessary inclusion of + + Above changes are required for PR 17229 + +Wed Oct 14 16:38:55 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise inclusion of clibincl/stdiosupp.hxx and + clibincl/stream.hxx. Tidying up PR 17502 + +Wed Oct 14 14:08:56 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGPKG_LIBC_STRING_OPTIMISATIONS to + CYGPKG_LIBC_STRING_OPTIMIZATIONS to make it truely merkin. + +Tue Oct 13 19:34:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_ARGUMENTS): + Add a default argv[0] of "" as many programs assume argc>0 + The standard allows argv[0] to be "" if the program name + is not available + +1998-09-26 Bart Veer + + * src/clibincl/stdiosupp.hxx: + PR 17502: this header file now does nothing if the stdio option + is disabled completely. This is the same behaviour is + clibincl/stream.hxx, although arguably the #ifdef protection + should happen wherever the header file is #include'd rather than + in the header file itself. + + * src/clibincl/clibdata.hxx: + PR 17502: this header file still #include's internal stdio-related + header files and references the FILE structure, even if stdio is + disabled. There were some #ifdef's for CYGPKG_LIBC_STDIO already. + One more has been added for _fopen() and _fclose(). + +1998-09-25 Bart Veer + + * src/clibincl/streambuf.inl (Cyg_StdioStreamBuffer): + PR 17487: Reorder the calls to initialize member fields, to + eliminate a compiler warning. + +Fri Sep 25 19:04:29 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/string/strtok.cxx, + src/time/clock.cxx: + Only define tracing variable and tracing level macro when + the relevant tracing level config options are set. Otherwise + keep the tracing level fixed at 0 + Fix for PR 17476 + + * include/pkgconf/libc.h: + Define trace levels only if parent CYGPKG_LIBC_TRACE is defined + for consistency with Configuration Tool + + +Fri Sep 25 17:24:45 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Make definition of vscanf() dependent on CYGFUN_LIBC_STDIO_ungetc + otherwise _vfscanf() won't be compiled. This therefore would + cause a link fail iff selective linking is not enabled. + Fix for PR 17455 + +Fri Sep 25 17:23:17 1998 Jonathan Larmour + + * src/stdlib/rand.cxx: + Make compilation dependent on CYGPKG_LIBC_RAND + Fix for PR 17473 + + * tests/stdlib/srand.c: + Make definition of dummy test pass conditional on CYGPKG_LIBC_RAND + not being defined, as well as CYGPKG_LIBC + Caused compilation failure when testing PR 17473 fix + +Mon Sep 21 17:11:04 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Make sscanf test conditional on CYGFUN_LIBC_STDIO_ungetc since + _vfscanf() only gets compiled if this is defined + Fix for PR 17346 + +1998-09-20 Mark Galassi + + * include/pkgconf/libc.h: updated CDL doc strings. + +Fri Sep 18 22:18:47 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_errno_p): + Rather than this function only being available in thread-safe mode, + instead make what it returns be either the per-thread errno, or + global errno depending on the configuration. + Include (conditionally) to support this change + +Wed Sep 16 11:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove "fix me" comment which I forgot to remove before + +Tue Sep 15 19:27:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Updated descriptions and a few other minor things after review. + Notably though, the NDEBUG config option has been removed + +1998-09-15 Bart Veer + + * include/pkgconf/libc.h: + PR 17201: removed dependency on CYGPKG_KERNEL in the option + CYGNUM_LIBC_MAIN_STACK_SIZE, since the actual dependencies cannot + be expressed sensibly in the current system. + +1998-09-11 Bart Veer + + * include/pkgconf/libc.h: + Sorting out dependencies for error package. + +1998-09-10 Mark Galassi + + * include/pkgconf/libc.h: started adding doc fields to the + cdl_package data, as a pilot for now. + +Wed Sep 9 17:41:23 1998 Hugo Tyson + + * include/pkgconf/libc.h: + Add option CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE to explicitly + control whether the empty delete functions (currently) in + kernel/.../common/delete.cxx are enabled; controls code bloat, see + the comments in delete.cxx. + +Fri Sep 4 16:43:38 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add a default CYG_TEST_PASS() to make sure the test infra doesn't + complain. + Also remove the unused string functionsa + +Fri Sep 4 15:43:48 1998 Hugo Tyson + + * src/stdlib/exit.cxx (__libc_exit): + * src/stdlib/_exit.cxx (__libc__exit): + * src/stdlib/malloc.cxx (_free): + * src/stdlib/abort.cxx (abort): + * src/support/cstartup.cxx (invoke_main): + Tracing system asserted cos it was being called incorrectly; these + are void functions so you shouldn't give a type to the function + reporting call. + +Fri Sep 4 15:03:10 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Fix CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE description to refer to + the table.cxx file, not table.h + +Fri Sep 4 14:38:52 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add description for CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE since + Proven won't be making any changes to the device driver + implementation after all. + Fix for PR 17148 + + * src/clibincl/stream.inl (set_position): + Remove "fix me" line. It is obvious that this will have to change + with a filesystem interface + Fix for PR 17147 + + * src/stdio/common/freopen.cxx: + Remove "fix me" - I know about this issue + Fix for PR 17145 + + * src/stdio/common/stream.cxx (read): + Remove "fix me" and change to use memcpy + Fix for PR 17144 + +Fri Sep 4 14:36:47 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Actually add it this time! + +Fri Sep 4 13:48:13 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add new tests for misc stdio output functions + + * tests/PKGconf.mak: + Build stdiooutput.c test + +Fri Sep 4 12:52:10 1998 Jonathan Larmour + + * src/clibincl/stream.inl (write_byte): + Remove bogus assert + + * tests/stdlib/getenv.c (main): + Check whether str is NULL before doing a strcmp() + + * tests/stdio/sprintf2.c (main): + Reformat to 76 columns + +Fri Sep 4 02:10:54 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/stdio/common/stream.cxx: + Add new peek_byte method to Cyg_StdioStream + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix up buffer access to work with new peek_byte method above + Fix for PR 16954 + +Thu Sep 3 19:40:11 1998 Jonathan Larmour + + * tests/stdlib/rand1.c, tests/stdlib/rand2.c, + tests/stdlib/rand3.c: + Add extra check for CYGPKG_LIBC_RAND to decide whether the test + is applicable or not + + * tests/stdlib/rand2.c (test): + Use CYGNUM_LIBC_RAND_SEED for default seed, not 1 + + * tests/string/strtok.c: + Add extra check for CYGFUN_LIBC_strtok to decide whether the + test is applicable or not + +Wed Sep 2 19:11:40 1998 Jonathan Larmour + + * src/stdio/input/fread.cxx, src/stdio/output/fwrite.cxx: + Add fread() and fwrite() functions + + * src/PKGconf.mak: + Build fread.cxx and fwrite.cxx from above + + * src/stdio/common/stream.cxx: + Reformat to 76 columns + In write(), move initialisation of *bytes_written to start + In read(), move initialisation of *bytes_read to start + + * include/stdio.h: + Reformat to 76 columns + + Replace all references to the ANSI + standard to instead by the ISO C standard + + Add commented argument names for "documentation" + + Add fread() and fwrite() prototypes + + * src/clibincl/stdiosupp.hxx: + Copy the above changes from stdio.h, and add _fread() and _fwrite() + prototypes + + * src/stdio/output/fputs.cxx, src/stdio/input/fgets.cxx: + Reformat to 76 columns + +Wed Sep 2 15:41:15 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Reformat to 76 columns + +Wed Sep 2 14:46:18 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Use trylock_me() instead of lock_me(), and loop to prevent + deadlocks + + * src/clibincl/stream.hxx, src/clibincl/stream.inl: + Add trylock_me() method + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/fflush.cxx: + Reformat to 76 columns + +Wed Sep 2 12:24:27 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change 0x7fff to 0x7fffffff. Oops! + give main stack size option a legal_values field + Undefine tracing by default + Add some more description in the header + +Tue Sep 1 20:02:07 1998 Jonathan Larmour + + * tests/i18n/setlocale.c (cyg_package_start): + Fix typo - extra "x" for no reason at all! :-) + +Tue Sep 1 19:44:58 1998 Jonathan Larmour + + * src/i18n/locale.cxx: + Fix bug in find_locale_data() that miscalculated size of + all_locales + + Make find_locale_data() match the locale "" and add some + other things in _setlocale() to ensure that "C" gets returned + when the default locale "" is passed. + + Only check the locale pointer when it is non-NULL + + * tests/i18n/setlocale.c: + New tests for setlocale() + + * tests/PKGconf.mak: + Update to build setlocale.c test + + * src/support/cstartup.cxx: + Don't actually call system default main() "main" otherwise GDB + gets confused and thinks its the entry point. Instead make a weak + alias and call the real function something different. + +Tue Sep 1 18:31:42 1998 Jonathan Larmour + + * src/i18n/locale.cxx (_setlocale): + Fix tracing macro name and remove "str maybe used before + initialised" warning + + * tests/stdlib/qsort.c: + Correct file description header + +Tue Sep 1 17:04:32 1998 Jonathan Larmour + + * include/locale.h, src/clibincl/i18nsupp.hxx, src/i18n/locale.cxx: + New files to add support for locales as defined by the ISO C + standard. i.e. setlocale() and localeconv() functions and some + other bits + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAX_LOCALE_NAME_SIZE config option for locale + support + + * src/PKGconf.mak: + build locale.cxx + + * include/errno.h, src/clibincl/ctypesupp.hxx: + Tidy up to 76 columns + +Tue Sep 1 00:24:22 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Move environment-related options from stdlib into new + CYGPKG_LIBC_STARTUP component. Also add options for main()'s + arguments (CYGPKG_LIBC_ARGUMENTS), main()'s default stack size + (CYGNUM_LIBC_MAIN_STACK_SIZE), number of atexit handlers + (CYGNUM_LIBC_ATEXIT_HANDLERS), and whether _exit() stops the + system (CYGSEM_LIBC_EXIT_STOPS_SYSTEM). + + * src/clibincl/stdlibsupp.hxx: + Fix a few comment bugs, and add new + cyg_libc_invoke_atexit_handlers() function prototype + + * src/stdlib/_exit.cxx, src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Implement exit(), atexit() and _exit() correctly now. Also + includes cyg_libc_invoke_atexit_handlers() in atexit.cxx. Now + we get the correct behaviour of atexit(), and exit() invokes the + atexit handlers and fflushs all the stdio streams. Add plenty of + tracing of asserts too. + + * src/support/cstartup.cxx: + Make main_thread object an exported global. Allow user-settable + arguments. Add MUCH more tracing and asserts. Improve comments. + Tidy up to 76 columns + + * tests/stdlib/atexit.c: + Add simple test for atexit() and it calling registered functions + + * tests/PKGconf.mak: + Build atexit.c test + +Mon Aug 31 18:54:48 1998 Jonathan Larmour + + * src/stdlib/getenv.cxx, tests/stdlib/getenv.c: + Add support for getenv(), and some tests to ensure it works + + * src/PKGconf.mak, tests/PKGconf.mak: + Update to include getenv.cxx and getenv.c test + + * src/clibincl/clibdata.hxx: + remove prototype for environ - we expect files needing it to + define it themselves + + * src/support/clibdata.cxx: + Tidy up to 76 columns and add definition of char **environ, but + with a configurable initialiser (see libc.h below) + + * tests/stdlib/abs.c (main): + Tidy up to 76 columns + + * src/stdlib/malloc.cxx: + Tidy up to 76 columns and remove warning for undefined _memcpy() + by changing to memcpy(), and casting away signedness + + * include/pkgconf/libc.h: + Add CYGPKG_LIBC_ENVIRONMENT and CYGDAT_LIBC_DEFAULT_ENVIRONMENT + configuration options + + * include/pkgconf/libc.h, src/clibincl/clibdata.hxx: + Tidy up to 76 columns + + * include/stdlib.h: + Add getenv() prototype and tidy up to 76 columns + + * src/clibincl/stdlibsupp.hxx: + Add _getenv() prototype + +Mon Aug 31 13:37:08 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Add realloc() + + * tests/stdlib/realloc.c: + Add this file to test new realloc() functionality + + * tests/PKGconf.mak: + Build realloc test + + * tests/stdlib/malloc3.c (main), tests/stdlib/malloc2.c (main), + tests/stdlib/malloc1.c (main): + Conditionalise local vars to prevent warnings + + * tests/stdlib/malloc3.c (fill_with_data): + Move '{' into "verb" line + + * include/pkgconf/libc.h: + Require infra tracing support to allow tracing + + * include/stdlib.h: + Add realloc() + + * src/clibincl/stdlibsupp.hxx: + Update the commented argument names from stdlib.h, including realloc() + +1998-08-28 Bart Veer + + * include/pkgconf/libc.h: + * src/clibincl/clibdata.hxx, src/time/clock.cxx: + + Updated for new kernel configuration option symbol names + +Fri Aug 28 19:18:25 1998 Hugo Tyson + + Changed the entry below to sat "tx39" instead of "mn10300". + It's been a long week. + +Fri Aug 28 18:59:20 1998 Hugo Tyson + + * src/support/cstartup.cxx: Add a weakly named main to allow the + default configuration to link on the tx39 which has no + scalextric linking yet. The static Cyg_Thread main_thread object + below continues to exist, though unreferenced, so all its + descendants must exist too. + +Fri Aug 28 08:54:29 1998 Jonathan Larmour + + * include/stdlib.h: + Add commented argument names Add exit(), and atexit(). And move + these along with abort() and _exit() to a new section. + + * src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Add trivial versions of atexit() and exit() + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAIN_STACK_SIZE config option + + * include/sys/cstartup.h, src/support/cstartup.cxx, src/PKGconf.mak: + New files to provide a new function cyg_iso_c_support(), which + invokes main "correctly". + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/srand.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcoll2.c, tests/string/strcpy1.c, + tests/string/strcpy2.c, tests/string/strcspn.c, + tests/string/strlen.c, tests/string/strncat1.c, + tests/string/strncat2.c, tests/string/strncpy1.c, + tests/string/strncpy2.c, tests/string/strpbrk.c, + tests/string/strrchr.c, tests/string/strspn.c, + tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, + tests/time/clock.c: + + Modify all tests to use new startup mechanism, and cyg_iso_c_start() + +Fri Aug 28 00:29:38 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Add #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO around all accesses to + flags.last_buffer_op_was_read. Fix for PR 16997 + +Thu Aug 27 01:12:42 1998 Jonathan Larmour + + * include/sys/file_if.h: + Fix comments and remove cyg_get_file_star() + +Wed Aug 26 20:24:32 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove #define CYGPKG_LIBC is that is meant to live in + after all + +Wed Aug 26 19:39:23 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + More fixes to CDL stuff to make it work better, and look better on + the screen + +Tue Aug 25 20:21:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Make some fixes after running the ConfigTool + +Tue Aug 25 16:46:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_STDIO_BUFSIZE): + Fix typo of CYGNUM_LIBC_STDIO_BUFSIZE + +Tue Aug 25 15:10:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Tidy up CDL stuff a bit more, prior to checking it actually works. + +Tue Aug 25 11:38:52 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c (main): + Prevent calls to CYG_TEST_STILL_ALIVE for now + +Tue Aug 25 05:39:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change cosmetic paragraph alignment. + +Tue Aug 25 03:11:34 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Make stderr initialise with buffer size 0. + For PR 16955 + +Mon Aug 24 17:38:46 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + First pass at CDL-ifying the C library configuration. Currently + deliberately disabled as there a few outstanding issues. + +Mon Aug 24 16:14:22 1998 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx (_vfnprintf): + clear up warning for unused argument + + * tests/stdlib/malloc2.c (NUM_ITERATIONS): + Lower to 100 from 50000 so it won't take too long under the simulator + +Thu Aug 20 17:48:43 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Remove now unnecessary inclusion of kernel/ktypes.h + +Wed Aug 19 19:19:14 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, + tests/stdio/sscanf.c, tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, + tests/stdlib/strtoul.c, tests/string/strtok.c, + tests/time/clock.c: + Add parameters to "main()" to silence warnings + +Wed Aug 19 18:52:59 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx (refill_read_buffer): + Put conditional error check into same #ifdef and if as what was being + checked in the first place! + +Wed Aug 19 18:49:19 1998 Jonathan Larmour + + * src/clibincl/stream.inl: + Reorder Cyg_StdioStream::check_this() to be first to silence + warnings + +Tue Aug 18 16:10:03 1998 Jonathan Larmour + + * ecc/language/c/libc/current/src/clibincl/clibdata.hxx, + ecc/language/c/libc/current/src/errno/errno.cxx, + ecc/language/c/libc/current/src/stdio/common/fopen.cxx, + ecc/language/c/libc/current/src/stdlib/rand.cxx, + ecc/language/c/libc/current/src/string/strtok.cxx: + Rename CYGIMP_LIBC_INTERNAL_DATA_PREAMBLE, + CYGIMP_LIBC_INTERNAL_DATA_ALLOC_CHECK_PREAMBLE, + CYGVAR_LIBC_INTERNAL_DATA, and + CYGIMP_LIBC_INTERNAL_DATA_CHECK to all have CYGPRI_ prefix instead + as recommended by the config name rules + + +Tue Aug 18 14:31:19 1998 Jonathan Larmour + + * src/stdio/common/setvbuf.cxx (_setvbuf): + Rename variable names in assert line, otherwise doesn't build + with asserts on! + +Sun Aug 16 18:15:12 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix some bugs, although there are some left to fix still. Unrelated + to the rest of the checkins, so I will check the partial fix in now. + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx: + Add parameters to constructor to allow more things to be done at + construction time. + + Now we have "new", remove separate "construct" method + + Add more documentation on constructor + + As requested by code review, where possible, move boolean flags + into separate packed bitfield structure for space efficiency + + Make readbuf_char be usable all the time rather than when configured + not to be buffering, as it is also needed for non-buffered mode i.e. + _IONBF + + * src/stdio/common/fopen.cxx: + Change to use new method of construction from above, using new + + Use thread-specific data, rather than global. And so change errnos + to access errno entry specifically + + Make process_mode() check for append mode too + + Reformat for coding standards to have { in same line as "verb" + + * src/stdio/common/setvbuf.cxx: + + Change to cope with different way of dealing with buffering policy + flags etc. in Cyg_StdioStream + + * src/stdio/common/vsnprintf.cxx, src/stdio/common/vsscanf.cxx, + src/support/clibdata.cxx: + Change construction of streams to use new parameters added above, + and change to use _IONBF mode for string stdio functions, + otherwise its a waste of memory. And use _IONBF for stderr as the + ISO standard tells us to! + + Reformat for coding standards to have { in same line as "verb" + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Change constructor so that it can be set with default size and + dynamic buffer (if applicable) + + Fix minor bug in destructor - should only call free when allocated + dynamically + + Change get_buffer_size to return -1 if the buffer was not allowed + to be set up + + * src/stdio/common/streambuf.cxx: + Remove unnecessary stdio.h include and add extra comment to whether + to free bit in set_buffer() + + * src/stdio/common/freopen.cxx: + Change @@@ to standard fix me string + + * src/stdio/output/fputc.cxx: + Remove unnecessary "written" variable + +Thu Aug 13 15:37:28 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: + Included use of "fix me" line to ensure this is discussed before + release + + * include/stdlib.h, src/stdlib/abort.cxx, src/PKGconf.mak: + Add abort.cxx to implement abort(), albeit naively + +Thu Jul 30 18:03:09 1998 Jonathan Larmour + + * src/stdio/common/vsscanf.cxx (_vsscanf), + src/stdio/common/vsnprintf.cxx (_vsnprintf): + Fix initialiser of pseudo string device table that didn't get updated + when the table changed (Bad proven, no biscuit). + + * src/clibincl/stream.inl (~Cyg_StdioStream): + Move invalidation of magic_validity_word to after unlock_me(), + otherwise it always fails! + +Tue Jul 28 21:29:53 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Shorten over-long lines + +Tue Jul 28 20:28:23 1998 Jonathan Larmour + + * src/clibincl/stream.hxx (class Cyg_StdioStream), + src/clibincl/stream.inl, src/stdio/common/stream.cxx: + Clarify some comments and get the CYGDBG_DEFINE_CHECK_THIS and + CYG_ASSERTCLASS stuff going + + * src/clibincl/stream.inl: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 15:31:06 1998 Jonathan Larmour + + * src/clibincl/streambuf.inl, src/stdio/common/streambuf.cxx: + Move set_buffer() from streambuf.inl to new file streambuf.cxx + + * src/PKGconf.mak (COMPILE): + Build new file streambuf.cxx + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + Add METHODS comment + + * src/stdio/common/stream.cxx: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 00:26:36 1998 Jonathan Larmour + + * include/stdlib.inl, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/div.cxx, + src/stdlib/ldiv.cxx, src/stdlib/qsort.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/string/strtok.cxx: + + Include proper Berkeley license inline in the file, rather than + referring to an external file + + * doc/COPYING.UCB: + Remove, now that it isn't referred to any more + +Mon Jul 27 23:34:26 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl, include/errno.h, + include/stdio.h, include/stdio.inl, include/stdlib.h, + include/stdlib.inl, include/string.h, include/string.inl, + include/time.h, include/sys/file_if.h, src/PKGconf.mak, + src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/stdiosupp.hxx, + src/clibincl/stream.hxx, src/clibincl/streambuf.hxx, + src/clibincl/streambuf.inl, src/clibincl/stringsupp.hxx, + src/clibincl/timesupp.hxx, src/ctype/isalnum.cxx, + src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, + src/ctype/islower.cxx, src/ctype/isprint.cxx, + src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, + src/ctype/tolower.cxx, src/ctype/toupper.cxx, + src/errno/errno.cxx, src/stdio/common/snprintf.cxx, + src/stdio/common/sprintf.cxx, src/stdio/common/sscanf.cxx, + src/stdio/common/stdioinlines.cxx, src/stdio/common/stream.cxx, + src/stdio/common/ungetc.cxx, src/stdio/common/vsnprintf.cxx, + src/stdio/common/vsscanf.cxx, src/stdio/input/fgetc.cxx, + src/stdio/input/fgets.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/gets.cxx, src/stdio/input/scanf.cxx, + src/stdio/output/fnprintf.cxx, src/stdio/output/fprintf.cxx, + src/stdio/output/fputc.cxx, src/stdio/output/fputs.cxx, + src/stdio/output/printf.cxx, src/stdlib/_exit.cxx, + src/stdlib/abs.cxx, src/stdlib/atof.cxx, src/stdlib/atoi.cxx, + src/stdlib/atol.cxx, src/stdlib/div.cxx, src/stdlib/labs.cxx, + src/stdlib/ldiv.cxx, src/stdlib/rand.cxx, src/stdlib/strtod.cxx, + src/string/memchr.cxx, src/string/memcmp.cxx, + src/string/memmove.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, + src/string/strcoll.cxx, src/string/strcpy.cxx, + src/string/strcspn.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx, src/string/strpbrk.cxx, + src/string/strrchr.cxx, src/string/strspn.cxx, + src/string/strstr.cxx, src/string/strsuppt.cxx, + src/string/strtok.cxx, src/string/strxfrm.cxx, + src/support/clibdata.cxx, src/time/clock.cxx: + Untabify + +Mon Jul 27 23:14:18 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/stdlib/malloc.cxx, src/stdlib/qsort.cxx, + tests/ctype/ctype.c, tests/stdlib/rand3.c, tests/stdlib/malloc3.c: + Remove all mentions of "register" in variable declarations. Also + untabify where needed + + * src/stdlib/bsearch.cxx: + Untabify this too + + +Mon Jul 27 22:18:51 1998 Jonathan Larmour + + * src/stdio/output/fputc.cxx (_fputc): + Replace call to stream write() with call to write_byte() + + * src/clibincl/stream.inl (write_byte): + Add asserts for stream write() returning odd values for how much has + been written + + (bytes_available_to_read): + Remove "register" def for variable declaration + +Mon Jul 27 22:06:22 1998 Jonathan Larmour + + * src/stdio/common/stdiosupp.cxx: + Remove #if 0'd cyg_get_file_star() and unnecessary pseudo string + device definition + +Mon Jul 27 21:57:25 1998 Jonathan Larmour + + * include/pkgconf/libc.h, src/support/clibdata.cxx: + Change CYGXXX_LIBC_STDIO_DEFAULT_CONSOLE to + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE + +Mon Jul 27 21:49:23 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/setjmpsupp.hxx, + src/clibincl/stdiosupp.hxx, src/clibincl/stdlibsupp.hxx, + src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl, + src/clibincl/stringsupp.hxx, src/clibincl/timesupp.hxx: + + Change CYGONCE_LIBC_*_{HXX,INL} to CYGONCE_LIBC_CLIBINCL_*_{HXX,INL} + +Mon Jul 27 21:34:05 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change #define XXXXX 1 to #define XXXXX where applicable as per code + review + + Also remove obsolete CYGIMP_LIBC_THREAD_START_SUSPENDS_SELF + +Mon Jul 27 19:42:27 1998 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): + Use #ifdef, not #if for config options + +Mon Jul 27 15:01:51 BST 1998 Chris Provenzano + + * src/stdio/common/stream.cxx, src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx: + Fixes to compile with the new Cyg_IORB field names. + +Thu Jul 9 03:40:21 1998 Jonathan Larmour + + * tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Adjust starting of tests to possibly start scheduler since + strtol/stroul rely on errno, which may be a per-thread variable + +Thu Jul 9 03:06:25 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx, src/stdio/common/setvbuf.cxx: + Consolidate read and write buffers into single buffer, as it should + have been all along + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Add drain_buffer() method to speed up the case when we want the + buffer completely emptied + +Tue Jul 7 21:26:33 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Add a couple of new tests that check that very long strings work too + +Wed Jul 1 19:52:39 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/streambuf.hxx: + Do not permit copy constructors + + * src/clibincl/stream.inl, src/stdio/common/fclose.cxx: + Make sure we use #ifdef and not #if + + * src/clibincl/streambuf.inl: + Use member initialisation list rather than explicit initialisation to + reduce warnings + +Wed Jul 1 19:17:55 1998 Jonathan Larmour + + * include/pkgconf/libc.h and all files using config options: + Rename configuration defines to make them more standard + +Thu Jun 25 20:09:30 1998 Jonathan Larmour + + * src/string/strcat.cxx: + Add parentheses on check to silence warning + (Verified by proven) + +Thu Jun 25 19:30:01 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Make sure that the malloc pool is initialised before other things + can use it. This is done with the hot new constructor ordering + feature. + +Thu Jun 25 18:27:03 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Remove bogus ifdef if floating point is _not_ wanted + +Thu Jun 25 17:31:42 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Fix argument checking to allow first argument of NULL + +Thu Jun 25 04:18:50 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_strtok_last_p): + Remove bogus assertion + + * src/stdlib/malloc.cxx: + Got sense of alignment check assertion the wrong way round, so negate + it + +Thu Jun 25 03:56:35 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: + Fix argument checking assertions with legitimate nulls here too + +Thu Jun 25 03:46:32 1998 Jonathan Larmour + + * src/stdlib/strtoul.cxx, src/stdlib/strtol.cxx: + Fix argument checking assertions to cope with legitimate nulls + +Wed Jun 24 09:01:45 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Remove extraneous info messages + +Wed Jun 24 05:59:17 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c: + + Change large automatic arrays to static arrays to prevent overuse + of a potentially small stack + +Wed Jun 24 05:45:28 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/string/strtok.c, tests/time/clock.c: + + Increase thread stack size from 4K to 32K as in some cases it was + too small. + + +Tue Jun 23 20:12:31 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Add extra tests, including floating point conversion testing + +Tue Jun 23 17:01:06 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Make sure this is only compiled if CYGFUN_LIBC_strtok is defined + +Tue Jun 23 06:10:13 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + add some comments - that's all + + * src/stdio/common/stream.cxx: + fix case in refill_read_buffer() for what to do when there's nothing + left. Now return EAGAIN + + * src/stdio/common/vsscanf.cxx, src/stdio/input/vfscanf.cxx: + Get sscanf working properly and passing tests. Also make sure it + ignores FP when its not configured + + * src/stdlib/atof.cxx: + Only compile at all if strtod() is present + + +Mon Jun 22 19:13:42 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise strtok_last and rand_seed better + +Mon Jun 22 14:14:12 1998 Jonathan Larmour + + * tests/stdlib/malloc3.c: + Add test for checking that mallocing and freeing repeatedly works + + * tests/PKGconf.mak: + Update to reflect addition of the above + +Mon Jun 22 13:09:33 BST 1998 Chris Provenzano + + * src/stdio/common/fopen.cxx + * src/stdio/common/stream.cxx + * src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx + Include cyg/devs/common/iorb.h instead of iorb.hxx + + * src/stdio/common/stream.cxx + Use read_blocking and write_blocking instead of just read and + write when accessing devices through the virtual device table. + +Sun Jun 21 18:19:13 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Propagate change of return code handling for puts from stdio.inl + into here + + * src/stdio/output/fputc.cxx: + make sure the right type is used for output - byte not int + + * src/support/clibdata.cxx: + Fix #define config mistook. #endif was in wrong place + +Sun Jun 21 16:11:04 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Allow explicit construction to get around a bug when + dynamically allocating per-thread structure + +Sun Jun 21 16:02:51 1998 Jonathan Larmour + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, tests/stdlib/qsort.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + + Update tests to "do the right thing" with all configuration settings + + +Sun Jun 21 04:54:14 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + I have to be careful not to use setjmp() in a way not exactly + defined by the standard, so make sure I do, and add a comment + documenting these ways. + + Also ensure this test does the right thing in all configurations + +Sun Jun 21 04:38:15 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add extra checks for invalid configurations + Also make default for thread safety OFF + + * src/clibincl/clibdata.inl: + Adjust indentation + + * src/stdio/output/vfnprintf.cxx: + Make printf of -0.0 floating point do the right thing + +Sun Jun 21 04:28:00 1998 Jonathan Larmour + + * src/stdio/common/snprintf.cxx, src/stdio/common/sprintf.cxx, + src/stdio/common/sscanf.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/scanf.cxx, src/stdio/output/fnprintf.cxx, + src/stdio/output/fprintf.cxx, src/stdio/output/printf.cxx: + + Had to remove inline functions with varargs. Which means separating + out each function from stdioinlines.cxx into a separate file, as they + no longer belong there. So all the above files were created. + + * include/stdio.inl, src/PKGconf.mak, + src/stdio/common/stdioinlines.cxx: + Changed to take account of the above + + +Sun Jun 21 03:58:42 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c: + Update with floating-point tests. Also make sure they DTRT in all + configurations + +Fri Jun 19 19:33:06 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + accidentally initialised stdin/out/err twice + +Fri Jun 19 19:09:29 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Another typo + +Fri Jun 19 18:59:07 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Missing #endif typo + +Fri Jun 19 18:51:42 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Fix initialisation of static data members. Unsure how it worked at + all before! + +Fri Jun 19 18:01:01 1998 Jonathan Larmour + + * include/stdio.inl: + puts should check whether fputs returns non-negative, rather than + non-zero + +Fri Jun 19 17:22:52 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl: + Make inclusion of get_errno_p conditional on thread-safety + +Wed Jun 17 10:55:32 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Add weak alias of vfscanf() to _vfscanf() + +Wed Jun 17 09:10:41 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Initialise err to silence compiler warning + +Wed Jun 17 08:59:20 1998 Jonathan Larmour + + * Most important is the addition of floating point support in + src/stdio/output/vfnprintf.cxx and src/stdio/input/vfscanf.cxx. This + also required the addition of atof() and strtod() in stdlib which is + definitely no bad thing! Other than that... + + * Fix a whole bunch of stuff I messed up first time round. Also the + sprintf and sscanf tests are included again. + +Tue Jun 16 16:38:02 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Typo with not putting comment character at the beginning. Sigh. + +Tue Jun 16 14:53:09 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Forgot to (temporarily) remove fputs test for now + +Mon Jun 15 20:40:03 1998 Jonathan Larmour + + Everything to do with stdio has almost completely changed, so there's + not much point documenting individual changes. + +Mon Jun 15 18:36:01 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c: + Stop it moaning quite as much when it fails by making it exit sooner + + * tests/time/clock.c : + This isn't a compound testcase + +Thu Jun 11 17:59:13 1998 Jonathan Larmour + + * include/assert.h + Reverse sense of NDEBUG ifdef, that was left in accidentally due + to testing + +Thu Jun 11 04:58:08 1998 Jonathan Larmour + + * include/errno.h, include/string.h, src/clibincl/stringsupp.hxx: + Modify as I've now added an "error" package which defines the error + codes and strerror() + + * src/errno/strerror.cxx: + Moved to new error package and thus deleted + +Wed Jun 10 18:37:37 1998 Jonathan Larmour + + * include/assert.h: + create this header and add assert() function + +Wed Jun 10 16:23:57 1998 Jonathan Larmour + + * include/stdlib.h, src/clibincl/stdlibsupp.hxx, src/stdlib/malloc.cxx: + Add malloc(), calloc() and free() functions + + * include/pkgconf/libc.h: + Add malloc memory pool size option + + * tests/stdlib/malloc1.c, tests/stdlib/malloc2.c: + new tests for malloc + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for new files + +Wed Jun 10 15:06:16 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + Add another test + +Tue Jun 9 18:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add some setjmp config's and a macro for the noreturn attribute + + * include/setjmp.h, include/setjmp.inl, src/clibincl/setjmpsupp.hxx, + src/setjmp/longjmp.cxx, tests/setjmp/setjmp.c: + Added to implement and test setjmp() and longjmp() + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for newly added files + +Thu Jun 4 01:29:18 1998 Jonathan Larmour + + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, src/string/strcpy.cxx, + src/string/strlen.cxx, src/string/strncat.cxx, + src/string/strncmp.cxx, src/string/strncpy.cxx: + Rename CYGIMP_LIBC_PREFER_SMALL_TO_FAST to + CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST + + Also use slower but smaller version when __OPTIMIZE_SIZE__ is + defined (which comes from using gcc -Os) + +Fri May 29 16:15:04 1998 Jonathan Larmour + + * include/ctype.inl, src/ctype/isxdigit.cxx: + Fix bug that numerals aren't considered hex digits + + * include/time.h: + Change clock_t and time_t to be signed so that they can accept -1, as + required by other libc functions + + * src/clibincl/clibdata.hxx: + Fix typo that CYGIMP_LIBC_THREAD_SUPPORT should be ..._SAFETY + Also fix macro to allocate thread-specific data to not set variables + in a different stack-frame + + * tests/ctype/ctype.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/stdlib/qsort.c: + make ctr unsigned to prevent warnings + + * tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/string/strrchr.c: + Fix off by one error + + * tests/string/strspn.c: + Fix case-sensitivity problem, and off-by-one error + + * tests/string/strxfrm1.c: + Remove bogus bit of test that doesn't apply to strxfrm, and fix typo + + +Fri May 22 16:33:04 1998 Jonathan Larmour + + * src/PKGconf.mak + Remove CXXFLAGS line now that its redundant + + * tests/everything! + Do a blitz change of all tests - break some of them down into + different files, add new tests, standardize format, fix bugs, + update for recent header file changes and much more! + +Wed May 20 17:50:04 1998 Jonathan Larmour + + * tests/PKGconf.mak: + interim checkin for different dir structure for Bart + +Fri May 15 20:30:46 1998 Jonathan Larmour + + * Tidy up some loose ends I forgot: rename src/include directory to + src/clibincl. And add clibdata.inl and timesupp.hxx in there. + +Thu May 14 19:56:32 1998 Jonathan Larmour + + * Basically everything has changed in the C library. Files have + been moved, renamed, deleted and reworked. This is a major + revision, and now starts from this new baseline rather than doing + incremental changes. + +Fri Apr 17 18:43:02 1998 Jonathan Larmour + + * src/ECCconf.mak: + added for new build system (actually Bart did this, but didn't + update this ChangeLog) + +Fri Apr 17 15:03:25 1998 Hugo Tyson + + * src/stdio/device/sim.cxx: + Make it build with CYG_EMPTY_STATEMENT; the unadorned one is being + removed. + +Thu Apr 16 00:24:24 1998 Jonathan Larmour + + * All source files: + replace ECCIMP_LIBC_* conditional ifdef with CYGIMP_LIBC_* + + * include/eccconf/libc.h: + improve comments and reorder a bit + +Wed Apr 8 14:35:20 1998 Jonathan Larmour + + * Makefile.am, src/Makefile.am, tests/Makefile.am, configure.in: + many changes to integrate build structure from release tree + + * src/ctype/Makefile.am, src/ctype/Makefile.in, src/errno/Makefile.am, + src/errno/Makefile.in, src/stdio/Makefile.am, src/stdio/Makefile.in, + src/stdio/common/Makefile.am, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.am, src/stdio/device/Makefile.in, + src/stdio/output/Makefile.am, src/stdio/output/Makefile.in, + src/stdio/input/Makefile.am, src/stdio/input/Makefile.in, + src/stdlib/Makefile.am, src/stdlib/Makefile.in, + src/string/Makefile.am, src/string/Makefile.in, + src/support/Makefile.am, src/support/Makefile.in, + src/time/Makefile.am, src/time/Makefile.in: + Remove as they are now redundant with above changes + + * include/Makefile.am: + Add to support above changes + + * include/eccconf/libc.h: + Change include file for configuration from kernel to system + + * src/include/kerndiag.hxx, src/stdio/device/kerndiag.cxx, + src/time/clockfn.cxx: + Change kernel include file to eccconf/kernel.h + + * src/include/strngdev.h: + remove unnecessary kernel include + + * Makefile.in, aclocal.m4, configure, src/Makefile.in, + tests/Makefile.in, include/Makefile.in: + regenerate + +Mon Apr 6 20:55:07 1998 Jonathan Larmour + + * src/stdlib/abs.cxx, src/stdlib/atoi.cxx, src/stdlib/atol.cxx, + src/stdlib/div.cxx, src/stdlib/labs.cxx, src/stdlib/ldiv.cxx: + Separated out functions from stdlib.cxx into separate files + + * src/stdlib/stdlib.cxx: + removed to be replaced by above files + + * Makefile.am, src/stdlib/Makefile.am: + modified to support building above and not building stdlib.cxx + + * src/support/tsd.cxx: + Remove unnecessary header file includes + + * Makefile.in, src/stdlib/Makefile.in: + regenerated + +Mon Apr 6 19:19:42 1998 Jonathan Larmour + + * src/support/tsd.cxx, include/eccconf/libc.h: + remove lame hack for tx39 compiler now that its fixed + + * src/include/sim.hxx: + define constants as static to placate compiler + +Thu Apr 2 21:01:21 1998 Jonathan Larmour + + * src/ctype/ctype.cxx: + deleted and separated out into below files + + * src/ctype/isalnum.cxx, src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, src/ctype/islower.cxx, + src/ctype/isprint.cxx, src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, src/ctype/tolower.cxx, + src/ctype/toupper.cxx: + Separated out individual ctype functions from ctype.cxx into separate + files + + * Makefile.am, src/ctype/Makefile.am: + modified to reflect above deletion/additions + + * Makefile.in, src/ctype/Makefile.in: + regenerated + +Thu Apr 2 19:08:26 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: optimise using prefix increments + +Thu Apr 2 15:18:15 1998 Jonathan Larmour + + * src/string/strchr.cxx: optimise setting of mask a little + +Thu Mar 26 14:07:01 1998 Jonathan Larmour + + * src/support/tsd.cxx: fixed some typos + +Thu Mar 26 11:58:47 1998 Jonathan Larmour + + * include/eccconf/libc.h, src/support/tsd.cxx: + Implement workaround for tx39 compiler bug. + + * src/include/strsuppt.hxx: + remove prototypes for _memcpy() and _memset() as they are now in the + kernel + +Wed Mar 25 18:31:53 1998 Jonathan Larmour + + * Makefile.am, src/string/Makefile.am: memcpy() and memset() are + now in the kernel so remove them from build + * include/string.h: add a comment to say as much + * Makefile.in, src/string/Makefile.in: regenerate + +Wed Mar 25 15:30:42 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx, src/include/file_if.inl: + Change _exit workaround to not cause a compiler optimisation + problem. Now just references _exit rather than calls it. + +Wed Mar 25 14:59:49 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fix bug causing tests to fail completely + for this function + +Wed Mar 25 12:55:53 1998 Jonathan Larmour + + * src/include/sim.hxx: add types to constants (oops!) + * Makefile.am: link src/stdio/device/sim.cxx + * Makefile.in: regenerated + +Wed Mar 25 04:14:30 1998 Jonathan Larmour + + * src/include/file_if.hxx, src/include/file_if.inl, + src/include/kerndiag.hxx, src/include/sim.hxx, + src/include/stdio_if.hxx, src/include/strngdev.hxx, + src/include/tsd.hxx, src/stdio/common/clearerr.cxx, + src/stdio/common/clearerr.cxx, src/stdio/common/feof.cxx, + src/stdio/common/ferror.cxx, src/stdio/common/file_if.cxx, + src/stdio/common/vsprintf.cxx, + src/stdio/device/kerndiag.cxx, src/stdio/device/sim.cxx, + src/stdio/device/strngdev.cxx, src/stdio/output/fputc.cxx, + src/stdio/output/fputs.cxx, src/stdio/output/puts.cxx, + src/stdio/output/vfnprintf.cxx, src/support/tsd.cxx: + Modified to support buffered reads including renaming + _EccInternalFileStruct to __EccStdioStream which is what affects + most of these files + * src/include/file_if.inl, src/stdio/common/file_if.cxx: added for + the above reason + * src/stdio/common/sscanf.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/input/Makefile.am: added to provide sscanf() functionality + * include/ctype.h, include/stdio.h, include/stdlib.h, + include/string.h, include/eccconf/libc.h, src/ctype/ctype.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/stdio/common/stdio.cxx: + rename *_INLINES macros with prefix CYG rather than ECC + * include/errno.h, src/errno/errno.cxx, src/errno/strerror.cxx: + rename ErrNo to _ErrNo and add EAGAIN and EWOULDBLOCK error codes + * configure.in, Makefile.am, src/stdio/Makefile.am, + src/stdio/input/Makefile.am: add support for building + file_if.cxx sscanf.cxx and vfscanf.cxx + * src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/input/Makefile.in, configure, Makefile.in: regenerated + +Tue Mar 24 19:51:40 1998 Jonathan Larmour + + * src/time/clockfn.cxx, src/time/clock.cxx: + Renamed clock.cxx to clockfn.cxx (preserving CVS history) + * Makefile.am, src/time/Makefile.am: updated to reflect name change + * Makefile.in, src/time/Makefile.in: regenerated + +Tue Mar 24 16:28:06 1998 Jonathan Larmour + + * include/ctype.inl: Swap around definitions to get right order so + inlining works + +Tue Mar 24 14:43:05 1998 Jonathan Larmour + + * include/ctype.h, include/stdio.h, include/stdlib.h, include/string.h: + modify to only conditionally include inlines + * src/ctype/ctype.cxx, src/stdio/common/stdio.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/ctype/Makefile.am: Add to provide real linkable alternatives + to inline functions + * Makefile.am, configure.in, src/Makefile.am, + src/stdio/common/Makefile.am, src/stdlib/Makefile.am, + src/string/Makefile.am: modified to support previous additions + * include/eccconf/libc.h: redefine inline macro to add extern inline, + and add conditional defines for inline functions. Also rename + space vs. speed macro to have CYG instead of ECC prefix + * include/stdio.inl: fix comment typo + * src/stdlib/qsort.cxx: fix to define inline functions properly + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/memcpy.cxx, + src/string/memset.cxx, src/string/strcat.cxx, src/string/strchr.cxx, + src/string/strcmp.cxx, src/string/strcpy.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx + * Makefile.in, configure, src/Makefile.in, src/ctype/Makefile.in, + src/stdio/common/Makefile.in, src/stdlib/Makefile.in, + src/string/Makefile.in: regenerate + + +Mon Mar 23 19:19:49 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: added to support temporary _exit + * include/stdlib.h, include/stdlib.inl: added support for _exit and + added abs(), labs(), div() and ldiv() functions + * src/include/file_if.hxx: added support for _exit kludge + * src/stdlib/qsort.cxx: Added Berkeley copyright message + * src/time/clock.cxx: Include correct kernel config header as + CYG_CONFIGURATION rather than + * Makefile.am src/stdlib/Makefile.am: added support for _exit + * Makefile.in, src/stdlib/Makefile.in: regenerated + +Mon Mar 23 14:41:07 1998 Jonathan Larmour + + * Replace ECCPKG_ANSI_LIBC with CYGPKG_ANSI_LIBC in all source files + +Mon Mar 23 14:28:44 1998 Jonathan Larmour + + * include/string.inl: add file to provide strcoll() + * include/string.h: include string.inl + * ctype.h: include ctype.inl (oops!) + * include/stdlib.h: include stdlib.inl (oops!) + +Mon Mar 23 13:30:38 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl: added to provide ANSI ctype + functionality + * include/stdlib.h, include/stdlib.inl, src/include/stdlibbsp.hxx, + src/stdlib/Makefile.am, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/stdlib/srand.cxx, + src/stdlib/strtol.cxx, src/stdlib/strtoul.cxx: Added to provide + many stdlib functions + * src/include/tsd.hxx: modified to support rand() random number + seed, and added some comments + * configure.in, Makefile.am, src/Makefile.am: modified to support + addition of above new sources + * include/eccconf/libc.h: Add extra helpful comments, and #include + kernel config file + * src/time/clock.cxx: #include clock.inl and fix to call + get_resolution() properly now + * Makefile.in, configure, src/Makefile.in, src/errno/Makefile.in, + src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.in, src/stdio/output/Makefile.in, + src/stdlib/Makefile.in, src/strings/Makefile.in, + src/support/Makefile.in, src/time/Makefile.in, + tests/Makefile.in: regenerated + + +Sun Mar 22 21:29:25 1998 Jonathan Larmour + + * include/time.h, src/include/timesupp.hxx, src/time/clock.cxx, + src/time/Makefile.am: added to provide clock() function + * src/Makefile.am: modified to try to build in src/time directory + * include/eccconf/libc.h: added and is now the main configuration + file for this package + * acconfig.h, include/libcconf.h.in, include/stamp-h.in: removed + due to usage of libc.h above instead + * Almost all *.h, *.hxx and *.cxx: replaced LIBC_CONFIG_HEADER + defined include with simple + * configure.in: remove AM_CONFIG_HEADER of libcconf.h and + LIBC_CONFIG_HEADER definition. Also remove usage of builtin + memcpy() etc. from gcc, and generate src/time/Makefile + * Makefile.am: link in src/time/clock.o + * src/include/file_if.hxx, src/include/sim.hxx: use config header + to decide whether C library is to be used + * Makefile.in, aclocal.m4, configure, src/Makefile.in: regenerated + +Fri Mar 20 18:08:10 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fixed bug with ignoring terminating NULL + +1998-03-20 Chris Tarpy + + * configure: - regenerated + * Makefile.am: - Support added for libc testcases + * Makefile.in: regenerated + * configure.in: set c compiler, descend test dir + * tests/Makefile.in: added + * tests/Makefile.am: added + * tests/tcdiag.cxx : added + + +Thu Mar 19 11:41:56 1998 Jonathan Larmour + + * Initial check-in of everything + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/string/current/cdl/string.cdl b/packages/language/c/libc/string/current/cdl/string.cdl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/cdl/string.cdl @@ -0,0 +1,181 @@ +# ==================================================================== +# +# string.cdl +# +# C library string related configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jlarmour +# Contributors: +# Date: 2000-04-14 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_LIBC_STRING { + display "ISO C library string functions" + description " + This package provides string functions specified by the + ISO C standard - ISO/IEC 9899:1990." + doc redirect/the-iso-standard-c-and-math-libraries.html + include_dir cyg/libc/string + parent CYGPKG_LIBC + implements CYGINT_ISO_STRTOK_R + implements CYGINT_ISO_STRING_LOCALE_FUNCS + implements CYGINT_ISO_STRING_MEMFUNCS + implements CYGINT_ISO_STRING_STRFUNCS + requires { CYGBLD_ISO_STRING_LOCALE_FUNCS_HEADER == \ + "" } + requires { CYGBLD_ISO_STRING_MEMFUNCS_HEADER == \ + "" } + requires { CYGBLD_ISO_STRING_STRFUNCS_HEADER == \ + "" } + requires { CYGBLD_ISO_STRTOK_R_HEADER == \ + "" } + requires CYGPKG_ISOINFRA + + compile memchr.cxx memcmp.cxx memmove.cxx \ + strcat.cxx strchr.cxx strcmp.cxx \ + strcoll.cxx strcpy.cxx strcspn.cxx \ + strlen.cxx strncat.cxx strncmp.cxx \ + strncpy.cxx strpbrk.cxx strrchr.cxx \ + strspn.cxx strstr.cxx strsuppt.cxx \ + strtok.cxx strxfrm.cxx + + +# ==================================================================== + + cdl_option CYGIMP_LIBC_STRING_INLINES { + display "Inline versions of functions" + default_value 1 + description " + This option chooses whether some of the + particularly simple string functions from + are available as inline + functions. This may improve performance, and as + the functions are small, may even improve code + size." + } + + cdl_option CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST { + display "Optimize string functions for code size" + flavor bool + default_value 0 + description " + This option tries to reduce string function + code size at the expense of execution speed. The + same effect can be produced if the code is + compiled with the -Os option to the compiler." + } + + cdl_component CYGPKG_LIBC_STRING_STRTOK { + display "strtok" + flavor none + description " + These options control the behaviour of the + strtok() and strtok_r() string tokenization + functions." + + cdl_option CYGSEM_LIBC_STRING_PER_THREAD_STRTOK { + display "Per-thread strtok()" + requires CYGVAR_KERNEL_THREADS_DATA + default_value 0 + description " + This option controls whether the string function + strtok() has its state recorded on a per-thread + basis rather than global. If this option is + disabled, some per-thread space can be saved. + Note there is also a POSIX-standard strtok_r() + function to achieve a similar effect with user + support. Enabling this option will use one slot + of kernel per-thread data. You should ensure you + have enough slots configured for all your + per-thread data." + } + + cdl_option CYGNUM_LIBC_STRING_STRTOK_TRACE_LEVEL { + display "Tracing level" + flavor data + legal_values 0 to 1 + default_value 0 + description " + Trace verbosity level for debugging the + functions strtok() and strtok_r(). Increase this + value to get additional trace output." + } + } + + cdl_component CYGPKG_LIBC_STRING_OPTIONS { + display "C library string functions build options" + flavor none + no_define + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_LIBC_STRING_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the C library. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_LIBC_STRING_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the C library. These flags are removed from + the set of global flags if present." + } + + cdl_option CYGPKG_LIBC_STRING_TESTS { + display "C library string function tests" + flavor data + no_define + calculated { "tests/memchr tests/memcmp1 tests/memcmp2 tests/memcpy1 tests/memcpy2 tests/memmove1 tests/memmove2 tests/memset tests/strcat1 tests/strcat2 tests/strchr tests/strcmp1 tests/strcmp2 tests/strcoll1 tests/strcoll2 tests/strcpy1 tests/strcpy2 tests/strcspn tests/strcspn tests/strlen tests/strncat1 tests/strncat2 tests/strncpy1 tests/strncpy2 tests/strpbrk tests/strrchr tests/strspn tests/strstr tests/strtok tests/strxfrm1 tests/strxfrm2" } + description " + This option specifies the set of tests for the C library + string functions." + } + } +} + +# ==================================================================== +# EOF string.cdl + diff --git a/packages/language/c/libc/string/current/include/string.h b/packages/language/c/libc/string/current/include/string.h new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/include/string.h @@ -0,0 +1,156 @@ +#ifndef CYGONCE_LIBC_STRING_H +#define CYGONCE_LIBC_STRING_H +/*=========================================================================== +// +// string.h +// +// ANSI standard string and memory area manipulation routines +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: This file provides various string functions required by +// ISO C 9899:1990 +// Description: The real contents of this file get filled in from the +// configuration set by the implementation +// Usage: Do not include this file directly - use #include +// +//####DESCRIPTIONEND#### +// +//=========================================================================*/ + +/* CONFIGURATION */ + +#include /* Configuration header */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* FUNCTION PROTOTYPES */ + +/*=========================================================================*/ + +/* 7.11.2 Copying functions */ + +extern void * +memmove( void *, const void *, size_t ); + +extern char * +strcpy( char *, const char * ); + +extern char * +strncpy( char *, const char *, size_t ); + +/*=========================================================================*/ + +/* 7.11.3 Concatenation functions */ + +extern char * +strcat( char *, const char * ); + +extern char * +strncat( char *, const char *, size_t ); + + +/*=========================================================================*/ + +/* 7.11.4 Comparison functions */ + +extern int +memcmp( const void *, const void *, size_t ); + +extern int +strcmp( const char *, const char * ); + +extern int +strcoll( const char *, const char * ); + +extern int +strncmp( const char *, const char *, size_t ); + +extern size_t +strxfrm( char *, const char *, size_t ); + + +/*=========================================================================*/ + +/* 7.11.5 Search functions */ + +extern void * +memchr( const void *, int, size_t ); + +extern char * +strchr( const char *, int ); + +extern size_t +strcspn( const char *, const char * ); + +extern char * +strpbrk( const char *, const char * ); + +extern char * +strrchr( const char *, int ); + +extern size_t +strspn( const char *, const char * ); + +extern char * +strstr( const char *, const char * ); + +extern char * +strtok( char *, const char * ); + +/* POSIX 1003.1 section 8.3.3 strtok_r() */ + +extern char * +strtok_r( char *, const char *, char ** ); + + +/*=========================================================================*/ + +/* 7.11.6 Miscellaneous functions */ + +extern size_t +strlen( const char * ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* INLINE FUNCTIONS */ + +#ifdef CYGIMP_LIBC_STRING_INLINES +#include +#endif + +#endif /* CYGONCE_LIBC_STRING_H multiple inclusion protection */ + +/* EOF string.h */ diff --git a/packages/language/c/libc/string/current/include/string.inl b/packages/language/c/libc/string/current/include/string.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/include/string.inl @@ -0,0 +1,63 @@ +#ifndef CYGONCE_LIBC_STRING_STRING_INL +#define CYGONCE_LIBC_STRING_STRING_INL +//=========================================================================== +// +// string.inl +// +// Inline functions for ANSI standard string and memory area +// manipulation routines described in ANSI para 7.11 +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: #include - do not include this file directly +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// FUNCTIONS + +extern __inline__ int +strcoll( const char *s1, const char *s2 ) +{ + return strcmp(s1, s2); +} // strcoll() + + +#endif // CYGONCE_LIBC_STRING_STRING_INL multiple inclusion protection + +// EOF string.inl diff --git a/packages/language/c/libc/string/current/include/stringsupp.hxx b/packages/language/c/libc/string/current/include/stringsupp.hxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/include/stringsupp.hxx @@ -0,0 +1,205 @@ +#ifndef CYGONCE_LIBC_STRING_STRINGSUPP_HXX +#define CYGONCE_LIBC_STRING_STRINGSUPP_HXX +//=========================================================================== +// +// stringsupp.hxx +// +// Support for the ANSI standard string functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 2000-04-14 +// Purpose: Internal support for the libc string function implementations +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Compiler definitions such as + // size_t, NULL etc. + +// CONSTANTS + +#ifndef CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST + +// Masks for CYG_LIBC_STR_DETECTNULL below +externC const cyg_uint64 Cyg_libc_str_null_mask_1; +externC const cyg_uint64 Cyg_libc_str_null_mask_2; + +#endif + +// MACROS + +// Nonzero if X is not aligned on a word boundary. +#define CYG_LIBC_STR_UNALIGNED(X) ((CYG_WORD)(X) & (sizeof (CYG_WORD) - 1)) + +// Nonzero if either X or Y is not aligned on a word boundary. +#define CYG_LIBC_STR_UNALIGNED2(X , Y) \ + (((CYG_WORD)(X) & (sizeof (CYG_WORD) - 1)) | \ + ((CYG_WORD)(Y) & (sizeof (CYG_WORD) - 1))) + +// Nonzero if any byte of X contains a NULL. +#define CYG_LIBC_STR_DETECTNULL(X) \ + (((X) - (CYG_WORD)Cyg_libc_str_null_mask_1) & \ + ~(X) & (CYG_WORD)Cyg_libc_str_null_mask_2) + +// How many bytes are copied each iteration of the 4X unrolled loop in the +// optimised string implementations +#define CYG_LIBC_STR_OPT_BIGBLOCKSIZE (sizeof(CYG_WORD) << 2) + +// How many bytes are copied each iteration of the word copy loop in the +// optimised string implementations +#define CYG_LIBC_STR_OPT_LITTLEBLOCKSIZE (sizeof (CYG_WORD)) + +// Threshold for punting to the byte copier in the optimised string +// implementations +#define CYG_LIBC_STR_OPT_TOO_SMALL(LEN) \ + ((LEN) < CYG_LIBC_STR_OPT_LITTLEBLOCKSIZE) + + +// FUNCTION PROTOTYPES + +// These are function prototypes for the aliased functions that actually +// implement the string functions + +//=========================================================================== + +// 7.11.2 Copying functions + +externC void * +__memmove( void *, const void *, size_t ); + + +externC char * +__strcpy( char *, const char * ); + + +externC char * +__strncpy( char *, const char *, size_t ); + + +//=========================================================================== + +// 7.11.3 Concatenation functions + + +externC char * +__strcat( char *, const char * ); + + +externC char * +__strncat( char *, const char *, size_t ); + + +//=========================================================================== + +// 7.11.4 Comparison functions + +externC int +__memcmp( const void *, const void *, size_t ); + + +externC int +__strcmp( const char *, const char * ); + + +externC int +__strcoll( const char *, const char * ); + + +externC int +__strncmp( const char *, const char *, size_t ); + + +externC size_t +__strxfrm( char *, const char *, size_t ); + + +//=========================================================================== + +// 7.11.5 Search functions + + +externC void * +__memchr( const void *, int , size_t ); + + +externC char * +__strchr( const char *, int ); + + +externC size_t +__strcspn( const char *, const char * ); + + +externC char * +__strpbrk( const char *, const char * ); + + +externC char * +__strrchr( const char *, int ); + + +externC size_t +__strspn( const char *, const char * ); + + +externC char * +__strstr( const char *, const char * ); + + +externC char * +__strtok( char *, const char * ); + +// For POSIX 1003.1 section 8.3.3 strtok_r() + +externC char * +__strtok_r( char *, const char *, char ** ); + + +//=========================================================================== + +// 7.11.6 Miscellaneous functions + +externC size_t +__strlen( const char * ); + +#endif // CYGONCE_LIBC_STRING_STRINGSUPP_HXX multiple inclusion protection + +// EOF stringsupp.hxx diff --git a/packages/language/c/libc/string/current/src/memchr.cxx b/packages/language/c/libc/string/current/src/memchr.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/memchr.cxx @@ -0,0 +1,169 @@ +//=========================================================================== +// +// memchr.cxx +// +// ANSI standard memchr() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC void * +memchr( const void *s, int c, size_t n ) CYGBLD_ATTRIB_WEAK_ALIAS(__memchr); + +// FUNCTIONS + +void * +__memchr( const void *s, int c, size_t n ) +{ + CYG_REPORT_FUNCNAMETYPE( "__memchr", "returning addr %08x" ); + CYG_REPORT_FUNCARG3( "s=%08x, c=%d, n=%d", s, c, n ); + + CYG_CHECK_DATA_PTR( s, "s is not a valid pointer!" ); + +#if defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || defined(__OPTIMIZE_SIZE__) + const unsigned char *src = (const unsigned char *) s; + + c &= 0xff; + + while (n--) + { + if (*src == c) + { + CYG_REPORT_RETVAL( src ); + return (void *) src; + } // if + src++; + } + CYG_REPORT_RETVAL( NULL ); + return NULL; +#else + const unsigned char *src = (const unsigned char *) s; + CYG_WORD *aligned_src; + CYG_WORD buffer; + CYG_WORD mask; + cyg_ucount8 i; + + c &= 0xff; + + // If the size is small, or src is unaligned, then + // use the bytewise loop. We can hope this is rare. + if (CYG_LIBC_STR_OPT_TOO_SMALL (n) || CYG_LIBC_STR_UNALIGNED (src)) + { + while (n--) + { + if (*src == c) + { + CYG_REPORT_RETVAL( src ); + return (void *) src; + } // if + src++; + } + CYG_REPORT_RETVAL( NULL ); + return NULL; + } + + // The fast code reads the ASCII one word at a time and only + // performs the bytewise search on word-sized segments if they + // contain the search character, which is detected by XORing + // the word-sized segment with a word-sized block of the search + // character and then detecting for the presence of NULL in the + // result. + + aligned_src = (CYG_WORD *) src; + mask = 0; + for (i = 0; i < CYG_LIBC_STR_OPT_LITTLEBLOCKSIZE; i++) + mask = (mask << 8) + c; + + while (n > CYG_LIBC_STR_OPT_LITTLEBLOCKSIZE) + { + buffer = *aligned_src; + buffer ^= mask; + if (CYG_LIBC_STR_DETECTNULL (buffer)) + { + src = (unsigned char*) aligned_src; + for ( i = 0; i < CYG_LIBC_STR_OPT_LITTLEBLOCKSIZE; i++ ) + { + if (*src == c) + { + CYG_REPORT_RETVAL( src ); + return (void *) src; + } // if + src++; + } + } + n -= CYG_LIBC_STR_OPT_LITTLEBLOCKSIZE; + aligned_src++; + } + + // If there are fewer than CYG_LIBC_STR_OPT_LITTLEBLOCKSIZE characters + // left, then we resort to the bytewise loop. + + src = (const unsigned char *) aligned_src; + while (n--) + { + if (*src == c) + { + CYG_REPORT_RETVAL( src ); + return (void *) src; + } // if + src++; + } + + CYG_REPORT_RETVAL( NULL ); + return NULL; +#endif // not defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || + // defined(__OPTIMIZE_SIZE__) +} // __memchr() + +// EOF memchr.cxx diff --git a/packages/language/c/libc/string/current/src/memcmp.cxx b/packages/language/c/libc/string/current/src/memcmp.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/memcmp.cxx @@ -0,0 +1,176 @@ +//=========================================================================== +// +// memcmp.cxx +// +// ANSI standard memcmp() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + + +// EXPORTED SYMBOLS + +externC int +memcmp( const void *s1, const void *s2, size_t n ) \ + CYGBLD_ATTRIB_WEAK_ALIAS(__memcmp); + +// FUNCTIONS + +int +__memcmp( const void *s1, const void *s2, size_t n ) +{ + int retval; + + CYG_REPORT_FUNCNAMETYPE( "__memcmp", "returning %d" ); + CYG_REPORT_FUNCARG3( "s1=%08x, s2=%08x, n=%d", s1, s2, n ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + +#if defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || defined(__OPTIMIZE_SIZE__) + const unsigned char *m1 = (const unsigned char *) s1; + const unsigned char *m2 = (const unsigned char *) s2; + + while (n--) + { + if (*m1 != *m2) + { + retval = *m1 - *m2; + CYG_REPORT_RETVAL( retval ); + return retval; + } + m1++; + m2++; + } + CYG_REPORT_RETVAL( 0 ); + return 0; +#else + const unsigned char *m1 = (const unsigned char *) s1; + const unsigned char *m2 = (const unsigned char *) s2; + const CYG_WORD *aligned_m1; + const CYG_WORD *aligned_m2; + + // If the size is too small, or either pointer is unaligned, + // then we punt to the byte compare loop. Hopefully this will + // not turn up in inner loops. + if (CYG_LIBC_STR_OPT_TOO_SMALL(n) || CYG_LIBC_STR_UNALIGNED2(m1,m2)) + { + while (n--) + { + if (*m1 != *m2) + { + retval = *m1 - *m2; + CYG_REPORT_RETVAL( retval ); + return retval; + } + m1++; + m2++; + } + CYG_REPORT_RETVAL( 0 ); + return 0; + } + + // Otherwise, load and compare the blocks of memory one + // word at a time. + aligned_m1 = (const CYG_WORD *) m1; + aligned_m2 = (const CYG_WORD *) m2; + while (n > CYG_LIBC_STR_OPT_LITTLEBLOCKSIZE) + { + if (*aligned_m1 != *aligned_m2) + { + // This block of characters has a mismatch, somewhere. + // xoring them together and then testing for null would + // be fastest, but this is clearer code. + m1 = (const unsigned char *)aligned_m1; + m2 = (const unsigned char *)aligned_m2; + while (n--) + { + if (*m1 != *m2) + { + retval = *m1 - *m2; + CYG_REPORT_RETVAL( retval ); + return retval; + } + m1++; + m2++; + } + // NOT REACHED + } + aligned_m1++; + aligned_m2++; + n -= CYG_LIBC_STR_OPT_LITTLEBLOCKSIZE; + } + + // checking the last few characters + + m1 = (const unsigned char *)aligned_m1; + m2 = (const unsigned char *)aligned_m2; + + while (n--) + { + if (*m1 != *m2) + { + retval = *m1 - *m2; + CYG_REPORT_RETVAL( retval ); + return retval; + } + m1++; + m2++; + } + + CYG_REPORT_RETVAL( 0 ); + return 0; +#endif // not defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || + // defined(__OPTIMIZE_SIZE__) +} // __memcmp() + +// EOF memcmp.cxx diff --git a/packages/language/c/libc/string/current/src/memmove.cxx b/packages/language/c/libc/string/current/src/memmove.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/memmove.cxx @@ -0,0 +1,102 @@ +//=========================================================================== +// +// memmove.cxx +// +// ANSI standard memmove() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC void * +memmove( void *s1, const void *s2, size_t n ) \ + CYGBLD_ATTRIB_WEAK_ALIAS(__memmove); + +// FUNCTIONS + +void * +__memmove( void *s1, const void *s2, size_t n ) +{ + char *dst = (char *)s1; + const char *src = (const char *)s2; + + CYG_REPORT_FUNCNAMETYPE( "__memmove", "returning %08x" ); + CYG_REPORT_FUNCARG3( "s1=%08x, s2=%08x, n=%d", s1, s2, n ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + + if ((src < dst) && (dst < (src + n))) + { + // Have to copy backwards + src += n; + dst += n; + while (n--) + { + *--dst = *--src; + } + } + else + { + while (n--) + { + *dst++ = *src++; + } + } + + CYG_REPORT_RETVAL( s1 ); + + return s1; +} // __memmove() + +// EOF memmove.cxx diff --git a/packages/language/c/libc/string/current/src/strcat.cxx b/packages/language/c/libc/string/current/src/strcat.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strcat.cxx @@ -0,0 +1,120 @@ +//=========================================================================== +// +// strcat.cxx +// +// ANSI standard strcat() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC char * +strcat( char *s1, const char *s2 ) CYGBLD_ATTRIB_WEAK_ALIAS(__strcat); + +// FUNCTIONS + +char * +__strcat( char *s1, const char *s2 ) +{ + CYG_REPORT_FUNCNAMETYPE( "__strcat", "returning %08x" ); + CYG_REPORT_FUNCARG2( "s1=%08x, s2=%08x", s1, s2 ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + +#if defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || defined(__OPTIMIZE_SIZE__) + char *s = s1; + + while (*s1) + s1++; + + while ((*s1++ = *s2++)) + ; + + CYG_REPORT_RETVAL( s ); + + return s; +#else + char *s = s1; + + + // Skip over the data in s1 as quickly as possible. + if (!CYG_LIBC_STR_UNALIGNED (s1)) + { + CYG_WORD *aligned_s1 = (CYG_WORD *)s1; + while (!CYG_LIBC_STR_DETECTNULL (*aligned_s1)) + aligned_s1++; + + s1 = (char *)aligned_s1; + } + + while (*s1) + s1++; + + // s1 now points to the its trailing null character, we can + // just use strcpy to do the work for us now. + // + // ?!? We might want to just include strcpy here. + // Also, this will cause many more unaligned string copies because + // s1 is much less likely to be aligned. I don't know if its worth + // tweaking strcpy to handle this better. + strcpy (s1, s2); + + CYG_REPORT_RETVAL( s ); + + return s; +#endif // not defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || + // defined(__OPTIMIZE_SIZE__) +} // __strcat() + +// EOF strcat.cxx diff --git a/packages/language/c/libc/string/current/src/strchr.cxx b/packages/language/c/libc/string/current/src/strchr.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strchr.cxx @@ -0,0 +1,139 @@ +//=========================================================================== +// +// strchr.cxx +// +// ANSI standard strchr() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC char * +strchr( const char *s, int c ) CYGBLD_ATTRIB_WEAK_ALIAS(__strchr); + +// MACROS + +// DETECTCHAR returns nonzero if X contains the byte used +// to fill MASK. +#define DETECTCHAR(X,MASK) (CYG_LIBC_STR_DETECTNULL( (X) ^ (MASK) )) + +// FUNCTIONS + +char * +__strchr( const char *s, int c ) +{ + CYG_REPORT_FUNCNAMETYPE( "__strchr", "returning %08x" ); + CYG_REPORT_FUNCARG2( "s=%08x, c=%d", s, c ); + + CYG_CHECK_DATA_PTR( s, "s is not a valid pointer!" ); + +#if defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || defined(__OPTIMIZE_SIZE__) + char charc = c; + + while (*s && *s != charc) + { + s++; + } + + if (*s != charc) + { + s = NULL; + } + + CYG_REPORT_RETVAL( s ); + + return (char *) s; +#else + char charc = c; + CYG_WORD mask; + CYG_WORD j; + CYG_WORD *aligned_addr; + + if (CYG_LIBC_STR_UNALIGNED (s)) + { + while (*s && *s != charc) + s++; + if (*s != charc) + s = NULL; + + CYG_REPORT_RETVAL( s ); + + return (char *) s; + } + + for (j = 0, mask = 0; j < sizeof(mask); j++) + mask = (mask << 8) + charc; + + aligned_addr = (CYG_WORD *)s; + while (!CYG_LIBC_STR_DETECTNULL (*aligned_addr) && + !DETECTCHAR (*aligned_addr, mask)) + aligned_addr++; + + // The block of bytes currently pointed to by aligned_addr + // contains either a null or the target char, or both. We + // catch it using the bytewise search. + + s = (char *)aligned_addr; + while (*s && *s != charc) + s++; + if (*s != charc) + s = NULL; + + CYG_REPORT_RETVAL( s ); + + return (char *)s; +#endif // not defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || + // defined(__OPTIMIZE_SIZE__) +} // __strchr() + +// EOF strchr.cxx diff --git a/packages/language/c/libc/string/current/src/strcmp.cxx b/packages/language/c/libc/string/current/src/strcmp.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strcmp.cxx @@ -0,0 +1,148 @@ +//=========================================================================== +// +// strcmp.cxx +// +// ANSI standard strcmp() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC int +strcmp( const char *s1, const char *s2 ) CYGBLD_ATTRIB_WEAK_ALIAS(__strcmp); + +// FUNCTIONS + +int +__strcmp( const char *s1, const char *s2 ) +{ + CYG_REPORT_FUNCNAMETYPE( "__strcmp", "returning %d" ); + CYG_REPORT_FUNCARG2( "s1=%08x, s2=%08x", s1, s2 ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + + int retval; + + CYG_UNUSED_PARAM( int, retval ); // in case tracing is off + +#if defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || defined(__OPTIMIZE_SIZE__) + while (*s1 != '\0' && *s1 == *s2) + { + s1++; + s2++; + } + + retval = (*(unsigned char *) s1) - (*(unsigned char *) s2); + + CYG_REPORT_RETVAL( retval ); + + return retval; +#else + const CYG_WORD *aligned_s1; + const CYG_WORD *aligned_s2; + + // If s1 or s2 are unaligned, then compare bytes. + if (CYG_LIBC_STR_UNALIGNED2 (s1, s2)) + { + while (*s1 != '\0' && *s1 == *s2) + { + s1++; + s2++; + } + retval = (*(unsigned char *) s1) - (*(unsigned char *) s2); + + CYG_REPORT_RETVAL( retval ); + + return retval; + } + + // If s1 and s2 are word-aligned, compare them a word at a time. + aligned_s1 = (const CYG_WORD *)s1; + aligned_s2 = (const CYG_WORD *)s2; + while (*aligned_s1 == *aligned_s2) + { + // To get here, *aligned_s1 == *aligned_s2, thus if we find a + // null in *aligned_s1, then the strings must be equal, so return + // zero. + if (CYG_LIBC_STR_DETECTNULL (*aligned_s1)) + { + CYG_REPORT_RETVAL( 0 ); + return 0; + } // if + + aligned_s1++; + aligned_s2++; + } + + // A difference was detected in last few bytes of s1, so search bytewise + s1 = (const char *)aligned_s1; + s2 = (const char *)aligned_s2; + + while (*s1 != '\0' && *s1 == *s2) + { + s1++; + s2++; + } + + retval = (*(unsigned char *) s1) - (*(unsigned char *) s2); + + CYG_REPORT_RETVAL( retval ); + + return retval; + +#endif // not defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || + // defined(__OPTIMIZE_SIZE__) +} // __strcmp() + +// EOF strcmp.cxx diff --git a/packages/language/c/libc/string/current/src/strcoll.cxx b/packages/language/c/libc/string/current/src/strcoll.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strcoll.cxx @@ -0,0 +1,88 @@ +//=========================================================================== +// +// strcoll.cxx +// +// Real function definition for ANSI string strcoll() function - not +// that there is an inline alternative +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +// We don't want the inline versions of string functions defined here + +#ifdef CYGIMP_LIBC_STRING_INLINES +#undef CYGIMP_LIBC_STRING_INLINES +#endif + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC int +strcoll( const char *s1, const char *s2 ) CYGBLD_ATTRIB_WEAK_ALIAS(__strcoll); + + +int +__strcoll( const char *s1, const char *s2 ) +{ + int retval; + + CYG_REPORT_FUNCNAMETYPE( "__strcoll", "returning %d" ); + CYG_REPORT_FUNCARG2( "s1=%08x, s2=%d", s1, s2 ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + + retval = strcmp(s1, s2); + + return retval; +} // __strcoll() + + +// EOF strcoll.cxx diff --git a/packages/language/c/libc/string/current/src/strcpy.cxx b/packages/language/c/libc/string/current/src/strcpy.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strcpy.cxx @@ -0,0 +1,124 @@ +//=========================================================================== +// +// strcpy.cxx +// +// ANSI standard strcpy() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC char * +strcpy( char *s1, const char *s2 ) CYGBLD_ATTRIB_WEAK_ALIAS(__strcpy); + +// FUNCTIONS + +char * +__strcpy( char *s1, const char *s2 ) +{ + CYG_REPORT_FUNCNAMETYPE( "__strcpy", "returning addr %08x" ); + CYG_REPORT_FUNCARG2( "s1=%08x, s2=%08x", s1, s2 ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + +#if defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || defined(__OPTIMIZE_SIZE__) + char *s = s1; + + while ((*s1++ = *s2++) != '\0') + ; + + CYG_REPORT_RETVAL( s ); + + return s; +#else + char *dst = s1; + const char *src = s2; + CYG_WORD *aligned_dst; + const CYG_WORD *aligned_src; + + // If SRC or DEST is unaligned, then copy bytes. + if (CYG_LIBC_STR_UNALIGNED2 (src, dst)) + { + while ((*dst++ = *src++) != '\0') + ; + + CYG_REPORT_RETVAL( s1 ); + + return s1; + } + + aligned_dst = (CYG_WORD *)dst; + aligned_src = (const CYG_WORD *)src; + + // SRC and DEST are both "CYG_WORD" aligned, try to do "CYG_WORD" + // sized copies. + while (!CYG_LIBC_STR_DETECTNULL(*aligned_src)) + { + *aligned_dst++ = *aligned_src++; + } + + dst = (char*)aligned_dst; + src = (char*)aligned_src; + + while ((*dst++ = *src++) != '\0') + ; + + CYG_REPORT_RETVAL( s1 ); + + return s1; +#endif // not defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || + // defined(__OPTIMIZE_SIZE__) +} // __strcpy() + +// EOF strcpy.cxx diff --git a/packages/language/c/libc/string/current/src/strcspn.cxx b/packages/language/c/libc/string/current/src/strcspn.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strcspn.cxx @@ -0,0 +1,98 @@ +//=========================================================================== +// +// strcspn.cxx +// +// ANSI standard strcspn() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC size_t +strcspn( const char *s1, const char *s2 ) CYGBLD_ATTRIB_WEAK_ALIAS(__strcspn); + +// FUNCTIONS + +size_t +__strcspn( const char *s1, const char *s2 ) +{ + const char *s = s1; + const char *c; + size_t retval; + + CYG_REPORT_FUNCNAMETYPE( "__strcspn", "returning size %d" ); + CYG_REPORT_FUNCARG2( "s1=%08x, s2=%08x", s1, s2 ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + + while (*s1) + { + for (c = s2; *c; c++) + { + if (*s1 == *c) + break; + } + if (*c) + break; + s1++; + } + + retval = s1 - s; + + CYG_REPORT_RETVAL( retval ); + + return retval; +} // __strcspn() + +// EOF strcspn.cxx diff --git a/packages/language/c/libc/string/current/src/strlen.cxx b/packages/language/c/libc/string/current/src/strlen.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strlen.cxx @@ -0,0 +1,125 @@ +//=========================================================================== +// +// strlen.cxx +// +// ANSI standard strlen() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC size_t +strlen( const char *s ) CYGBLD_ATTRIB_WEAK_ALIAS(__strlen); + +// FUNCTIONS + +size_t +__strlen( const char *s ) +{ + int retval; + + CYG_REPORT_FUNCNAMETYPE( "__strlen", "returning length %d" ); + CYG_REPORT_FUNCARG1( "s=%08x", s ); + + CYG_CHECK_DATA_PTR( s, "s is not a valid pointer!" ); + +#if defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || defined(__OPTIMIZE_SIZE__) + const char *start = s; + + while (*s) + s++; + + retval = s - start; + + CYG_REPORT_RETVAL( retval ); + + return retval; + +#else + + const char *start = s; + CYG_WORD *aligned_addr; + + if (CYG_LIBC_STR_UNALIGNED (s)) + { + while (*s) + s++; + retval = s - start; + + CYG_REPORT_RETVAL( retval ); + + return retval; + } + + // If the string is word-aligned, we can check for the presence of + // a null in each word-sized block. + + aligned_addr = (CYG_WORD *)s; + while (!CYG_LIBC_STR_DETECTNULL (*aligned_addr)) + aligned_addr++; + + // Once a null is detected, we check each byte in that block for a + // precise position of the null. + s = (char*)aligned_addr; + while (*s) + s++; + retval = s - start; + + CYG_REPORT_RETVAL( retval ); + + return retval; +#endif // not defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || + // defined(__OPTIMIZE_SIZE__) +} // __strlen() + +// EOF strlen.cxx diff --git a/packages/language/c/libc/string/current/src/strncat.cxx b/packages/language/c/libc/string/current/src/strncat.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strncat.cxx @@ -0,0 +1,126 @@ +//=========================================================================== +// +// strncat.cxx +// +// ANSI standard strncat() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC char * +strncat( char *s1, const char *s2, size_t n ) \ + CYGBLD_ATTRIB_WEAK_ALIAS(__strncat); + +// FUNCTIONS + +char * +__strncat( char *s1, const char *s2, size_t n) +{ + CYG_REPORT_FUNCNAMETYPE( "__strncat", "returning %08x" ); + CYG_REPORT_FUNCARG3( "s1=%08x, s2=%08x, n=%d", s1, s2, n ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + +#if defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || defined(__OPTIMIZE_SIZE__) + char *s = s1; + + while (*s1) + s1++; + while (n-- != 0 && (*s1++ = *s2++)) + { + if (n == 0) + *s1 = '\0'; + } + + CYG_REPORT_RETVAL( s ); + + return s; +#else + char *s = s1; + + // Skip over the data in s1 as quickly as possible. + if (!CYG_LIBC_STR_UNALIGNED (s1)) + { + CYG_WORD *aligned_s1 = (CYG_WORD *)s1; + while (!CYG_LIBC_STR_DETECTNULL (*aligned_s1)) + aligned_s1++; + + s1 = (char *)aligned_s1; + } + + while (*s1) + s1++; + + // s1 now points to the its trailing null character, now copy + // up to N bytes from S2 into S1 stopping if a NULL is encountered + // in S2. + // + // It is not safe to use strncpy here since it copies EXACTLY N + // characters, NULL padding if necessary. + + while (n-- != 0 && (*s1++ = *s2++)) + { + if (n == 0) + *s1 = '\0'; + } + + CYG_REPORT_RETVAL( s ); + + return s; +#endif // not defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || + // defined(__OPTIMIZE_SIZE__) +} // __strncat() + +// EOF strncat.cxx diff --git a/packages/language/c/libc/string/current/src/strncmp.cxx b/packages/language/c/libc/string/current/src/strncmp.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strncmp.cxx @@ -0,0 +1,170 @@ +//=========================================================================== +// +// strncmp.cxx +// +// ANSI standard strncmp() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC int +strncmp( const char *s1, const char *s2, size_t n ) \ + CYGBLD_ATTRIB_WEAK_ALIAS(__strncmp); + +// FUNCTIONS + +int +__strncmp( const char *s1, const char *s2, size_t n ) +{ + int retval; + + CYG_REPORT_FUNCNAMETYPE( "__strncmp", "returning %d" ); + CYG_REPORT_FUNCARG3( "s1=%08x, s2=%08x, n=%d", s1, s2, n ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + +#if defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || defined(__OPTIMIZE_SIZE__) + if (n == 0) + return 0; + + while (n-- != 0 && *s1 == *s2) + { + if (n == 0 || *s1 == '\0' || *s2 == '\0') + break; + s1++; + s2++; + } + + retval = (*(unsigned char *) s1) - (*(unsigned char *) s2); + + CYG_REPORT_RETVAL( retval ); + + return retval; +#else + const CYG_WORD *aligned_s1; + const CYG_WORD *aligned_s2; + + if (n == 0) + { + CYG_REPORT_RETVAL( 0 ); + return 0; + } // if + + // If s1 or s2 are unaligned, then compare bytes. + if (CYG_LIBC_STR_UNALIGNED2 (s1, s2)) + { + while (n-- != 0 && *s1 == *s2) + { + // If we've run out of bytes or hit a null, return zero + // since we already know *s1 == *s2. + if (n == 0 || *s1 == '\0') + return 0; + s1++; + s2++; + } + retval = (*(unsigned char *) s1) - (*(unsigned char *) s2); + + CYG_REPORT_RETVAL( retval ); + + return retval; + } //if + + // If s1 and s2 are word-aligned, compare them a word at a time. + aligned_s1 = (const CYG_WORD *)s1; + aligned_s2 = (const CYG_WORD *)s2; + while (n >= sizeof(CYG_WORD) && *aligned_s1 == *aligned_s2) + { + n -= sizeof (CYG_WORD); + + // If we've run out of bytes or hit a null, return zero + // since we already know *aligned_s1 == *aligned_s2. + if (n == 0 || CYG_LIBC_STR_DETECTNULL (*aligned_s1)) + { + CYG_REPORT_RETVAL( 0 ); + return 0; + } // if + + aligned_s1++; + aligned_s2++; + } // while + + // A difference was detected in last few bytes of s1, so search bytewise + s1 = (const char *)aligned_s1; + s2 = (const char *)aligned_s2; + + while (n-- > 0 && *s1 == *s2) + { + // If we've run out of bytes or hit a null, return zero + // since we already know *s1 == *s2. + if (n == 0 || *s1 == '\0') + { + CYG_REPORT_RETVAL( 0 ); + return 0; + } // if + s1++; + s2++; + } // while + + retval = (*(unsigned char *) s1) - (*(unsigned char *) s2); + + CYG_REPORT_RETVAL( retval ); + + return retval; + +#endif // not defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || + // defined(__OPTIMIZE_SIZE__) +} // __strncmp() + +// EOF strncmp.cxx diff --git a/packages/language/c/libc/string/current/src/strncpy.cxx b/packages/language/c/libc/string/current/src/strncpy.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strncpy.cxx @@ -0,0 +1,137 @@ +//=========================================================================== +// +// strncpy.cxx +// +// ISO C standard strncpy() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC char * +strncpy( char *s1, const char *s2, size_t n ) \ + CYGBLD_ATTRIB_WEAK_ALIAS(__strncpy); + +// FUNCTIONS + +char * +__strncpy( char *s1, const char *s2, size_t n) +{ + CYG_REPORT_FUNCNAMETYPE( "__strncpy", "returning %08x" ); + CYG_REPORT_FUNCARG3( "s1=%08x, s2=%08x, n=%d", s1, s2, n ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + +#if defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || defined(__OPTIMIZE_SIZE__) + char *dscan; + const char *sscan; + + dscan = s1; + sscan = s2; + while (n > 0) + { + --n; + if ((*dscan++ = *sscan++) == '\0') + break; + } + while (n-- > 0) + *dscan++ = '\0'; + + CYG_REPORT_RETVAL( s1 ); + + return s1; +#else + char *dst = s1; + const char *src = s2; + CYG_WORD *aligned_dst; + const CYG_WORD *aligned_src; + + // If SRC and DEST is aligned and count large enough, then copy words. + if (!CYG_LIBC_STR_UNALIGNED2 (src, dst) && + !CYG_LIBC_STR_OPT_TOO_SMALL (n)) { + + aligned_dst = (CYG_WORD *)dst; + aligned_src = (CYG_WORD *)src; + + // SRC and DEST are both "CYG_WORD" aligned, try to do "CYG_WORD" + // sized copies. + while (n >= sizeof (CYG_WORD) && + !CYG_LIBC_STR_DETECTNULL(*aligned_src)) { + + n -= sizeof (CYG_WORD); + *aligned_dst++ = *aligned_src++; + } + + dst = (char *)aligned_dst; + src = (const char *)aligned_src; + } // if + + while (n > 0) + { + --n; + if ((*dst++ = *src++) == '\0') + break; + } + + while (n-- > 0) + *dst++ = '\0'; + + CYG_REPORT_RETVAL( s1 ); + + return s1; +#endif // not defined(CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST) || + // defined(__OPTIMIZE_SIZE__) +} // __strncpy() + +// EOF strncpy.cxx diff --git a/packages/language/c/libc/string/current/src/strpbrk.cxx b/packages/language/c/libc/string/current/src/strpbrk.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strpbrk.cxx @@ -0,0 +1,104 @@ +//=========================================================================== +// +// strpbrk.cxx +// +// ANSI standard strpbrk() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC char * +strpbrk( const char *s1, const char *s2 ) CYGBLD_ATTRIB_WEAK_ALIAS(__strpbrk); + +// FUNCTIONS + +char * +__strpbrk( const char *s1, const char *s2 ) +{ + const char *c; + + CYG_REPORT_FUNCNAMETYPE( "__strpbrk", "returning %08x" ); + CYG_REPORT_FUNCARG2( "s1=%08x, s2=%08x", s1, s2 ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + + if (!*s1) + { + CYG_REPORT_RETVAL( NULL ); + return (char *) NULL; + } // if + + do + { + for (c = s2; *c; c++) + { + if (*s1 == *c) + break; + } + if (*c) + break; + s1++; + } + while (*s1); + + if (*c == '\0') + s1 = NULL; + + CYG_REPORT_RETVAL( s1 ); + + return (char *) s1; +} // __strpbrk() + +// EOF strpbrk.cxx diff --git a/packages/language/c/libc/string/current/src/strrchr.cxx b/packages/language/c/libc/string/current/src/strrchr.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strrchr.cxx @@ -0,0 +1,96 @@ +//=========================================================================== +// +// strrchr.cxx +// +// ANSI standard strrchr() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC char * +strrchr( const char *s, int c ) CYGBLD_ATTRIB_WEAK_ALIAS(__strrchr); + +// FUNCTIONS + +char * +__strrchr( const char *s, int c ) +{ + const char *last = NULL; + const char charc = c; + + CYG_REPORT_FUNCNAMETYPE( "__strrchr", "returning %08x" ); + CYG_REPORT_FUNCARG2( "s=%08x, c=%d", s, c ); + + CYG_CHECK_DATA_PTR( s, "s is not a valid pointer!" ); + + while (*s) + { + if (*s == charc) + { + last = s; + } + s++; + } + + if (*s == charc) + { + last = s; + } + + CYG_REPORT_RETVAL( last ); + + return (char *) last; +} // __strrchr() + +// EOF strrchr.cxx diff --git a/packages/language/c/libc/string/current/src/strspn.cxx b/packages/language/c/libc/string/current/src/strspn.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strspn.cxx @@ -0,0 +1,98 @@ +//=========================================================================== +// +// strspn.cxx +// +// ANSI standard strspn() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC size_t +strspn( const char *s1, const char *s2 ) CYGBLD_ATTRIB_WEAK_ALIAS(__strspn); + +// FUNCTIONS + +size_t +__strspn( const char *s1, const char *s2 ) +{ + const char *s = s1; + const char *c; + size_t retval; + + CYG_REPORT_FUNCNAMETYPE( "__strspn", "returning size %d" ); + CYG_REPORT_FUNCARG2( "s1=%08x, s2=%08x", s1, s2 ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + + while (*s1) + { + for (c = s2; *c; c++) + { + if (*s1 == *c) + break; + } + if (*c == '\0') + break; + s1++; + } + + retval = s1 - s; + + CYG_REPORT_RETVAL( retval ); + + return retval; +} // __strspn() + +// EOF strspn.cxx diff --git a/packages/language/c/libc/string/current/src/strstr.cxx b/packages/language/c/libc/string/current/src/strstr.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strstr.cxx @@ -0,0 +1,114 @@ +//=========================================================================== +// +// strstr.cxx +// +// ANSI standard strstr() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC char * +strstr( const char *s1, const char *s2 ) CYGBLD_ATTRIB_WEAK_ALIAS(__strstr); + +// FUNCTIONS + +char * +__strstr( const char *s1, const char *s2 ) +{ + CYG_REPORT_FUNCNAMETYPE( "__strstr", "returning %08x" ); + CYG_REPORT_FUNCARG2( "s1=%08x, s2=%08x", s1, s2 ); + + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + + if (*s1 == '\0') + { + if (*s2) + { + CYG_REPORT_RETVAL( NULL ); + return (char *) NULL; + } // if + else + { + CYG_REPORT_RETVAL( s1 ); + return (char *) s1; + } // else + } // if + + while (*s1) + { + cyg_ucount32 i; + + for (i=0 ; ; i++) + { + if (s2[i] == '\0') + { + CYG_REPORT_RETVAL( s1 ); + return (char *) s1; + } // if + + if (s2[i] != s1[i]) + { + break; + } // if + } // for + s1++; + } // while + + CYG_REPORT_RETVAL( NULL ); + + return (char *) NULL; +} // __strstr() + +// EOF strstr.cxx diff --git a/packages/language/c/libc/string/current/src/strsuppt.cxx b/packages/language/c/libc/string/current/src/strsuppt.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strsuppt.cxx @@ -0,0 +1,61 @@ +//=========================================================================== +// +// strsuppt.cxx +// +// Support for the ANSI standard string functions +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Header for this file + +// CONSTANTS + +// Masks for CYG_LIBC_DETECTNULL macro so they are only defined once in +// the library +const cyg_uint64 Cyg_libc_str_null_mask_1 = 0x0101010101010101LL; +const cyg_uint64 Cyg_libc_str_null_mask_2 = 0x8080808080808080LL; + +// EOF strsuppt.cxx diff --git a/packages/language/c/libc/string/current/src/strtok.cxx b/packages/language/c/libc/string/current/src/strtok.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strtok.cxx @@ -0,0 +1,231 @@ +//=========================================================================== +// +// strtok.cxx +// +// ISO standard strtok() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 2000-04-14 +// Purpose: Provide ISO C strtok() and POSIX strtok_r() routines +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== +// +// This code is based on original code with the following copyright: +// +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +#ifdef CYGSEM_LIBC_STRING_PER_THREAD_STRTOK +# include // kernel configuration +# include // per-thread data +# include // per-thread data +# include // mutexes +#endif + +// TRACE + +#if defined(CYGDBG_USE_TRACING) && defined(CYGNUM_LIBC_STRING_STRTOK_TRACE_LEVEL) +static int strtok_trace = CYGNUM_LIBC_STRING_STRTOK_TRACE_LEVEL; +# define TL1 (0 < strtok_trace) +#else +# define TL1 (0) +#endif + +// STATICS + +#ifdef CYGSEM_LIBC_STRING_PER_THREAD_STRTOK +static cyg_ucount32 strtok_data_index=CYGNUM_KERNEL_THREADS_DATA_MAX; +static Cyg_Mutex strtok_data_mutex CYG_INIT_PRIORITY(LIBC); +#else +static char *cyg_libc_strtok_last; +#endif + +// FUNCTIONS + +char * +strtok( char *s1, const char *s2 ) +{ + char **lasts; + char *retval; + + CYG_REPORT_FUNCNAMETYPE( "strtok", "returning %08x" ); + CYG_REPORT_FUNCARG2( "s1=%08x, s2=%08x", s1, s2 ); + + if (s1 != NULL) + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + +#ifdef CYGSEM_LIBC_STRING_PER_THREAD_STRTOK + Cyg_Thread *self = Cyg_Thread::self(); + + // Get a per-thread data slot if we haven't got one already + // Do a simple test before locking and retrying test, as this is a + // rare situation + if (CYGNUM_KERNEL_THREADS_DATA_MAX==strtok_data_index) { + strtok_data_mutex.lock(); + if (CYGNUM_KERNEL_THREADS_DATA_MAX==strtok_data_index) { + + // the kernel just throws an assert if this doesn't work + // FIXME: Should use real CDL to pre-allocate a slot at compile + // time to ensure there are enough slots + strtok_data_index = self->new_data_index(); + + } + strtok_data_mutex.unlock(); + } // if + + // we have a valid index now + + lasts = (char **)self->get_data_ptr(strtok_data_index); +#else + lasts = &cyg_libc_strtok_last; +#endif + + CYG_TRACE2( TL1, "Retrieved strtok_last address %08x containing %s", + lasts, *lasts ); + + retval = strtok_r( s1, s2, lasts ); + + CYG_REPORT_RETVAL( retval ); + + return retval; +} // strtok() + +char * +strtok_r( char *s1, const char *s2, char **lasts ) +{ + char *spanp; + int c, sc; + char *tok; + + CYG_REPORT_FUNCNAMETYPE( "strtok_r", "returning %08x" ); + CYG_REPORT_FUNCARG3( "s1=%08x, s2=%08x, lasts=%08x", s1, s2, lasts ); + + if (s1 != NULL) + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( lasts, "lasts is not a valid pointer!" ); + + + if (s1 == NULL && (s1 = *lasts) == NULL) + { + CYG_REPORT_RETVAL( NULL ); + return NULL; + } // if + + // + // Skip (span) leading delimiters (s += strspn(s, delim), sort of). + // +cont: + c = *s1++; + for (spanp = (char *)s2; (sc = *spanp++) != 0;) { + if (c == sc) + goto cont; + } // for + + if (c == 0) { // no non-delimiter characters + *lasts = NULL; + + CYG_REPORT_RETVAL( NULL ); + return NULL; + } // if + tok = s1 - 1; + + // + // Scan token (scan for delimiters: s += strcspn(s, delim), sort of). + // Note that delim must have one NUL; we stop if we see that, too. + // + for (;;) { + c = *s1++; + spanp = (char *)s2; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s1 = NULL; + else + s1[-1] = 0; + *lasts = s1; + + CYG_REPORT_RETVAL( tok ); + + return (tok); + } // if + } while (sc != 0); + } // for + // NOTREACHED +} // strtok_r() + +// EOF strtok.cxx diff --git a/packages/language/c/libc/string/current/src/strxfrm.cxx b/packages/language/c/libc/string/current/src/strxfrm.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/src/strxfrm.cxx @@ -0,0 +1,101 @@ +//=========================================================================== +// +// strxfrm.cxx +// +// ANSI standard strxfrm() routine +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: +// Description: +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include // Common type definitions +#include // Tracing support +#include // Assertion support +#include // Header for this file +#include // Compiler definitions such as size_t, NULL etc. +#include // Useful string function support and + // prototypes + +// EXPORTED SYMBOLS + +externC size_t +strxfrm( char *s1, const char *s2, size_t n ) \ + CYGBLD_ATTRIB_WEAK_ALIAS(__strxfrm); + +// FUNCTIONS + +size_t +__strxfrm( char *s1, const char *s2, size_t n ) +{ + size_t res = 0; + + CYG_REPORT_FUNCNAMETYPE( "__strxfrm", "returning size %d" ); + CYG_REPORT_FUNCARG3( "s1=%08x, s2=%08x, n=%d", s1, s2, n ); + + if (s1 != NULL) + CYG_CHECK_DATA_PTR( s1, "s1 is not a valid pointer!" ); + CYG_CHECK_DATA_PTR( s2, "s2 is not a valid pointer!" ); + + while (n-- > 0) + { + if ((*s1++ = *s2++) != '\0') + ++res; + else + { + CYG_REPORT_RETVAL( res ); + return res; + } // else + } // while + + while (*s2) + { + ++s2; + ++res; + } // while + + CYG_REPORT_RETVAL( res ); + + return res; +} // __strxfrm() + +// EOF strxfrm.cxx diff --git a/packages/language/c/libc/string/current/tests/memchr.c b/packages/language/c/libc/string/current/tests/memchr.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/memchr.c @@ -0,0 +1,103 @@ +//================================================================= +// +// memchr.c +// +// Testcase for C library memchr() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library memchr() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + +int main( int argc, char *argv[] ) +{ + char x[] = "Your feeble skills are no match for the power of " + "the dark side!"; + void *ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "memchr() function"); + + // Check 1 + ret = memchr(x, (int)'k', sizeof(x)); + CYG_TEST_PASS_FAIL( (my_strcmp(ret, x+13) == 0), "Simple test 1" ); + + // Check 2 + ret = memchr(x, (int)'p', sizeof(x)); + CYG_TEST_PASS_FAIL( (my_strcmp(ret, x+40) == 0), "Simple test 2" ); + + // Check 3 + ret = memchr(x, (int)'z', sizeof(x)); + CYG_TEST_PASS_FAIL( (ret == NULL), "Simple test 3" ); + + // Check 4 (boundary condition) + ret = memchr(x, (int)'\0', sizeof(x)); + CYG_TEST_PASS_FAIL( ret == (x+sizeof(x)-1), "Boundary test 1" ); + + // Check 5 (boundary condition) + ret = memchr(x, (int)'\0', sizeof(x)-1); + CYG_TEST_PASS_FAIL( ret == NULL, "Boundary test 2" ); + + // Check 6 (boundary condition) + ret = memchr( (void *)"", (int)'\0', 0 ); + CYG_TEST_PASS_FAIL( ret == NULL, "Boundary test 3" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "memchr() function"); +} // main() + +// EOF memchr.c diff --git a/packages/language/c/libc/string/current/tests/memcmp1.c b/packages/language/c/libc/string/current/tests/memcmp1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/memcmp1.c @@ -0,0 +1,133 @@ +//================================================================= +// +// memcmp1.c +// +// Testcase for C library memcmp() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library memcmp() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "memcmp() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "I have become, comfortably numb"); + my_strcpy(y, "I have become, comfortably numb"); + CYG_TEST_PASS_FAIL( (memcmp(x, y, my_strlen(x)) == 0), "Simple compare"); + + + // Check 2 + my_strcpy(x, ""); + my_strcpy(y, ""); + CYG_TEST_PASS_FAIL( (memcmp(x, y, 0) == 0), "Simple empty string compare"); + + + // Check 3 + my_strcpy(x, "..shall snuff it. And the Lord did grin"); + my_strcpy(y, "..shall snuff it. And the Lord did grio"); + CYG_TEST_PASS_FAIL( (memcmp(x, y, my_strlen(x)) < 0), + "Memory less than #1" ); + + + // Check 4 + my_strcpy(x, "A reading from the Book of Armaments, Chapter 4, " + "Verses 16 to 20:"); + my_strcpy(y, "Bless this, O Lord, that with it thou mayst blow thine " + "enemies to tiny bits, in thy mercy."); + CYG_TEST_PASS_FAIL( (memcmp(x, y, my_strlen(x)) < 0), + "Memory less than #2"); + + // Check 5 + my_strcpy(x, "Lobeth this thy holy hand grenade at thy foe"); + my_strcpy(y, "Lobeth this thy holy hand grenade at thy fod"); + CYG_TEST_PASS_FAIL( (memcmp(x, y, my_strlen(x)) > 0), + "Memory greater than #1" ); + + + // Check 6 + my_strcpy(y, "Three shall be the number of the counting and the"); + my_strcpy(x, "number of the counting shall be three"); + CYG_TEST_PASS_FAIL( (memcmp(x, y, my_strlen(x)) > 0), + "Memory greater than #2" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "memcmp() function"); +} // main() + + + +// EOF memcmp1.c diff --git a/packages/language/c/libc/string/current/tests/memcmp2.c b/packages/language/c/libc/string/current/tests/memcmp2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/memcmp2.c @@ -0,0 +1,121 @@ +//================================================================= +// +// memcmp2.c +// +// Testcase for C library memcmp() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library memcmp() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// CONSTANTS + +#define NUM_ROBUSTNESS_RUNS 300 + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char z[300]; + int ctr; + int fail; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "memcmp() function"); + CYG_TEST_INFO("This testcase tests robustness, and may take some time"); + + + fail = 0; + for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) + { + my_strcpy(x, "Spare a talent for an old ex-leper"); + my_strcpy(y, "Spare a talent for an old ex-leper"); + my_strcpy(z, "I was hopping along, when suddenly he"); + + if (memcmp(x, y,my_strlen(x)) != 0) + { + fail = 1; + break; + } + if (memcmp(x, z, my_strlen(z)) == 0) + { + fail = 1; + break; + } // if + } // for + + CYG_TEST_PASS_FAIL( (fail==0), "Robustness test"); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "memcmp() function"); +} // main() + + +// EOF memcmp2.c diff --git a/packages/language/c/libc/string/current/tests/memcpy1.c b/packages/language/c/libc/string/current/tests/memcpy1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/memcpy1.c @@ -0,0 +1,141 @@ +//================================================================= +// +// memcpy1.c +// +// Testcase for C library memcpy() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library memcpy() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + void *ret, *ptr1, *ptr2; + char *c_ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "memcpy() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + ptr1 = x; + ptr2 = y; + my_strcpy(x, "Great shot kid! That was one in a million!"); + ret = memcpy(ptr2, ptr1, my_strlen(x) + 1); + CYG_TEST_PASS_FAIL( (my_strcmp(x, ptr2)==0), "Simple copy" ); + + // Check return value + CYG_TEST_PASS_FAIL( (my_strcmp(ret, ptr2)==0), "Simple copy return value"); + + + // Check 2 + ptr1 = x; + ptr2 = y; + my_strcpy(x, ""); + my_strcpy(y, "xxxx"); // Bogus val to get overwritten + ret = memcpy(ptr2, ptr1, 1); + c_ret = ret; + if ((*c_ret == '\0') && (y[0] == '\0') && (y[1] == 'x')) + CYG_TEST_PASS("Simple copy with boundary check worked"); + else + CYG_TEST_FAIL("Simple copy with boundary check failed"); + + // Check 3 + ptr1 = x; + ptr2 = y; + my_strcpy(x, "xxxx"); + my_strcpy(y, "yyyy"); + ret = memcpy(ptr1, ptr2, 0); + c_ret = ret; + if ((*c_ret =='x') && (x[0] == 'x')) + CYG_TEST_PASS("Simple copy with size=0 worked"); + else + CYG_TEST_FAIL("Simple copy with size=0 failed"); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "memcpy() function"); +} // main() + + +// EOF memcpy1.c diff --git a/packages/language/c/libc/string/current/tests/memcpy2.c b/packages/language/c/libc/string/current/tests/memcpy2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/memcpy2.c @@ -0,0 +1,129 @@ +//================================================================= +// +// memcpy2.c +// +// Testcase for C library memcpy() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library memcpy() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// CONSTANTS + +#define NUM_ROBUSTNESS_RUNS 300 + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + void *ret, *ptr1, *ptr2; + char *c_ret; + int ctr; + int fail; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "memcpy() function"); + CYG_TEST_INFO("This testcase tests robustness, and may take some time"); + + + fail = 0; + for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) { + my_strcpy(x, "in the land of Mordor"); + my_strcpy(y, " "); + ptr1 = x; + ptr2 = y; + ret = memcpy(ptr2, ptr1, my_strlen(x) + 1); + c_ret = ret; + if ((my_strcmp(y, x) != 0) || (my_strcmp(c_ret, x)!=0)) { + fail = 1; + break; + } + } + + CYG_TEST_PASS_FAIL( (fail == 0), "Robustness test"); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "memcpy() function"); +} // main() + + +// EOF memcpy2.c diff --git a/packages/language/c/libc/string/current/tests/memmove1.c b/packages/language/c/libc/string/current/tests/memmove1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/memmove1.c @@ -0,0 +1,162 @@ +//================================================================= +// +// memmove1.c +// +// Testcase for C library memmove() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library memmove() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + void *ret, *ptr1, *ptr2; + char *c_ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "memmove() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + ptr1 = x; + ptr2 = y; + my_strcpy(x, "Great shot kid! That was one in a million!"); + ret = memmove(ptr2, ptr1, my_strlen(x) + 1); + CYG_TEST_PASS_FAIL( (my_strcmp(x, ptr2)==0), "Simple copy" ); + + // Check return value + CYG_TEST_PASS_FAIL( (my_strcmp(ret, ptr2)==0), "Simple copy return value"); + + + // Check 2 + ptr1 = x; + ptr2 = y; + my_strcpy(x, ""); + my_strcpy(y, "xxxx"); // Bogus val to get overwritten + ret = memmove(ptr2, ptr1, 1); + c_ret = ret; + if ((*c_ret == '\0') && (y[0] == '\0') && (y[1] == 'x')) + CYG_TEST_PASS("Simple copy with boundary check worked"); + else + CYG_TEST_FAIL("Simple copy with boundary check failed"); + + // Check 3 + ptr1 = x; + ptr2 = y; + my_strcpy(x, "xxxx"); + my_strcpy(y, "yyyy"); + ret = memmove(ptr1, ptr2, 0); + c_ret = ret; + if ((*c_ret =='x') && (x[0] == 'x')) + CYG_TEST_PASS("Simple copy with size=0 worked"); + else + CYG_TEST_FAIL("Simple copy with size=0 failed"); + + // Check 4 + ptr1 = &x[0]; + ptr2 = &x[1]; + my_strcpy(x, "abcd"); + ret = memmove(ptr1, ptr2, 4); + c_ret = ret; + if ( (c_ret==x) && (my_strcmp(x, "bcd")==0) ) + CYG_TEST_PASS("Overlapping copy #1 worked"); + else + CYG_TEST_FAIL("Overlapping copy #1 worked"); + + // Check 5 + ptr1 = &x[0]; + ptr2 = &x[4]; + my_strcpy(x, "abcdefghijk"); + ret = memmove(ptr1, ptr2, 6); + c_ret = ret; + if ( (c_ret==x) && (my_strcmp(x, "efghijghijk")==0) ) + CYG_TEST_PASS("Overlapping copy #2 worked"); + else + CYG_TEST_FAIL("Overlapping copy #2 worked"); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "memmove() function"); +} // main() + + +// EOF memmove1.c diff --git a/packages/language/c/libc/string/current/tests/memmove2.c b/packages/language/c/libc/string/current/tests/memmove2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/memmove2.c @@ -0,0 +1,128 @@ +//================================================================= +// +// memmove2.c +// +// Testcase for C library memmove() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library memmove() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// CONSTANTS + +#define NUM_ROBUSTNESS_RUNS 300 + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + void *ret, *ptr1, *ptr2; + char *c_ret; + int ctr; + int fail; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "memmove() function"); + CYG_TEST_INFO("This testcase tests robustness, and may take some time"); + + fail = 0; + for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) { + my_strcpy(x, "in the land of Mordor"); + my_strcpy(y, " "); + ptr1 = x; + ptr2 = y; + ret = memmove(ptr2, ptr1, my_strlen(x) + 1); + c_ret = ret; + if ((my_strcmp(y, x) != 0) || (my_strcmp(c_ret, x)!=0)) { + fail = 1; + break; + } + } + + CYG_TEST_PASS_FAIL( (fail == 0), "Robustness test"); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "memmove() function"); +} // main() + + +// EOF memmove2.c diff --git a/packages/language/c/libc/string/current/tests/memset.c b/packages/language/c/libc/string/current/tests/memset.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/memset.c @@ -0,0 +1,109 @@ +//================================================================= +// +// memset.c +// +// Testcase for C library memset() function +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library memset() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char *ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "memset() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, " "); + ret = memset(x, 'X', 5); + if ((my_strcmp(x, "XXXXX ") == 0) && (ret == x)) + CYG_TEST_PASS("Simple memset"); + else + CYG_TEST_FAIL("Simple memset"); + + // Check 2 + my_strcpy(x, "XXXXX "); + ret = memset(x, 'Y', 0); + if ((my_strcmp(x, "XXXXX ") == 0) && (ret == x)) + CYG_TEST_PASS("Boundary case of 0 bytes"); + else + CYG_TEST_FAIL("Boundary case of 0 bytes"); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "memset() function"); + +} // main() + +// EOF memset.c diff --git a/packages/language/c/libc/string/current/tests/strcat1.c b/packages/language/c/libc/string/current/tests/strcat1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strcat1.c @@ -0,0 +1,131 @@ +//================================================================= +// +// strcat1.c +// +// Testcase for C library strcat() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strcat() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char *ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strcat() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "One ring to rule them all."); + my_strcpy(y, "One ring to find them."); + ret = strcat(x, y); + if ( my_strcmp(x, "One ring to rule them all.One ring to find them.")==0 ) + CYG_TEST_PASS("Simple concatenation"); + else + CYG_TEST_FAIL("Simple concatenation"); + // Check return val + CYG_TEST_PASS_FAIL( ( ret == x ), "Simple concatenation return value" ); + + + // Check 2 + my_strcpy(x, "One ring to bring them all,"); + my_strcpy(y, ""); + ret = strcat(x, y); + if ( my_strcmp(x, "One ring to bring them all,")==0 ) + CYG_TEST_PASS("Concatenation of empty string"); + else + CYG_TEST_FAIL("Concatenation of empty string"); + // Check return val + CYG_TEST_PASS_FAIL( ( ret == x ), + "Concatenation of empty string return value" ); + + + // Check 3 + my_strcpy(x, "and in the darkness bind them"); + my_strcpy(y, ""); + ret = strcat(y, x); + if ( my_strcmp(x, "and in the darkness bind them")==0 ) + CYG_TEST_PASS("Concatenation to empty string"); + else + CYG_TEST_FAIL("Concatenation to empty string"); + // Check return val + CYG_TEST_PASS_FAIL( ( ret == y ), + "Concatenation to empty string return value" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strcat() function"); +} // main() + + +// EOF strcat1.c diff --git a/packages/language/c/libc/string/current/tests/strcat2.c b/packages/language/c/libc/string/current/tests/strcat2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strcat2.c @@ -0,0 +1,119 @@ +//================================================================= +// +// strcat2.c +// +// Testcase for C library strcat() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strcat() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// CONSTANTS + +#define NUM_ROBUSTNESS_RUNS 300 + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char *ret; + int ctr; + int fail; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strcat() function"); + CYG_TEST_INFO("This testcase tests robustness, and may take some time"); + + fail = 0; + for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) + { + my_strcpy(x, "in the land of Mordor, "); + my_strcpy(y, "where the shadows lie."); + ret = strcat(x, y); + if ((my_strcmp(x, "in the land of Mordor, where the shadows lie.")!=0)) + { + fail = 1; + break; + } // if + if (ret != x) + { + fail = 1; + break; + } // if + } + CYG_TEST_PASS_FAIL( (fail == 0), "Robustness test passed" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strcat() function"); + +} // main() + + +// EOF strcat2.c diff --git a/packages/language/c/libc/string/current/tests/strchr.c b/packages/language/c/libc/string/current/tests/strchr.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strchr.c @@ -0,0 +1,100 @@ +//================================================================= +// +// strchr.c +// +// Testcase for C library strchr() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strchr() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +int main( int argc, char *argv[] ) +{ + char x[] = "Your feeble skills are no match for the power of " + "the dark side!"; + char empty_str[] = ""; + char *ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strchr() function"); + + // Check 1 + ret = strchr(x, (int)'k'); + CYG_TEST_PASS_FAIL( (my_strcmp(ret, x+13) == 0), "Simple test 1" ); + + // Check 2 + ret = strchr(x, (int)'p'); + CYG_TEST_PASS_FAIL( (my_strcmp(ret, x+40) == 0), "Simple test 2" ); + + // Check 3 + ret = strchr(x, (int)'z'); + CYG_TEST_PASS_FAIL( (ret == NULL), "Simple test 3" ); + + // Check 4 (boundary condition) + ret = strchr(x, (int)'\0'); + CYG_TEST_PASS_FAIL( ret == (x+sizeof(x)-1), "Boundary test 1" ); + + // Check 5 (boundary condition) + ret = strchr( empty_str, (int)'\0' ); + CYG_TEST_PASS_FAIL( ret == empty_str, "Boundary test 2" ); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strchr() function"); +} // main() + +// EOF strchr.c diff --git a/packages/language/c/libc/string/current/tests/strcmp1.c b/packages/language/c/libc/string/current/tests/strcmp1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strcmp1.c @@ -0,0 +1,121 @@ +//================================================================= +// +// strcmp1.c +// +// Testcase for C library strcmp() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strcmp() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// FUNCTIONS + +// Functions to avoid having to use libc strings + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strcmp() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "I have become, comfortably numb"); + my_strcpy(y, "I have become, comfortably numb"); + CYG_TEST_PASS_FAIL( (strcmp(x, y) == 0), "Simple compare"); + + + // Check 2 + my_strcpy(x, ""); + my_strcpy(y, ""); + CYG_TEST_PASS_FAIL( (strcmp(x, y) == 0), "Simple empty string compare"); + + + // Check 3 + my_strcpy(x, "..shall snuff it. And the Lord did grin"); + my_strcpy(y, "..shall snuff it. And the Lord did grio"); + CYG_TEST_PASS_FAIL( (strcmp(x, y) < 0), + "Memory less than #1" ); + + + // Check 4 + my_strcpy(x, "A reading from the Book of Armaments, Chapter 4, " + "Verses 16 to 20:"); + my_strcpy(y, "Bless this, O Lord, that with it thou mayst blow thine " + "enemies to tiny bits, in thy mercy."); + CYG_TEST_PASS_FAIL( (strcmp(x, y) < 0), + "Memory less than #2"); + + // Check 5 + my_strcpy(x, "Lobeth this thy holy hand grenade at thy foe"); + my_strcpy(y, "Lobeth this thy holy hand grenade at thy fod"); + CYG_TEST_PASS_FAIL( (strcmp(x, y) > 0), + "Memory greater than #1" ); + + + // Check 6 + my_strcpy(y, "Three shall be the number of the counting and the"); + my_strcpy(x, "number of the counting shall be three"); + CYG_TEST_PASS_FAIL( (strcmp(x, y) > 0), + "Memory greater than #2" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strcmp() function"); +} // main() + + + +// EOF strcmp1.c diff --git a/packages/language/c/libc/string/current/tests/strcmp2.c b/packages/language/c/libc/string/current/tests/strcmp2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strcmp2.c @@ -0,0 +1,108 @@ +//================================================================= +// +// strcmp2.c +// +// Testcase for C library strcmp() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strcmp() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// CONSTANTS + +#define NUM_ROBUSTNESS_RUNS 300 + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char z[300]; + int ctr; + int fail; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strcmp() function"); + CYG_TEST_INFO("This testcase tests robustness, and may take some time"); + + fail = 0; + for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) + { + my_strcpy(x, "Spare a talent for an old ex-leper"); + my_strcpy(y, "Spare a talent for an old ex-leper"); + my_strcpy(z, "I was hopping along, when suddenly he"); + + if (strcmp(x, y) != 0) + { + fail = 1; + break; + } + if (strcmp(x, z) == 0) + { + fail = 1; + break; + } // if + } // for + + CYG_TEST_PASS_FAIL( (fail==0), "Robustness test"); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strcmp() function"); +} // main() + + +// EOF strcmp2.c diff --git a/packages/language/c/libc/string/current/tests/strcoll1.c b/packages/language/c/libc/string/current/tests/strcoll1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strcoll1.c @@ -0,0 +1,123 @@ +//================================================================= +// +// strcoll1.c +// +// Testcase for C library strcoll() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strcoll() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +// Functions to avoid having to use libc strings + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strcoll() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "I have become, comfortably numb"); + my_strcpy(y, "I have become, comfortably numb"); + CYG_TEST_PASS_FAIL( (strcoll(x, y) == 0), "Simple compare"); + + + // Check 2 + my_strcpy(x, ""); + my_strcpy(y, ""); + CYG_TEST_PASS_FAIL( (strcoll(x, y) == 0), "Simple empty string compare"); + + + // Check 3 + my_strcpy(x, "..shall snuff it. And the Lord did grin"); + my_strcpy(y, "..shall snuff it. And the Lord did grio"); + CYG_TEST_PASS_FAIL( (strcoll(x, y) < 0), + "Memory less than #1" ); + + + // Check 4 + my_strcpy(x, "A reading from the Book of Armaments, Chapter 4, " + "Verses 16 to 20:"); + my_strcpy(y, "Bless this, O Lord, that with it thou mayst blow thine " + "enemies to tiny bits, in thy mercy."); + CYG_TEST_PASS_FAIL( (strcoll(x, y) < 0), + "Memory less than #2"); + + // Check 5 + my_strcpy(x, "Lobeth this thy holy hand grenade at thy foe"); + my_strcpy(y, "Lobeth this thy holy hand grenade at thy fod"); + CYG_TEST_PASS_FAIL( (strcoll(x, y) > 0), + "Memory greater than #1" ); + + + // Check 6 + my_strcpy(y, "Three shall be the number of the counting and the"); + my_strcpy(x, "number of the counting shall be three"); + CYG_TEST_PASS_FAIL( (strcoll(x, y) > 0), + "Memory greater than #2" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strcoll() function"); +} // main() + + + +// EOF strcoll1.c diff --git a/packages/language/c/libc/string/current/tests/strcoll2.c b/packages/language/c/libc/string/current/tests/strcoll2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strcoll2.c @@ -0,0 +1,106 @@ +//================================================================= +// +// strcoll2.c +// +// Testcase for C library strcoll() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strcoll() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// CONSTANTS + +#define NUM_ROBUSTNESS_RUNS 300 + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char z[300]; + int ctr; + int fail; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strcoll() function"); + CYG_TEST_INFO("This testcase tests robustness, and may take some time"); + + fail = 0; + for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) + { + my_strcpy(x, "Spare a talent for an old ex-leper"); + my_strcpy(y, "Spare a talent for an old ex-leper"); + my_strcpy(z, "I was hopping along, when suddenly he"); + + if (strcoll(x, y) != 0) + { + fail = 1; + break; + } + if (strcoll(x, z) == 0) + { + fail = 1; + break; + } // if + } // for + + CYG_TEST_PASS_FAIL( (fail==0), "Robustness test"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strcoll() function"); +} // main() + + +// EOF strcoll2.c diff --git a/packages/language/c/libc/string/current/tests/strcpy1.c b/packages/language/c/libc/string/current/tests/strcpy1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strcpy1.c @@ -0,0 +1,110 @@ +//================================================================= +// +// strcpy1.c +// +// Testcase for C library strcpy() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strcpy() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char *ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strcpy() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "Nine rings for men doomed to die"); + ret = strcpy(y, "Nine rings for men doomed to die"); + CYG_TEST_PASS_FAIL( (my_strcmp(x, y) == 0), "Simple copy" ); + // Check return value + CYG_TEST_PASS_FAIL( (y == ret), "Simple copy return value" ); + + + // Check 2 + my_strcpy(x, ""); + my_strcpy(y, "Seven rings for the dwarves in their halls of stone"); + ret = strcpy(y, x); + CYG_TEST_PASS_FAIL( (my_strcmp(y, "") == 0), "Copy empty string" ); + // Check return value + CYG_TEST_PASS_FAIL( (y == ret), "Copy empty string return value" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strcpy() function"); + +} // main() + +// EOF strcpy1.c diff --git a/packages/language/c/libc/string/current/tests/strcpy2.c b/packages/language/c/libc/string/current/tests/strcpy2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strcpy2.c @@ -0,0 +1,114 @@ +//================================================================= +// +// strcpy2.c +// +// Testcase for C library strcpy() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strcpy() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// CONSTANTS + +#define NUM_ROBUSTNESS_RUNS 300 + +// FUNCTIONS + + +// Functions to avoid having to use libc strings + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char *ret; + int ctr; + int fail; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strcpy() function"); + CYG_TEST_INFO("This testcase tests robustness, and may take some time"); + + fail = 0; + for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) { + my_strcpy(x, "Green plastic watering can, "); + my_strcpy(y, "for her fake Chineese rubber plant"); + ret = strcpy(x, y); + if ( (my_strcmp(x, "for her fake Chineese rubber plant") != 0) || + ( ret != x ) ) + { + fail = 1; + break; + } // if + } // for + CYG_TEST_PASS_FAIL( (fail == 0), "Robustness test" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strcpy() function"); +} // main() + +// EOF strcpy2.c diff --git a/packages/language/c/libc/string/current/tests/strcspn.c b/packages/language/c/libc/string/current/tests/strcspn.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strcspn.c @@ -0,0 +1,132 @@ +//================================================================= +// +// strcspn.c +// +// Testcase for C library strcspn() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strcspn() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + int ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strcspn() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "ah blow my nose at you, so-called Arthur king!"); + my_strcpy(y, "A"); + ret = strcspn(x, y); + CYG_TEST_PASS_FAIL( (ret == 34), "Simple strcspn() for one char" ); + + + // Check 2 + my_strcpy(x, "Not bad for a little fur ball. You! Stay here."); + my_strcpy(y, "fd"); + ret = strcspn(x, y); + CYG_TEST_PASS_FAIL( (ret == 6), "Simple strcspn() for two chars" ); + + // Check 3 (boundary condition) + my_strcpy(x, ""); + my_strcpy(y, "zx"); + ret = strcspn(x, y); + CYG_TEST_PASS_FAIL( (ret == 0), "Empty string to search"); + + + // Check 4 (boundary condition) + my_strcpy(x, "So, if she weighs the same as a duck, she's made of wood!"); + my_strcpy(y, "zx"); + ret = strcspn(x, y); + CYG_TEST_PASS_FAIL( (ret == my_strlen(x)), "Characters not in string" ); + + // Check 5 (boundary condition) + my_strcpy(x, "So, if she weighs the same as a duck, she's made of wood!"); + my_strcpy(y, "S"); + ret = strcspn(x, y); + CYG_TEST_PASS_FAIL( (ret == 0), "First character of string" ); + + // Check 6 (boundary condition) + my_strcpy(x, "So, if she weighs the same as a duck, she's made of wood!"); + my_strcpy(y, "!"); + ret = strcspn(x, y); + CYG_TEST_PASS_FAIL( (ret == (my_strlen(x) - 1)), + "Penultimate character of string" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strcspn() function"); +} // main() + +// EOF strcspn.c diff --git a/packages/language/c/libc/string/current/tests/strlen.c b/packages/language/c/libc/string/current/tests/strlen.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strlen.c @@ -0,0 +1,76 @@ +//================================================================= +// +// strlen.c +// +// Testcase for C library strlen() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strlen() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +int main( int argc, char *argv[] ) +{ + char x[]=""; + char y[]="The force is strong in this one"; + char z[]="I told you. We're an anarcho-cynicalist commune"; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strlen() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + CYG_TEST_PASS_FAIL( (strlen(x) == 0), "strlen(\"\")" ); + + CYG_TEST_PASS_FAIL( (strlen(y) == 31), "Simple length check #1" ); + + CYG_TEST_PASS_FAIL( (strlen(z) == 47), "Simple length check #2" ); + + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strlen() function"); +} // main() + + +// EOF strlen.c diff --git a/packages/language/c/libc/string/current/tests/strncat1.c b/packages/language/c/libc/string/current/tests/strncat1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strncat1.c @@ -0,0 +1,160 @@ +//================================================================= +// +// strncat1.c +// +// Testcase for C library strncat() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strncat() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include +#include // Configuration header + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char *ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "memmove() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "One ring to rule them all."); + my_strcpy(y, "One ring to find them."); + ret = strncat(x, y, my_strlen(y)+1); + if ( my_strcmp(x, "One ring to rule them all.One ring to find them.")==0 ) + CYG_TEST_PASS("Simple concatenation"); + else + CYG_TEST_FAIL("Simple concatenation"); + // Check return val + CYG_TEST_PASS_FAIL( ( ret == x ), "Simple concatenation return value" ); + + + // Check 2 + my_strcpy(x, "One ring to bring them all,"); + my_strcpy(y, ""); + ret = strncat(x, y, my_strlen(y)+1); + if ( my_strcmp(x, "One ring to bring them all,")==0 ) + CYG_TEST_PASS("Concatenation of empty string"); + else + CYG_TEST_FAIL("Concatenation of empty string"); + // Check return val + CYG_TEST_PASS_FAIL( ( ret == x ), + "Concatenation of empty string return value" ); + + + // Check 3 + my_strcpy(x, "and in the darkness bind them"); + my_strcpy(y, ""); + ret = strncat(y, x, my_strlen(x)+1 ); + if ( my_strcmp(x, "and in the darkness bind them")==0 ) + CYG_TEST_PASS("Concatenation to empty string"); + else + CYG_TEST_FAIL("Concatenation to empty string"); + // Check return val + CYG_TEST_PASS_FAIL( ( ret == y ), + "Concatenation to empty string return value" ); + + // Check 4 + my_strcpy(x, "in the land of "); + my_strcpy(y, "Mordor, where the shadows lie"); + ret = strncat(x, y, 6 ); + if ( my_strcmp(x, "in the land of Mordor")==0 ) + CYG_TEST_PASS("Concatenation of partial string string"); + else + CYG_TEST_FAIL("Concatenation of partial string"); + // Check return val + CYG_TEST_PASS_FAIL( ( ret == x ), + "Concatenation to empty string return value" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strncat() function"); +} // main() + + +// EOF strncat1.c diff --git a/packages/language/c/libc/string/current/tests/strncat2.c b/packages/language/c/libc/string/current/tests/strncat2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strncat2.c @@ -0,0 +1,132 @@ +//================================================================= +// +// strncat2.c +// +// Testcase for C library strncat() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strncat() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// CONSTANTS + +#define NUM_ROBUSTNESS_RUNS 300 + +// FUNCTIONS + + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char *ret; + int ctr; + int fail; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strncat() function"); + CYG_TEST_INFO("This testcase tests robustness, and may take some time"); + + fail = 0; + for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) + { + my_strcpy(x, "in the land of Mordor, "); + my_strcpy(y, "where the shadows lie."); + ret = strncat(x, y, my_strlen(y)+1 ); + if ((my_strcmp(x, "in the land of Mordor, where the shadows lie.")!=0)) + { + fail = 1; + break; + } // if + if (ret != x) + { + fail = 1; + break; + } // if + } + CYG_TEST_PASS_FAIL( (fail == 0), "Robustness test passed" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strncat() function"); + +} // main() + + +// EOF strncat2.c diff --git a/packages/language/c/libc/string/current/tests/strncpy1.c b/packages/language/c/libc/string/current/tests/strncpy1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strncpy1.c @@ -0,0 +1,153 @@ +//================================================================= +// +// strncpy1.c +// +// Testcase for C library strncpy() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strncpy() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int my_strncmp(const char *s1, const char *s2, size_t n) +{ + if (n==0) + return 0; + + while (n-- != 0 && *s1 == *s2) + { + if (n == 0 || *s1 == '\0' || *s2 == '\0') + break; + s1++; + s2++; + } + + return (*s1 - *s2); +} // my_strncmp() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int +main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char *ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strncpy() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "Nine rings for men doomed to die"); + ret = strncpy(y, "Nine rings for men doomed to die", my_strlen(x)); + CYG_TEST_PASS_FAIL( (my_strncmp(x, y, my_strlen(x)) == 0), + "Simple copy" ); + // Check return value + CYG_TEST_PASS_FAIL( (y == ret), "Simple copy return value" ); + + + // Check 2 + my_strcpy(x, ""); + my_strcpy(y, "Seven rings for the dwarves in their halls of stone"); + ret = strncpy(y, x, 1); + CYG_TEST_PASS_FAIL( (my_strcmp(y, "") == 0), "Copy empty string" ); + // Check return value + CYG_TEST_PASS_FAIL( (y == ret), "Copy empty string return value" ); + + // Check 3 + my_strcpy(x, ""); + my_strcpy(y, "Seven rings for the dwarves in their halls of stone"); + ret = strncpy(y, x, 0); + if (my_strcmp(y, "Seven rings for the dwarves " + "in their halls of stone") == 0) + CYG_TEST_PASS("Copy 0 characters"); + else + CYG_TEST_FAIL("Copy 0 characters"); + // Check return value + CYG_TEST_PASS_FAIL( (y == ret), "Copy empty string return value" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strncpy() function"); + +} // main() + +// EOF strncpy1.c diff --git a/packages/language/c/libc/string/current/tests/strncpy2.c b/packages/language/c/libc/string/current/tests/strncpy2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strncpy2.c @@ -0,0 +1,124 @@ +//================================================================= +// +// strncpy2.c +// +// Testcase for C library strncpy() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strncpy() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// CONSTANTS + +#define NUM_ROBUSTNESS_RUNS 300 + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char *ret; + int ctr; + int fail; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strncpy() function"); + CYG_TEST_INFO("This testcase tests robustness, and may take some time"); + + fail = 0; + for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) { + my_strcpy(x, "Green plastic watering can, "); + my_strcpy(y, "for her fake Chineese rubber plant"); + ret = strncpy(x, y, my_strlen(y)+1); + if ( (my_strcmp(x, "for her fake Chineese rubber plant") != 0) || + ( ret != x ) ) + { + fail = 1; + break; + } // if + } // for + CYG_TEST_PASS_FAIL( (fail == 0), "Robustness test" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strncpy() function"); +} // main() + +// EOF strncpy2.c diff --git a/packages/language/c/libc/string/current/tests/strpbrk.c b/packages/language/c/libc/string/current/tests/strpbrk.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strpbrk.c @@ -0,0 +1,112 @@ +//================================================================= +// +// strpbrk.c +// +// Testcase for C library strpbrk() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strpbrk() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char *ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strpbrk() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "I will not have my fwends widiculed by the common soldiewy"); + my_strcpy(y, "zpm1"); // Finds the 'm' + ret = strpbrk(x, y); + CYG_TEST_PASS_FAIL( (ret == &x[16]), "Simple strpbrk()" ); + + // Check 2 + my_strcpy(x, "Not bad for a little fur ball. You! Stay here."); + my_strcpy(y, "zx"); + ret = strpbrk(x, y); + CYG_TEST_PASS_FAIL( (ret == NULL), "Letters not found"); + + // Check 3 (boundary condition) + my_strcpy(x, ""); + my_strcpy(y, "zx"); + ret = strpbrk(x, y); + CYG_TEST_PASS_FAIL( (ret == NULL), "String to search empty" ); + + // Check 4 (boundary condition) + my_strcpy(x, "zx"); + my_strcpy(y, ""); + ret = strpbrk(x, y); + CYG_TEST_PASS_FAIL( (ret == NULL), "Empty search string" ); + + // Check 5 (boundary condition) + my_strcpy(x, ""); + my_strcpy(y, ""); + ret = strpbrk(x, y); + CYG_TEST_PASS_FAIL( (ret == NULL), "Both strings empty" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strpbrk() function"); + +} // main() + +// EOF strpbrk.c diff --git a/packages/language/c/libc/string/current/tests/strrchr.c b/packages/language/c/libc/string/current/tests/strrchr.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strrchr.c @@ -0,0 +1,107 @@ +//================================================================= +// +// strrchr.c +// +// Testcase for C library strrchr() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strrchr() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char *ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strrchr() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "I will not have my fwends widiculed by the common soldiewy"); + ret = strrchr(x, (int) 'c'); + CYG_TEST_PASS_FAIL( (ret == &x[43]), "Simple strrchr()" ); + + // Check 2 + my_strcpy(x, "Not bad for a little fur ball. You! Stay here."); + ret = strrchr(x, (int) 'z'); + CYG_TEST_PASS_FAIL( (ret == NULL), "Character not found"); + + // Check 3 (boundary condition) + my_strcpy(x, ""); + ret = strrchr(x, (int) 'c'); + CYG_TEST_PASS_FAIL( (ret == NULL), "String to search empty" ); + + // Check 4 (boundary condition) + my_strcpy(x, "zx"); + ret = strrchr(x, '\0'); + CYG_TEST_PASS_FAIL( (ret == &x[2]), "Null search character" ); + + // Check 5 (boundary condition) + my_strcpy(x, ""); + ret = strrchr(x, '\0'); + CYG_TEST_PASS_FAIL( (ret == x), "String empty and null search char" ); + + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strrchr() function"); + +} // main() + +// EOF strrchr.c diff --git a/packages/language/c/libc/string/current/tests/strspn.c b/packages/language/c/libc/string/current/tests/strspn.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strspn.c @@ -0,0 +1,119 @@ +//================================================================= +// +// strspn.c +// +// Testcase for C library strspn() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strspn() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + + +// FUNCTIONS + + +// Functions to avoid having to use libc strings + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + int ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strspn() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "ah blow my nose at you, so-called Arthur king!"); + my_strcpy(y, "wolbah "); + ret = strspn(x, y); + CYG_TEST_PASS_FAIL( (ret == 8), "Simple strspn() #1" ); + + + // Check 2 + my_strcpy(x, "Not bad for a little fur ball. You! Stay here."); + my_strcpy(y, "litea rofdbN"); + ret = strspn(x, y); + CYG_TEST_PASS_FAIL( (ret == 22), "Simple strspn() #2" ); + + // Check 3 + my_strcpy(x, "Not bad for a little fur ball. You! Stay here."); + my_strcpy(y, "litearofdbN"); + ret = strspn(x, y); + CYG_TEST_PASS_FAIL( (ret == 3), "Simple strspn() #3"); + + // Check 4 (boundary condition) + my_strcpy(x, "Not bad for a little fur ball. You! Stay here."); + my_strcpy(y, "litearofdb"); + ret = strspn(x, y); + CYG_TEST_PASS_FAIL( (ret == 0), "First character not in string"); + + + // Check 5 (boundary condition) + my_strcpy(x, "So, if she weighs the same as a duck, she's made of wood!"); + my_strcpy(y, "zx"); + ret = strspn(x, y); + CYG_TEST_PASS_FAIL( (ret == 0), "No characters in string" ); + + // Check 6 (boundary condition) + my_strcpy(x, ""); + my_strcpy(y, "qwerty"); + ret = strspn(x, y); + CYG_TEST_PASS_FAIL( (ret == 0), "Empty search string" ); + + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strspn() function"); +} // main() + +// EOF strspn.c diff --git a/packages/language/c/libc/string/current/tests/strstr.c b/packages/language/c/libc/string/current/tests/strstr.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strstr.c @@ -0,0 +1,115 @@ +//================================================================= +// +// strstr.c +// +// Testcase for C library strstr() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strstr() function +// +// +//####DESCRIPTIONEND#### + +// INCLUDES + +#include +#include + +// FUNCTIONS + +// Functions to avoid having to use libc strings + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + char *ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strstr() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "I will not have my fwends widiculed by the common soldiewy"); + my_strcpy(y, "fwends"); + ret = strstr(x, y); + CYG_TEST_PASS_FAIL( (ret == &x[19]), "Simple strstr()" ); + + + // Check 2 (boundary condition) + my_strcpy(x, "Not bad for a little fur ball. You! Stay here."); + my_strcpy(y, "ball "); + ret = strstr(x, y); + CYG_TEST_PASS_FAIL( (ret == NULL), "String to search for not present" ); + + + // Check 3 (boundary condition) + my_strcpy(x, ""); + my_strcpy(y, "zx"); + ret = strstr(x, y); + CYG_TEST_PASS_FAIL( (ret == NULL), "Empty string to search" ); + + + // Check 4 (boundary condition) + my_strcpy(x, "fdafdafdfahjgf"); + my_strcpy(y, ""); + ret = strstr(x, y); + CYG_TEST_PASS_FAIL( (ret == x), "Empty search string" ); + + // Check 5 (boundary condition) + my_strcpy(x, ""); + my_strcpy(y, ""); + ret = strstr(x, y); + CYG_TEST_PASS_FAIL( (ret == x), "Both strings empty" ); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strstr() function"); + +} // main() + +// EOF strstr.c diff --git a/packages/language/c/libc/string/current/tests/strtok.c b/packages/language/c/libc/string/current/tests/strtok.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strtok.c @@ -0,0 +1,155 @@ +//================================================================= +// +// strtok.c +// +// Testcase for C library strtok() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 1999-01-20 +// Description: Contains testcode for C library strtok() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include +#include // Configuration header + +// INCLUDES + +#include +#include + +// FUNCTIONS + +// Functions to avoid having to use libc strings + + +static int +my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char * +my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +static void +test( CYG_ADDRWORD data ) +{ + char x[300]; + + // Check 1 + my_strcpy(x, "tok1 tok2 3kot"); + if (( my_strcmp("tok1", strtok(x, " ")) == 0 ) && + ( my_strcmp("tok2", strtok(NULL, " ")) == 0 ) && + ( my_strcmp("3kot", strtok(NULL, " ")) == 0 )) + + CYG_TEST_PASS("Simple strtok() #1"); + else + CYG_TEST_FAIL("Simple strtok() #1"); + + // Check 2 + my_strcpy(x, "Hitteth@ye *not, the vicar"); + if (( my_strcmp("Hitteth", strtok(x, "@,*")) == 0 ) && + ( my_strcmp("ye ", strtok(NULL, ",@*")) == 0 ) && + ( my_strcmp("not", strtok(NULL, "*@,")) == 0 ) && + ( my_strcmp(" the vicar", strtok(NULL, "*@,")) == 0 ) ) + + CYG_TEST_PASS("Simple strtok() #2"); + else + CYG_TEST_FAIL("Simple strtok() #2"); + + // Check 3 + my_strcpy(x, "on his bonce, with thine football"); + if ( my_strcmp(strtok(x, "@*"), x) == 0 ) + CYG_TEST_PASS("strtok() with token delimiters not found"); + else + CYG_TEST_FAIL("strtok() with token delimiters not found"); + + // Check 4 + my_strcpy(x, "@@@,,,...@,.,.@"); + if (strtok(x, "@,.") == NULL) + CYG_TEST_PASS("All characters of string are token delimiters"); + else + CYG_TEST_FAIL("All characters of string are token delimiters"); + + // Check 5 + my_strcpy(x, ""); + if (strtok(x, "@,.") == NULL) + CYG_TEST_PASS("String to tokenize empty"); + else + CYG_TEST_FAIL("String to tokenize empty"); + + // Check 6 + my_strcpy(x, "fdafda"); + if (strtok(x, "") == x) + CYG_TEST_PASS("String to tokenize empty"); + else + CYG_TEST_FAIL("String to tokenize empty"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strtok() function"); + +} // test() + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strtok() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + test(0); + + CYG_TEST_NA("Testing is not applicable to this configuration"); +} // main() + + +// EOF strtok.c diff --git a/packages/language/c/libc/string/current/tests/strxfrm1.c b/packages/language/c/libc/string/current/tests/strxfrm1.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strxfrm1.c @@ -0,0 +1,142 @@ +//================================================================= +// +// strxfrm1.c +// +// Testcase for C library strxfrm() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strxfrm() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include +#include // Configuration header + +// INCLUDES + +#include +#include + +// FUNCTIONS + + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + int ret; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strxfrm() function"); + CYG_TEST_INFO("This testcase provides simple basic tests"); + + // Check 1 + my_strcpy(x, "Nine rings for men doomed to die"); + ret = strxfrm(y, x, my_strlen(x)+1); + if (my_strcmp(x, y) == 0) + CYG_TEST_PASS("Simple strxfrm()"); + else + CYG_TEST_FAIL("Simple strxfrm()"); + // Check return value + CYG_TEST_PASS_FAIL( (my_strlen(x) == ret), + "Simple strxfrm() return value"); + + // Check 2 + x[0] = '\0'; + my_strcpy(y, "Seven rings for the dwarves in their halls of stone"); + ret = strxfrm(y, x, my_strlen(x)+1); + if (my_strcmp(y, "") == 0) + CYG_TEST_PASS("strxfrm() of empty string"); + else + CYG_TEST_FAIL("strxfrm() of empty string"); + // Check return value + CYG_TEST_PASS_FAIL( (my_strlen(x) == ret), + "strxfrm() of empty string return value"); + + // Check 3 + my_strcpy(y, "Seven rings for the dwarves in their halls of stone"); + ret = strxfrm(NULL, y, 0); + + // Check return value + CYG_TEST_PASS_FAIL( (my_strlen(y) == ret), + "strxfrm() of NULL string for 0 bytes return value"); + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strxfrm() function"); +} // main() + + +// EOF strxfrm1.c diff --git a/packages/language/c/libc/string/current/tests/strxfrm2.c b/packages/language/c/libc/string/current/tests/strxfrm2.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/string/current/tests/strxfrm2.c @@ -0,0 +1,129 @@ +//================================================================= +// +// strxfrm2.c +// +// Testcase for C library strxfrm() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 2000-04-30 +// Description: Contains testcode for C library strxfrm() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include +#include // Configuration header + +// INCLUDES + +#include +#include + +// CONSTANTS + +#define NUM_ROBUSTNESS_RUNS 300 + + +// FUNCTIONS + +// Functions to avoid having to use libc strings + +static int my_strlen(const char *s) +{ + const char *ptr; + + ptr = s; + for ( ptr=s ; *ptr != '\0' ; ptr++ ) + ; + + return (int)(ptr-s); +} // my_strlen() + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static char *my_strcpy(char *s1, const char *s2) +{ + while (*s2 != '\0') { + *(s1++) = *(s2++); + } + *s1 = '\0'; + + return s1; +} // my_strcpy() + +int main( int argc, char *argv[] ) +{ + char x[300]; + char y[300]; + int ret; + int ctr; + int fail; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strxfrm() function"); + CYG_TEST_INFO("This testcase tests robustness, and may take some time"); + + fail = 0; + for (ctr = 0; ctr < NUM_ROBUSTNESS_RUNS; ctr++) { + my_strcpy(x, "Green plastic watering can, "); + my_strcpy(y, "for her fake Chineese rubber plant"); + ret = strxfrm(x, y, my_strlen(y)+1); + if ( (my_strcmp(x, "for her fake Chineese rubber plant") != 0) || + (my_strlen(y) != ret) ) { + fail = 1; + break; + } + } + CYG_TEST_PASS_FAIL( (fail == 0), "Robustness test" ); + + +// CYG_TEST_NA("Testing is not applicable to this configuration"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strxfrm() function"); +} // main() + +// EOF strxfrm2.c diff --git a/packages/language/c/libc/time/current/ChangeLog b/packages/language/c/libc/time/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/ChangeLog @@ -0,0 +1,57 @@ +2000-07-26 Jonathan Larmour + + * cdl/time.cdl: Add CYGINT_ISO_DIV dependency + +2000-07-24 Jonathan Larmour + + * src/time.cxx: + * src/settime.cxx: + Wallclock moved to io/ + +2000-06-20 Jonathan Larmour + + * include/time.inl (__gmtime_r): Don't save leap year status when + calculating tm_wday + +2000-06-17 Jonathan Larmour + + * include/time.inl (gmtime_r): Deal with boundary case correctly + + * tests/gmtime.c (test): Add a couple more test cases + +2000-05-02 Jonathan Larmour + + * include/time.h: Just use the defaults for time_t, clock_t and + CLOCKS_PER_SEC in isoinfra + + * New package + Separated original libc out into separate packages on functional + boundaries. + Header files are now managed by isoinfra package + Plenty of cleanups done, but no major functionality changes + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/time/current/ChangeLog.libc b/packages/language/c/libc/time/current/ChangeLog.libc new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/ChangeLog.libc @@ -0,0 +1,2727 @@ +This ChangeLog file is now obsolete. This is the original ChangeLog from when +libc was one large package, before being separated. It is included for +historical reasons. + +2000-04-05 Jesper Skov + + * src/time/settime.cxx: + * src/time/time.cxx: + Wallclock moved to io/. + +2000-03-28 John Dallaway + + * cdl/string.cdl, + cdl/stdlib.cdl, + cdl/stdio.cdl, + cdl/libc.cdl: + + Adjust documentation URLs. + +2000-03-27 Jesper Skov + + * src/clibincl/stream.inl (check_this): Use cyb_bool instead of bool. + +2000-03-06 Jesper Skov + + * tests/time/strftime.c (test): Adjust test to match below change. + +2000-03-02 Jonathan Larmour + + * src/time/strftime.cxx (do_format): Make sure %m counts from + 1..12 rather than 0..11. Fix for case 103300 + +2000-02-29 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: Correctly use 'n' parameter to + restrict length. Credit due to Andrew Lunn here as well. + Resolves 103057-CR-1 + + * tests/stdio/sprintf2.c (test): + Add snprintf tests to verify the correct behaviour of restricting + output length + +2000-02-10 Jesper Skov + + * tests/signal/signal2.c (main): + Also reclaim DATA_TLB_MISS vector if available. + +2000-01-31 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-28 Simon FitzMaurice + * cdl/*.cdl: + + Adjust help URLs in line with new doc layout. + +2000-01-19 Hugo Tyson + + * cdl/*.cdl: Add descriptions to a number of options &c which were + lacking same, also tidied up other typos as noticed en passant. + +1999-11-11 Bart Veer + + * cdl/string.cdl: + Switch to a single boolean configuration option for code size vs. + speed optimization. + +1999-11-03 John Dallaway + + * cdl/libc.cdl: Define tests. + +1999-10-19 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx: We can now remove Berkeley + advertising clause + * src/stdlib/div.cxx: ditto + * src/stdlib/ldiv.cxx: ditto + * src/stdlib/strtol.cxx: ditto + * src/stdlib/strtoul.cxx: ditto + * src/string/strtok.cxx: ditto + +1999-10-19 John Dallaway + + * cdl/libc.cdl: + + Define CDL options for package-specific CFLAGS. + +1999-10-08 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_THREAD_PRIORITY): Change + default to 10 to keep test farm happy + * cdl/startup.cdl: Likewise + +1999-10-07 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Specify radio buttons using CDL interfaces. + +1999-10-06 Jonathan Larmour + + * cdl/stdio.cdl: Change default to /dev/ttydiag as per 1999-10-01 + change below + * cdl/startup.cdl: Add new form CDL for the startup changes as + per 1999-10-05 + +1999-10-05 Jonathan Larmour + + * include/libc.h: Add CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM to allow + the user to supply their own stack. + Rename CYGNUM_LIBC_MAIN_STACK_SIZE to + CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE and reparent under + CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM + Add CYGNUM_LIBC_MAIN_THREAD_PRIORITY to provide main() thread + priority + + * src/support/mainthread.cxx: Add support for user-supplied stack + Allow user to specify thread priority + + These changes fix CR 101069 + +1999-10-01 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE): Change + default to /dev/ttydiag to get correct console-like behaviour + Also don't preclude use if haldiag package isn't included + (case 102065) + +1999-09-15 Jesper Skov + + * tests/signal/signal2.c (cause_fpe): Try both float and integer + division by zero. + +1999-09-10 Jesper Skov + + * src/stdlib/malloc.cxx (cyg_libc_get_malloc_pool): Added for + stress_threads test. + +1999-09-07 Jesper Skov + PRs 20243, 20433 + * tests/signal/signal2.c: Disabled test3 on ARM. + +1999-09-02 Hugo Tyson + + * include/assert.h: Make the sense of NDEBUG correct; it is "set" + when NOT debugging. Fix for CR 101983-CR-1 + See Stroustrup, "The C++ Programming Language." + +1999-08-18 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): Set buffer size 0 when not + buffering + Fix for case 101868 + +1999-08-17 John Dallaway + + * cdl/stdlib.cdl, cdl/string.cdl: + + Implement radio buttons using "FIXME radio" hack in + description field for now. + +1999-08-12 John Dallaway + + * cdl/stdlib.cdl: + Take advantage of MACRONAME_ENUMVAL macros output by CDL. + +1999-08-06 Jonathan Larmour + + * tests/stdio/sprintf2.c (test): Don't rely on 2.345 being exactly + representable in binary as a difference of 1 ulp will make it round + the wrong way. + +1999-07-16 Jonathan Larmour + + * src/stdio/input/fgetc.cxx: + Include outline versions of getc() (actually just a symbol alias for + fgetc() ) and getchar() + Some minor clean-ups + Add tracing/assertions + + * src/stdio/input/fputc.cxx: + Likewise (except applied to putc() and putchar()) + + * src/stdio/common/stdioinlines.cxx (_puts): + Call fputc() not _fputc() + + * src/clibincl/stdiosupp.hxx: + Remove now obsolete prototypes for _fgetc() and _fputc() + + * include/stdio.h: + Don't bother with getc()/putc() macros any more, just call + them as functions + Include protos for getc(), putc(), getchar() and putchar() functions + +1999-06-21 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for SH EDK7708. + +1999-06-11 Jonathan Larmour + + * include/stdio.h: Make FILEs array types so they won't be + given $gp relocations on MIPS targets + +1999-05-27 Jesper Skov + + * tests/time/ctime.c: Fixed compiler warning. + +1999-05-25 Jonathan Larmour + + * tests/signal/signal2.c (main): + Update CYGPKG_HAL_TX39 -> CYGPKG_HAL_MIPS_TX39 due to recent MIPS + HAL changes + Fix for PR 20116 + +1999-04-30 Jesper Skov + PR 19945/19946 workaround + * tests/signal/signal2.c: Disabled test 3 for PowerPC sim. + +1999-04-19 Jonathan Larmour + + * include/time.inl: + Ensure all calls to cyg_libc_time_year_is_leap() are with the full + year, and not the direct contents of a struct tm, which are (year-1900) + +1999-04-19 Jesper Skov + PR 19308, 19410, 19528 + * tests/time/clock.c (test): Also disable data cache which may + affect timing when tracing/assertions are enabled. + +1999-04-15 Jonathan Larmour + + * src/clibincl/stdiosupp.hxx: + Add prototype for new cyg_libc_stdio_flush_all_but() function + + * src/clibincl/stream.hxx: + Don't include stdiosupp.hxx any more to prevent circular dependency, + therefore manually provide _setvbuf prototype + Make sure pkgconf/kernel.h is included before mutex.hxx + + * src/clibincl/stream.inl (Cyg_StdioStream::set_error()): + Add missing unlock_me() + + * src/stdio/common/fflush.cxx: + Separate most of code for fflush(NULL) into separate + cyg_libc_stdio_flush_all_but() function, which has the extra + capability of omitting one stream + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Add missing clibincl/stdiosupp.hxx include + + * src/stdio/common/stream.cxx (Cyg_StdioStream::read()): + When reading, ensure we flush all output streams + + * src/stdio/common/stream.cxx (Cyg_StdioStream::flush_output_unlocked): + Flush the device as well + +1999-04-15 Jonathan Larmour + + * src/stdio/common/streambuf.cxx (set_buffer): + * src/stdio/common/stdioinlines.cxx (_setbuf): + * src/clibincl/streambuf.inl: + * src/clibincl/streambuf.hxx: + * src/clibincl/stream.hxx (class Cyg_StdioStream): + * include/pkgconf/libc.h: + * include/stdio.inl (setbuf): + Fix dumb typo: BUFSIZE -> BUFSIZ + This fixes PR19837 + +1999-04-15 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx (_setbuf): + * include/stdio.inl (setbuf): + Use _IONBF when buf==NULL, and _IOLBF otherwise. + Fix for PR 19836 + +1999-04-15 John Dallaway + + * include/pkgconf/libc.h: Tidy display string capitalization. + +1999-04-12 Jonathan Larmour + + * include/pkgconf/libc.h: + Clarify CDL description of CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE + + * tests/signal/signal2.c: Try harder to generate an exception by + accessing a misaligned address + Don't handle SIGTRAP any more + Part of fix for PRs 19731/19607 + +1999-04-07 Jesper Skov + PR 19667 + * src/support/mainthread.cxx: + Changed to use the new Cyg_Thread constructor. + +1999-04-07 Hugo Tyson + + * tests/signal/signal2.c (main): Use new macro + HAL_VSR_SET_TO_ECOS_HANDLER if defined, to wrest control from + CygMon, for example, by reinstalling eCos' default VSRs for + exceptions that we are provoking. + +1999-03-29 Jonathan Larmour + + * src/signal/siginit.cxx: Include stdlib.h for exit() + Fix for PR 19720 + +1999-03-29 Jonathan Larmour + + * tests/time/clock.c (test): Disable instruction cache + Hopefully fixes PR 19308 + +1999-03-29 Jesper Skov + + * tests/signal/signal2.c: Disabled test 3 for PPC as it cannot + trap division by zero. + +1999-03-26 Jonathan Larmour + + * src/support/main.cxx (main): Invoke cyg_user_start() if no kernel + Only sensible thing to do in our default main in a non-kernel config + +1999-03-25 Jonathan Larmour + + * tests/time/time.c: + Increase MAX_TIMEOUT since the sparclite gets very close to overrunning + it even when working. + Should return -1 iff CYGSEM_LIBC_TIME_TIME_WORKING isn't defined + Cosmetic changes + +1999-03-25 Hugo Tyson + + * tests/time/time.c (test): Take into account setting of + CYGSEM_LIBC_TIME_SETTIME_WORKING ie. does cyg_libc_time_settime() + work? If not, check that it returns an error. + This was exposed by the random combo in PR#19479. + +1999-03-23 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 to + CYGIMP_... + + Add another rand implementation CYGIMP_LIBC_RAND_SIMPLE1 which is + the default + + Part of fix for PR 19562 + + * include/sys/cstartup.h: + Tidy and remove unnecessary dependencies + + * src/stdlib/rand.cxx: + Rename algorithms from CYGSEM_... to CYGIMP_... + Add new "simple1" algorithm + + * tests/ctype/ctype.c: + Tidy + + * tests/stdlib/rand3.c: + Fix so that 0..RAND_MAX is split evenly over buckets, which it wasn't + before + Deal with case of RAND_MAX not being divisible by NUM_BUCKETS + exactly + Increase TEST_LENGTH to 200000 to provide more representative sample + Add CYG_TEST_INFO output to help ensure it doesn't time out + Tidy + + * tests/stdlib/rand4.c: + Only fail if more than _two_ thirds (rather than one third) match. + This is because half would match for a perfectly random distribution + This is the rest of the fix for PR 19562 + Cosmetic changes + +1999-03-22 Hugo Tyson + + * src/support/mainthread.cxx (CYGNUM_LIBC_MAIN_STACK_SIZE): + Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of + CYGNUM_HAL_MINIMUM_STACK_SIZE. + +1999-03-22 Jonathan Larmour + + * tests/PKGconf.mak: Add -Wno-format when building strftime otherwise + it generates warnings for things that we do want to test (null + string, and %y format) + +1999-03-19 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Put brackets back round negative number since sdf says the config + tool is fixed now (PR 19537) + + Add new CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 + options for different rand() algorithms in a so far failed attempt + to fix PR 19562 + + * src/stdlib/rand.cxx: + Add new optional algorithm from Knuth vol.2 + + * tests/stdlib/rand4.c: + Some tidies + Don't run test when using simplest algorithm + + * tests/signal/signal2.c (main): + Don't try to make an FPE on tx39 - its possible to detect but requires + too much HAL work to be sensible + +1999-03-18 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Use HAL_ENABLE_INTERRUPTS() rather than kernel to enable interrupts + +1999-03-18 Mark Galassi + + * tests/PKGconf.mak (TESTS): added rand4 compilation. + + * tests/stdlib/rand4.c: added this test for periodicity in the + least significant bit of rand(). + +1999-03-18 Jonathan Larmour + + * include/pkgconf/libc.h: Remove CYGFUN_LIBC_TIME_POSIX dependency + on CYGPKG_LIBC_STDIO + + * src/stdlib/itoa.cxx: + New file to convert integers to ascii + + * include/stdlib.h: + Add proto for new cyg_libc_itoa() function + + * include/time.inl: + Rework __asctime_r() to use memcpy() and cyg_libc_itoa() rather than + sprintf() + + * src/PKGconf.mak: + Build stdlib/itoa.cxx + + The above changes fix PR 19448 + +1999-03-17 Jonathan Larmour + + * include/time.h: Add #define of __time_t_defined to placate newlib + if it is used by accident. This is just a temporary workaround though. + +1999-03-16 Gary Thomas + + * src/PKGconf.mak: Add compile option to step around ARM compiler bug. + +1999-03-16 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE): + Don't use parentheses for now + + * src/stdio/common/stream.cxx (refill_read_buffer): + Silence bogus compiler warning + +1999-03-16 Jesper Skov + + * tests/signal/signal2.c (main): Enable SIGSEGV test for + i386/Linux. + + +1999-03-15 Jonathan Larmour + + * src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler): + Only enable interrupts if they were disabled + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: + Add FIX ME line as a reminder that the workaround there can go away + in future + + * include/pkgconf/libc.h: + Add proper define for CYGSEM_LIBC_EXIT_CALLS_FFLUSH + Put brackets round negative CYGNUM_LIBC_TIME_DST_DEFAULT_STATE define + Fix run time typo + + * include/time.inl (__localtime_r): + Include sys/timeutil.h before this to get + cyg_libc_time_normalize_structtm() + +1999-03-12 Gary Thomas + + * include/sys/timeutil.h: + * src/time/timeutil.cxx: Remove 'const' from char arrays since + this fails [silently] on ARM when -fwritable-strings (PR19440) + +1999-03-12 Jesper Skov + + * tests/signal/signal2.c (main): Compiler warnings fix was + slightly broken. + +1999-03-12 Jesper Skov + PR 19473 + * tests/signal/signal2.c (main): + Disabling SIGTRAP handling on i386/Linux is not a good idea. +1999-03-11 Jesper Skov + PR 19473 + * tests/signal/signal2.c: + Added compiler warnings fix. + Added N/A handling for i386/Linux. + +1999-03-10 Gary Thomas + + * include/pkgconf/libc.h: Force "haldiag" device to be present. + 'asctime' and friends need 'stdio' as well. + + * include/time.inl: Fix syntax error on difftime() declaration. + +1999-03-08 Gary Thomas + + * src/clibincl/stream.hxx: needed for this file. + + * src/stdio/common/vsscanf.cxx (str_read): Fix problem with string + pointer [created by merge with new I/O package]. + +1999-03-05 John Dallaway + + * include/pkgconf/libc.h: + Add legal values for CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET + and CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET. + +1999-03-05 Jonathan Larmour + + * include/time.inl (cyg_libc_time_year_is_leap): + Fix bug with modulo year 400 + Fix typo in asctime_r macro + Fix gmtime_r, and mktime as a result of testing + + * tests/time/asctime.c, tests/time/ctime.c, tests/time/gmtime.c, + tests/time/gmtime.c, tests/time/localtime.c, tests/time/mktime.c, + tests/time/strftime.c, tests/time/time.c: + New tests + + * tests/PKGconf.mak: + Build above new tests + + * include/pkgconf/libc.h: + Add reminder FIX ME about extra config option + + * src/time/strftime.cxx: + Fix %w and %Y parameters as a result of testing + + * src/time/timeutil.cxx: + Fix cyg_libc_time_normalize_structtm() as a result of testing + of mktime() + + * tests/time/clock.c: + Reformat, remove obsolete bits and tidy + + * include/time.h: + Add Cyg_libc_time_dst type and new functions + cyg_libc_time_setzoneoffsets(), cyg_libc_time_setdst(), + cyg_libc_time_getzoneoffsets(), cyg_libc_time_settime() + + * include/time.inl: + Implement the above functions. This allows us to adjust for timezone + diffences and set the time. + Change localtime() to adjust for STD/DST + Change mktime() to adjust for STD/DST + + * include/libc.h: + Add new config options CYGSEM_LIBC_TIME_SETTIME_WORKING + and component CYGPKG_LIBC_TIME_ZONES containing options + CYGNUM_LIBC_TIME_DST_DEFAULT_STATE, + CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET, + CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET + + * src/strftime.cxx: + Adjust handling of %Z to _not_ deal with STD/DST + + * src/time/settime.cxx: + New file to implement cyg_libc_time_settime() + + * src/PKGconf.mak: + Build settime.cxx + + * src/time/timeutil.cxx: + Supply outline versions of cyg_libc_time_setzoneoffsets(), + cyg_libc_time_setdst(), and cyg_libc_time_getzoneoffsets() + Add variables for STD/DST state + Some minor comment changes + + * include/errno.h: + Use CYGBLD_ATTRIB_CONST instead of __attribute__((const)) directly + + * include/signal.h: + Change format of function comment headers + + * include/signal.inl: + Restrict errno.h inclusion to when its actually used + Fix a spelling typo + + * include/stdlib.h: + Add CYGBLD_ATTRIB_CONST to abs, div, labs, ldiv + + * include/stdlib.inl: + Reformat and tidy + Include new versions of div and ldiv which are more portable and + are cleanly rewritten so aren't covered by the BSD licence, which + is now removed + + * src/stdlib/div.cxx, src/stdlib/ldiv.cxx: + Non-inline, non-BSD and portable versions of the new versions of div + and ldiv from stdlib.inl + + * include/time.h: + Much reformatting, tidying and improving comments + Change CLOCKS_PER_SEC from 1000 to 1000000 + Add new functions asctime_r, ctime_r, gmtime_r, localtime_r, clock, + difftime, mktime, time, asctime, ctime, gmtime, localtime, strftime + Include new time.inl file + + * include/pkgconf/libc.h: + Add new options CYGSEM_LIBC_TIME_CLOCK_WORKING, + CYGSEM_LIBC_TIME_TIME_WORKING, CYGFUN_LIBC_TIME_POSIX, + CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL, CYGIMP_LIBC_TIME_ASCTIME_INLINE, + CYGIMP_LIBC_TIME_CTIME_INLINE, CYGIMP_LIBC_TIME_DIFFTIME_INLINE, + CYGIMP_LIBC_TIME_GMTIME_INLINE, CYGIMP_LIBC_TIME_LOCALTIME_INLINE, + CYGIMP_LIBC_TIME_MKTIME_INLINE, CYGIMP_LIBC_TIME_ASCTIME_R_INLINE, + CYGIMP_LIBC_TIME_CTIME_R_INLINE, CYGIMP_LIBC_TIME_GMTIME_R_INLINE, + and CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE + + * time/asctime.cxx, time/asctime_r.cxx, time/clock.cxx, time/ctime.cxx, + time/ctime_r.cxx, time/difftime.cxx, time/gmtime.cxx, + time/gmtime_r.cxx, time/localtime.cxx, time/localtime_r.cxx, + time/mktime.cxx, time/strftime.cxx, time/time.cxx, time/timeutil.cxx, + include/time.inl: + New files to implement the new time functions. Many of them simply + provide the outline definitions, but the real body of the function + comes from time.inl + + * src/PKGconf.mak: + Build new .cxx files + + * src/clibincl/stdlibsupp.hxx: + Remove _div and _ldiv prototypes since they're no longer needed + + * src/clibincl/timesupp.hxx: + Delete as its now obsolete + + * src/time/clock.cxx: + Use new CYGSEM_LIBC_TIME_CLOCK_WORKING option to control whether it + just returns (clock_t)-1 or not. + Much reformatting and tidying + Change real imlpementation from _clock to __clock + Use CYGBLD_ATTRIB_WEAK_ALIAS now + + * tests/stdlib/div.c, tests/stdlib/ldiv.c: + Add some extra tests for handling of negative numbers + Reformat and tidy a bit, including removing the test for CYGPKG_LIBC + since its now always defined if the test is to be compiled + + * tests/time/clock.c: + Remove duplication CYG_TEST_INFO line + Check if unimplemented using "(clock_t)-1" and not just "-1" + +1999-03-04 Jonathan Larmour + + * src/stdlib/system.cxx: + Make sure system() is a weak alias for __system() + + * include/pkgconf/libc.h: Rework CDL description for + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE and change its default to + "/dev/haldiag" + + * src/stdio/common/stream.cxx: + Check that dev is valid when passed to stream constructor + + * src/stdio/common/stdiosupp.cxx: + Tidy + + * src/support/mainthread.cxx: Make this depend on + CYGSEM_LIBC_STARTUP_MAIN_THREAD rather than just CYGPKG_KERNEL + +1999-03-04 Gary Thomas + + Merged in changes from 'ecos-new_devs-19990216-branch' + + (1999-02-24 Jonathan Larmour ) + + * src/stdio/common/stream.cxx: + Add "fix me" comments and remove a couple of commented out lines + + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/vsscanf.cxx: + Revert to using pointer to string for private data, not just string. + This preserves the state across multiple calls + + (1999-02-24 Gary Thomas ) + + * src/stdio/common/vsscanf.cxx: + * src/stdio/common/vsnprintf.cxx: + * src/stdio/common/stream.cxx: + * src/stdio/common/stdiosupp.cxx: + * src/stdio/common/fopen.cxx: + * src/clibincl/stream.inl: + * src/clibincl/stream.hxx: + * src/clibincl/stdiosupp.hxx: + * include/pkgconf/libc.h: Changes for new I/O system. + +1999-03-03 Jonathan Larmour + + * tests/stdlib/atexit.c: Forgot to config atexit test for + CYGFUN_LIBC_ATEXIT option + + * include/pkgconf/libc.h: + Require CYGVAR_KERNEL_THREADS_DATA for CYGSEM_LIBC_PER_THREAD_STRTOK + This fixes PR 19362 + Require CYGPKG_KERNEL for thread safe streams + Also don't need "requires CYGPKG_KERNEL" for per-thread rand and errno + if we already require a finer granularity kernel option + +1999-02-25 Jonathan Larmour + + * include/pkgconf/libc.h: Fix CYGNUM_LIBC_MAIN_STACK_SIZE by changing + CYGPKG_LIBC_STARTUP_MAIN_THREAD -> CYGSEM_LIBC_STARTUP_MAIN_THREAD + Fix for PR 19304 + +1999-02-23 Jonathan Larmour + + * src/stdlib/system.cxx: Add to implement trivial system() call + * include/stdlib.h: Add system() prototype + * src/PKGconf.mak: Build system.cxx + + * tests/ctype/ctype.c, tests/i18n/setlocale.c, tests/setjmp/setjmp.c, + tests/signal/signal1.c, tests/signal/signal2.c, + tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdio/stdiooutput.c, tests/stdlib/atexit.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/getenv.c, tests/stdlib/labs.c, + tests/stdlib/ldiv.c, tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/realloc.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + Use CYG_TEST_NA() macro for non-applicable test configurations + +1999-02-20 Jonathan Larmour + + * include/signal.h: + * include/signal.inl: + * src/signal/raise.cxx: + * src/signal/siginit.cxx: + * src/signal/signal.cxx: + * tests/signal/signal1.c + * tests/signal/signal2.c: + New files to implement ISO standard signals + + * src/PKGconf.mak (TESTS): + * tests/PKGconf.mak (TESTS): + Update to build new files above + + * include/stdlib.h: + * src/clibincl/stdlibsupp.hxx: + Comment and QA changes (including giving better names to some types) + + * include/libc.h: + Add new configuration options for signals + Add new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + Add a note to CYGNUM_LIBC_MAIN_STACK_SIZE option that it may be + overriden by HAL + Add new CYGFUN_LIBC_ATEXIT option and move ...ATEXIT_HANDLERS under + it + Add new CYGSEM_LIBC_EXIT_CALLS_FFLUSH option + Require CYGSEM_LIBC_STARTUP_MAIN_THREAD for "Invoke default static + constructors" option + + * src/stdlib/atexit.cxx: + Support above CYGFUN_LIBC_ATEXIT and QA changes + + * src/stdlib/exit.cxx: + Support for above new libc.h options, and some QA changes + + * src/support/cstartup.cxx: + Add support for new CYGSEM_LIBC_STARTUP_MAIN_THREAD option + + * src/support/mainthread.cxx: + Override main stack size if the HAL has a minimum + + * src/string/strncpy.cxx: + Use improved algorithm for aligned copies - imported from newlib + QA changes + + * src/stdlib/abort.cxx: + Support raise(SIGABRT), and some QA + + * include/errno.h: + Add const attribute + + * tests/stdlib/abs.c: + QA improvements + +1999-02-04 Jesper Skov + + * src/support/cstartup.cxx: Only define cyg_libc_main_thread when + the kernel is around. + +1999-02-01 Jesper Skov + + * tests/time/clock.c: Joined the two test/NOP checks into + one. + Increased tolerance in attempt to fix PRs 18737,18787,18846. + Fixed typo. + +1999-01-28 Jonathan Larmour + + * src/string/strtok.cxx: + * src/stdlib/rand.cxx: + Include if we use kernel header files + +1999-01-25 Jonathan Larmour + + * tests/stdio/sscanf.c (test): + CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT should be + CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT + Fix for PR 18786 + + * src/string/strtok.cxx: + * src/stdio/common/stdiofiles.cxx: + * src/errno/errno.cxx: + * src/stdlib/rand.cxx: + Give mutex protection objects a libc constructor priority + + * src/support/invokemain.cxx: + Add prototype for cyg_hal_invoke_constructors() + + * src/support/mainthread.cxx: + Give cyg_libc_dummy_constructor_obj a libc constructor priority, + and make its class have a public constructor + + * src/stdio/common/stderr.cxx: + * src/stdio/common/stdout.cxx: + * src/stdio/common/stdin.cxx: + Give cyg_libc_stdio_stdin/out/err static objects a libc constructor + priority + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + * src/clibincl/stream.hxx (class Cyg_StdioStream): + Remove private copy constructor. Needed to make prioritised + static constructors work. Fix for PR 18898 + +1999-01-22 Jonathan Larmour + + * src/errno/errno.cxx: + Include pkgconf/kernel.h otherwise it fails with per-thread errno + enabled + + * include/pkgconf/libc.h: + Enable per-thread errno by default since that is what POSIX would + want + + * tests/time/clock.c (test): + Placate compiler by initializing clock_first/second/third anyway, + even though they won't be in practice. This is only a test program + so adding an extra instruction doesn't matter. + + * src/i18n/locale.cxx (_setlocale): + Placate compiler, since it is dumb, by nesting, not serializing, if's + This is an idempotent change, but screws up the formatting :-(. + + * src/string/strpbrk.cxx (_strpbrk): + Change while loop to do loop to placate compiler. It'll even save an + instruction too (wow!) + +1999-01-22 John Dallaway + + * include/pkgconf/libc.h: + Add closing curly brace to CYGPKG_LIBC_STRING_STRTOK definition + +1999-01-21 Jonathan Larmour + + * include/errno.h: + Tidy up and add to header description + Change cyg_get_errno_p() to cyg_libc_get_errno_p() + Remove ifdef CYGPKG_LIBC + + * include/sys/file_if.h: + Remove - move contents to stdio.h + + * include/stdio.h: + Tidy up header description + Move FILE typedef here from sys/file_if.h + SEEK_SET, SEEK_CUR, SEEK_END defined to 0, 1, 2 respectively + for backwards compatibility with old UNIX + Change definitions of stdin/out/err to be addresses of FILE + globals - even though they're actually Cyg_StdioStream it'll work + + * include/pkgconf/libc.h: + Make CYGPRI_LIBC_WEAK et al macros depend on new ones in infra + Reorganise trace options under the individual components they are + associated with. + Reorganise thread-safety options under the individual components + they are associated with. + Add new CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS option + Misc. reformatting + Remove dependency on pkgconf/kernel.h - Configuration Tool will + generate check macros anyway. + Remove CYGPKG_LIBC_TRACE, CYGFUN_LIBC_strtok, CYGPKG_LIBC_RAND + options + Tidy up description header + + * src/clibincl/clibdata.hxx: + * src/clibincl/clibdata.inl: + * src/support/clibdata.cxx: + Remove and instead rely on each component to initialise its own data + + * src/clibincl/stdiofiles.hxx, src/clibincl/stdiofiles.inl: + New files to contain global file list and lock (if applicable). + Implemented as class with member access functions + + * src/errno/errno.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Rename cyg_get_errno_p() to cyg_libc_get_errno_p() + + * src/stdio/common/fclose.cxx: + * src/stdio/common/fflush.cxx: + * src/stdio/common/fopen.cxx: + * src/stdio/common/freopen.cxx: + Remove ifdef CYGPKG_LIBC + Use new global file access method from stdiofiles.hxx + Tidy up description header + Use new CYGBLD_ATTRIB_WEAK_ALIAS + Access errno "normally" rather than clibdata way + + * src/stdio/common/stdin.cxx: + * src/stdio/common/stdout.cxx + * src/stdio/common/stderr.cxx: + New files. Implement Cyg_StdioStream objects for each stream. In + separate self-contained files so using one doesn't bring in the + others + + * src/stdio/common/stdiofiles.cxx: + New file. Implements global files array and lock + + * src/stdlib/_exit.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Use infra CYGBLD* macros + + * src/stdlib/malloc.cxx: + Tidy up description header + Remove ifdef CYGPKG_LIBC + Add pkgconf/kernel.h now that pkgconf/libc.h doesn't have it + Use infra CYGBLD* macros + Make pool visible externally with weak attribute and new name + cyg_libc_malloc_memorypool + + * src/stdlib/rand.cxx: + * src/stdlib/strtok.cxx: + Reorganise with self-contained per-thread data, if applicable + Remove ifdef CYGPKG_LIBC + Tidy up description header + Use infra CYGBLD* macros + + * src/support/cstartup.cxx: + Split into smaller files to make selective linking work better, + fix i386 port problem and make GDB happy + + * src/support/environ.cxx: + * src/support/invokemain.cxx: + * src/support/main.cxx: + * src/support/mainthread.cxx: + New files from bits of the old cstartup.cxx + Add support for CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG + + * src/PKGconf.mak: + Update to reflect file additions/deletion + + * tests/stdlib/rand1.c: + * tests/stdlib/rand2.c: + * tests/stdlib/rand3.c: + * tests/stdlib/srand.c: + Make conform to coding standards + Remove ifdef CYGPKG_LIBC_RAND + Tidy up description header + + * tests/string/strtok.c: + Make conform to coding standards + Remove ifdef CYGFUN_LIBC_strtok + Tidy up description header + +1999-01-15 Mark Galassi + + * tests/stdlib/getenv.c (main): added tests for the case in which + the user does not supply environ and in which the user supplies a + NULL environ. + +1999-01-15 Jesper Skov + + * src/support/cstartup.cxx: Added workaround for weak aliasing + problem in i386 gcc. + + +1999-01-15 Gary Thomas + + * include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_STACK_SIZE): + (CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE): Change defaults to be + more reasonable on small systems. + +1999-01-04 Jonathan Larmour + + * src/support/clibdata.cxx: + Minor bug with environ not being initialised correctly by + default + +1998-12-24 Bart Veer + + * src/clibincl/stream.inl (Cyg_StdioStream): + check_this() member functions should now be const + +1998-12-22 Jonathan Larmour + + * src/string/memchr.cxx (_memchr): + treat search value parameter to memchr as an unsigned byte, + not a signed int - copied fix from newlib PR 18471 + +1998-12-21 Jonathan Larmour + + * tests/stdlib/realloc.c: + * tests/stdlib/malloc3.c: + * tests/stdlib/malloc2.c: + Warning cleanup + +1998-12-14 Jonathan Larmour + + * tests/stdlib/malloc2.c, tests/stdlib/malloc3.c, + tests/stdlib/realloc.c: + Only run these tests when we have a coalescing memory allocator + +1998-12-14 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Only check buffer init success if buffering + + * src/stdio/common/streambuf.cxx (set_buffer): + Check for diff of requested size against buffer_size, not + get_buffer_size(), since this may return -1, which won't be + equal to size, and will cause malloc to be called + +1998-12-01 Jesper Skov + + * tests/stdlib/getenv.c (main): Don't declare variables when they + are not used. + +Thu Nov 26 17:59:12 1998 Jonathan Larmour + + * tests/string/strncpy1.c: + Fix off-by-one error since it called my_strcmp() and not + my_strncmp(), which meant in included the trailing NULL when it + shouldn't have. + +1998-11-26 Jesper Skov + + * src/stdlib/qsort.cxx (_qsort): + * src/stdlib/rand.cxx (_srand): + Changed CYG_REPORT_FUNCNAMETYPE to CYG_REPORT_FUNCNAME in void + functions. + +Mon Oct 26 18:49:00 1998 Jonathan Larmour + + * src/support/cstartup.cxx (cyg_libc_dummy_main): + Silence compiler warning with cast of char * to CYG_ADDRWORD + +Wed Oct 28 17:31:21 1998 Jonathan Larmour + + * src/time/clock.cxx (_clock): + Reorder scaling expression as it was both incorrect and risked + overflow. + Fix for PR 18076 + +Mon Oct 19 14:40:06 1998 Jonathan Larmour + + * include/stdio.h (EOF): + Change from -64 to (-1), to allow broken code to work :-/ + Also change other negative defines to be within parentheses + +1998-10-19 Mark Galassi + + * include/pkgconf/libc.h: updated the doc URL + +Thu Oct 15 21:33:44 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Only include kernel thread headers when we're in thread-safe mode + + * src/time/clock.cxx: + Only include kernel clock headers if there's a kernel with the + right functionality available + + * tests/time/clock.c: + Remove unnecessary inclusion of + + Above changes are required for PR 17229 + +Wed Oct 14 16:38:55 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise inclusion of clibincl/stdiosupp.hxx and + clibincl/stream.hxx. Tidying up PR 17502 + +Wed Oct 14 14:08:56 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Rename CYGPKG_LIBC_STRING_OPTIMISATIONS to + CYGPKG_LIBC_STRING_OPTIMIZATIONS to make it truely merkin. + +Tue Oct 13 19:34:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGDAT_LIBC_ARGUMENTS): + Add a default argv[0] of "" as many programs assume argc>0 + The standard allows argv[0] to be "" if the program name + is not available + +1998-09-26 Bart Veer + + * src/clibincl/stdiosupp.hxx: + PR 17502: this header file now does nothing if the stdio option + is disabled completely. This is the same behaviour is + clibincl/stream.hxx, although arguably the #ifdef protection + should happen wherever the header file is #include'd rather than + in the header file itself. + + * src/clibincl/clibdata.hxx: + PR 17502: this header file still #include's internal stdio-related + header files and references the FILE structure, even if stdio is + disabled. There were some #ifdef's for CYGPKG_LIBC_STDIO already. + One more has been added for _fopen() and _fclose(). + +1998-09-25 Bart Veer + + * src/clibincl/streambuf.inl (Cyg_StdioStreamBuffer): + PR 17487: Reorder the calls to initialize member fields, to + eliminate a compiler warning. + +Fri Sep 25 19:04:29 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/string/strtok.cxx, + src/time/clock.cxx: + Only define tracing variable and tracing level macro when + the relevant tracing level config options are set. Otherwise + keep the tracing level fixed at 0 + Fix for PR 17476 + + * include/pkgconf/libc.h: + Define trace levels only if parent CYGPKG_LIBC_TRACE is defined + for consistency with Configuration Tool + + +Fri Sep 25 17:24:45 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Make definition of vscanf() dependent on CYGFUN_LIBC_STDIO_ungetc + otherwise _vfscanf() won't be compiled. This therefore would + cause a link fail iff selective linking is not enabled. + Fix for PR 17455 + +Fri Sep 25 17:23:17 1998 Jonathan Larmour + + * src/stdlib/rand.cxx: + Make compilation dependent on CYGPKG_LIBC_RAND + Fix for PR 17473 + + * tests/stdlib/srand.c: + Make definition of dummy test pass conditional on CYGPKG_LIBC_RAND + not being defined, as well as CYGPKG_LIBC + Caused compilation failure when testing PR 17473 fix + +Mon Sep 21 17:11:04 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Make sscanf test conditional on CYGFUN_LIBC_STDIO_ungetc since + _vfscanf() only gets compiled if this is defined + Fix for PR 17346 + +1998-09-20 Mark Galassi + + * include/pkgconf/libc.h: updated CDL doc strings. + +Fri Sep 18 22:18:47 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_errno_p): + Rather than this function only being available in thread-safe mode, + instead make what it returns be either the per-thread errno, or + global errno depending on the configuration. + Include (conditionally) to support this change + +Wed Sep 16 11:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove "fix me" comment which I forgot to remove before + +Tue Sep 15 19:27:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Updated descriptions and a few other minor things after review. + Notably though, the NDEBUG config option has been removed + +1998-09-15 Bart Veer + + * include/pkgconf/libc.h: + PR 17201: removed dependency on CYGPKG_KERNEL in the option + CYGNUM_LIBC_MAIN_STACK_SIZE, since the actual dependencies cannot + be expressed sensibly in the current system. + +1998-09-11 Bart Veer + + * include/pkgconf/libc.h: + Sorting out dependencies for error package. + +1998-09-10 Mark Galassi + + * include/pkgconf/libc.h: started adding doc fields to the + cdl_package data, as a pilot for now. + +Wed Sep 9 17:41:23 1998 Hugo Tyson + + * include/pkgconf/libc.h: + Add option CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE to explicitly + control whether the empty delete functions (currently) in + kernel/.../common/delete.cxx are enabled; controls code bloat, see + the comments in delete.cxx. + +Fri Sep 4 16:43:38 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add a default CYG_TEST_PASS() to make sure the test infra doesn't + complain. + Also remove the unused string functionsa + +Fri Sep 4 15:43:48 1998 Hugo Tyson + + * src/stdlib/exit.cxx (__libc_exit): + * src/stdlib/_exit.cxx (__libc__exit): + * src/stdlib/malloc.cxx (_free): + * src/stdlib/abort.cxx (abort): + * src/support/cstartup.cxx (invoke_main): + Tracing system asserted cos it was being called incorrectly; these + are void functions so you shouldn't give a type to the function + reporting call. + +Fri Sep 4 15:03:10 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Fix CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE description to refer to + the table.cxx file, not table.h + +Fri Sep 4 14:38:52 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add description for CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE since + Proven won't be making any changes to the device driver + implementation after all. + Fix for PR 17148 + + * src/clibincl/stream.inl (set_position): + Remove "fix me" line. It is obvious that this will have to change + with a filesystem interface + Fix for PR 17147 + + * src/stdio/common/freopen.cxx: + Remove "fix me" - I know about this issue + Fix for PR 17145 + + * src/stdio/common/stream.cxx (read): + Remove "fix me" and change to use memcpy + Fix for PR 17144 + +Fri Sep 4 14:36:47 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Actually add it this time! + +Fri Sep 4 13:48:13 1998 Jonathan Larmour + + * tests/stdio/stdiooutput.c: + Add new tests for misc stdio output functions + + * tests/PKGconf.mak: + Build stdiooutput.c test + +Fri Sep 4 12:52:10 1998 Jonathan Larmour + + * src/clibincl/stream.inl (write_byte): + Remove bogus assert + + * tests/stdlib/getenv.c (main): + Check whether str is NULL before doing a strcmp() + + * tests/stdio/sprintf2.c (main): + Reformat to 76 columns + +Fri Sep 4 02:10:54 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/stdio/common/stream.cxx: + Add new peek_byte method to Cyg_StdioStream + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix up buffer access to work with new peek_byte method above + Fix for PR 16954 + +Thu Sep 3 19:40:11 1998 Jonathan Larmour + + * tests/stdlib/rand1.c, tests/stdlib/rand2.c, + tests/stdlib/rand3.c: + Add extra check for CYGPKG_LIBC_RAND to decide whether the test + is applicable or not + + * tests/stdlib/rand2.c (test): + Use CYGNUM_LIBC_RAND_SEED for default seed, not 1 + + * tests/string/strtok.c: + Add extra check for CYGFUN_LIBC_strtok to decide whether the + test is applicable or not + +Wed Sep 2 19:11:40 1998 Jonathan Larmour + + * src/stdio/input/fread.cxx, src/stdio/output/fwrite.cxx: + Add fread() and fwrite() functions + + * src/PKGconf.mak: + Build fread.cxx and fwrite.cxx from above + + * src/stdio/common/stream.cxx: + Reformat to 76 columns + In write(), move initialisation of *bytes_written to start + In read(), move initialisation of *bytes_read to start + + * include/stdio.h: + Reformat to 76 columns + + Replace all references to the ANSI + standard to instead by the ISO C standard + + Add commented argument names for "documentation" + + Add fread() and fwrite() prototypes + + * src/clibincl/stdiosupp.hxx: + Copy the above changes from stdio.h, and add _fread() and _fwrite() + prototypes + + * src/stdio/output/fputs.cxx, src/stdio/input/fgets.cxx: + Reformat to 76 columns + +Wed Sep 2 15:41:15 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Reformat to 76 columns + +Wed Sep 2 14:46:18 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Use trylock_me() instead of lock_me(), and loop to prevent + deadlocks + + * src/clibincl/stream.hxx, src/clibincl/stream.inl: + Add trylock_me() method + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/fflush.cxx: + Reformat to 76 columns + +Wed Sep 2 12:24:27 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change 0x7fff to 0x7fffffff. Oops! + give main stack size option a legal_values field + Undefine tracing by default + Add some more description in the header + +Tue Sep 1 20:02:07 1998 Jonathan Larmour + + * tests/i18n/setlocale.c (cyg_package_start): + Fix typo - extra "x" for no reason at all! :-) + +Tue Sep 1 19:44:58 1998 Jonathan Larmour + + * src/i18n/locale.cxx: + Fix bug in find_locale_data() that miscalculated size of + all_locales + + Make find_locale_data() match the locale "" and add some + other things in _setlocale() to ensure that "C" gets returned + when the default locale "" is passed. + + Only check the locale pointer when it is non-NULL + + * tests/i18n/setlocale.c: + New tests for setlocale() + + * tests/PKGconf.mak: + Update to build setlocale.c test + + * src/support/cstartup.cxx: + Don't actually call system default main() "main" otherwise GDB + gets confused and thinks its the entry point. Instead make a weak + alias and call the real function something different. + +Tue Sep 1 18:31:42 1998 Jonathan Larmour + + * src/i18n/locale.cxx (_setlocale): + Fix tracing macro name and remove "str maybe used before + initialised" warning + + * tests/stdlib/qsort.c: + Correct file description header + +Tue Sep 1 17:04:32 1998 Jonathan Larmour + + * include/locale.h, src/clibincl/i18nsupp.hxx, src/i18n/locale.cxx: + New files to add support for locales as defined by the ISO C + standard. i.e. setlocale() and localeconv() functions and some + other bits + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAX_LOCALE_NAME_SIZE config option for locale + support + + * src/PKGconf.mak: + build locale.cxx + + * include/errno.h, src/clibincl/ctypesupp.hxx: + Tidy up to 76 columns + +Tue Sep 1 00:24:22 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Move environment-related options from stdlib into new + CYGPKG_LIBC_STARTUP component. Also add options for main()'s + arguments (CYGPKG_LIBC_ARGUMENTS), main()'s default stack size + (CYGNUM_LIBC_MAIN_STACK_SIZE), number of atexit handlers + (CYGNUM_LIBC_ATEXIT_HANDLERS), and whether _exit() stops the + system (CYGSEM_LIBC_EXIT_STOPS_SYSTEM). + + * src/clibincl/stdlibsupp.hxx: + Fix a few comment bugs, and add new + cyg_libc_invoke_atexit_handlers() function prototype + + * src/stdlib/_exit.cxx, src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Implement exit(), atexit() and _exit() correctly now. Also + includes cyg_libc_invoke_atexit_handlers() in atexit.cxx. Now + we get the correct behaviour of atexit(), and exit() invokes the + atexit handlers and fflushs all the stdio streams. Add plenty of + tracing of asserts too. + + * src/support/cstartup.cxx: + Make main_thread object an exported global. Allow user-settable + arguments. Add MUCH more tracing and asserts. Improve comments. + Tidy up to 76 columns + + * tests/stdlib/atexit.c: + Add simple test for atexit() and it calling registered functions + + * tests/PKGconf.mak: + Build atexit.c test + +Mon Aug 31 18:54:48 1998 Jonathan Larmour + + * src/stdlib/getenv.cxx, tests/stdlib/getenv.c: + Add support for getenv(), and some tests to ensure it works + + * src/PKGconf.mak, tests/PKGconf.mak: + Update to include getenv.cxx and getenv.c test + + * src/clibincl/clibdata.hxx: + remove prototype for environ - we expect files needing it to + define it themselves + + * src/support/clibdata.cxx: + Tidy up to 76 columns and add definition of char **environ, but + with a configurable initialiser (see libc.h below) + + * tests/stdlib/abs.c (main): + Tidy up to 76 columns + + * src/stdlib/malloc.cxx: + Tidy up to 76 columns and remove warning for undefined _memcpy() + by changing to memcpy(), and casting away signedness + + * include/pkgconf/libc.h: + Add CYGPKG_LIBC_ENVIRONMENT and CYGDAT_LIBC_DEFAULT_ENVIRONMENT + configuration options + + * include/pkgconf/libc.h, src/clibincl/clibdata.hxx: + Tidy up to 76 columns + + * include/stdlib.h: + Add getenv() prototype and tidy up to 76 columns + + * src/clibincl/stdlibsupp.hxx: + Add _getenv() prototype + +Mon Aug 31 13:37:08 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Add realloc() + + * tests/stdlib/realloc.c: + Add this file to test new realloc() functionality + + * tests/PKGconf.mak: + Build realloc test + + * tests/stdlib/malloc3.c (main), tests/stdlib/malloc2.c (main), + tests/stdlib/malloc1.c (main): + Conditionalise local vars to prevent warnings + + * tests/stdlib/malloc3.c (fill_with_data): + Move '{' into "verb" line + + * include/pkgconf/libc.h: + Require infra tracing support to allow tracing + + * include/stdlib.h: + Add realloc() + + * src/clibincl/stdlibsupp.hxx: + Update the commented argument names from stdlib.h, including realloc() + +1998-08-28 Bart Veer + + * include/pkgconf/libc.h: + * src/clibincl/clibdata.hxx, src/time/clock.cxx: + + Updated for new kernel configuration option symbol names + +Fri Aug 28 19:18:25 1998 Hugo Tyson + + Changed the entry below to sat "tx39" instead of "mn10300". + It's been a long week. + +Fri Aug 28 18:59:20 1998 Hugo Tyson + + * src/support/cstartup.cxx: Add a weakly named main to allow the + default configuration to link on the tx39 which has no + scalextric linking yet. The static Cyg_Thread main_thread object + below continues to exist, though unreferenced, so all its + descendants must exist too. + +Fri Aug 28 08:54:29 1998 Jonathan Larmour + + * include/stdlib.h: + Add commented argument names Add exit(), and atexit(). And move + these along with abort() and _exit() to a new section. + + * src/stdlib/atexit.cxx, src/stdlib/exit.cxx: + Add trivial versions of atexit() and exit() + + * include/pkgconf/libc.h: + Add CYGNUM_LIBC_MAIN_STACK_SIZE config option + + * include/sys/cstartup.h, src/support/cstartup.cxx, src/PKGconf.mak: + New files to provide a new function cyg_iso_c_support(), which + invokes main "correctly". + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, + tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c, + tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/srand.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcoll2.c, tests/string/strcpy1.c, + tests/string/strcpy2.c, tests/string/strcspn.c, + tests/string/strlen.c, tests/string/strncat1.c, + tests/string/strncat2.c, tests/string/strncpy1.c, + tests/string/strncpy2.c, tests/string/strpbrk.c, + tests/string/strrchr.c, tests/string/strspn.c, + tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, + tests/time/clock.c: + + Modify all tests to use new startup mechanism, and cyg_iso_c_start() + +Fri Aug 28 00:29:38 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx: + Add #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO around all accesses to + flags.last_buffer_op_was_read. Fix for PR 16997 + +Thu Aug 27 01:12:42 1998 Jonathan Larmour + + * include/sys/file_if.h: + Fix comments and remove cyg_get_file_star() + +Wed Aug 26 20:24:32 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Remove #define CYGPKG_LIBC is that is meant to live in + after all + +Wed Aug 26 19:39:23 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + More fixes to CDL stuff to make it work better, and look better on + the screen + +Tue Aug 25 20:21:41 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Make some fixes after running the ConfigTool + +Tue Aug 25 16:46:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h (CYGNUM_LIBC_STDIO_BUFSIZE): + Fix typo of CYGNUM_LIBC_STDIO_BUFSIZE + +Tue Aug 25 15:10:57 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Tidy up CDL stuff a bit more, prior to checking it actually works. + +Tue Aug 25 11:38:52 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c (main): + Prevent calls to CYG_TEST_STILL_ALIVE for now + +Tue Aug 25 05:39:28 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change cosmetic paragraph alignment. + +Tue Aug 25 03:11:34 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Make stderr initialise with buffer size 0. + For PR 16955 + +Mon Aug 24 17:38:46 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + First pass at CDL-ifying the C library configuration. Currently + deliberately disabled as there a few outstanding issues. + +Mon Aug 24 16:14:22 1998 Jonathan Larmour + + * src/stdio/output/vfnprintf.cxx (_vfnprintf): + clear up warning for unused argument + + * tests/stdlib/malloc2.c (NUM_ITERATIONS): + Lower to 100 from 50000 so it won't take too long under the simulator + +Thu Aug 20 17:48:43 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Remove now unnecessary inclusion of kernel/ktypes.h + +Wed Aug 19 19:19:14 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, + tests/stdio/sscanf.c, tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, + tests/stdlib/strtoul.c, tests/string/strtok.c, + tests/time/clock.c: + Add parameters to "main()" to silence warnings + +Wed Aug 19 18:52:59 1998 Jonathan Larmour + + * src/stdio/common/stream.cxx (refill_read_buffer): + Put conditional error check into same #ifdef and if as what was being + checked in the first place! + +Wed Aug 19 18:49:19 1998 Jonathan Larmour + + * src/clibincl/stream.inl: + Reorder Cyg_StdioStream::check_this() to be first to silence + warnings + +Tue Aug 18 16:10:03 1998 Jonathan Larmour + + * ecc/language/c/libc/current/src/clibincl/clibdata.hxx, + ecc/language/c/libc/current/src/errno/errno.cxx, + ecc/language/c/libc/current/src/stdio/common/fopen.cxx, + ecc/language/c/libc/current/src/stdlib/rand.cxx, + ecc/language/c/libc/current/src/string/strtok.cxx: + Rename CYGIMP_LIBC_INTERNAL_DATA_PREAMBLE, + CYGIMP_LIBC_INTERNAL_DATA_ALLOC_CHECK_PREAMBLE, + CYGVAR_LIBC_INTERNAL_DATA, and + CYGIMP_LIBC_INTERNAL_DATA_CHECK to all have CYGPRI_ prefix instead + as recommended by the config name rules + + +Tue Aug 18 14:31:19 1998 Jonathan Larmour + + * src/stdio/common/setvbuf.cxx (_setvbuf): + Rename variable names in assert line, otherwise doesn't build + with asserts on! + +Sun Aug 16 18:15:12 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx (_vfscanf): + Fix some bugs, although there are some left to fix still. Unrelated + to the rest of the checkins, so I will check the partial fix in now. + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx: + Add parameters to constructor to allow more things to be done at + construction time. + + Now we have "new", remove separate "construct" method + + Add more documentation on constructor + + As requested by code review, where possible, move boolean flags + into separate packed bitfield structure for space efficiency + + Make readbuf_char be usable all the time rather than when configured + not to be buffering, as it is also needed for non-buffered mode i.e. + _IONBF + + * src/stdio/common/fopen.cxx: + Change to use new method of construction from above, using new + + Use thread-specific data, rather than global. And so change errnos + to access errno entry specifically + + Make process_mode() check for append mode too + + Reformat for coding standards to have { in same line as "verb" + + * src/stdio/common/setvbuf.cxx: + + Change to cope with different way of dealing with buffering policy + flags etc. in Cyg_StdioStream + + * src/stdio/common/vsnprintf.cxx, src/stdio/common/vsscanf.cxx, + src/support/clibdata.cxx: + Change construction of streams to use new parameters added above, + and change to use _IONBF mode for string stdio functions, + otherwise its a waste of memory. And use _IONBF for stderr as the + ISO standard tells us to! + + Reformat for coding standards to have { in same line as "verb" + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Change constructor so that it can be set with default size and + dynamic buffer (if applicable) + + Fix minor bug in destructor - should only call free when allocated + dynamically + + Change get_buffer_size to return -1 if the buffer was not allowed + to be set up + + * src/stdio/common/streambuf.cxx: + Remove unnecessary stdio.h include and add extra comment to whether + to free bit in set_buffer() + + * src/stdio/common/freopen.cxx: + Change @@@ to standard fix me string + + * src/stdio/output/fputc.cxx: + Remove unnecessary "written" variable + +Thu Aug 13 15:37:28 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: + Included use of "fix me" line to ensure this is discussed before + release + + * include/stdlib.h, src/stdlib/abort.cxx, src/PKGconf.mak: + Add abort.cxx to implement abort(), albeit naively + +Thu Jul 30 18:03:09 1998 Jonathan Larmour + + * src/stdio/common/vsscanf.cxx (_vsscanf), + src/stdio/common/vsnprintf.cxx (_vsnprintf): + Fix initialiser of pseudo string device table that didn't get updated + when the table changed (Bad proven, no biscuit). + + * src/clibincl/stream.inl (~Cyg_StdioStream): + Move invalidation of magic_validity_word to after unlock_me(), + otherwise it always fails! + +Tue Jul 28 21:29:53 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx: + Shorten over-long lines + +Tue Jul 28 20:28:23 1998 Jonathan Larmour + + * src/clibincl/stream.hxx (class Cyg_StdioStream), + src/clibincl/stream.inl, src/stdio/common/stream.cxx: + Clarify some comments and get the CYGDBG_DEFINE_CHECK_THIS and + CYG_ASSERTCLASS stuff going + + * src/clibincl/stream.inl: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 15:31:06 1998 Jonathan Larmour + + * src/clibincl/streambuf.inl, src/stdio/common/streambuf.cxx: + Move set_buffer() from streambuf.inl to new file streambuf.cxx + + * src/PKGconf.mak (COMPILE): + Build new file streambuf.cxx + + * src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer): + Add METHODS comment + + * src/stdio/common/stream.cxx: + Put '{'s on same line as "action" as per coding standards + Shorten over-long lines + +Tue Jul 28 00:26:36 1998 Jonathan Larmour + + * include/stdlib.inl, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/div.cxx, + src/stdlib/ldiv.cxx, src/stdlib/qsort.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/string/strtok.cxx: + + Include proper Berkeley license inline in the file, rather than + referring to an external file + + * doc/COPYING.UCB: + Remove, now that it isn't referred to any more + +Mon Jul 27 23:34:26 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl, include/errno.h, + include/stdio.h, include/stdio.inl, include/stdlib.h, + include/stdlib.inl, include/string.h, include/string.inl, + include/time.h, include/sys/file_if.h, src/PKGconf.mak, + src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/stdiosupp.hxx, + src/clibincl/stream.hxx, src/clibincl/streambuf.hxx, + src/clibincl/streambuf.inl, src/clibincl/stringsupp.hxx, + src/clibincl/timesupp.hxx, src/ctype/isalnum.cxx, + src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, + src/ctype/islower.cxx, src/ctype/isprint.cxx, + src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, + src/ctype/tolower.cxx, src/ctype/toupper.cxx, + src/errno/errno.cxx, src/stdio/common/snprintf.cxx, + src/stdio/common/sprintf.cxx, src/stdio/common/sscanf.cxx, + src/stdio/common/stdioinlines.cxx, src/stdio/common/stream.cxx, + src/stdio/common/ungetc.cxx, src/stdio/common/vsnprintf.cxx, + src/stdio/common/vsscanf.cxx, src/stdio/input/fgetc.cxx, + src/stdio/input/fgets.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/gets.cxx, src/stdio/input/scanf.cxx, + src/stdio/output/fnprintf.cxx, src/stdio/output/fprintf.cxx, + src/stdio/output/fputc.cxx, src/stdio/output/fputs.cxx, + src/stdio/output/printf.cxx, src/stdlib/_exit.cxx, + src/stdlib/abs.cxx, src/stdlib/atof.cxx, src/stdlib/atoi.cxx, + src/stdlib/atol.cxx, src/stdlib/div.cxx, src/stdlib/labs.cxx, + src/stdlib/ldiv.cxx, src/stdlib/rand.cxx, src/stdlib/strtod.cxx, + src/string/memchr.cxx, src/string/memcmp.cxx, + src/string/memmove.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, + src/string/strcoll.cxx, src/string/strcpy.cxx, + src/string/strcspn.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx, src/string/strpbrk.cxx, + src/string/strrchr.cxx, src/string/strspn.cxx, + src/string/strstr.cxx, src/string/strsuppt.cxx, + src/string/strtok.cxx, src/string/strxfrm.cxx, + src/support/clibdata.cxx, src/time/clock.cxx: + Untabify + +Mon Jul 27 23:14:18 1998 Jonathan Larmour + + * src/errno/errno.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/output/vfnprintf.cxx, src/stdlib/strtol.cxx, + src/stdlib/strtoul.cxx, src/stdlib/malloc.cxx, src/stdlib/qsort.cxx, + tests/ctype/ctype.c, tests/stdlib/rand3.c, tests/stdlib/malloc3.c: + Remove all mentions of "register" in variable declarations. Also + untabify where needed + + * src/stdlib/bsearch.cxx: + Untabify this too + + +Mon Jul 27 22:18:51 1998 Jonathan Larmour + + * src/stdio/output/fputc.cxx (_fputc): + Replace call to stream write() with call to write_byte() + + * src/clibincl/stream.inl (write_byte): + Add asserts for stream write() returning odd values for how much has + been written + + (bytes_available_to_read): + Remove "register" def for variable declaration + +Mon Jul 27 22:06:22 1998 Jonathan Larmour + + * src/stdio/common/stdiosupp.cxx: + Remove #if 0'd cyg_get_file_star() and unnecessary pseudo string + device definition + +Mon Jul 27 21:57:25 1998 Jonathan Larmour + + * include/pkgconf/libc.h, src/support/clibdata.cxx: + Change CYGXXX_LIBC_STDIO_DEFAULT_CONSOLE to + CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE + +Mon Jul 27 21:49:23 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl, + src/clibincl/ctypesupp.hxx, src/clibincl/setjmpsupp.hxx, + src/clibincl/stdiosupp.hxx, src/clibincl/stdlibsupp.hxx, + src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl, + src/clibincl/stringsupp.hxx, src/clibincl/timesupp.hxx: + + Change CYGONCE_LIBC_*_{HXX,INL} to CYGONCE_LIBC_CLIBINCL_*_{HXX,INL} + +Mon Jul 27 21:34:05 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Change #define XXXXX 1 to #define XXXXX where applicable as per code + review + + Also remove obsolete CYGIMP_LIBC_THREAD_START_SUSPENDS_SELF + +Mon Jul 27 19:42:27 1998 Jonathan Larmour + + * src/stdio/common/fopen.cxx (_fopen): + Use #ifdef, not #if for config options + +Mon Jul 27 15:01:51 BST 1998 Chris Provenzano + + * src/stdio/common/stream.cxx, src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx: + Fixes to compile with the new Cyg_IORB field names. + +Thu Jul 9 03:40:21 1998 Jonathan Larmour + + * tests/stdlib/atoi.c, tests/stdlib/atol.c, + tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Adjust starting of tests to possibly start scheduler since + strtol/stroul rely on errno, which may be a per-thread variable + +Thu Jul 9 03:06:25 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/stream.inl, + src/stdio/common/stream.cxx, src/stdio/common/setvbuf.cxx: + Consolidate read and write buffers into single buffer, as it should + have been all along + + * src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl: + Add drain_buffer() method to speed up the case when we want the + buffer completely emptied + +Tue Jul 7 21:26:33 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Add a couple of new tests that check that very long strings work too + +Wed Jul 1 19:52:39 1998 Jonathan Larmour + + * src/clibincl/stream.hxx, src/clibincl/streambuf.hxx: + Do not permit copy constructors + + * src/clibincl/stream.inl, src/stdio/common/fclose.cxx: + Make sure we use #ifdef and not #if + + * src/clibincl/streambuf.inl: + Use member initialisation list rather than explicit initialisation to + reduce warnings + +Wed Jul 1 19:17:55 1998 Jonathan Larmour + + * include/pkgconf/libc.h and all files using config options: + Rename configuration defines to make them more standard + +Thu Jun 25 20:09:30 1998 Jonathan Larmour + + * src/string/strcat.cxx: + Add parentheses on check to silence warning + (Verified by proven) + +Thu Jun 25 19:30:01 1998 Jonathan Larmour + + * src/stdlib/malloc.cxx: + Make sure that the malloc pool is initialised before other things + can use it. This is done with the hot new constructor ordering + feature. + +Thu Jun 25 18:27:03 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Remove bogus ifdef if floating point is _not_ wanted + +Thu Jun 25 17:31:42 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Fix argument checking to allow first argument of NULL + +Thu Jun 25 04:18:50 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl (get_strtok_last_p): + Remove bogus assertion + + * src/stdlib/malloc.cxx: + Got sense of alignment check assertion the wrong way round, so negate + it + +Thu Jun 25 03:56:35 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: + Fix argument checking assertions with legitimate nulls here too + +Thu Jun 25 03:46:32 1998 Jonathan Larmour + + * src/stdlib/strtoul.cxx, src/stdlib/strtol.cxx: + Fix argument checking assertions to cope with legitimate nulls + +Wed Jun 24 09:01:45 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c: + Remove extraneous info messages + +Wed Jun 24 05:59:17 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c: + + Change large automatic arrays to static arrays to prevent overuse + of a potentially small stack + +Wed Jun 24 05:45:28 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/string/strtok.c, tests/time/clock.c: + + Increase thread stack size from 4K to 32K as in some cases it was + too small. + + +Tue Jun 23 20:12:31 1998 Jonathan Larmour + + * tests/stdio/sscanf.c: + Add extra tests, including floating point conversion testing + +Tue Jun 23 17:01:06 1998 Jonathan Larmour + + * src/string/strtok.cxx: + Make sure this is only compiled if CYGFUN_LIBC_strtok is defined + +Tue Jun 23 06:10:13 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + add some comments - that's all + + * src/stdio/common/stream.cxx: + fix case in refill_read_buffer() for what to do when there's nothing + left. Now return EAGAIN + + * src/stdio/common/vsscanf.cxx, src/stdio/input/vfscanf.cxx: + Get sscanf working properly and passing tests. Also make sure it + ignores FP when its not configured + + * src/stdlib/atof.cxx: + Only compile at all if strtod() is present + + +Mon Jun 22 19:13:42 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Conditionalise strtok_last and rand_seed better + +Mon Jun 22 14:14:12 1998 Jonathan Larmour + + * tests/stdlib/malloc3.c: + Add test for checking that mallocing and freeing repeatedly works + + * tests/PKGconf.mak: + Update to reflect addition of the above + +Mon Jun 22 13:09:33 BST 1998 Chris Provenzano + + * src/stdio/common/fopen.cxx + * src/stdio/common/stream.cxx + * src/stdio/common/vsnprintf.cxx + * src/stdio/common/vsscanf.cxx + Include cyg/devs/common/iorb.h instead of iorb.hxx + + * src/stdio/common/stream.cxx + Use read_blocking and write_blocking instead of just read and + write when accessing devices through the virtual device table. + +Sun Jun 21 18:19:13 1998 Jonathan Larmour + + * src/stdio/common/stdioinlines.cxx: + Propagate change of return code handling for puts from stdio.inl + into here + + * src/stdio/output/fputc.cxx: + make sure the right type is used for output - byte not int + + * src/support/clibdata.cxx: + Fix #define config mistook. #endif was in wrong place + +Sun Jun 21 16:11:04 1998 Jonathan Larmour + + * src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl: + Allow explicit construction to get around a bug when + dynamically allocating per-thread structure + +Sun Jun 21 16:02:51 1998 Jonathan Larmour + + * tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c, + tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c, + tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c, + tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c, + tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, tests/stdlib/qsort.c, + tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c, + tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c, + tests/string/memchr.c, tests/string/memcmp1.c, + tests/string/memcmp2.c, tests/string/memcpy1.c, + tests/string/memcpy2.c, tests/string/memmove1.c, + tests/string/memmove2.c, tests/string/memset.c, + tests/string/strcat1.c, tests/string/strcat2.c, + tests/string/strchr.c, tests/string/strcmp1.c, + tests/string/strcmp2.c, tests/string/strcoll1.c, + tests/string/strcpy1.c, tests/string/strcpy2.c, + tests/string/strcspn.c, tests/string/strlen.c, + tests/string/strncat1.c, tests/string/strncat2.c, + tests/string/strncpy1.c, tests/string/strncpy2.c, + tests/string/strpbrk.c, tests/string/strrchr.c, + tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c, + tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c: + + Update tests to "do the right thing" with all configuration settings + + +Sun Jun 21 04:54:14 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + I have to be careful not to use setjmp() in a way not exactly + defined by the standard, so make sure I do, and add a comment + documenting these ways. + + Also ensure this test does the right thing in all configurations + +Sun Jun 21 04:38:15 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add extra checks for invalid configurations + Also make default for thread safety OFF + + * src/clibincl/clibdata.inl: + Adjust indentation + + * src/stdio/output/vfnprintf.cxx: + Make printf of -0.0 floating point do the right thing + +Sun Jun 21 04:28:00 1998 Jonathan Larmour + + * src/stdio/common/snprintf.cxx, src/stdio/common/sprintf.cxx, + src/stdio/common/sscanf.cxx, src/stdio/input/fscanf.cxx, + src/stdio/input/scanf.cxx, src/stdio/output/fnprintf.cxx, + src/stdio/output/fprintf.cxx, src/stdio/output/printf.cxx: + + Had to remove inline functions with varargs. Which means separating + out each function from stdioinlines.cxx into a separate file, as they + no longer belong there. So all the above files were created. + + * include/stdio.inl, src/PKGconf.mak, + src/stdio/common/stdioinlines.cxx: + Changed to take account of the above + + +Sun Jun 21 03:58:42 1998 Jonathan Larmour + + * tests/stdio/sprintf1.c, tests/stdio/sprintf2.c: + Update with floating-point tests. Also make sure they DTRT in all + configurations + +Fri Jun 19 19:33:06 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + accidentally initialised stdin/out/err twice + +Fri Jun 19 19:09:29 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Another typo + +Fri Jun 19 18:59:07 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Missing #endif typo + +Fri Jun 19 18:51:42 1998 Jonathan Larmour + + * src/support/clibdata.cxx: + Fix initialisation of static data members. Unsure how it worked at + all before! + +Fri Jun 19 18:01:01 1998 Jonathan Larmour + + * include/stdio.inl: + puts should check whether fputs returns non-negative, rather than + non-zero + +Fri Jun 19 17:22:52 1998 Jonathan Larmour + + * src/clibincl/clibdata.inl: + Make inclusion of get_errno_p conditional on thread-safety + +Wed Jun 17 10:55:32 1998 Jonathan Larmour + + * src/stdio/input/vfscanf.cxx: + Add weak alias of vfscanf() to _vfscanf() + +Wed Jun 17 09:10:41 1998 Jonathan Larmour + + * src/stdio/common/fflush.cxx: + Initialise err to silence compiler warning + +Wed Jun 17 08:59:20 1998 Jonathan Larmour + + * Most important is the addition of floating point support in + src/stdio/output/vfnprintf.cxx and src/stdio/input/vfscanf.cxx. This + also required the addition of atof() and strtod() in stdlib which is + definitely no bad thing! Other than that... + + * Fix a whole bunch of stuff I messed up first time round. Also the + sprintf and sscanf tests are included again. + +Tue Jun 16 16:38:02 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Typo with not putting comment character at the beginning. Sigh. + +Tue Jun 16 14:53:09 1998 Jonathan Larmour + + * tests/PKGconf.mak: + Forgot to (temporarily) remove fputs test for now + +Mon Jun 15 20:40:03 1998 Jonathan Larmour + + Everything to do with stdio has almost completely changed, so there's + not much point documenting individual changes. + +Mon Jun 15 18:36:01 1998 Jonathan Larmour + + * tests/stdlib/malloc2.c: + Stop it moaning quite as much when it fails by making it exit sooner + + * tests/time/clock.c : + This isn't a compound testcase + +Thu Jun 11 17:59:13 1998 Jonathan Larmour + + * include/assert.h + Reverse sense of NDEBUG ifdef, that was left in accidentally due + to testing + +Thu Jun 11 04:58:08 1998 Jonathan Larmour + + * include/errno.h, include/string.h, src/clibincl/stringsupp.hxx: + Modify as I've now added an "error" package which defines the error + codes and strerror() + + * src/errno/strerror.cxx: + Moved to new error package and thus deleted + +Wed Jun 10 18:37:37 1998 Jonathan Larmour + + * include/assert.h: + create this header and add assert() function + +Wed Jun 10 16:23:57 1998 Jonathan Larmour + + * include/stdlib.h, src/clibincl/stdlibsupp.hxx, src/stdlib/malloc.cxx: + Add malloc(), calloc() and free() functions + + * include/pkgconf/libc.h: + Add malloc memory pool size option + + * tests/stdlib/malloc1.c, tests/stdlib/malloc2.c: + new tests for malloc + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for new files + +Wed Jun 10 15:06:16 1998 Jonathan Larmour + + * tests/setjmp/setjmp.c: + Add another test + +Tue Jun 9 18:20:31 1998 Jonathan Larmour + + * include/pkgconf/libc.h: + Add some setjmp config's and a macro for the noreturn attribute + + * include/setjmp.h, include/setjmp.inl, src/clibincl/setjmpsupp.hxx, + src/setjmp/longjmp.cxx, tests/setjmp/setjmp.c: + Added to implement and test setjmp() and longjmp() + + * src/PKGconf.mak, tests/PKGconf.mak: + Update for newly added files + +Thu Jun 4 01:29:18 1998 Jonathan Larmour + + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/strcat.cxx, + src/string/strchr.cxx, src/string/strcmp.cxx, src/string/strcpy.cxx, + src/string/strlen.cxx, src/string/strncat.cxx, + src/string/strncmp.cxx, src/string/strncpy.cxx: + Rename CYGIMP_LIBC_PREFER_SMALL_TO_FAST to + CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST + + Also use slower but smaller version when __OPTIMIZE_SIZE__ is + defined (which comes from using gcc -Os) + +Fri May 29 16:15:04 1998 Jonathan Larmour + + * include/ctype.inl, src/ctype/isxdigit.cxx: + Fix bug that numerals aren't considered hex digits + + * include/time.h: + Change clock_t and time_t to be signed so that they can accept -1, as + required by other libc functions + + * src/clibincl/clibdata.hxx: + Fix typo that CYGIMP_LIBC_THREAD_SUPPORT should be ..._SAFETY + Also fix macro to allocate thread-specific data to not set variables + in a different stack-frame + + * tests/ctype/ctype.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/stdlib/qsort.c: + make ctr unsigned to prevent warnings + + * tests/stdlib/strtol.c, tests/stdlib/strtoul.c: + Fix some misunderstandings in tests, and add a few new ones + + * tests/string/strrchr.c: + Fix off by one error + + * tests/string/strspn.c: + Fix case-sensitivity problem, and off-by-one error + + * tests/string/strxfrm1.c: + Remove bogus bit of test that doesn't apply to strxfrm, and fix typo + + +Fri May 22 16:33:04 1998 Jonathan Larmour + + * src/PKGconf.mak + Remove CXXFLAGS line now that its redundant + + * tests/everything! + Do a blitz change of all tests - break some of them down into + different files, add new tests, standardize format, fix bugs, + update for recent header file changes and much more! + +Wed May 20 17:50:04 1998 Jonathan Larmour + + * tests/PKGconf.mak: + interim checkin for different dir structure for Bart + +Fri May 15 20:30:46 1998 Jonathan Larmour + + * Tidy up some loose ends I forgot: rename src/include directory to + src/clibincl. And add clibdata.inl and timesupp.hxx in there. + +Thu May 14 19:56:32 1998 Jonathan Larmour + + * Basically everything has changed in the C library. Files have + been moved, renamed, deleted and reworked. This is a major + revision, and now starts from this new baseline rather than doing + incremental changes. + +Fri Apr 17 18:43:02 1998 Jonathan Larmour + + * src/ECCconf.mak: + added for new build system (actually Bart did this, but didn't + update this ChangeLog) + +Fri Apr 17 15:03:25 1998 Hugo Tyson + + * src/stdio/device/sim.cxx: + Make it build with CYG_EMPTY_STATEMENT; the unadorned one is being + removed. + +Thu Apr 16 00:24:24 1998 Jonathan Larmour + + * All source files: + replace ECCIMP_LIBC_* conditional ifdef with CYGIMP_LIBC_* + + * include/eccconf/libc.h: + improve comments and reorder a bit + +Wed Apr 8 14:35:20 1998 Jonathan Larmour + + * Makefile.am, src/Makefile.am, tests/Makefile.am, configure.in: + many changes to integrate build structure from release tree + + * src/ctype/Makefile.am, src/ctype/Makefile.in, src/errno/Makefile.am, + src/errno/Makefile.in, src/stdio/Makefile.am, src/stdio/Makefile.in, + src/stdio/common/Makefile.am, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.am, src/stdio/device/Makefile.in, + src/stdio/output/Makefile.am, src/stdio/output/Makefile.in, + src/stdio/input/Makefile.am, src/stdio/input/Makefile.in, + src/stdlib/Makefile.am, src/stdlib/Makefile.in, + src/string/Makefile.am, src/string/Makefile.in, + src/support/Makefile.am, src/support/Makefile.in, + src/time/Makefile.am, src/time/Makefile.in: + Remove as they are now redundant with above changes + + * include/Makefile.am: + Add to support above changes + + * include/eccconf/libc.h: + Change include file for configuration from kernel to system + + * src/include/kerndiag.hxx, src/stdio/device/kerndiag.cxx, + src/time/clockfn.cxx: + Change kernel include file to eccconf/kernel.h + + * src/include/strngdev.h: + remove unnecessary kernel include + + * Makefile.in, aclocal.m4, configure, src/Makefile.in, + tests/Makefile.in, include/Makefile.in: + regenerate + +Mon Apr 6 20:55:07 1998 Jonathan Larmour + + * src/stdlib/abs.cxx, src/stdlib/atoi.cxx, src/stdlib/atol.cxx, + src/stdlib/div.cxx, src/stdlib/labs.cxx, src/stdlib/ldiv.cxx: + Separated out functions from stdlib.cxx into separate files + + * src/stdlib/stdlib.cxx: + removed to be replaced by above files + + * Makefile.am, src/stdlib/Makefile.am: + modified to support building above and not building stdlib.cxx + + * src/support/tsd.cxx: + Remove unnecessary header file includes + + * Makefile.in, src/stdlib/Makefile.in: + regenerated + +Mon Apr 6 19:19:42 1998 Jonathan Larmour + + * src/support/tsd.cxx, include/eccconf/libc.h: + remove lame hack for tx39 compiler now that its fixed + + * src/include/sim.hxx: + define constants as static to placate compiler + +Thu Apr 2 21:01:21 1998 Jonathan Larmour + + * src/ctype/ctype.cxx: + deleted and separated out into below files + + * src/ctype/isalnum.cxx, src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx, + src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, src/ctype/islower.cxx, + src/ctype/isprint.cxx, src/ctype/ispunct.cxx, src/ctype/isspace.cxx, + src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, src/ctype/tolower.cxx, + src/ctype/toupper.cxx: + Separated out individual ctype functions from ctype.cxx into separate + files + + * Makefile.am, src/ctype/Makefile.am: + modified to reflect above deletion/additions + + * Makefile.in, src/ctype/Makefile.in: + regenerated + +Thu Apr 2 19:08:26 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: optimise using prefix increments + +Thu Apr 2 15:18:15 1998 Jonathan Larmour + + * src/string/strchr.cxx: optimise setting of mask a little + +Thu Mar 26 14:07:01 1998 Jonathan Larmour + + * src/support/tsd.cxx: fixed some typos + +Thu Mar 26 11:58:47 1998 Jonathan Larmour + + * include/eccconf/libc.h, src/support/tsd.cxx: + Implement workaround for tx39 compiler bug. + + * src/include/strsuppt.hxx: + remove prototypes for _memcpy() and _memset() as they are now in the + kernel + +Wed Mar 25 18:31:53 1998 Jonathan Larmour + + * Makefile.am, src/string/Makefile.am: memcpy() and memset() are + now in the kernel so remove them from build + * include/string.h: add a comment to say as much + * Makefile.in, src/string/Makefile.in: regenerate + +Wed Mar 25 15:30:42 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx, src/include/file_if.inl: + Change _exit workaround to not cause a compiler optimisation + problem. Now just references _exit rather than calls it. + +Wed Mar 25 14:59:49 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fix bug causing tests to fail completely + for this function + +Wed Mar 25 12:55:53 1998 Jonathan Larmour + + * src/include/sim.hxx: add types to constants (oops!) + * Makefile.am: link src/stdio/device/sim.cxx + * Makefile.in: regenerated + +Wed Mar 25 04:14:30 1998 Jonathan Larmour + + * src/include/file_if.hxx, src/include/file_if.inl, + src/include/kerndiag.hxx, src/include/sim.hxx, + src/include/stdio_if.hxx, src/include/strngdev.hxx, + src/include/tsd.hxx, src/stdio/common/clearerr.cxx, + src/stdio/common/clearerr.cxx, src/stdio/common/feof.cxx, + src/stdio/common/ferror.cxx, src/stdio/common/file_if.cxx, + src/stdio/common/vsprintf.cxx, + src/stdio/device/kerndiag.cxx, src/stdio/device/sim.cxx, + src/stdio/device/strngdev.cxx, src/stdio/output/fputc.cxx, + src/stdio/output/fputs.cxx, src/stdio/output/puts.cxx, + src/stdio/output/vfnprintf.cxx, src/support/tsd.cxx: + Modified to support buffered reads including renaming + _EccInternalFileStruct to __EccStdioStream which is what affects + most of these files + * src/include/file_if.inl, src/stdio/common/file_if.cxx: added for + the above reason + * src/stdio/common/sscanf.cxx, src/stdio/input/vfscanf.cxx, + src/stdio/input/Makefile.am: added to provide sscanf() functionality + * include/ctype.h, include/stdio.h, include/stdlib.h, + include/string.h, include/eccconf/libc.h, src/ctype/ctype.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/stdio/common/stdio.cxx: + rename *_INLINES macros with prefix CYG rather than ECC + * include/errno.h, src/errno/errno.cxx, src/errno/strerror.cxx: + rename ErrNo to _ErrNo and add EAGAIN and EWOULDBLOCK error codes + * configure.in, Makefile.am, src/stdio/Makefile.am, + src/stdio/input/Makefile.am: add support for building + file_if.cxx sscanf.cxx and vfscanf.cxx + * src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/input/Makefile.in, configure, Makefile.in: regenerated + +Tue Mar 24 19:51:40 1998 Jonathan Larmour + + * src/time/clockfn.cxx, src/time/clock.cxx: + Renamed clock.cxx to clockfn.cxx (preserving CVS history) + * Makefile.am, src/time/Makefile.am: updated to reflect name change + * Makefile.in, src/time/Makefile.in: regenerated + +Tue Mar 24 16:28:06 1998 Jonathan Larmour + + * include/ctype.inl: Swap around definitions to get right order so + inlining works + +Tue Mar 24 14:43:05 1998 Jonathan Larmour + + * include/ctype.h, include/stdio.h, include/stdlib.h, include/string.h: + modify to only conditionally include inlines + * src/ctype/ctype.cxx, src/stdio/common/stdio.cxx, + src/stdlib/stdlib.cxx, src/string/strcoll.cxx, + src/ctype/Makefile.am: Add to provide real linkable alternatives + to inline functions + * Makefile.am, configure.in, src/Makefile.am, + src/stdio/common/Makefile.am, src/stdlib/Makefile.am, + src/string/Makefile.am: modified to support previous additions + * include/eccconf/libc.h: redefine inline macro to add extern inline, + and add conditional defines for inline functions. Also rename + space vs. speed macro to have CYG instead of ECC prefix + * include/stdio.inl: fix comment typo + * src/stdlib/qsort.cxx: fix to define inline functions properly + * src/string/memchr.cxx, src/string/memcmp.cxx, src/string/memcpy.cxx, + src/string/memset.cxx, src/string/strcat.cxx, src/string/strchr.cxx, + src/string/strcmp.cxx, src/string/strcpy.cxx, src/string/strlen.cxx, + src/string/strncat.cxx, src/string/strncmp.cxx, + src/string/strncpy.cxx + * Makefile.in, configure, src/Makefile.in, src/ctype/Makefile.in, + src/stdio/common/Makefile.in, src/stdlib/Makefile.in, + src/string/Makefile.in: regenerate + + +Mon Mar 23 19:19:49 1998 Jonathan Larmour + + * src/stdlib/_exit.cxx: added to support temporary _exit + * include/stdlib.h, include/stdlib.inl: added support for _exit and + added abs(), labs(), div() and ldiv() functions + * src/include/file_if.hxx: added support for _exit kludge + * src/stdlib/qsort.cxx: Added Berkeley copyright message + * src/time/clock.cxx: Include correct kernel config header as + CYG_CONFIGURATION rather than + * Makefile.am src/stdlib/Makefile.am: added support for _exit + * Makefile.in, src/stdlib/Makefile.in: regenerated + +Mon Mar 23 14:41:07 1998 Jonathan Larmour + + * Replace ECCPKG_ANSI_LIBC with CYGPKG_ANSI_LIBC in all source files + +Mon Mar 23 14:28:44 1998 Jonathan Larmour + + * include/string.inl: add file to provide strcoll() + * include/string.h: include string.inl + * ctype.h: include ctype.inl (oops!) + * include/stdlib.h: include stdlib.inl (oops!) + +Mon Mar 23 13:30:38 1998 Jonathan Larmour + + * include/ctype.h, include/ctype.inl: added to provide ANSI ctype + functionality + * include/stdlib.h, include/stdlib.inl, src/include/stdlibbsp.hxx, + src/stdlib/Makefile.am, src/stdlib/bsearch.cxx, + src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/stdlib/srand.cxx, + src/stdlib/strtol.cxx, src/stdlib/strtoul.cxx: Added to provide + many stdlib functions + * src/include/tsd.hxx: modified to support rand() random number + seed, and added some comments + * configure.in, Makefile.am, src/Makefile.am: modified to support + addition of above new sources + * include/eccconf/libc.h: Add extra helpful comments, and #include + kernel config file + * src/time/clock.cxx: #include clock.inl and fix to call + get_resolution() properly now + * Makefile.in, configure, src/Makefile.in, src/errno/Makefile.in, + src/stdio/Makefile.in, src/stdio/common/Makefile.in, + src/stdio/device/Makefile.in, src/stdio/output/Makefile.in, + src/stdlib/Makefile.in, src/strings/Makefile.in, + src/support/Makefile.in, src/time/Makefile.in, + tests/Makefile.in: regenerated + + +Sun Mar 22 21:29:25 1998 Jonathan Larmour + + * include/time.h, src/include/timesupp.hxx, src/time/clock.cxx, + src/time/Makefile.am: added to provide clock() function + * src/Makefile.am: modified to try to build in src/time directory + * include/eccconf/libc.h: added and is now the main configuration + file for this package + * acconfig.h, include/libcconf.h.in, include/stamp-h.in: removed + due to usage of libc.h above instead + * Almost all *.h, *.hxx and *.cxx: replaced LIBC_CONFIG_HEADER + defined include with simple + * configure.in: remove AM_CONFIG_HEADER of libcconf.h and + LIBC_CONFIG_HEADER definition. Also remove usage of builtin + memcpy() etc. from gcc, and generate src/time/Makefile + * Makefile.am: link in src/time/clock.o + * src/include/file_if.hxx, src/include/sim.hxx: use config header + to decide whether C library is to be used + * Makefile.in, aclocal.m4, configure, src/Makefile.in: regenerated + +Fri Mar 20 18:08:10 1998 Jonathan Larmour + + * src/string/strxfrm.cxx: Fixed bug with ignoring terminating NULL + +1998-03-20 Chris Tarpy + + * configure: - regenerated + * Makefile.am: - Support added for libc testcases + * Makefile.in: regenerated + * configure.in: set c compiler, descend test dir + * tests/Makefile.in: added + * tests/Makefile.am: added + * tests/tcdiag.cxx : added + + +Thu Mar 19 11:41:56 1998 Jonathan Larmour + + * Initial check-in of everything + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/language/c/libc/time/current/cdl/time.cdl b/packages/language/c/libc/time/current/cdl/time.cdl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/cdl/time.cdl @@ -0,0 +1,309 @@ +# ==================================================================== +# +# time.cdl +# +# C library time related configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jlarmour +# Contributors: +# Date: 2000-04-14 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_LIBC_TIME { + display "ISO C library date and time functions" + description " + This package provides time functions specified by the + ISO C standard - ISO/IEC 9899:1990." + doc redirect/the-iso-standard-c-and-math-libraries.html + include_dir cyg/libc/time + parent CYGPKG_LIBC + implements CYGINT_ISO_C_TIME_TYPES + implements CYGINT_ISO_C_CLOCK_FUNCS + requires { CYGBLD_ISO_C_TIME_TYPES_HEADER == "" } + requires { CYGBLD_ISO_C_CLOCK_FUNCS_HEADER == \ + "" } + requires CYGPKG_ISOINFRA + requires CYGINT_ISO_DIV + + compile asctime.cxx asctime_r.cxx clock.cxx \ + ctime.cxx ctime_r.cxx difftime.cxx \ + gmtime.cxx gmtime_r.cxx localtime.cxx \ + localtime_r.cxx mktime.cxx settime.cxx \ + strftime.cxx time.cxx timeutil.cxx + + +# ==================================================================== + + cdl_option CYGSEM_LIBC_TIME_CLOCK_WORKING { + display "Working clock() function" + requires CYGFUN_KERNEL_THREADS_TIMER + requires CYGVAR_KERNEL_COUNTERS_CLOCK + default_value 1 + description " + This option controls whether clock() will + actually try and determine the process time + usage. With this option disabled, clock() does + not disappear, but will permanently return + (clock_t)-1 as mandated by the ISO C standard." + } + + cdl_option CYGSEM_LIBC_TIME_TIME_WORKING { + display "Working time() function" + requires CYGPKG_IO_WALLCLOCK + default_value 1 + description " + This option controls whether time() will + actually try and determine the current calendar + time. With this option disabled, time() does + not disappear, but will permanently return + (time_t)-1 as mandated by the ISO C standard." + } + + cdl_option CYGSEM_LIBC_TIME_SETTIME_WORKING { + display "Working cyg_libc_time_settime() function" + requires CYGPKG_IO_WALLCLOCK + default_value 1 + description " + This option controls whether cyg_libc_time_settime() + will actually try and set the current calendar + time. With this option disabled, + cyg_libc_time_settime() does not disappear, but + will permanently return an error." + } + + cdl_option CYGFUN_LIBC_TIME_POSIX { + display "POSIX time functions" + default_value 1 + description " + Enabling this option allows the use of the + following functions defined in POSIX 1003.1: + asctime_r(), ctime_r(), gmtime_r(), and + localtime_r()." + } + + cdl_component CYGPKG_LIBC_TIME_ZONES { + display "Time zone offsets" + flavor none + description " + These options control the default STandarD (STD) + and Daylight Savings Time (DST) + time offsets so that dates can be set correctly + for the local environment." + + cdl_option CYGNUM_LIBC_TIME_DST_DEFAULT_STATE { + display "Default Daylight Savings Time state" + flavor data + legal_values -- -1 to 1 + default_value -- -1 + description " + This option controls whether the initial + time environment is set up as STD, DST or + unknown. Use the value 1 for DST, 0 for STD, + and (-1) for unknown. This can also be set at + runtime using the cyg_libc_time_setdst() + function." + } + + cdl_option CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET { + display "Default Standard Time offset" + flavor data + legal_values -- -90000 to 90000 + default_value -- 0 + description " + This option controls the offset from UTC in + seconds when in local Standard Time. This + value can be positive or negative. It + can also be set at run time using the + cyg_libc_time_setzoneoffsets() function." + } + + cdl_option CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET { + display "Default Daylight Savings Time offset" + flavor data + legal_values -- -90000 to 90000 + default_value -- 3600 + description " + This option controls the offset from UTC in + seconds when in local Daylight Savings Time. This + value can be positive or negative. It + can also be set at run time using the + cyg_libc_time_setzoneoffsets() function." + } + } + + cdl_component CYGPKG_LIBC_TIME_INLINES { + display "Inline functions" + flavor none + description " + These options control whether certain functions + are available in inline form. This may lead to + faster code at the expense of code space. But for + some functions, or some functions with constant + arguments, it may in fact lead to smaller code." + + cdl_option CYGIMP_LIBC_TIME_ASCTIME_INLINE { + display "asctime()" + default_value 1 + description " + Allow the asctime() function to be inlined" + } + + cdl_option CYGIMP_LIBC_TIME_CTIME_INLINE { + display "ctime()" + default_value 1 + description " + Allow the ctime() function to be inlined" + } + + cdl_option CYGIMP_LIBC_TIME_DIFFTIME_INLINE { + display "difftime()" + default_value 1 + description " + Allow the difftime() function to be inlined" + } + + cdl_option CYGIMP_LIBC_TIME_GMTIME_INLINE { + display "gmtime()" + default_value 1 + description " + Allow the gmtime() function to be inlined" + } + + cdl_option CYGIMP_LIBC_TIME_LOCALTIME_INLINE { + display "localtime()" + default_value 1 + description " + Allow the localtime() function to be inlined" + } + + cdl_option CYGIMP_LIBC_TIME_MKTIME_INLINE { + display "mktime()" + default_value 1 + description " + Allow the mktime() function to be inlined" + } + + cdl_option CYGIMP_LIBC_TIME_ASCTIME_R_INLINE { + display "asctime_r()" + requires CYGFUN_LIBC_TIME_POSIX + default_value 1 + description " + Allow the asctime_r() function to be inlined" + } + + cdl_option CYGIMP_LIBC_TIME_CTIME_R_INLINE { + display "ctime_r()" + requires CYGFUN_LIBC_TIME_POSIX + default_value 1 + description " + Allow the ctime_r() function to be inlined" + } + + cdl_option CYGIMP_LIBC_TIME_GMTIME_R_INLINE { + display "gmtime_r()" + requires CYGFUN_LIBC_TIME_POSIX + default_value 1 + description " + Allow the gmtime_r() function to be inlined" + } + + cdl_option CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE { + display "localtime_r()" + requires CYGFUN_LIBC_TIME_POSIX + default_value 1 + description " + Allow the localtime_r() function to be inlined" + } + } +# FIXME: Also want "inline all" and "don't inline any" options which requires +# (or not) all the above, but +# if we do that then we will require the ones that also depend on +# CYGFUN_LIBC_TIME_POSIX :-( Wait for full CDL to fix this + + cdl_option CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL { + display "clock() tracing level" + flavor data + legal_values 0 to 1 + default_value 0 + description " + Trace verbosity level for debugging the clock() + function. Increase this value to get + additional trace output when tracing is enabled." + } + + cdl_component CYGPKG_LIBC_TIME_OPTIONS { + display "C library time functions build options" + flavor none + no_define + description " + Package specific build options including control over + compiler flags used only in building this package, + and details of which tests are built." + + + cdl_option CYGPKG_LIBC_TIME_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the C library. These flags are used in addition + to the set of global flags." + } + + cdl_option CYGPKG_LIBC_TIME_CFLAGS_REMOVE { + display "Suppressed compiler flags" + flavor data + no_define + default_value { "" } + description " + This option modifies the set of compiler flags for + building the C library. These flags are removed from + the set of global flags if present." + } + + cdl_option CYGPKG_LIBC_TIME_TESTS { + display "C library time and date function tests" + flavor data + no_define + calculated { "tests/asctime tests/clock tests/ctime tests/gmtime tests/localtime tests/mktime tests/strftime tests/time" } + description " + This option specifies the set of tests for the C library + time and date functions." + } + } +} + +# ==================================================================== +# EOF time.cdl diff --git a/packages/language/c/libc/time/current/include/time.h b/packages/language/c/libc/time/current/include/time.h new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/include/time.h @@ -0,0 +1,300 @@ +#ifndef CYGONCE_LIBC_TIME_TIME_H +#define CYGONCE_LIBC_TIME_TIME_H +/*=========================================================================== +// +// time.h +// +// Date and time routines from ISO C section 7.12 and POSIX 1003.1 +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-14 +// Purpose: Provide definitions required by ISO C section 7.12 and +// POSIX 1003.1 8.3.4-8.3.7 +// Description: +// Usage: Do not include this file directly - use #include +// +//####DESCRIPTIONEND#### +// +//=========================================================================*/ + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include // Common type definitions and support + +// TYPE DEFINITIONS + +// Define struct tm as per ISO C para 7.12.1 +struct tm { + int tm_sec; // seconds after the minute - [0..61] + // (note 61 allows for two leap seconds) + int tm_min; // minutes after the hour - [0..59] + int tm_hour; // hours since midnight - [0..23] + int tm_mday; // days of the month - [1..31] + int tm_mon; // months since January - [0..11] + int tm_year; // years since 1900 + int tm_wday; // days since Sunday - [0..6] + int tm_yday; // days since January 1 - [0..365] + int tm_isdst; // Daylight Saving Time flag - positive if DST is in + // effect, 0 if not in effect, and negative if the info + // is not available +}; + +// The following struct is used by the implementation-defined functions +// to manipulate the Daylight Savings Time state +typedef enum { + CYG_LIBC_TIME_DSTNA = -1, + CYG_LIBC_TIME_DSTOFF = 0, + CYG_LIBC_TIME_DSTON = 1 +} Cyg_libc_time_dst; + +// FUNCTION PROTOTYPES + +#ifdef __cplusplus +extern "C" { +#endif + +//=========================================================================== +// +// POSIX 1003.1 functions + +#ifdef CYGFUN_LIBC_TIME_POSIX + +///////////////////////////////// +// asctime_r() - POSIX.1 8.3.4 // +///////////////////////////////// +// +// This returns a textual representation of a struct tm, and writes +// the string to return into __buf +// + +extern char * +asctime_r( const struct tm *__timeptr, char *__buf ); + +/////////////////////////////// +// ctime_r() - POSIX.1 8.3.5 // +/////////////////////////////// +// +// This returns the equivalent of ctime() but writes to __buf +// to store the returned string +// + +extern char * +ctime_r( const time_t *__timer, char *__buf ); + +//////////////////////////////// +// gmtime_r() - POSIX.1 8.3.6 // +//////////////////////////////// +// +// This converts a time_t into a struct tm expressed in UTC, and stores +// the result in the space occupied by __result +// + +extern struct tm * +gmtime_r( const time_t *__timer, struct tm *__result ); + +/////////////////////////////////// +// localtime_r() - POSIX.1 8.3.7 // +/////////////////////////////////// +// +// This converts a time_t into a struct tm expressed in local time, and +// stores the result in the space occupied by __result +// + +extern struct tm * +localtime_r( const time_t *__timer, struct tm *__result ); + + +#endif // ifdef CYGFUN_LIBC_TIME_POSIX + +//=========================================================================== + +// ISO C functions + +// Time manipulation functions - ISO C 7.12.2 + +////////////////////////////// +// clock() - ISO C 7.12.2.1 // +////////////////////////////// +// +// Returns processor time used in "clock"s. For a single process, +// multi-threaded system this will just be the time since booting +// + +extern clock_t +clock( void ); + +///////////////////////////////// +// difftime() - ISO C 7.12.2.2 // +///////////////////////////////// +// +// This returns (__time1 - __time0) in seconds +// + +extern double +difftime( time_t __time1, time_t __time0 ); + +/////////////////////////////// +// mktime() - ISO C 7.12.2.3 // +/////////////////////////////// +// +// This converts a "struct tm" to a "time_t" +// + +extern time_t +mktime( struct tm *__timeptr ); + +///////////////////////////// +// time() - ISO C 7.12.2.4 // +///////////////////////////// +// +// This returns calendar time as a time_t +// + +extern time_t +time( time_t *__timer ); + +// Time conversion functions - ISO C 7.12.3 + +//////////////////////////////// +// asctime() - ISO C 7.12.3.1 // +//////////////////////////////// +// +// This returns a textual representation of a struct tm +// + +extern char * +asctime( const struct tm *__timeptr ); + +////////////////////////////// +// ctime() - ISO C 7.12.3.2 // +////////////////////////////// +// +// This returns asctime(localtime(__timeptr)) +// + +extern char * +ctime( const time_t *__timer ); + +/////////////////////////////// +// gmtime() - ISO C 7.12.3.3 // +/////////////////////////////// +// +// This converts a time_t into a struct tm expressed in UTC +// + +extern struct tm * +gmtime( const time_t *__timer ); + +////////////////////////////////// +// localtime() - ISO C 7.12.3.4 // +////////////////////////////////// +// +// This converts a time_t into a struct tm expressed in local time +// + +extern struct tm * +localtime( const time_t *__timer ); + +///////////////////////////////// +// strftime() - ISO C 7.12.3.5 // +///////////////////////////////// +// +// This converts a string using format specifiers that signify various +// time-related quantities +// + +extern size_t +strftime( char *__s, size_t __maxsize, const char *__format, + const struct tm *__timeptr); //__attribute__ ((format (strftime, 3))); + +//=========================================================================== + +// Implementation-specific functions + +//////////////////////////////////// +// cyg_libc_time_setzoneoffsets() // +//////////////////////////////////// +// +// This function sets the offsets used when Daylight Savings Time is enabled +// or disabled. The offsets are in time_t's +// + +extern void +cyg_libc_time_setzoneoffsets( time_t __stdoffset, time_t __dstoffset ); + +//////////////////////////// +// cyg_libc_time_setdst() // +//////////////////////////// +// +// This function sets the state of Daylight Savings Time: on, off, or unknown +// + +extern void +cyg_libc_time_setdst( Cyg_libc_time_dst __state ); + + +//////////////////////////////////// +// cyg_libc_time_getzoneoffsets() // +//////////////////////////////////// +// +// This function retrieves the current state of the Daylight Savings Time +// and the offsets of both STD and DST +// The offsets are both in time_t's +// + +extern Cyg_libc_time_dst +cyg_libc_time_getzoneoffsets( time_t *__stdoffset, time_t *__dstoffset ); + +///////////////////////////// +// cyg_libc_time_settime() // +///////////////////////////// +// +// This function sets the current time for the system. The time is +// specified as a time_t in UTC. It returns non-zero on error. +// + +extern cyg_bool +cyg_libc_time_settime( time_t __utctime ); + + +#ifdef __cplusplus +} // extern "C" +#endif + +#include + +#endif // CYGONCE_LIBC_TIME_TIME_H multiple inclusion protection + +// EOF time.h diff --git a/packages/language/c/libc/time/current/include/time.inl b/packages/language/c/libc/time/current/include/time.inl new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/include/time.inl @@ -0,0 +1,780 @@ +#ifndef CYGONCE_LIBC_TIME_INL +#define CYGONCE_LIBC_TIME_INL +//=========================================================================== +// +// time.inl +// +// Inline implementations of date and time routines from +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 1999-02-25 +// Purpose: Provide inline implementations for some of the date and time +// routines declared in for ISO C section 7.12 and +// POSIX 1003.1 8.3.4-8.3.7 +// Description: +// Usage: Do not include this file directly. Instead include +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include // Common type definitions and support +#include // Header for this file +#include // Assertion infrastructure +#include // Tracing infrastructure + +// DEFINES + +// The following are overriden by the libc implementation to get a non-inline +// version to prevent duplication of code + +#ifndef CYGPRI_LIBC_TIME_ASCTIME_R_INLINE +# define CYGPRI_LIBC_TIME_ASCTIME_R_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_CTIME_R_INLINE +# define CYGPRI_LIBC_TIME_CTIME_R_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_GMTIME_R_INLINE +# define CYGPRI_LIBC_TIME_GMTIME_R_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_LOCALTIME_R_INLINE +# define CYGPRI_LIBC_TIME_LOCALTIME_R_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_DIFFTIME_INLINE +# define CYGPRI_LIBC_TIME_DIFFTIME_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_MKTIME_INLINE +# define CYGPRI_LIBC_TIME_MKTIME_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_ASCTIME_INLINE +# define CYGPRI_LIBC_TIME_ASCTIME_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_CTIME_INLINE +# define CYGPRI_LIBC_TIME_CTIME_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_GMTIME_INLINE +# define CYGPRI_LIBC_TIME_GMTIME_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_LOCALTIME_INLINE +# define CYGPRI_LIBC_TIME_LOCALTIME_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_GETZONEOFFSETS_INLINE +# define CYGPRI_LIBC_TIME_GETZONEOFFSETS_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_SETZONEOFFSETS_INLINE +# define CYGPRI_LIBC_TIME_SETZONEOFFSETS_INLINE extern __inline__ +#endif + +#ifndef CYGPRI_LIBC_TIME_SETDST_INLINE +# define CYGPRI_LIBC_TIME_SETDST_INLINE extern __inline__ +#endif + +#define CYGNUM_LIBC_TIME_EPOCH_WDAY 4 // Jan 1st 1970 was a Thursday + +#ifdef __cplusplus +extern "C" { +#endif + +// EXTERNS + +// These are used in the dst access functions below. Do not access these +// directly - use the functions declared in time.h instead + +extern Cyg_libc_time_dst cyg_libc_time_current_dst_stat; +extern time_t cyg_libc_time_current_std_offset; +extern time_t cyg_libc_time_current_dst_offset; + +// INLINE FUNCTIONS + +//=========================================================================== +// +// Utility functions + +////////////////////////////////// +// cyg_libc_time_year_is_leap() // +////////////////////////////////// +// +// This returns true if the year is a leap year. +// The argument is of type int in line with struct tm +// + +static __inline__ cyg_bool +cyg_libc_time_year_is_leap( int __year ) +{ + cyg_bool _leap=false; + + if (!(__year % 400)) + _leap = true; + else if (!(__year % 4) && (__year % 100)) + _leap = true; + return _leap; +} // cyg_libc_time_year_is_leap() + + +//////////////////////////////////// +// cyg_libc_time_getzoneoffsets() // +//////////////////////////////////// +// +// This function retrieves the current state of the Daylight Savings Time +// and the offsets of both STD and DST +// The offsets are both in time_t's i.e. seconds +// + +CYGPRI_LIBC_TIME_GETZONEOFFSETS_INLINE Cyg_libc_time_dst +cyg_libc_time_getzoneoffsets( time_t *__stdoffset, time_t *__dstoffset ) +{ + CYG_REPORT_FUNCNAMETYPE("cyg_libc_time_getzoneoffsets", + "returning DST state %d"); + CYG_REPORT_FUNCARG2("__stdoffset is at address %08x, " + "__dstoffset is at %08x", __stdoffset, __dstoffset); + + CYG_CHECK_DATA_PTR(__stdoffset, "__stdoffset is not a valid pointer!"); + CYG_CHECK_DATA_PTR(__dstoffset, "__dstoffset is not a valid pointer!"); + + *__stdoffset = cyg_libc_time_current_std_offset; + *__dstoffset = cyg_libc_time_current_dst_offset; + + CYG_REPORT_RETVAL(cyg_libc_time_current_dst_stat); + + return cyg_libc_time_current_dst_stat; +} // cyg_libc_time_getzoneoffsets() + + +//////////////////////////////////// +// cyg_libc_time_setzoneoffsets() // +//////////////////////////////////// +// +// This function sets the offsets used when Daylight Savings Time is enabled +// or disabled. The offsets are in time_t's i.e. seconds +// + +CYGPRI_LIBC_TIME_SETZONEOFFSETS_INLINE void +cyg_libc_time_setzoneoffsets( time_t __stdoffset, time_t __dstoffset ) +{ + CYG_REPORT_FUNCNAME("cyg_libc_time_setzoneoffsets"); + CYG_REPORT_FUNCARG2DV(__stdoffset, __dstoffset); + + cyg_libc_time_current_std_offset = __stdoffset; + cyg_libc_time_current_dst_offset = __dstoffset; + + CYG_REPORT_RETURN(); +} // cyg_libc_time_setzoneoffsets() + + +//////////////////////////// +// cyg_libc_time_setdst() // +//////////////////////////// +// +// This function sets the state of Daylight Savings Time: on, off, or unknown +// + +CYGPRI_LIBC_TIME_SETDST_INLINE void +cyg_libc_time_setdst( Cyg_libc_time_dst __state ) +{ + CYG_REPORT_FUNCNAME("cyg_libc_time_setdst"); + CYG_REPORT_FUNCARG1("__state=%d", __state); + + cyg_libc_time_current_dst_stat = __state; + + CYG_REPORT_RETURN(); +} // cyg_libc_time_setdst() + + + +//=========================================================================== +// +// POSIX 1003.1 functions + +///////////////////////////////// +// asctime_r() - POSIX.1 8.3.4 // +///////////////////////////////// +// +// This returns a textual representation of a struct tm, and writes +// the string to return into __buf +// + +#ifdef CYGIMP_LIBC_TIME_ASCTIME_R_INLINE + +#include // for sprintf() +#include // for cyg_libc_time_{day,month}_name + // and cyg_libc_time_itoa() +#include // for memcpy() + +CYGPRI_LIBC_TIME_ASCTIME_R_INLINE char * +asctime_r( const struct tm *__timeptr, char *__buf ) +{ + cyg_uint8 __i; + + // These initializers are [4] since C++ dictates you _must_ leave space + // for the trailing '\0', even though ISO C says you don't need to! + + CYG_REPORT_FUNCNAMETYPE("asctime_r", "returning \"%s\""); + CYG_REPORT_FUNCARG2("__timeptr = %08x, __buf = %08x", __timeptr, __buf); + + // paranoia - most of these aren't required but could be helpful to + // a programmer debugging their own app. + CYG_CHECK_DATA_PTR(__timeptr, "__timeptr is not a valid pointer!"); + CYG_CHECK_DATA_PTR(__buf, "__buf is not a valid pointer!"); + + CYG_PRECONDITION((__timeptr->tm_sec >= 0) && (__timeptr->tm_sec < 62), + "__timeptr->tm_sec out of range!"); + CYG_PRECONDITION((__timeptr->tm_min >= 0) && (__timeptr->tm_min < 60), + "__timeptr->tm_min out of range!"); + CYG_PRECONDITION((__timeptr->tm_hour >= 0) && (__timeptr->tm_hour < 24), + "__timeptr->tm_hour out of range!"); + // Currently I don't check _actual_ numbers of days in each month here + // FIXME: No reason why not though + CYG_PRECONDITION((__timeptr->tm_mday >= 1) && (__timeptr->tm_mday < 32), + "__timeptr->tm_mday out of range!"); + CYG_PRECONDITION((__timeptr->tm_mon >= 0) && (__timeptr->tm_mon < 12), + "__timeptr->tm_mon out of range!"); + CYG_PRECONDITION((__timeptr->tm_wday >= 0) && (__timeptr->tm_wday < 7), + "__timeptr->tm_wday out of range!"); + CYG_PRECONDITION((__timeptr->tm_yday >= 0) && (__timeptr->tm_yday < 366), + "__timeptr->tm_yday out of range!"); + CYG_PRECONDITION((__timeptr->tm_year > -1900) && + (__timeptr->tm_year < 8100), + "__timeptr->tm_year out of range!"); + + // we can't use strftime because ISO C is stupid enough not to allow + // the strings in asctime() to be localized. Duh. + + // day of the week + memcpy(&__buf[0], cyg_libc_time_day_name[__timeptr->tm_wday], 3); + __buf[3] = ' '; + + // month + memcpy(&__buf[4], cyg_libc_time_month_name[__timeptr->tm_mon], 3); + __buf[7] = ' '; + + __i = 8; + + // day of the month + __i += cyg_libc_time_itoa( (cyg_uint8 *)&__buf[__i], __timeptr->tm_mday, 2, + true); + __buf[__i++] = ' '; + + // hour + __i += cyg_libc_time_itoa( (cyg_uint8 *)&__buf[__i], __timeptr->tm_hour, 2, + true); + __buf[__i++] = ':'; + + // minute + __i += cyg_libc_time_itoa( (cyg_uint8 *)&__buf[__i], __timeptr->tm_min, 2, + true); + __buf[__i++] = ':'; + + // second + __i += cyg_libc_time_itoa((cyg_uint8 *) &__buf[__i], __timeptr->tm_sec, 2, + true); + __buf[__i++] = ' '; + + // year + __i += cyg_libc_time_itoa( (cyg_uint8 *)&__buf[__i], + 1900+__timeptr->tm_year, 0, true); + + __buf[__i++] = '\n'; + __buf[__i++] = '\0'; + + CYG_REPORT_RETVAL(__buf); + return __buf; +} // asctime_r() + +#endif // ifdef CYGIMP_LIBC_TIME_ASCTIME_R_INLINE + +//////////////////////////////// +// gmtime_r() - POSIX.1 8.3.6 // +//////////////////////////////// +// +// This converts a time_t into a struct tm expressed in UTC, and stores +// the result in the space occupied by __result +// + +#ifdef CYGIMP_LIBC_TIME_GMTIME_R_INLINE + +#include // for cyg_libc_time_month_lengths + +CYGPRI_LIBC_TIME_GMTIME_R_INLINE struct tm * +gmtime_r( const time_t *__timer, struct tm *__result ) +{ + time_t _tim; + const cyg_uint8 *_months_p; + + CYG_REPORT_FUNCNAMETYPE("gmtime_r", "returning %08x"); + CYG_CHECK_DATA_PTR(__timer, "__timer is not a valid pointer!"); + CYG_CHECK_DATA_PTR(__result, "__result is not a valid pointer!"); + CYG_REPORT_FUNCARG2("*__timer=%d, __result is at %08x", + *__timer, __result); + +#define CYGNUM_LIBC_TIME_SECSPERDAY (60*60*24) +#define CYGNUM_LIBC_TIME_SECSPERYEAR (CYGNUM_LIBC_TIME_SECSPERDAY * 365) +#define CYGNUM_LIBC_TIME_SECSPERLEAPYEAR (CYGNUM_LIBC_TIME_SECSPERDAY * 366) + + _tim = *__timer; + + // First, work out year. Start off with 1970 and work forwards or backwards + // depending on the sign of _tim + __result->tm_year = 70; + + // we also work out the day of the week of the start of the year as we + // go along + __result->tm_wday = CYGNUM_LIBC_TIME_EPOCH_WDAY; + + while (_tim < 0) { + // Work backwards + + --__result->tm_year; + + // Check for a leap year. + if (cyg_libc_time_year_is_leap(1900 + __result->tm_year)) { + _tim += CYGNUM_LIBC_TIME_SECSPERLEAPYEAR; + __result->tm_wday -= 366; + } // if + else { + _tim += CYGNUM_LIBC_TIME_SECSPERYEAR; + __result->tm_wday -= 365; + } // else + + } // while + + while (_tim >= CYGNUM_LIBC_TIME_SECSPERYEAR) { + // Work forwards + + if (cyg_libc_time_year_is_leap(1900 + __result->tm_year)) { + + // But if this is a leap year, its possible that we are in the + // middle of the last "extra" day + if (_tim < CYGNUM_LIBC_TIME_SECSPERLEAPYEAR) + break; + + _tim -= CYGNUM_LIBC_TIME_SECSPERLEAPYEAR; + __result->tm_wday += 366; + } // if + else { + _tim -= CYGNUM_LIBC_TIME_SECSPERYEAR; + __result->tm_wday += 365; + } + ++__result->tm_year; + } // while + + // Day of the year. We know _tim is +ve now + CYG_ASSERT(_tim >= 0, + "Number of seconds since start of year is negative!"); + __result->tm_yday = _tim / CYGNUM_LIBC_TIME_SECSPERDAY; + + // Day of the week. Normalize to be 0..6, and note that it might + // be negative, so we have to deal with the modulus being + // implementation-defined for -ve numbers (ISO C 6.3.5) + __result->tm_wday = (((__result->tm_wday + __result->tm_yday)%7)+7)%7; + + // Month and Day of the month + + _months_p = cyg_libc_time_month_lengths[ + cyg_libc_time_year_is_leap(1900 + __result->tm_year) ? 1 : 0 ]; + + __result->tm_mday = __result->tm_yday+1; + + for (__result->tm_mon = 0; + __result->tm_mday > _months_p[__result->tm_mon]; + ++__result->tm_mon) { + + __result->tm_mday -= _months_p[__result->tm_mon]; + + } // for + + _tim -= __result->tm_yday*CYGNUM_LIBC_TIME_SECSPERDAY; + + // hours, mins secs + __result->tm_hour = (int) (_tim / 3600); + _tim %= 3600; + __result->tm_min = (int) (_tim / 60); + __result->tm_sec = (int) (_tim % 60); + + __result->tm_isdst = 0; // gmtime always returns non-DST + + CYG_REPORT_RETVAL(__result); + + return __result; +} // gmtime_r() + +#endif // ifdef CYGIMP_LIBC_TIME_GMTIME_R_INLINE + +/////////////////////////////////// +// localtime_r() - POSIX.1 8.3.7 // +/////////////////////////////////// +// +// This converts a time_t into a struct tm expressed in local time, and +// stores the result in the space occupied by __result +// + +#ifdef CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE + +#include // for cyg_libc_time_normalize_structtm() + +CYGPRI_LIBC_TIME_LOCALTIME_R_INLINE struct tm * +localtime_r( const time_t *__timer, struct tm *__result ) +{ + time_t __stdoffset, __dstoffset; + CYG_REPORT_FUNCNAMETYPE("localtime_r", "returning %08x"); + CYG_CHECK_DATA_PTR(__timer, "__timer is not a valid pointer!"); + CYG_CHECK_DATA_PTR(__result, "__result is not a valid pointer!"); + CYG_REPORT_FUNCARG2("*__timer=%d, __result is at %08x", + *__timer, __result); + + gmtime_r(__timer, __result); + + // Adjust for STD/DST + __result->tm_isdst = cyg_libc_time_getzoneoffsets(&__stdoffset, + &__dstoffset); + + if (__result->tm_isdst == 0) { // STD + __result->tm_sec += __stdoffset; + cyg_libc_time_normalize_structtm( __result ); + } // if + else if (__result->tm_isdst > 0) { // DST + __result->tm_sec += __dstoffset; + cyg_libc_time_normalize_structtm( __result ); + } // if + // Don't do anything for tm_isdst == -1 + + CYG_REPORT_RETVAL(__result); + + return __result; +} // localtime_r() + +#endif // ifdef CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE + + +/////////////////////////////// +// ctime_r() - POSIX.1 8.3.5 // +/////////////////////////////// +// +// This returns the equivalent of ctime() but writes to __buf +// to store the returned string +// + +#ifdef CYGIMP_LIBC_TIME_CTIME_R_INLINE + +CYGPRI_LIBC_TIME_CTIME_R_INLINE char * +ctime_r( const time_t *__timer, char *__buf ) +{ + struct tm _mytm; + + CYG_REPORT_FUNCNAMETYPE("ctime_r", "returning \"%s\""); + + CYG_CHECK_DATA_PTR(__timer, "__timer is not a valid pointer!"); + CYG_CHECK_DATA_PTR(__buf, "__buf is not a valid pointer!"); + + CYG_REPORT_FUNCARG2("*__timer = %d, __buf=%08x", *__timer, __buf); + + localtime_r( __timer, &_mytm ); + + asctime_r(&_mytm, __buf); + + CYG_REPORT_RETVAL(__buf); + + return __buf; +} // ctime_r() + +#endif // ifdef CYGIMP_LIBC_TIME_CTIME_R_INLINE + + +//=========================================================================== +// +// ISO C functions + +// Time manipulation functions - ISO C 7.12.2 + +///////////////////////////////// +// difftime() - ISO C 7.12.2.2 // +///////////////////////////////// +// +// This returns (__time1 - __time0) in seconds +// + +#ifdef CYGIMP_LIBC_TIME_DIFFTIME_INLINE + +CYGPRI_LIBC_TIME_DIFFTIME_INLINE double +difftime( time_t __time1, time_t __time0 ) +{ + double _ret; + + CYG_REPORT_FUNCNAMETYPE("difftime", "returning %f"); + CYG_REPORT_FUNCARG2("__time1=%d, __time0=%d", __time1, __time0); + + _ret = (double)(__time1 - __time0); + + CYG_REPORT_RETVAL(_ret); + + return _ret; +} // difftime() + +#endif // ifdef CYGIMP_LIBC_TIME_DIFFTIME_INLINE + +/////////////////////////////// +// mktime() - ISO C 7.12.2.3 // +/////////////////////////////// +// +// This converts a "struct tm" to a "time_t" +// + +#ifdef CYGIMP_LIBC_TIME_MKTIME_INLINE + +#include // for cyg_libc_time_normalize_structtm() + // and cyg_libc_time_month_lengths + +CYGPRI_LIBC_TIME_MKTIME_INLINE time_t +mktime( struct tm *__timeptr ) +{ + time_t _ret; + cyg_count16 _i; + cyg_count32 _daycount; + cyg_bool _leap; + + CYG_REPORT_FUNCNAMETYPE("mktime", "returning %d"); + CYG_REPORT_FUNCARG1( "__timeptr is at address %08x", __timeptr); + + CYG_CHECK_DATA_PTR(__timeptr, "__timeptr is not a valid pointer!"); + + // First deal with STD/DST. If tm_isdst==-1 (the "autodetect" value) + // we assume its already in UTC. FIXME: is this correct behaviour? Hmm.... + +#if 0 +// FIXME: This doesn't seem to be the way to go + if (__timeptr->tm_isdst == 0) { // STD + // take _off_ the std offset to get us back to UTC from localtime + __timeptr->tm_sec -= (int)cyg_libc_time_current_std_offset; + } // if + else if (__timeptr->tm_isdst > 0) { // DST + // take _off_ the dst offset to get us back to UTC from localtime + __timeptr->tm_sec -= (int)cyg_libc_time_current_dst_offset; + } // if +#endif + + cyg_libc_time_normalize_structtm(__timeptr); + + // check if a time_t can hold the year. FIXME: we assume it is + // 32 bits which gives the year range 1902 - 2038 + if ( (__timeptr->tm_year <= 2) || (__timeptr->tm_year >= 138) ) { + CYG_REPORT_RETVAL(-1); + return (time_t)-1; + } + + // fill in the rest of the struct tm i.e. tm_wday and tm_yday + + _leap = cyg_libc_time_year_is_leap(1900 + __timeptr->tm_year); + + for (_i=0, _daycount=0; _i<12; ++_i) { + if (_i == __timeptr->tm_mon) { + _daycount += __timeptr->tm_mday - 1; + break; + } // if + else { + _daycount += cyg_libc_time_month_lengths[_leap][_i]; + } // else + } // for + + CYG_ASSERT(_i<12, "Reached end of year. __timeptr->tm_mon must be bad"); + + __timeptr->tm_yday = _daycount; + + // now tm_wday + + if (__timeptr->tm_year > 70) { + for (_i=70; _i < __timeptr->tm_year; ++_i) + _daycount += (cyg_libc_time_year_is_leap(1900 + _i) ? 366 : 365); + } // if + else if (__timeptr->tm_year < 70) { + for (_i=70; _i > __timeptr->tm_year; --_i) + _daycount -= (cyg_libc_time_year_is_leap(1900 + _i-1) ? 366 : 365); + } // else if + + __timeptr->tm_wday = (_daycount + CYGNUM_LIBC_TIME_EPOCH_WDAY) % 7; + + // if _daycount was negative, on some targets the modulo operator will + // return negative, so we adjust for that + + if (__timeptr->tm_wday < 0) + __timeptr->tm_wday += 7; + + // now finally work out return value + + _ret = __timeptr->tm_sec + 60*__timeptr->tm_min + 60*60*__timeptr->tm_hour; + _ret += _daycount*24*60*60; + + CYG_REPORT_RETVAL(_ret); + + return _ret; +} // mktime() + +#endif // ifdef CYGIMP_LIBC_TIME_MKTIME_INLINE + + +// Time conversion functions - ISO C 7.12.3 + +//////////////////////////////// +// asctime() - ISO C 7.12.3.1 // +//////////////////////////////// +// +// This returns a textual representation of a struct tm +// + +#ifdef CYGIMP_LIBC_TIME_ASCTIME_INLINE + +extern char cyg_libc_time_asctime_buf[]; + +CYGPRI_LIBC_TIME_ASCTIME_INLINE char * +asctime( const struct tm *__timeptr ) +{ + CYG_REPORT_FUNCNAMETYPE("__asctime", "returning \"%s\""); + CYG_REPORT_FUNCARG1("__timeptr = %08x", __timeptr); + + // paranoia + CYG_CHECK_DATA_PTR(__timeptr, "__timeptr is not a valid pointer!"); + + (void)asctime_r( __timeptr, cyg_libc_time_asctime_buf ); + + CYG_REPORT_RETVAL(cyg_libc_time_asctime_buf); + + return cyg_libc_time_asctime_buf; +} // asctime() + +#endif // ifdef CYGIMP_LIBC_TIME_ASCTIME_INLINE + + +/////////////////////////////// +// gmtime() - ISO C 7.12.3.3 // +/////////////////////////////// +// +// This converts a time_t into a struct tm expressed in UTC +// + +#ifdef CYGIMP_LIBC_TIME_GMTIME_INLINE + +extern struct tm cyg_libc_time_gmtime_buf; + +CYGPRI_LIBC_TIME_GMTIME_INLINE struct tm * +gmtime( const time_t *__timer ) +{ + CYG_REPORT_FUNCNAMETYPE("gmtime", "returning %08x"); + CYG_CHECK_DATA_PTR(__timer, "__timer is not a valid pointer!"); + CYG_REPORT_FUNCARG1("*__timer=%d", *__timer); + + gmtime_r(__timer, &cyg_libc_time_gmtime_buf); + + CYG_REPORT_RETVAL(&cyg_libc_time_gmtime_buf); + + return &cyg_libc_time_gmtime_buf; +} // gmtime() + +#endif // ifdef CYGIMP_LIBC_TIME_GMTIME_INLINE + + +////////////////////////////////// +// localtime() - ISO C 7.12.3.4 // +////////////////////////////////// +// +// This converts a time_t into a struct tm expressed in local time +// + +#ifdef CYGIMP_LIBC_TIME_LOCALTIME_INLINE + +extern struct tm cyg_libc_time_localtime_buf; + +CYGPRI_LIBC_TIME_LOCALTIME_INLINE struct tm * +localtime( const time_t *__timer ) +{ + CYG_REPORT_FUNCNAMETYPE("localtime", "returning %08x"); + CYG_CHECK_DATA_PTR(__timer, "__timer is not a valid pointer!"); + CYG_REPORT_FUNCARG1("*__timer=%d", *__timer); + + localtime_r(__timer, &cyg_libc_time_localtime_buf); + + CYG_REPORT_RETVAL(&cyg_libc_time_localtime_buf); + + return &cyg_libc_time_localtime_buf; +} // localtime() + +#endif // ifdef CYGIMP_LIBC_TIME_LOCALTIME_INLINE + + +////////////////////////////// +// ctime() - ISO C 7.12.3.2 // +////////////////////////////// +// +// This returns asctime(localtime(__timeptr)) +// + +#ifdef CYGIMP_LIBC_TIME_CTIME_INLINE + +CYGPRI_LIBC_TIME_CTIME_INLINE char * +ctime( const time_t *__timer ) +{ + char *_str; + + CYG_REPORT_FUNCNAMETYPE("ctime", "returning \"%s\""); + CYG_CHECK_DATA_PTR( __timer, "__timer is not a valid pointer!"); + CYG_REPORT_FUNCARG1("*__timer = %d", *__timer); + + _str = asctime(localtime(__timer)); + + CYG_REPORT_RETVAL(_str); + + return _str; +} // ctime() + +#endif // ifdef CYGIMP_LIBC_TIME_CTIME_INLINE + + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // CYGONCE_LIBC_TIME_INL multiple inclusion protection + +// EOF time.inl diff --git a/packages/language/c/libc/time/current/include/timeutil.h b/packages/language/c/libc/time/current/include/timeutil.h new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/include/timeutil.h @@ -0,0 +1,102 @@ +#ifndef CYGONCE_LIBC_TIME_TIMEUTIL_H +#define CYGONCE_LIBC_TIME_TIMEUTIL_H +//======================================================================== +// +// timeutil.h +// +// ISO C date and time implementation support functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-03-03 +// Purpose: Provide declarations for support functions used by the +// ISO C date and time implementation +// Description: +// Usage: #include +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// INCLUDES + +#include // Common type definitions and support + +#ifdef __cplusplus +extern "C" { +#endif + +// GLOBALS + +// Strings of the days and month names +// FIXME: should comment out "const" in multi-dimensional arrays until +// PR 19440 is fixed +extern const char cyg_libc_time_day_name[7][10]; +extern const cyg_uint8 cyg_libc_time_day_name_len[7]; +extern const char cyg_libc_time_month_name[12][10]; +extern const cyg_uint8 cyg_libc_time_month_name_len[12]; + +// number of days in each month, defined for normal and leap years +extern const cyg_uint8 cyg_libc_time_month_lengths[2][12]; + + +// FUNCTION PROTOTYPES + +//////////////////////////////////////// +// cyg_libc_time_normalize_structtm() // +//////////////////////////////////////// +// +// cyg_libc_time_normalize_structtm() will adjust the fields of a struct tm +// so that they are within the normal ranges expected. +// tm_wday, tm_yday, and tm_isdst are ignored + +extern void +cyg_libc_time_normalize_structtm( struct tm *__timeptr ); + +////////////////////////// +// cyg_libc_time_itoa() // +////////////////////////// +// +// This converts num to a string and puts it into s padding with +// "0"'s if padzero is set, or spaces otherwise if necessary. +// The number of chars written to s is returned +// + +extern cyg_uint8 +cyg_libc_time_itoa( cyg_uint8 *__s, cyg_int32 __num, cyg_uint8 __width, + cyg_bool __padzero ); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // CYGONCE_LIBC_TIME_TIMEUTIL_H multiple inclusion protection + +// EOF timeutil.h diff --git a/packages/language/c/libc/time/current/src/asctime.cxx b/packages/language/c/libc/time/current/src/asctime.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/asctime.cxx @@ -0,0 +1,68 @@ +//======================================================================== +// +// asctime.cxx +// +// ISO C date and time implementation for asctime() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide implementation of ISO C asctime() +// Description: This file provides the linkable symbol version of asctime() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include // Common type definitions and support + +// The following lines allow asctime() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_TIME_ASCTIME_INLINE +#ifndef CYGIMP_LIBC_TIME_ASCTIME_INLINE +# define CYGIMP_LIBC_TIME_ASCTIME_INLINE +#endif + +#include // Main date and time definitions + +// GLOBALS + +// 26 isn't such a magic value if you work out what asctime is returning +// It should do until 23:59:59 31st Dec 9999 anyway :-) +char cyg_libc_time_asctime_buf[26]; + +// EOF asctime.cxx diff --git a/packages/language/c/libc/time/current/src/asctime_r.cxx b/packages/language/c/libc/time/current/src/asctime_r.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/asctime_r.cxx @@ -0,0 +1,66 @@ +//======================================================================== +// +// asctime_r.cxx +// +// POSIX 1003.1 date and time implementation for asctime_r() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide implementation of POSIX 1003.1 asctime() +// Description: This file provides the linkable symbol version of asctime_r() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +#ifdef CYGFUN_LIBC_TIME_POSIX + +// INCLUDES + +#include // Common type definitions and support + +// The following lines allow asctime_r() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_TIME_ASCTIME_R_INLINE +#ifndef CYGIMP_LIBC_TIME_ASCTIME_R_INLINE +# define CYGIMP_LIBC_TIME_ASCTIME_R_INLINE +#endif + +#include // Main date and time definitions + +#endif // ifdef CYGFUN_LIBC_TIME_POSIX + +// EOF asctime_r.cxx diff --git a/packages/language/c/libc/time/current/src/clock.cxx b/packages/language/c/libc/time/current/src/clock.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/clock.cxx @@ -0,0 +1,122 @@ +//=========================================================================== +// +// clock.cxx +// +// ISO C date and time implementation for clock() +// +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-03-05 +// Purpose: Provides an implementation of the ISO C function clock() +// from ISO C section 7.12.2.1 +// Description: This file uses the kernel real time clock to determine +// the complete running time of the system - since we only +// have one task, even though there are perhaps multiple threads +// that is still the running time of the "program" +// Usage: +// +//####DESCRIPTIONEND#### +// +//=========================================================================== + +// CONFIGURATION + +#include // Configuration header + +#ifdef CYGSEM_LIBC_TIME_CLOCK_WORKING +# include // Kernel config header +#endif + +// INCLUDES + +#include // Common type definitions and support +#include // Assertion infrastructure +#include // Tracing infrastructure + +#include // Header for all time-related functions + +#ifdef CYGSEM_LIBC_TIME_CLOCK_WORKING +# include // Kernel clock definitions +# include // Kernel clock inline functions +#endif + + +// TRACE + +# if defined(CYGDBG_USE_TRACING) && defined(CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL) +static int clock_trace = CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL; +# define TL1 (0 < clock_trace) +# else +# define TL1 (0) +# endif + +// FUNCTIONS + +externC clock_t +clock( void ) +{ + CYG_REPORT_FUNCNAMETYPE( "clock", "returning clock tick %d" ); + CYG_REPORT_FUNCARGVOID(); + +#ifdef CYGSEM_LIBC_TIME_CLOCK_WORKING + cyg_tick_count curr_clock; // kernel clock value + Cyg_Clock::cyg_resolution resolution; // kernel clock resolution + clock_t clocks; + + CYG_TRACE0( TL1, "getting clock resolution" ); + + // get the resolution + resolution = Cyg_Clock::real_time_clock->get_resolution(); + + CYG_TRACE2( TL1, "got resolution dividend %d divisor %d. Getting " + "clock value", resolution.dividend, resolution.divisor ); + + // get the value + curr_clock = Cyg_Clock::real_time_clock->current_value(); + + CYG_TRACE1( TL1, "got clock value %d", curr_clock ); + + // scale the value so that clock()/CLOCKS_PER_SEC works - clock_t + // should be big enough to cope + clocks = ((clock_t)curr_clock * resolution.dividend) / + (resolution.divisor * (1000000000 / CLOCKS_PER_SEC)); + + CYG_REPORT_RETVAL( clocks ); + return clocks; + +#else // i.e. ifndef CYGSEM_LIBC_TIME_CLOCK_WORKING + CYG_REPORT_RETVAL( -1 ); + return (clock_t) -1; +#endif + +} // clock() + + +// EOF clock.cxx diff --git a/packages/language/c/libc/time/current/src/ctime.cxx b/packages/language/c/libc/time/current/src/ctime.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/ctime.cxx @@ -0,0 +1,58 @@ +//======================================================================== +// +// ctime.cxx +// +// ISO C date and time implementation for ctime() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide implementation of ISO C ctime() +// Description: This file provides the linkable symbol version of ctime() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +// The following lines allow ctime() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_TIME_CTIME_INLINE +#ifndef CYGIMP_LIBC_TIME_CTIME_INLINE +# define CYGIMP_LIBC_TIME_CTIME_INLINE +#endif + +#include // Main date and time definitions + +// EOF ctime.cxx diff --git a/packages/language/c/libc/time/current/src/ctime_r.cxx b/packages/language/c/libc/time/current/src/ctime_r.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/ctime_r.cxx @@ -0,0 +1,62 @@ +//======================================================================== +// +// ctime_r.cxx +// +// POSIX 1003.1 date and time implementation for ctime_r() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide implementation of POSIX 1003.1 ctime() +// Description: This file provides the linkable symbol version of ctime_r() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +#ifdef CYGFUN_LIBC_TIME_POSIX + +// The following lines allow ctime_r() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_TIME_CTIME_R_INLINE +#ifndef CYGIMP_LIBC_TIME_CTIME_R_INLINE +# define CYGIMP_LIBC_TIME_CTIME_R_INLINE +#endif + +#include // Main date and time definitions + +#endif // ifdef CYGFUN_LIBC_TIME_POSIX + +// EOF ctime_r.cxx diff --git a/packages/language/c/libc/time/current/src/difftime.cxx b/packages/language/c/libc/time/current/src/difftime.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/difftime.cxx @@ -0,0 +1,58 @@ +//======================================================================== +// +// difftime.cxx +// +// ISO C date and time implementation for difftime() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide implementation of ISO C difftime() +// Description: This file provides the linkable symbol version of difftime() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +// The following lines allow difftime() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_TIME_DIFFTIME_INLINE +#ifndef CYGIMP_LIBC_TIME_DIFFTIME_INLINE +# define CYGIMP_LIBC_TIME_DIFFTIME_INLINE +#endif + +#include // Main date and time definitions + +// EOF difftime.cxx diff --git a/packages/language/c/libc/time/current/src/gmtime.cxx b/packages/language/c/libc/time/current/src/gmtime.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/gmtime.cxx @@ -0,0 +1,66 @@ +//======================================================================== +// +// gmtime.cxx +// +// ISO C date and time implementation for gmtime() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide implementation of ISO C gmtime() +// Description: This file provides the linkable symbol version of gmtime() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include // Common type definitions and support + +// The following lines allow gmtime() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_TIME_GMTIME_INLINE +#ifndef CYGIMP_LIBC_TIME_GMTIME_INLINE +# define CYGIMP_LIBC_TIME_GMTIME_INLINE +#endif + +#include // Main date and time definitions + +// GLOBALS + +struct tm cyg_libc_time_gmtime_buf; + +// EOF gmtime.cxx diff --git a/packages/language/c/libc/time/current/src/gmtime_r.cxx b/packages/language/c/libc/time/current/src/gmtime_r.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/gmtime_r.cxx @@ -0,0 +1,62 @@ +//======================================================================== +// +// gmtime_r.cxx +// +// POSIX 1003.1 date and time implementation for gmtime_r() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide implementation of POSIX 1003.1 gmtime() +// Description: This file provides the linkable symbol version of gmtime_r() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +#ifdef CYGFUN_LIBC_TIME_POSIX + +// The following lines allow gmtime_r() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_TIME_GMTIME_R_INLINE +#ifndef CYGIMP_LIBC_TIME_GMTIME_R_INLINE +# define CYGIMP_LIBC_TIME_GMTIME_R_INLINE +#endif + +#include // Main date and time definitions + +#endif // ifdef CYGFUN_LIBC_TIME_POSIX + +// EOF gmtime_r.cxx diff --git a/packages/language/c/libc/time/current/src/localtime.cxx b/packages/language/c/libc/time/current/src/localtime.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/localtime.cxx @@ -0,0 +1,62 @@ +//======================================================================== +// +// localtime.cxx +// +// ISO C date and time implementation for localtime() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide implementation of ISO C localtime() +// Description: This file provides the linkable symbol version of localtime() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +// The following lines allow localtime() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_TIME_LOCALTIME_INLINE +#ifndef CYGIMP_LIBC_TIME_LOCALTIME_INLINE +# define CYGIMP_LIBC_TIME_LOCALTIME_INLINE +#endif + +#include // Main date and time definitions + +// GLOBALS + +struct tm cyg_libc_time_localtime_buf; + +// EOF localtime.cxx diff --git a/packages/language/c/libc/time/current/src/localtime_r.cxx b/packages/language/c/libc/time/current/src/localtime_r.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/localtime_r.cxx @@ -0,0 +1,63 @@ +//======================================================================== +// +// localtime_r.cxx +// +// POSIX 1003.1 date and time implementation for localtime_r() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide implementation of POSIX 1003.1 localtime() +// Description: This file provides the linkable symbol version of +// localtime_r() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +#ifdef CYGFUN_LIBC_TIME_POSIX + +// The following lines allow localtime_r() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_TIME_LOCALTIME_R_INLINE +#ifndef CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE +# define CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE +#endif + +#include // Main date and time definitions + +#endif // ifdef CYGFUN_LIBC_TIME_POSIX + +// EOF localtime_r.cxx diff --git a/packages/language/c/libc/time/current/src/mktime.cxx b/packages/language/c/libc/time/current/src/mktime.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/mktime.cxx @@ -0,0 +1,58 @@ +//======================================================================== +// +// mktime.cxx +// +// ISO C date and time implementation for mktime() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide implementation of ISO C mktime() +// Description: This file provides the linkable symbol version of mktime() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +// The following lines allow mktime() to be included non-inline which +// actually defines it as a function here +#define CYGPRI_LIBC_TIME_MKTIME_INLINE +#ifndef CYGIMP_LIBC_TIME_MKTIME_INLINE +# define CYGIMP_LIBC_TIME_MKTIME_INLINE +#endif + +#include // Main date and time definitions + +// EOF mktime.cxx diff --git a/packages/language/c/libc/time/current/src/settime.cxx b/packages/language/c/libc/time/current/src/settime.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/settime.cxx @@ -0,0 +1,88 @@ +//======================================================================== +// +// settime.cxx +// +// Date and time support function to set time +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide support function to set the time +// Description: The wallclock device is used to store the time in UTC +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include // Common type definitions and support +#include // Main date and time definitions +#include // Assertion infrastructure +#include // Tracing infrastructure +#ifdef CYGSEM_LIBC_TIME_SETTIME_WORKING +# include // Wallclock class definitions +#endif + +// FUNCTIONS + +///////////////////////////// +// cyg_libc_time_settime() // +///////////////////////////// +// +// This function sets the current time for the system. The time is +// specified as a time_t in UTC. It returns non-zero on error. +// + +externC cyg_bool +cyg_libc_time_settime( time_t utctime ) +{ + CYG_REPORT_FUNCNAMETYPE("cyg_libc_time_settime", "returning status %d"); + CYG_REPORT_FUNCARG1DV(utctime); + +#ifdef CYGSEM_LIBC_TIME_SETTIME_WORKING + + Cyg_WallClock::wallclock->set_current_time((cyg_uint32) utctime); + + CYG_REPORT_RETVAL(false); + return false; +#else + CYG_REPORT_RETVAL(true); + return true; +#endif + +} // cyg_libc_time_settime() + +// EOF settime.cxx diff --git a/packages/language/c/libc/time/current/src/strftime.cxx b/packages/language/c/libc/time/current/src/strftime.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/strftime.cxx @@ -0,0 +1,300 @@ +//======================================================================== +// +// strftime.cxx +// +// ISO C date and time implementation for strftime() +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-02-26 +// Purpose: Provide implementation of the ISO C function strftime() +// from ISO C section 7.12.3.5 +// Description: This file provides the implementation of strftime() +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include // Common type definitions and support +#include // Assertion infrastructure +#include // Tracing infrastructure +#include // Main date and time definitions +#include // For cyg_libc_time_{day,month}_name{,_len} + +// FUNCTION PROTOTYPES + +// FIXME: This all needs to be internationalized and localized, both in +// terms of reading and writing multibyte characters, and that it should +// refer to the settings of LC_TIME + +// FUNCTIONS + +// This helper function actually processes the format. Which format to insert +// is indicated by fmtchar, sizeleft is the maximum space allowed to be used +// in buf. The number of bytes written is returned, or -1 if there was no +// space + +static cyg_int8 +do_format(cyg_uint8 fmtchar, cyg_ucount32 sizeleft, char *buf, + const struct tm *timeptr) +{ + cyg_count8 i; + + switch (fmtchar) { + case 'a': + if (sizeleft<3) + return -1; + buf[0] = cyg_libc_time_day_name[timeptr->tm_wday][0]; + buf[1] = cyg_libc_time_day_name[timeptr->tm_wday][1]; + buf[2] = cyg_libc_time_day_name[timeptr->tm_wday][2]; + return 3; + case 'A': + if (sizeleft < cyg_libc_time_day_name_len[timeptr->tm_wday]) + return -1; + for (i=0; itm_wday]; ++i) + buf[i] = cyg_libc_time_day_name[timeptr->tm_wday][i]; + return i; + case 'b': + if (sizeleft<3) + return -1; + buf[0] = cyg_libc_time_month_name[timeptr->tm_mon][0]; + buf[1] = cyg_libc_time_month_name[timeptr->tm_mon][1]; + buf[2] = cyg_libc_time_month_name[timeptr->tm_mon][2]; + return 3; + case 'B': + if (sizeleft < cyg_libc_time_month_name_len[timeptr->tm_mon]) + return -1; + for (i=0; itm_mon]; ++i) + buf[i] = cyg_libc_time_month_name[timeptr->tm_mon][i]; + return i; + case 'c': + if (sizeleft < 26) + return -1; + + // Recurse! Note that we know that we will have left room for the + // trailing NULL in the strftime body + + i = strftime( buf, sizeleft+1, "%a %b %d %I:%M:%S%p %Y", timeptr); + + return ((0==i) ? -1 : i); + case 'd': + if (sizeleft < 2) + return -1; + buf[0] = (timeptr->tm_mday / 10) + '0'; + buf[1] = (timeptr->tm_mday % 10) + '0'; + return 2; + case 'H': + if (sizeleft < 2) + return -1; + buf[0] = (timeptr->tm_hour / 10) + '0'; + buf[1] = (timeptr->tm_hour % 10) + '0'; + return 2; + case 'I': + if (sizeleft < 2) + return -1; + buf[0] = ((timeptr->tm_hour%12 + 1) / 10) + '0'; + buf[1] = ((timeptr->tm_hour%12 + 1) % 10) + '0'; + return 2; + case 'j': + if (sizeleft < 3) + return -1; + buf[0] = (timeptr->tm_yday / 100) + '0'; + buf[1] = ((timeptr->tm_yday % 100) / 10) + '0'; + buf[2] = (timeptr->tm_yday % 10) + '0'; + return 3; + case 'm': + if (sizeleft < 2) + return -1; + buf[0] = ((timeptr->tm_mon+1) / 10) + '0'; + buf[1] = ((timeptr->tm_mon+1) % 10) + '0'; + return 2; + case 'M': + if (sizeleft < 2) + return -1; + buf[0] = (timeptr->tm_min / 10) + '0'; + buf[1] = (timeptr->tm_min % 10) + '0'; + return 2; + case 'p': + if (sizeleft < 2) + return -1; + buf[0] = (timeptr->tm_hour > 11) ? 'p' : 'a'; + buf[1] = 'm'; + return 2; + case 'S': + if (sizeleft < 2) + return -1; + buf[0] = (timeptr->tm_sec / 10) + '0'; + buf[1] = (timeptr->tm_sec % 10) + '0'; + return 2; + case 'U': + if (sizeleft < 2) + return -1; + i = (timeptr->tm_yday - timeptr->tm_wday + 7) / 7; + buf[0] = (i / 10) + '0'; + buf[1] = (i % 10) + '0'; + return 2; + case 'w': + // Don't need to check size - we'll always be called with sizeleft > 0 + buf[0] = timeptr->tm_wday + '0'; + return 1; + case 'W': + if (sizeleft < 2) + return -1; + i = (timeptr->tm_yday + ((8-timeptr->tm_wday) % 7)) / 7; + buf[0] = (i / 10) + '0'; + buf[1] = (i % 10) + '0'; + return 2; + case 'x': + if (sizeleft < 15) + return -1; + + // Recurse! Note that we know that we will have left room for the + // trailing NULL in the strftime body + + i = strftime( buf, sizeleft+1, "%a %b %d %Y", timeptr); + + return (0==i) ? -1 : i; + case 'X': + if (sizeleft < 10) + return -1; + + // Recurse! Note that we know that we will have left room for the + // trailing NULL in the strftime body + + i = strftime( buf, sizeleft+1, "%I:%M:%S%p", timeptr); + + return (0==i) ? -1 : i; + case 'y': + if (sizeleft < 2) + return -1; + buf[0] = ((timeptr->tm_year % 100) / 10) + '0'; + buf[1] = ((timeptr->tm_year % 100) % 10) + '0'; + return 2; + case 'Y': + if (sizeleft < 4) + return -1; + buf[0] = ((1900+timeptr->tm_year) / 1000) + '0'; + buf[1] = (((1900+timeptr->tm_year) % 1000) / 100) + '0'; + buf[2] = ((timeptr->tm_year % 100) / 10) + '0'; + buf[3] = (timeptr->tm_year % 10) + '0'; + return 4; + case 'Z': + // FIXME: Should store zone in timeptr->tm_zone, or failing that + // read TZ env variable using tzset() + return 0; + case '%': + // Don't need to check size - we'll always be called with sizeleft > 0 + buf[0] = '%'; + return 1; + default: + CYG_FAIL("invalid format character!"); + return -1; + } // switch + +} // do_format() + +externC size_t +strftime( char *s, size_t maxsize, const char *format, + const struct tm *timeptr) +{ + CYG_REPORT_FUNCNAMETYPE("strftime", "returning string length %d"); + CYG_CHECK_DATA_PTR(s, "string s is not a valid address!"); + CYG_CHECK_DATA_PTR(format, "format string is not at a valid address!"); + CYG_CHECK_DATA_PTR(timeptr, + "struct tm argument is not at a valid address!"); + CYG_REPORT_FUNCARG4("s is at address %08x, maxsize=%d, format=\"%s\", " + "timeptr is at address %08x", + s, maxsize, format, timeptr); + + CYG_PRECONDITION((timeptr->tm_sec >= 0) && (timeptr->tm_sec < 62), + "timeptr->tm_sec out of range!"); + CYG_PRECONDITION((timeptr->tm_min >= 0) && (timeptr->tm_min < 60), + "timeptr->tm_min out of range!"); + CYG_PRECONDITION((timeptr->tm_hour >= 0) && (timeptr->tm_hour < 24), + "timeptr->tm_hour out of range!"); + // Currently I don't check _actual_ numbers of days in each month here + // FIXME: No reason why not though + CYG_PRECONDITION((timeptr->tm_mday >= 1) && (timeptr->tm_mday < 32), + "timeptr->tm_mday out of range!"); + CYG_PRECONDITION((timeptr->tm_mon >= 0) && (timeptr->tm_mon < 12), + "timeptr->tm_mon out of range!"); + CYG_PRECONDITION((timeptr->tm_wday >= 0) && (timeptr->tm_wday < 7), + "timeptr->tm_wday out of range!"); + CYG_PRECONDITION((timeptr->tm_yday >= 0) && (timeptr->tm_yday < 366), + "timeptr->tm_yday out of range!"); + CYG_PRECONDITION((timeptr->tm_year > -1900) && + (timeptr->tm_year < 8100), + "timeptr->tm_year out of range!"); + + if (!maxsize) { + CYG_REPORT_RETVAL(0); + return 0; + } // if + + // lets leave the room for the trailing null up front + --maxsize; + + cyg_ucount32 i, spos; + cyg_int8 dof_ret; + + for (i=0, spos=0; (spos // C library configuration + +// INCLUDES + +#include // Common type definitions and support +#include // Assertion infrastructure +#include // Tracing infrastructure +#include // Main date and time definitions + +#ifdef CYGSEM_LIBC_TIME_TIME_WORKING +# include // Wallclock class definitions +#endif + +// FUNCTIONS + +externC time_t +time( time_t *timer ) +{ + CYG_REPORT_FUNCNAMETYPE("time", "returning %d"); + if (timer) // its allowed to be NULL + CYG_CHECK_DATA_PTR( timer, "timer is not a valid pointer!"); + CYG_REPORT_FUNCARG1("timer = %08x", timer); + +#ifdef CYGSEM_LIBC_TIME_TIME_WORKING + time_t ret; + + ret = (time_t) Cyg_WallClock::wallclock->get_current_time(); + + if (timer) + *timer = ret; + + CYG_REPORT_RETVAL(ret); + + return ret; + +#else // i.e. ifndef CYGSEM_LIBC_TIME_TIME_WORKING + + if (timer) + *timer = (time_t)-1; + CYG_REPORT_RETVAL(-1); + return (time_t)-1; + +#endif + +} // time() + + +// EOF time.cxx diff --git a/packages/language/c/libc/time/current/src/timeutil.cxx b/packages/language/c/libc/time/current/src/timeutil.cxx new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/src/timeutil.cxx @@ -0,0 +1,286 @@ +//======================================================================== +// +// timeutil.cxx +// +// ISO C date and time implementation support functions +// +//======================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//======================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 2000-04-28 +// Purpose: Provide support functions used by the ISO C date and time +// implementation +// Description: This file provides the functions: +// cyg_libc_time_normalize_structtm() +// cyg_libc_time_getzoneoffsets() +// cyg_libc_time_setzoneoffsets() +// cyg_libc_time_setdst() +// cyg_libc_time_itoa() +// and the globals: +// cyg_libc_time_day_name +// cyg_libc_time_day_name_len +// cyg_libc_time_month_name +// cyg_libc_time_month_name_len +// cyg_libc_time_month_lengths +// cyg_libc_time_current_dst_stat +// cyg_libc_time_current_std_offset +// cyg_libc_time_current_dst_offset +// Usage: +// +//####DESCRIPTIONEND#### +// +//======================================================================== + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +// define these functions as outline, not inline, functions in this file +#define CYGPRI_LIBC_TIME_GETZONEOFFSETS_INLINE extern "C" +#define CYGPRI_LIBC_TIME_SETZONEOFFSETS_INLINE extern "C" +#define CYGPRI_LIBC_TIME_SETDST_INLINE extern "C" + +#include // Common type definitions and support +#include // Header for this file +#include // Main date and time definitions +#include // for div() and abs() + + +// GLOBALS + +// FIXME: PR19440 - const char & -fwritable-strings don't mix +const char cyg_libc_time_day_name[7][10] = { + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", + "Saturday" +}; +const cyg_uint8 cyg_libc_time_day_name_len[7] = { 6, 6, 7, 9, 8, 6, 8 }; + +// FIXME: PR19440 - const char & -fwritable-strings don't mix +const char cyg_libc_time_month_name[12][10] = { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" +}; +const cyg_uint8 cyg_libc_time_month_name_len[12] = { 7, 8, 5, 5, 3, 4, + 4, 6, 9, 7, 8, 8 }; + +const cyg_uint8 cyg_libc_time_month_lengths[2][12] = { + {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, + {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} +}; + +Cyg_libc_time_dst cyg_libc_time_current_dst_stat = + (Cyg_libc_time_dst)CYGNUM_LIBC_TIME_DST_DEFAULT_STATE; +time_t cyg_libc_time_current_std_offset = + (time_t)CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET; +time_t cyg_libc_time_current_dst_offset = + (time_t)CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET; + + +// FUNCTIONS + +//////////////////////////////////////// +// cyg_libc_time_normalize_structtm() // +//////////////////////////////////////// +// +// cyg_libc_time_normalize_structtm() will adjust the fields of a struct tm +// so that they are within the normal ranges expected. +// tm_wday, tm_yday and tm_isdst are ignored + +externC void +cyg_libc_time_normalize_structtm( struct tm *timeptr ) +{ + div_t t; + + CYG_REPORT_FUNCNAME("cyg_libc_time_normalize_structtm"); + CYG_REPORT_FUNCARG1("timeptr is at address %08x", timeptr); + + // normalize seconds to 0..59 + if ((timeptr->tm_sec < 0) || (timeptr->tm_sec > 59)) { + t = div(timeptr->tm_sec, 60); + while (t.rem < 0) { + t.rem += 60; + --t.quot; + } + timeptr->tm_min += t.quot; + timeptr->tm_sec = t.rem; + } // if + + // normalize minutes to 0..59 + if ((timeptr->tm_min < 0) || (timeptr->tm_min > 59)) { + t = div(timeptr->tm_min, 60); + while (t.rem < 0) { + t.rem += 60; + --t.quot; + } + timeptr->tm_hour += t.quot; + timeptr->tm_min = t.rem; + } // if + + // normalize hours to 0..23 + if ((timeptr->tm_hour < 0) || (timeptr->tm_hour > 23)) { + t = div(timeptr->tm_hour, 24); + while (t.rem < 0) { + t.rem += 24; + --t.quot; + } + timeptr->tm_mday += t.quot; + timeptr->tm_hour = t.rem; + } // if + + // we wait before normalizing tm_mday as per ISO C 7.12.2.3 (although + // actually it only makes sense if you think about it + + // normalize months to 0..11 + if ((timeptr->tm_mon < 0) || (timeptr->tm_mon > 11)) { + t = div(timeptr->tm_mon, 12); + while (t.rem < 0) { + t.rem += 12; + --t.quot; + } + timeptr->tm_year += t.quot; + timeptr->tm_mon = t.rem; + } // if + + // now tm_mday which needs to go to 1..31 + cyg_bool leap = cyg_libc_time_year_is_leap(timeptr->tm_year); + + while (timeptr->tm_mday < 1) { + // move back a month + + if (--timeptr->tm_mon < 0) { + --timeptr->tm_year; + timeptr->tm_mon = 11; + leap = cyg_libc_time_year_is_leap(timeptr->tm_year); + } // if + + // we move backward the number of days in the _new_ current month + timeptr->tm_mday += cyg_libc_time_month_lengths[leap][timeptr->tm_mon]; + + } // while + + while (timeptr->tm_mday > + cyg_libc_time_month_lengths[leap][timeptr->tm_mon]) { + + // move forward a month + + // we move forward the number of days in the _old_ current month + timeptr->tm_mday -= cyg_libc_time_month_lengths[leap][timeptr->tm_mon]; + + if (++timeptr->tm_mon > 11) { + ++timeptr->tm_year; + timeptr->tm_mon = 0; + leap = cyg_libc_time_year_is_leap(timeptr->tm_year); + } // if + + } // while + + CYG_REPORT_RETURN(); + +} // cyg_libc_time_normalize_structtm() + + +////////////////////////// +// cyg_libc_time_itoa() // +////////////////////////// +// +// This converts num to a string and puts it into s padding with +// "0"'s if padzero is set, or spaces otherwise if necessary. +// The number of chars written to s is returned +// + +// This implementation is probably suboptimal in terms of performance +// but there wouldn't be much in it with only 11 chars max to convert :-/. +// Actually FIXME: what if someone passes a width >11 + +externC cyg_uint8 +cyg_libc_time_itoa( cyg_uint8 *s, cyg_int32 num, cyg_uint8 width, + cyg_bool padzero ) +{ + CYG_REPORT_FUNCNAMETYPE("cyg_libc_time_itoa", "returning %d"); + CYG_REPORT_FUNCARG4( "s=%08x, num=%d, width=%d, padzero=%d", + s, num, width, padzero ); + + CYG_CHECK_DATA_PTR(s, "input string not a valid pointer"); + + // special case for zero otherwise we'd have to treat it specially later + // on anyway + + if (num==0) { + cyg_ucount8 i; + + for (i=0; i 0)) { + *s++ = '-'; + --width; + num = abs(num); + ++ret; + } + + cyg_ucount32 i; + cyg_bool reachednum = false; + cyg_uint8 c, j; + + // i starts off with factor of 10 digits - which is the string length + // of a positive 32-bit number + for (i=1000000000, j=10; i>0; i/=10, --j) { + c = (num / i); + + if (!reachednum && c==0) { + if (j <= width) { + *s++ = padzero ? '0' : ' '; + ++ret; + } + } // if + else { + *s++ = c + '0'; + ++ret; + reachednum = true; + } + num %= i; + } // for + + CYG_POSTCONDITION(ret >= width, "Didn't output enough chars!"); + + CYG_REPORT_RETVAL(ret); + return ret; +} // cyg_libc_time_itoa() + + +// EOF timeutil.cxx diff --git a/packages/language/c/libc/time/current/tests/asctime.c b/packages/language/c/libc/time/current/tests/asctime.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/tests/asctime.c @@ -0,0 +1,196 @@ +//================================================================= +// +// asctime.c +// +// Testcase for C library asctime() function +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 1999-03-05 +// Description: Contains testcode for C library asctime() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include +#include + +// HOW TO START TESTS + +# define START_TEST( test ) test(0) + +// FUNCTIONS + + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static void +test( CYG_ADDRWORD data ) +{ + struct tm tm1; + char *ret; + + tm1.tm_sec = 4; + tm1.tm_min = 23; + tm1.tm_hour = 20; + tm1.tm_mday = 21; + tm1.tm_mon = 1; + tm1.tm_year = 74; + tm1.tm_wday = 4; + tm1.tm_yday = 51; + tm1.tm_isdst = 0; + + ret = asctime(&tm1); + + CYG_TEST_PASS_FAIL(!my_strcmp(ret, "Thu Feb 21 20:23:04 1974\n"), + "asctime test #1"); + tm1.tm_sec = 3; + tm1.tm_min = 51; + tm1.tm_hour = 5; + tm1.tm_mday = 2; + tm1.tm_mon = 11; + tm1.tm_year = 68; + tm1.tm_wday = 1; + tm1.tm_yday = 336; + tm1.tm_isdst = 0; + + ret = asctime(&tm1); + + CYG_TEST_PASS_FAIL(!my_strcmp(ret, "Mon Dec 02 05:51:03 1968\n"), + "asctime test #2"); + + // make this predictable - independent of the user option + cyg_libc_time_setzoneoffsets(0, 3600); + + tm1.tm_sec = 3; + tm1.tm_min = 51; + tm1.tm_hour = 5; + tm1.tm_mday = 2; + tm1.tm_mon = 6; + tm1.tm_year = 68; + tm1.tm_wday = 2; + tm1.tm_yday = 183; + tm1.tm_isdst = 1; + + ret = asctime(&tm1); + + CYG_TEST_PASS_FAIL(!my_strcmp(ret, "Tue Jul 02 05:51:03 1968\n"), + "asctime test #3"); + + tm1.tm_sec = 0; + tm1.tm_min = 0; + tm1.tm_hour = 0; + tm1.tm_mday = 1; + tm1.tm_mon = 0; + tm1.tm_year = 0; + tm1.tm_wday = 1; + tm1.tm_yday = 0; + tm1.tm_isdst = 0; + + ret = asctime(&tm1); + + CYG_TEST_PASS_FAIL(!my_strcmp(ret, "Mon Jan 01 00:00:00 1900\n"), + "asctime test #4"); + + tm1.tm_sec = 0; + tm1.tm_min = 0; + tm1.tm_hour = 0; + tm1.tm_mday = 1; + tm1.tm_mon = 0; + tm1.tm_year = 100; + tm1.tm_wday = 6; + tm1.tm_yday = 0; + tm1.tm_isdst = 0; + + ret = asctime(&tm1); + + CYG_TEST_PASS_FAIL(!my_strcmp(ret, "Sat Jan 01 00:00:00 2000\n"), + "asctime Y2K test #5"); + +#ifdef CYGFUN_LIBC_TIME_POSIX + { + char ret2[100]; + + tm1.tm_sec = 3; + tm1.tm_min = 51; + tm1.tm_hour = 5; + tm1.tm_mday = 2; + tm1.tm_mon = 11; + tm1.tm_year = 68; + tm1.tm_wday = 1; + tm1.tm_yday = 336; + tm1.tm_isdst = 0; + + ret = asctime_r(&tm1, ret2); + + CYG_TEST_PASS_FAIL((ret==ret2) && + !my_strcmp(ret, "Mon Dec 02 05:51:03 1968\n"), + "asctime_r test #1"); + + } +#endif + + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "asctime() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "asctime() function"); + + START_TEST( test ); + + CYG_TEST_NA("Testing is not applicable to this configuration"); + +} // main() + +// EOF asctime.c diff --git a/packages/language/c/libc/time/current/tests/clock.c b/packages/language/c/libc/time/current/tests/clock.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/tests/clock.c @@ -0,0 +1,200 @@ +//================================================================= +// +// clock.c +// +// Testcase for C library clock() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): ctarpy, jlarmour +// Contributors: +// Date: 1999-03-05 +// Description: Contains testcode for C library clock() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include +#include + +#define RUN_TEST 1 + +// This test is bound to fail on Linux -- we don't have exclusive access +// to the CPU. +#if defined(CYGPKG_HAL_I386_LINUX) +#undef RUN_TEST +#define RUN_TEST 0 +#endif + + +// HOW TO START TESTS + +#if RUN_TEST + +#include +#include + +# define START_TEST( test ) test(0) + +#else + +# define START_TEST( test ) CYG_EMPTY_STATEMENT + +#endif + + +// CONSTANTS + +// This defines how many loops before we decide that +// the clock doesnt work +#define MAX_TIMEOUT 1000000 + +// Percentage error before we declare fail: range 0 - 100 +#define TOLERANCE 40 + + +// FUNCTIONS + +#if RUN_TEST + +static int +my_abs(int i) +{ + return (i < 0) ? -i : i; +} // my_abs() + + +static void +test( CYG_ADDRWORD data ) +{ + unsigned long ctr, ctr2, err; + clock_t clock_init; + clock_t clock_first=0, clock_second=0, clock_third=0; + + // First disable the caches - they may affect the timing loops + // below - especially if tracing or assertions are enabled, causing + // the elapsed time during the clock() call to vary. + { + register CYG_INTERRUPT_STATE oldints; + + HAL_DISABLE_INTERRUPTS(oldints); + HAL_DCACHE_SYNC(); + HAL_ICACHE_DISABLE(); + HAL_DCACHE_DISABLE(); + HAL_DCACHE_SYNC(); + HAL_ICACHE_INVALIDATE_ALL(); + HAL_DCACHE_INVALIDATE_ALL(); + HAL_RESTORE_INTERRUPTS(oldints); + } + + // This waits for a clock tick, to ensure that we are at the + // start of a clock period. Then sit in a tight loop to get + // the clock period. Repeat this, and make sure that it the + // two timed periods are acceptably close. + + err = 101; + clock_init = clock(); + + if (clock_init == (clock_t)-1) // unimplemented is just as valid + { + CYG_TEST_PASS_FINISH( "clock() returns -1, meaning unimplemented"); + } // if + + for (ctr = 0; ctr clock_init) + break; // Hit the next clock pulse + } + if (ctr < MAX_TIMEOUT) + { + // We hit a clock pulse, rather than a timeout + // Now we are at the beginning of a pulse, so time until the + // next one in order to get a measure of the length. + for (ctr = 0; ctr clock_first) + break; // Hit the next clock pulse + } // for + if (ctr < MAX_TIMEOUT) + { + // We hit a clock pulse, rather than a timeout. ctr contains + // the number of loops/tick. Measure this again, and see if + // the two results are acceptably close. + for (ctr2 = 0; ctr2 clock_second) + break; // Hit the next clock pulse + } // for + if (ctr2 < MAX_TIMEOUT) + { + err = (100 * my_abs(ctr-ctr2)) / ctr; + } // if (ctr < MAX_TIMEOUT) + else + { + CYG_TEST_FAIL_FINISH("No change in clock state!"); + } // else (ctr < MAX_TIMEOUT) + } // if (ctr < MAX_TIMEOUT) + else + { + CYG_TEST_FAIL_FINISH("No change in clock state!"); + } // else (ctr < MAX_TIMEOUT) + + } // if (ctr < MAX_TIMEOUT) + else + { + CYG_TEST_FAIL_FINISH("No change in clock state!"); + } // else (ctr < MAX_TIMEOUT) + + CYG_TEST_PASS_FAIL(err < TOLERANCE, "clock() stability"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "clock() function"); +} // test() +#endif + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "clock() function"); + + START_TEST( test ); + + CYG_TEST_NA("Testing is not applicable to this configuration"); + +} // main() + +// EOF clock.c diff --git a/packages/language/c/libc/time/current/tests/ctime.c b/packages/language/c/libc/time/current/tests/ctime.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/tests/ctime.c @@ -0,0 +1,132 @@ +//================================================================= +// +// ctime.c +// +// Testcase for C library ctime() function +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-03-05 +// Description: Contains testcode for C library ctime() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include +#include + +// HOW TO START TESTS + +# define START_TEST( test ) test(0) + +// FUNCTIONS + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + + +static void +test( CYG_ADDRWORD data ) +{ + time_t t; + char *ret; + + // make this predictable - independent of the user option + cyg_libc_time_setzoneoffsets(0, 3600); + cyg_libc_time_setdst( CYG_LIBC_TIME_DSTOFF ); + + t = (time_t)130710184; + + ret = ctime(&t); + CYG_TEST_PASS_FAIL(!my_strcmp(ret, "Thu Feb 21 20:23:04 1974\n"), + "ctime test #1"); + + t = (time_t)946689894; + + ret = ctime(&t); + CYG_TEST_PASS_FAIL(!my_strcmp(ret, "Sat Jan 01 01:24:54 2000\n"), + "ctime Y2K test #2"); + + cyg_libc_time_setdst( CYG_LIBC_TIME_DSTON ); + + t = (time_t)-113186106; + + ret = ctime(&t); + CYG_TEST_PASS_FAIL(!my_strcmp(ret, "Tue Jun 01 00:24:54 1966\n"), + "ctime test #3"); + +#ifdef CYGFUN_LIBC_TIME_POSIX + cyg_libc_time_setdst( CYG_LIBC_TIME_DSTOFF ); + + t = (time_t)915510061; + + { + char ret2[26]; + + ret = ctime_r(&t, ret2); + CYG_TEST_PASS_FAIL(!my_strcmp(ret2, "Tue Jan 05 04:21:01 1999\n"), + "ctime_r test #1"); + } +#endif + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "ctime() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "ctime() function"); + + START_TEST( test ); + + CYG_TEST_NA("Testing is not applicable to this configuration"); + +} // main() + +// EOF ctime.c diff --git a/packages/language/c/libc/time/current/tests/gmtime.c b/packages/language/c/libc/time/current/tests/gmtime.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/tests/gmtime.c @@ -0,0 +1,196 @@ +//================================================================= +// +// gmtime.c +// +// Testcase for C library gmtime() function +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 1999-03-05 +// Description: Contains testcode for C library gmtime() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include +#include + +// HOW TO START TESTS + +# define START_TEST( test ) test(0) + +// FUNCTIONS + +static int +cmp_structtm(struct tm *tm1, struct tm *tm2) +{ + if ((tm1->tm_sec != tm2->tm_sec) || + (tm1->tm_min != tm2->tm_min) || + (tm1->tm_hour != tm2->tm_hour) || + (tm1->tm_mday != tm2->tm_mday) || + (tm1->tm_mon != tm2->tm_mon) || + (tm1->tm_year != tm2->tm_year) || + (tm1->tm_wday != tm2->tm_wday) || + (tm1->tm_yday != tm2->tm_yday) || + (tm1->tm_isdst != tm2->tm_isdst)) + return 1; + else + return 0; +} + +static void +test( CYG_ADDRWORD data ) +{ + struct tm tm1, *tm2; + time_t t; + + // make this predictable - independent of the user option + cyg_libc_time_setzoneoffsets(0, 3600); + cyg_libc_time_setdst( CYG_LIBC_TIME_DSTOFF ); + + tm1.tm_sec = 4; + tm1.tm_min = 23; + tm1.tm_hour = 20; + tm1.tm_mday = 21; + tm1.tm_mon = 1; + tm1.tm_year = 74; + tm1.tm_wday = 4; + tm1.tm_yday = 51; + tm1.tm_isdst = 0; + + t = (time_t)130710184; + + tm2 = gmtime(&t); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, tm2), "gmtime test #1"); + + + tm1.tm_sec = 1; + tm1.tm_min = 21; + tm1.tm_hour = 4; + tm1.tm_mday = 5; + tm1.tm_mon = 0; + tm1.tm_wday = 2; + tm1.tm_yday = 4; + tm1.tm_year = 99; + tm1.tm_isdst = 0; + + t = (time_t)915510061; + + tm2 = gmtime(&t); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, tm2), "gmtime test #2"); + + tm1.tm_sec = 54; + tm1.tm_min = 24; + tm1.tm_hour = 1; + tm1.tm_mday = 1; + tm1.tm_mon = 0; + tm1.tm_year = 100; + tm1.tm_wday = 6; + tm1.tm_yday = 0; + tm1.tm_isdst = 0; + + t = (time_t)946689894; + + tm2 = gmtime(&t); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, tm2), "gmtime Y2K test #3"); + + cyg_libc_time_setdst( CYG_LIBC_TIME_DSTON ); + + tm1.tm_sec = 54; + tm1.tm_min = 24; + tm1.tm_hour = 23; + tm1.tm_mday = 31; + tm1.tm_mon = 4; + tm1.tm_wday = 2; + tm1.tm_yday = 150; + tm1.tm_year = 66; + tm1.tm_isdst = 0; + + t = (time_t)-113186106; + + tm2 = gmtime(&t); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, tm2), "gmtime test #4"); + + tm1.tm_sec = 59; + tm1.tm_min = 59; + tm1.tm_hour = 23; + tm1.tm_mday = 31; + tm1.tm_mon = 4; + tm1.tm_wday = 3; + tm1.tm_yday = 151; + tm1.tm_year = 100; + tm1.tm_isdst = 0; + + t = (time_t)959817599; + + tm2 = gmtime(&t); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, tm2), "gmtime test #5"); + + tm1.tm_sec = 0; + tm1.tm_min = 0; + tm1.tm_hour = 0; + tm1.tm_mday = 1; + tm1.tm_mon = 5; + tm1.tm_wday = 4; + tm1.tm_yday = 152; + tm1.tm_year = 100; + tm1.tm_isdst = 0; + + t = (time_t)959817600; + + tm2 = gmtime(&t); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, tm2), "gmtime test #6"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "gmtime() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "gmtime() function"); + + START_TEST( test ); + + CYG_TEST_NA("Testing is not applicable to this configuration"); + +} // main() + +// EOF gmtime.c diff --git a/packages/language/c/libc/time/current/tests/localtime.c b/packages/language/c/libc/time/current/tests/localtime.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/tests/localtime.c @@ -0,0 +1,166 @@ +//================================================================= +// +// localtime.c +// +// Testcase for C library localtime() function +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-03-05 +// Description: Contains testcode for C library localtime() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include +#include + +// HOW TO START TESTS + +# define START_TEST( test ) test(0) + +// FUNCTIONS + +static int +cmp_structtm(struct tm *tm1, struct tm *tm2) +{ + if ((tm1->tm_sec != tm2->tm_sec) || + (tm1->tm_min != tm2->tm_min) || + (tm1->tm_hour != tm2->tm_hour) || + (tm1->tm_mday != tm2->tm_mday) || + (tm1->tm_mon != tm2->tm_mon) || + (tm1->tm_year != tm2->tm_year) || + (tm1->tm_wday != tm2->tm_wday) || + (tm1->tm_yday != tm2->tm_yday) || + (tm1->tm_isdst != tm2->tm_isdst)) + return 1; + else + return 0; +} + +static void +test( CYG_ADDRWORD data ) +{ + struct tm tm1, *tm2; + time_t t; + + // make this predictable - independent of the user option + cyg_libc_time_setzoneoffsets(0, 3600); + cyg_libc_time_setdst( CYG_LIBC_TIME_DSTOFF ); + + tm1.tm_sec = 4; + tm1.tm_min = 23; + tm1.tm_hour = 20; + tm1.tm_mday = 21; + tm1.tm_mon = 1; + tm1.tm_year = 74; + tm1.tm_wday = 4; + tm1.tm_yday = 51; + tm1.tm_isdst = 0; + + t = (time_t)130710184; + + tm2 = localtime(&t); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, tm2), "localtime test #1"); + + + tm1.tm_sec = 1; + tm1.tm_min = 21; + tm1.tm_hour = 4; + tm1.tm_mday = 5; + tm1.tm_mon = 0; + tm1.tm_wday = 2; + tm1.tm_yday = 4; + tm1.tm_year = 99; + tm1.tm_isdst = 0; + + t = (time_t)915510061; + + tm2 = localtime(&t); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, tm2), "localtime test #2"); + + tm1.tm_sec = 54; + tm1.tm_min = 24; + tm1.tm_hour = 1; + tm1.tm_mday = 1; + tm1.tm_mon = 0; + tm1.tm_year = 100; + tm1.tm_wday = 6; + tm1.tm_yday = 0; + tm1.tm_isdst = 0; + + t = (time_t)946689894; + + tm2 = localtime(&t); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, tm2), "localtime Y2K test #3"); + + cyg_libc_time_setdst( CYG_LIBC_TIME_DSTON ); + + tm1.tm_sec = 54; + tm1.tm_min = 24; + tm1.tm_hour = 0; + tm1.tm_mday = 1; + tm1.tm_mon = 5; + tm1.tm_wday = 2; + tm1.tm_yday = 150; + tm1.tm_year = 66; + tm1.tm_isdst = 1; + + t = (time_t)-113186106; + + tm2 = localtime(&t); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, tm2), "localtime test #4"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "localtime() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "localtime() function"); + + START_TEST( test ); + + CYG_TEST_NA("Testing is not applicable to this configuration"); + +} // main() + +// EOF localtime.c diff --git a/packages/language/c/libc/time/current/tests/mktime.c b/packages/language/c/libc/time/current/tests/mktime.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/tests/mktime.c @@ -0,0 +1,168 @@ +//================================================================= +// +// mktime.c +// +// Testcase for C library mktime() function +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-03-05 +// Description: Contains testcode for C library mktime() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include +#include + +// HOW TO START TESTS + +# define START_TEST( test ) test(0) + +// FUNCTIONS + +static int +cmp_structtm(struct tm *tm1, struct tm *tm2) +{ + if ((tm1->tm_sec != tm2->tm_sec) || + (tm1->tm_min != tm2->tm_min) || + (tm1->tm_hour != tm2->tm_hour) || + (tm1->tm_mday != tm2->tm_mday) || + (tm1->tm_mon != tm2->tm_mon) || + (tm1->tm_year != tm2->tm_year) || + (tm1->tm_wday != tm2->tm_wday) || + (tm1->tm_yday != tm2->tm_yday) || + (tm1->tm_isdst != tm2->tm_isdst)) + return 1; + else + return 0; +} + +static void +test( CYG_ADDRWORD data ) +{ + struct tm tm1, tm2; + time_t t; + + // make this predictable - independent of the user option + cyg_libc_time_setzoneoffsets(0, 3600); + + tm1.tm_sec = 4; + tm1.tm_min = 23; + tm1.tm_hour = 20; + tm1.tm_mday = 21; + tm1.tm_mon = 1; + tm1.tm_year = 74; + tm1.tm_isdst = 0; + + tm2 = tm1; + tm2.tm_wday = 4; + tm2.tm_yday = 51; + + t = mktime(&tm1); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, &tm2), "mktime test #1"); + CYG_TEST_PASS_FAIL(t == 130710184, "mktime return test #1"); + + tm1.tm_sec = 61; + tm1.tm_min = 20; + tm1.tm_hour = 4; + tm1.tm_mday = 5; + tm1.tm_mon = 0; + tm1.tm_year = 99; + tm1.tm_isdst = 0; + + tm2 = tm1; + tm2.tm_sec=1; + tm2.tm_min = 21; + tm2.tm_wday = 2; + tm2.tm_yday = 4; + + t = mktime(&tm1); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, &tm2), "mktime test #2"); + CYG_TEST_PASS_FAIL(t == 915510061, "mktime return test #2"); + + tm1.tm_sec = 54; + tm1.tm_min = 24; + tm1.tm_hour = 1; + tm1.tm_mday = 1; + tm1.tm_mon = 0; + tm1.tm_year = 100; + tm1.tm_isdst = 0; + + tm2 = tm1; + tm2.tm_wday = 6; + tm2.tm_yday = 0; + + t = mktime(&tm1); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, &tm2), "mktime Y2K test #3"); + CYG_TEST_PASS_FAIL(t == 946689894, "mktime Y2K return test #3"); + + tm1.tm_sec = 54; + tm1.tm_min = 24; + tm1.tm_hour = 23; + tm1.tm_mday = 31; + tm1.tm_mon = 4; + tm1.tm_year = 66; + tm1.tm_isdst = 1; + + tm2 = tm1; + tm2.tm_wday = 2; + tm2.tm_yday = 150; + + t = mktime(&tm1); + CYG_TEST_PASS_FAIL(!cmp_structtm(&tm1, &tm2), "mktime test #4"); + CYG_TEST_PASS_FAIL(t == -113186106, "mktime return test #4"); + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "mktime() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "mktime() function"); + + START_TEST( test ); + + CYG_TEST_NA("Testing is not applicable to this configuration"); + +} // main() + +// EOF mktime.c diff --git a/packages/language/c/libc/time/current/tests/strftime.c b/packages/language/c/libc/time/current/tests/strftime.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/tests/strftime.c @@ -0,0 +1,186 @@ +//================================================================= +// +// strftime.c +// +// Testcase for C library strftime() function +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: +// Date: 1999-03-05 +// Description: Contains testcode for C library strftime() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // C library configuration + +// INCLUDES + +#include +#include + +// HOW TO START TESTS + +# define START_TEST( test ) test(0) + +// FUNCTIONS + +static int my_strcmp(const char *s1, const char *s2) +{ + for ( ; *s1 == *s2 ; s1++,s2++ ) + { + if ( *s1 == '\0' ) + break; + } // for + + return (*s1 - *s2); +} // my_strcmp() + +static void +test( CYG_ADDRWORD data ) +{ + struct tm tm1; + char s[1000]; + size_t size; + + tm1.tm_sec = 4; + tm1.tm_min = 23; + tm1.tm_hour = 20; + tm1.tm_mday = 21; + tm1.tm_mon = 1; + tm1.tm_year = 74; + tm1.tm_wday = 4; + tm1.tm_yday = 51; + tm1.tm_isdst = 0; + + size = strftime(s, 1000, "", &tm1); + CYG_TEST_PASS_FAIL((size==0) && (*s=='\0'), "strftime test #1"); + + size = strftime(s, 1000, "%a", &tm1); + CYG_TEST_PASS_FAIL((size==3) && !my_strcmp(s, "Thu"), "strftime test #2"); + + size = strftime(s, 1000, "%A", &tm1); + CYG_TEST_PASS_FAIL((size==8) && !my_strcmp(s, "Thursday"), + "strftime test #3"); + + size = strftime(s, 1000, "%b", &tm1); + CYG_TEST_PASS_FAIL((size==3) && !my_strcmp(s, "Feb"), + "strftime test #4"); + + size = strftime(s, 1000, "%B", &tm1); + CYG_TEST_PASS_FAIL((size==8) && !my_strcmp(s, "February"), + "strftime test #5"); + + size = strftime(s, 1000, "%d", &tm1); + CYG_TEST_PASS_FAIL((size==2) && !my_strcmp(s, "21"), + "strftime test #6"); + + size = strftime(s, 1000, "%H", &tm1); + CYG_TEST_PASS_FAIL((size==2) && !my_strcmp(s, "20"), + "strftime test #7"); + + size = strftime(s, 1000, "%I", &tm1); + CYG_TEST_PASS_FAIL((size==2) && !my_strcmp(s, "09"), + "strftime test #8"); + + size = strftime(s, 1000, "%j", &tm1); + CYG_TEST_PASS_FAIL((size==3) && !my_strcmp(s, "051"), + "strftime test #9"); + + size = strftime(s, 1000, "%m", &tm1); + CYG_TEST_PASS_FAIL((size==2) && !my_strcmp(s, "02"), + "strftime test #10"); + + size = strftime(s, 1000, "%M", &tm1); + CYG_TEST_PASS_FAIL((size==2) && !my_strcmp(s, "23"), + "strftime test #11"); + + size = strftime(s, 1000, "%p", &tm1); + CYG_TEST_PASS_FAIL((size==2) && !my_strcmp(s, "pm"), + "strftime test #12"); + + size = strftime(s, 1000, "%S", &tm1); + CYG_TEST_PASS_FAIL((size==2) && !my_strcmp(s, "04"), + "strftime test #13"); + + size = strftime(s, 1000, "%U", &tm1); + CYG_TEST_PASS_FAIL((size==2) && !my_strcmp(s, "07"), + "strftime test #14"); + + size = strftime(s, 1000, "%w", &tm1); + CYG_TEST_PASS_FAIL((size==1) && !my_strcmp(s, "4"), + "strftime test #15"); + + size = strftime(s, 1000, "%W", &tm1); + CYG_TEST_PASS_FAIL((size==2) && !my_strcmp(s, "07"), + "strftime test #16"); + + size = strftime(s, 1000, "%y", &tm1); + CYG_TEST_PASS_FAIL((size==2) && !my_strcmp(s, "74"), + "strftime test #17"); + + size = strftime(s, 1000, "%Y", &tm1); + CYG_TEST_PASS_FAIL((size==4) && !my_strcmp(s, "1974"), + "strftime test #18"); + + size = strftime(s, 1000, "%%", &tm1); + CYG_TEST_PASS_FAIL((size==1) && !my_strcmp(s, "%"), + "strftime test #19"); + + size = strftime(s, 5, "%Y", &tm1); + CYG_TEST_PASS_FAIL((size==4) && !my_strcmp(s, "1974"), + "strftime test #20"); + + size = strftime(s, 4, "%Y", &tm1); + CYG_TEST_PASS_FAIL((size==0), "strftime test #21"); + + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "strftime() function"); +} // test() + + +int +main(int argc, char *argv[]) +{ + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "strftime() function"); + + START_TEST( test ); + + CYG_TEST_NA("Testing is not applicable to this configuration"); + +} // main() + +// EOF strftime.c diff --git a/packages/language/c/libc/time/current/tests/time.c b/packages/language/c/libc/time/current/tests/time.c new file mode 100644 --- /dev/null +++ b/packages/language/c/libc/time/current/tests/time.c @@ -0,0 +1,114 @@ +//================================================================= +// +// time.c +// +// Testcase for C library time() +// +//================================================================= +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//================================================================= +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jlarmour +// Contributors: jlarmour +// Date: 1999-03-05 +// Description: Contains testcode for C library time() function +// +// +//####DESCRIPTIONEND#### + +// CONFIGURATION + +#include // Configuration header + +// INCLUDES + +#include +#include + +// CONSTANTS + +// This defines how many loops before we decide that +// time() doesn't work +#define MAX_TIMEOUT 5000000 + + +// FUNCTIONS + +int +main(int argc, char *argv[]) +{ + time_t t1, t2; + unsigned long ctr; + + CYG_TEST_INIT(); + + CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library " + "time() function"); + + t1 = time(&t2); + + CYG_TEST_PASS_FAIL(t1==t2, "time() return value == argument"); + + if (t1 == (time_t)-1) // unimplemented is just as valid + { +#ifndef CYGSEM_LIBC_TIME_TIME_WORKING + CYG_TEST_PASS_FINISH( "time() returns -1, meaning unimplemented"); +#else + CYG_TEST_FAIL("time() returned -1 unnecessarily"); +#endif + } // if + + // First wait for a clock tick + + for (ctr = 0; ctr t1) + break; // Hit the next time pulse + } + CYG_TEST_PASS_FAIL( ctr< MAX_TIMEOUT, "time()'s state changes"); + +#ifdef CYGSEM_LIBC_TIME_SETTIME_WORKING + CYG_TEST_PASS_FAIL(cyg_libc_time_settime(0)==0, "Set time to 0"); + + t1 = time(NULL); + + // give it a small amount of tolerance + CYG_TEST_PASS_FAIL(t1 < 3, "t1 remembered setting"); + + CYG_TEST_PASS_FAIL(cyg_libc_time_settime(1000)==0, "Set time to 1000"); + + // give it a small amount of tolerance + CYG_TEST_PASS_FAIL(t1 < 1003, "t1 remembered setting"); + +#else // ! CYGSEM_LIBC_TIME_SETTIME_WORKING + CYG_TEST_PASS_FAIL(cyg_libc_time_settime(0)!=0, + "Set time expected fail"); +#endif // CYGSEM_LIBC_TIME_SETTIME_WORKING + + CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library " + "time() function"); +} // main() + +// EOF time.c diff --git a/packages/language/c/libm/current/ChangeLog b/packages/language/c/libm/current/ChangeLog --- a/packages/language/c/libm/current/ChangeLog +++ b/packages/language/c/libm/current/ChangeLog @@ -7,6 +7,12 @@ 2000-05-26 Jesper Skov + + * tests/vectors/vector_support.h: + Update startup configury to reflect changes in libc startup. + Use default stacksize of CYGNUM_HAL_STACK_SIZE_TYPICAL rather than 32K + 2000-03-28 John Dallaway * cdl/libm.cdl: diff --git a/packages/language/c/libm/current/tests/vectors/vector_support.h b/packages/language/c/libm/current/tests/vectors/vector_support.h --- a/packages/language/c/libm/current/tests/vectors/vector_support.h +++ b/packages/language/c/libm/current/tests/vectors/vector_support.h @@ -46,10 +46,8 @@ // CONFIGURATION -#include // Configuration header - -// Include the Math library? -#ifdef CYGPKG_LIBM +#include // Configuration header +#include // CYGINT_ISO_MAIN_STARTUP // INCLUDES @@ -70,38 +68,16 @@ // HOW TO START TESTS -#ifndef CYGPKG_LIBM - -externC int main( int, char ** ); - -externC void -cyg_user_start( void ) -{ - (void) main(0, NULL); -} // cyg_user_start() - -# define START_TEST( test ) CYG_MACRO_START \ - CYG_ADDRESS _foo_ = (CYG_ADDRESS)&test; \ - CYG_UNUSED_PARAM( CYG_ADDRESS, _foo_ ); \ - CYG_MACRO_END - -#elif defined(CYGPKG_LIBC) - -# include - -externC void -cyg_package_start( void ) -{ - cyg_iso_c_start(); -} // cyg_package_start() +#if CYGINT_ISO_MAIN_STARTUP # define START_TEST( test ) test(0) #elif defined(CYGFUN_KERNEL_API_C) +# include # include -# define STACKSIZE 32768 +# define STACKSIZE CYGNUM_HAL_STACK_SIZE_TYPICAL static cyg_uint8 stack[STACKSIZE]; static cyg_handle_t thr_handle; @@ -122,7 +98,7 @@ cyg_user_start( void ) (void) main(0, NULL); } // cyg_user_start() -#else +#else // !defined(CYGFUN_KERNEL_API_C) externC int main( int, char ** ); @@ -132,14 +108,10 @@ cyg_user_start( void ) (void) main(0, NULL); } // cyg_user_start() -# define START_TEST( test ) CYG_MACRO_START \ - CYG_ADDRESS _foo_ = (CYG_ADDRESS)&test; \ - CYG_UNUSED_PARAM( CYG_ADDRESS, _foo_ ); \ - CYG_MACRO_END +# define START_TEST( test ) test(0) #endif - // TYPE DEFINITIONS @@ -514,8 +486,6 @@ doTestVec( CYG_ADDRESS func_ptr, } // doTestVec() -#endif // ifdef CYGPKG_LIBM - #endif // CYGONCE_LIBM_VECTOR_SUPPORT_H multiple inclusion protection // EOF vector_support.h diff --git a/packages/net/snmp/agent/current/ChangeLog b/packages/net/snmp/agent/current/ChangeLog --- a/packages/net/snmp/agent/current/ChangeLog +++ b/packages/net/snmp/agent/current/ChangeLog @@ -1,3 +1,22 @@ +2000-08-16 Hugo Tyson + + * src/snmpd.c (snmpd): Remove call to + init_all_network_interfaces(); it's a bad idea for the situations + when initialization has been done externally to our helper + functions. This adds the constraint that you must initialize the + network interfaces first, by whatever means. Starting snmpd + before the network is up may cause confusion. + [CASE 104330] + + Also tidied some warnings. + +2000-07-25 Hugo Tyson + + * tests/snmpping.c (net_test): Make it ping the loopback + interfaces so as to do some valid testing in the absence of any + real interfaces on the platform. Also make it run less time or no + doubt the farm will report many non-failures. + 2000-07-13 Hugo Tyson * tests/snmpping.c: Up the stack size to cope with full DHCP diff --git a/packages/net/snmp/agent/current/src/snmpd.c b/packages/net/snmp/agent/current/src/snmpd.c --- a/packages/net/snmp/agent/current/src/snmpd.c +++ b/packages/net/snmp/agent/current/src/snmpd.c @@ -272,13 +272,13 @@ int smux_listen_sd; */ int snmp_read_packet (int); int snmp_input (int, struct snmp_session *, int, struct snmp_pdu *, void *); -static void usage (char *); int main (int, char **); static void SnmpTrapNodeDown (void); static int receive(void); int snmp_check_packet(struct snmp_session*, snmp_ipaddr); int snmp_check_parse(struct snmp_session*, struct snmp_pdu*, int); +#if !defined(__ECOS) static void usage(char *prog) { printf("\nUsage: %s [-h] [-v] [-f] [-a] [-d] [-V] [-P PIDFILE] [-q] [-D] [-p NUM] [-L] [-l LOGFILE] [-r]",prog); @@ -322,6 +322,7 @@ static void usage(char *prog) printf("\n"); exit(1); } +#endif // !defined(__ECOS) RETSIGTYPE SnmpdShutDown(int a) @@ -616,16 +617,11 @@ main(int argc, char *argv[]) #else /* __ECOS environment: */ void snmpd( void ) { - int arg, i; int ret; u_short dest_port = SNMP_PORT; #define stderr_log 1 #endif - extern void init_all_network_interfaces(void); - - init_all_network_interfaces(); - SOCK_STARTUP; init_agent("snmpd"); /* do what we need to do first. */ init_mib_modules(); @@ -693,7 +689,6 @@ void snmpd( void ) { SnmpTrapNodeDown(); DEBUGMSGTL(("snmpd", "Bye...\n")); snmp_shutdown("snmpd"); - return 0; } /* End main() -- snmpd */ diff --git a/packages/net/snmp/agent/current/tests/snmpping.c b/packages/net/snmp/agent/current/tests/snmpping.c --- a/packages/net/snmp/agent/current/tests/snmpping.c +++ b/packages/net/snmp/agent/current/tests/snmpping.c @@ -138,6 +138,8 @@ CONNECTION WITH THE USE OR PERFORMANCE O #include +#include + #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000) static char stack[STACK_SIZE]; static cyg_thread thread_data; @@ -149,16 +151,6 @@ static unsigned char pkt1[MAX_PACKET], p #define UNIQUEID 0x1234 -extern void -cyg_test_exit(void); - -void -pexit(char *s) -{ - perror(s); - cyg_test_exit(); -} - // Compute INET checksum int inet_cksum(u_short *addr, int len) @@ -309,10 +301,42 @@ ping_test(struct bootp *bp) close(s); } +static void +ping_test_loopback( int lo ) +{ + struct protoent *p; + struct timeval tv; + struct sockaddr_in host; + int s; + + if ((p = getprotobyname("icmp")) == (struct protoent *)0) { + perror("getprotobyname"); + return; + } + s = socket(AF_INET, SOCK_RAW, p->p_proto); + if (s < 0) { + perror("socket"); + return; + } + tv.tv_sec = 1; + tv.tv_usec = 0; + setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + // Set up host address + host.sin_family = AF_INET; + host.sin_addr.s_addr = htonl(INADDR_LOOPBACK + (0x100 * lo)); + host.sin_port = 0; + ping_host(s, &host); + // Now try a bogus host + host.sin_addr.s_addr = htonl(ntohl(host.sin_addr.s_addr) + 32); + ping_host(s, &host); + close(s); +} + void net_test(cyg_addrword_t p) { - int i = 4; + int i = 0; + int j; diag_printf("Start PING test\n"); init_all_network_interfaces(); #ifdef CYGPKG_SNMPAGENT @@ -325,17 +349,23 @@ net_test(cyg_addrword_t p) #ifdef CYGHWR_NET_DRIVER_ETH0 if (eth0_up) { ping_test(ð0_bootp_data); + cyg_thread_delay(500); } - cyg_thread_delay(500); +#endif +#if NLOOP > 0 + for ( j = 0; j < NLOOP; j++ ) { + ping_test_loopback( j ); + cyg_thread_delay(500); + } #endif #ifdef CYGHWR_NET_DRIVER_ETH1 if (eth1_up) { ping_test(ð1_bootp_data); + cyg_thread_delay(500); } - cyg_thread_delay(500); #endif } while ( i-- > 0 ); - cyg_test_exit(); + CYG_TEST_PASS_FINISH( "Done pinging while SNMP looks on" ); } void diff --git a/packages/net/tcpip/current/ChangeLog b/packages/net/tcpip/current/ChangeLog --- a/packages/net/tcpip/current/ChangeLog +++ b/packages/net/tcpip/current/ChangeLog @@ -1,3 +1,103 @@ +2000-08-17 Hugo Tyson + + * src/ecos/timeout.c (timeout): Rework the timeout system to + record last-time-we-set-the-alarm and whence values, so that new + timeouts being added can be set up relative to the correct + absolute time. Otherwise adding a new timeout sets them *all* + into the future by the expired portion of the previous minimum + pending timeout. Also deal better with recursion ie. timeout + handlers themselves setting new timeouts as is only natural. + Lots of asserts too. + + * src/ecos/support.c (cyg_splsoftnet): Use the new kernel facility + to lock mutex &c atomically, with the scheduler locked already. + (cyg_tsleep): Similarly, and reclaim the mutex likewise. + Also added lots of asserts to both calls the better to document + what's going on. + +2000-08-17 Hugo Tyson + + * src/lib/tftp_server.c: Fix contributors field. + +2000-08-16 Hugo Tyson + + * src/lib/tftp_server.c: Improvements to server wrt better error + messages and detection of filesystem errors eg. on close-file. + Contrib from ASCOM. I tidied up some comments and indent to + minimize the diff. [CASE 104354] + +2000-08-15 Hugo Tyson + + * doc/bridge.html: New file... + * doc/bridge.doc: New file... + provided by ASCOM from the OpenBSD version. + +2000-08-15 Hugo Tyson + + * src/sys/net/if_bridge.c (bridge_ioctl): SIOCBRDGSTO takes + argument in seconds not in ticks. So move around some mul/div by + hz ops to get this right. + +2000-08-14 Gary Thomas + + * src/ecos/support.c: Use new table definition mechanism. + +2000-07-27 Hugo Tyson + + * src/lib/dhcp_prot.c (do_dhcp): Use xmit->bp_htype = + HTYPE_ETHERNET rather than ifr.ifr_hwaddr.sa_family; sa_family is + in a different namespace, despite appearances. + + * src/lib/bootp_support.c (do_bootp): Use bp_htype = + HTYPE_ETHERNET rather than ifr.ifr_hwaddr.sa_family; sa_family is + in a different namespace, despite appearances. + +2000-07-27 Nick Garnett + + * cdl/net.cdl: Require the C library STDIO package to be present + if there is more than one loopback interface. This is because it + needs sprintf() to form the interface names. + + * src/sys/net/if_loop.c (loopattach): + Only use sprintf() to form the loopback interface names when there + is more than one. The CDL ensures that this will work. + + * src/lib/network_support.c: + Added diag_printf() version of perror() for when STDIO package is + absent. + Only use sprintf() to form the loopback interface names when there + is more than one. The CDL ensures that this will work. + + * tests/multi_lo_select.c: + * tests/ping_lo_test.c: + * tests/tcp_lo_test.c: + Removed dependence on C library by adding a substitute perror() + based on diag_printf() that is enabled when the STDIO package is + absent. + +2000-07-26 Hugo Tyson + + * src/lib/dhcp_prot.c (do_dhcp): Set the broadcast flag where + necessary, and the client address too. This makes it talk to a + greater range of servers OK. + +2000-07-25 Nick Garnett + + * tests/multi_lo_select.c: Changed definition of NLISTENERS to + work correctly with FILEIO package. + + * src/sys/net/if_loop.c (loopattach): Changed initialization of + if_xname to "lo0". + + * src/ecos/support.c (cyg_net_init): Removed redundant code to + initialize loop-back interface. + +2000-07-25 Hugo Tyson + + * src/lib/getserv.c: Add a list terminator record with NULLs in it + so that the search finishes (without throwing asserts about bad + strings). + 2000-07-21 Hugo Tyson * src/sys/net/if_bridge.c: Move the include of stdio.h lower, @@ -207,11 +307,18 @@ 2000-07-11 Gary Thomas * include/bootp.h: Fix namespace pollution from "#define int32 int" - it fights against application code too much. +2000-07-04 Jonathan Larmour + + * cdl/net.cdl: Package requires CYGPKG_MEMALLOC + 2000-06-26 Hugo Tyson * tests/ping_test.c (net_test): Added use of the @@ -271,6 +378,12 @@ 2000-06-21 Hugo Tyson + + * src/ecos/support.c: + * include/netdev.h: + Converted to use of new table construction mechanism. + 2000-06-16 Jonathan Larmour * include/bootp.h: Remove RCS id tag @@ -282,11 +395,96 @@ 2000-06-16 Jonathan Larmour + + * src/sys/kern/sockio.c: Added cyg_selinit() calls to bad_socket() + and bsd_accept() functions. + + * src/ecos/support.c (cyg_tsleep): Changed tests on wakeup from + semaphore waits to enable return of EINTR results. + +2000-06-09 Nick Garnett + + * src/sys/net/if_loop.c: Substituted sprintf() for a straight + strcpy() when initalizing if name. This currently only works for + one loopback interface. However, there seems little need to have + more than one. + + * src/sys/kern/sockio.c (bsd_select): Added select support. + + * include/sys/time.h: Moved timeval structure definition to + isoinfra time.h header since it is needed by the select() API. + + * include/sys/select.h: Added option to use fileio select + mechanism if it is present. + + * src/ecos/support.c (cyg_net_init): + Added code to bring up the loopback interface. This is to help + with testing on platforms without network hardware. + 2000-06-08 Hugo Tyson * include/netinet/ip_var.h: Export ipforwarding as well as ip_defttl for monitoring applications. +2000-06-07 Nick Garnett + + * tests/tcp_echo.c: + * tests/socket_test.c: + * tests/server_test.c: + * tests/ping_test.c: + * tests/nc_test_master.c: + * tests/nc_test_slave.c: + * tests/ftp_test.c: + Removed dependence of these programs on STDIO. For most this + simply required the use of a diag_printf() based perror() clone is + CYGPKG_LIBC_STDIO is not defined. For server_test is also required + the substitution of sprintf() with some more primitive string + functions. + + * src/sys/netinet/ip_input.c: Rewrote inet_ntoa() to not use + sprintf(). This was the only place in the TCP/IP stack that was + dependent on a STDIO function. We really should avoid building + this kind of casual dependency into the code. + + * src/sys/kern/sockio.c: This new file contain code to support the + fileio package. So far only a few of these functions have actually + been tested. + + * include/sys/kernel.h (time): The time variable clashes with the + C library time() function. To prevent this it is renamed ktime, + and a #define allows "kernel" code to continue accessing it as + time. + + * src/ecos/support.c: Added definition for ktime variable, as + described above. I could not find any definition for struct + timeval time. I have a nasty suspicion that it was using the + time() function - let's hope that no code that actually uses this + has been run. + + * src/lib/bootp_support.c: Another substitution of a diag_printf() + based perror() clone when STDIO is absent. + + * include/sys/bsdtypes.h: This is the original + include/sys/types.h. Renamed to avoid clashing with + defined by the isoinfra package. + + * include/sys/types.h: Renamed to bsdtypes.h. + + * include/machine/limits.h: + Various changes to make these headers play nicely with those + defined in isoinfra package. + + * include/network.h: Added include of . Fixed + prototypes of functions here to match POSIX specifications. + + * cdl/net.cdl: + Split list of files to compile into the common set plus those + needed when the fileio package is present and those that are + needed when it is absent. + Added CDL to export our definitions to . + + 2000-05-31 Hugo Tyson * src/lib/network_support.c (init_all_network_interfaces): Make diff --git a/packages/net/tcpip/current/cdl/net.cdl b/packages/net/tcpip/current/cdl/net.cdl --- a/packages/net/tcpip/current/cdl/net.cdl +++ b/packages/net/tcpip/current/cdl/net.cdl @@ -45,21 +45,24 @@ cdl_package CYGPKG_NET { doc doc/index.html include_dir . requires CYGPKG_IO - requires CYGPKG_LIBC + requires CYGPKG_ISOINFRA + requires CYGPKG_LIBC_TIME requires CYGPKG_ERROR + requires CYGPKG_MEMALLOC description "Basic networking support, including TCP/IP." + # Export our types to + implements CYGINT_ISO_BSDTYPES + requires { CYGBLD_ISO_BSDTYPES_HEADER == "" } + compile ecos/support.c \ ecos/timeout.c \ ecos/init.cxx \ sys/kern/uipc_mbuf.c \ - sys/kern/uipc_socket.c \ - sys/kern/uipc_socket2.c \ sys/kern/uipc_domain.c \ - sys/kern/uipc_syscalls.c \ + sys/kern/uipc_socket.c \ + sys/kern/uipc_socket2.c \ sys/kern/kern_subr.c \ - sys/kern/sys_socket.c \ - sys/kern/sys_generic.c \ sys/net/if.c \ sys/net/rtsock.c \ sys/net/raw_cb.c \ @@ -94,7 +97,18 @@ cdl_package CYGPKG_NET { lib/network_support.c \ lib/getproto.c \ lib/getserv.c \ - lib/gethost.c \ + lib/gethost.c + + + cdl_option CYGPKG_NET_API_LOCAL { + display "Implement the socket API locally" + flavor bool + active_if !CYGPKG_IO_FILEIO + default_value 1 + + compile sys/kern/uipc_syscalls.c \ + sys/kern/sys_socket.c \ + sys/kern/sys_generic.c \ lib/socket.c \ lib/close.c \ lib/read.c \ @@ -113,6 +127,22 @@ cdl_package CYGPKG_NET { lib/ioctl.c \ lib/select.c + description " + This option controls support for the network-stack supplied + API." + } + + cdl_option CYGPKG_NET_API_FILEIO { + display "Implement the socket API via Fileio package" + active_if CYGPKG_IO_FILEIO + default_value 1 + + compile -library=libextras.a sys/kern/sockio.c + + description " + This option controls support for the fileio subsystem supplied API." + } + cdl_component CYGPKG_NET_INET { display "INET support" flavor bool @@ -286,8 +316,12 @@ cdl_package CYGPKG_NET { display "Number of loopback interfaces" flavor data default_value 1 + requires { (CYGPKG_NET_NLOOP > 1) ? CYGPKG_LIBC_STDIO : 1 } description " - This option controls the number of loopback, i.e. local, interfaces." + This option controls the number of loopback, i.e. local, interfaces. + There is seldom need for this value to be anything other than one. + If a different value is required, then the C library STDIO package + is required for sprintf()." define_proc { puts $::cdl_header "#define NLOOP CYGPKG_NET_NLOOP" } diff --git a/packages/net/tcpip/current/doc/bridge.html b/packages/net/tcpip/current/doc/bridge.html new file mode 100644 --- /dev/null +++ b/packages/net/tcpip/current/doc/bridge.html @@ -0,0 +1,319 @@ + + +
+NAME
+     bridge - Ethernet bridge interface
+
+SYNOPSIS
+     pseudo-device bridge 2
+
+DESCRIPTION
+     The bridge device creates a logical link between two or more Ethernet in
+     terfaces.  This link between the interfaces selectively forwards frames
+     from each interface on the bridge to every other interface on the bridge.
+     A bridge can serve several services, including, isolation of traffic be
+     tween sets of machines so that traffic local to one set of machines is
+     not available on the wire of another set of machines, and it can act as a
+     transparent filter for ip(4) datagrams.
+
+     The bridges provided by this interface are learning bridges with IP fil
+     tering, see ipf(4).  In general a bridge works like a hub, forwarding
+     traffic from one interface to another.  It differs from a hub in that it
+     will "learn" which machines are on each of its attached segments by ac
+     tively listening to incoming traffic and examining the headers of each
+     frame.  A table is built containing the MAC address and segment to which
+     the MAC address is attached.  This allows a bridge to be more selective
+     about what it forwards, which can be used to reduce traffic on a set of
+     segments and also to provide an IP firewall without changing the topology
+     of the network.
+
+     The algorithm works as follows by default, but can be modified via
+     ioctl(2) or the utility brconfig(8).  When a frame comes in, the origin
+     segment and the source address are recorded.  If the bridge has no knowl
+     edge about where the destination is to be found, the bridge will forward
+     the frame to all attached segments.  If the destination is known to be on
+     a different segment from its origin, the bridge will forward the packet
+     only to the destination segment.  If the destination is on the same seg
+     ment as the origin segment, the bridge will drop the packet because the
+     receiver has already had a chance to see the frame.  Before forwarding a
+     frame, the bridge will check to see if the packet contains an ip(4) data
+     gram; if so, the datagram is run through the ipf(4) interface so that it
+     can be filtered.  Only the ipf(4) input rules for the source interface
+     are checked with the datagram; output rules have no effect.
+
+IOCTLS
+     A bridge interface responds to all of the ioctl(2) calls specific to oth
+     er interfaces listed in netintro(4).  The following ioctl(2) calls are
+     specific to bridge devices.  They are defined in .
+
+     SIOCBRDGIFS      (struct ifbifconf) Retrieve member interface list from a
+                      bridge.  This request takes an ifbifconf structure (see
+                      below) as a value-result parameter.  The ifbic_len field
+                      should be initially set to the size of the buffer point
+                      ed to by ifbic_buf. On return it will contain the
+                      length, in bytes, of the configuration list.  Alterna
+                      tively, if the ifbic_len passed in is set to 0,
+                      SIOCBRDGIFS will set ifbic_len to the size that
+                      ifbic_buf needs to be to fit the entire configuration
+                      list, and will not fill in the other parameters.  This
+                      is useful for determining the exact size that ifbic_buf
+                      needs to be in advance.
+
+                      The argument structure is defined as follows:
+
+                            struct ifbreq {
+                                    char ifbr_name[IFNAMSIZ];    /* brdg nam */
+                                    char ifbr_ifsname[IFNAMSIZ]; /* if name */
+                                    u_int32_t ifbr_ifsflags;     /* if flags */
+                            };
+
+                            #define IFBIF_LEARNING  0x1 /* learns addrs */
+                            #define IFBIF_DISCOVER  0x2 /* gets fwd'd pkts */
+
+                            struct ifbifconf {
+                                    char ifbic_name[IFNAMSIZ]; /* brdg name */
+                                    u_int32_t       ifbic_len; /* buf size */
+                                    union {
+                                            caddr_t ifbicu_buf; /* buffer */
+                                            struct  ifbreq *ifbicu_req;
+                                    } ifbic_ifbicu;
+                            #define ifbic_buf       ifbic_ifbicu.ifbicu_buf
+                            #define ifbic_req       ifbic_ifbicu.ifbicu_req
+                            };
+
+     SIOCBRDGADD      (struct ifbreq) Add the interface named in ifbr_ifsname
+                      to the bridge named in ifbr_name.
+
+     SIOCBRDGDEL      (struct ifbreq) Delete the interface named in
+                      ifbr_ifsname from the bridge named in ifbr_name.
+
+     SIOCBRDGSIFFLGS  (struct ifbreq) Set the bridge member interface flags
+                      for the interface named in ifbr_ifsname attached to the
+                      bridge ifbr_name. If the flag IFBIF_LEARNING is set on
+                      an interface, source addresses from frames received on
+                      the interface are recorded in the address cache.  If the
+                      flag IFBIF_DISCOVER is set, the interface will receive
+                      packets destined for unknown destinations, otherwise a
+                      frame that has a destination not found in the address
+                      cache is not forwarded to this interface.  The default
+                      for newly added interfaces has both flags set.  If the
+                      flag IFBIF_BLOCKNONIP is set, packets that are one of
+                      ip(4),  ip6(4),  arp(4),  or Reverse ARP, will not be
+                      bridged from and to the interface.
+
+     SIOCBRDGGIFFLGS  Retrieve the bridge member interface flags for the in
+                      terface named in ifbr_ifsname attached to the bridge
+                      ifbr_name.
+
+     SIOCBRDGRTS      (struct ifbaconf) Retrieve the address cache of the
+                      bridge named in ifbac_name. This request takes an
+                      ifbaconf structure (see below) as a value result parame
+                      ter.  The ifbac_len field should be initially set to the
+                      size of the buffer pointed to by ifbac_buf. On return,
+                      it will contain the length, in bytes, of the configura
+                      tion list.  Alternatively, if the ifbac_len passed in is
+                      set to 0, SIOCBRDGRTS will set it to the size that
+                      ifbac_buf needs to be to fit the entire configuration
+                      list and not fill in the other parameters.  As with
+                      SIOCBRDGIFS, this is useful for determining the exact
+                      size that ifbac_buf needs to be in advance.
+
+                      The argument structure is defined as follows:
+
+                            struct ifbareq {
+                                    char ifba_name[IFNAMSIZ];   /* brdg nam */
+                                    char ifba_ifsname[IFNAMSIZ];/* dest ifs */
+                                    u_int8_t ifba_age;          /* addr age */
+                                    u_int8_t ifba_flags;        /* addr flag */
+                                    struct ether_addr ifba_dst; /* dst addr */
+                            };
+
+                            #define IFBAF_TYPEMASK 0x03  /* addr type mask */
+                            #define IFBAF_DYNAMIC  0x00  /* dynamic addr */
+                            #define IFBAF_STATIC   0x01  /* static address */
+
+                            struct ifbaconf {
+                                    char ifbac_name[IFNAMSIZ]; /* brdg name */
+                                    u_int32_t ifbac_len;       /* buf size */
+                                    union {
+                                            caddr_t ifbacu_buf;     /* buf */
+                                            struct ifbareq *ifbacu_req;
+                                    } ifbac_ifbacu;
+                            #define ifbac_buf       ifbac_ifbacu.ifbacu_buf
+                            #define ifbac_req       ifbac_ifbacu.ifbacu_req
+                            };
+                      Address cache entries with the type set to IFBAF_DYNAMIC
+                      in ifba_flags are entries learned by the bridge.  En
+                      tries with the type set to IFBAF_STATIC are manually
+                      added entries.
+
+     SIOCBRDGSADDR    (struct ifbareq) Add an entry, manually, to the address
+                      cache for the bridge named in ifba_name. The address and
+                      its associated interface and flags are set in the
+                      ifba_dst, ifba_ifsname, ifba_flags fields, respectively.
+
+     SIOCBRDGDADDR    (struct ifbareq) Delete an entry from the address cache
+                      of the bridge named in ifba_name. Entries are deleted
+                      strictly based on the address field ifba_dst.
+
+     SIOCBRDGSCACHE   (struct ifbcachereq) Set the maximum address cache size
+                      for the bridge named in ifbc_name to ifbc_size entries.
+
+                      The argument structure is as follows:
+
+                            struct ifbcachereq {
+                                    char ifbc_name[IFNAMSIZ]; /* bridge */
+                                    u_int32_t ifbc_size;      /* size */
+                            };
+
+     SIOCBRDGGCACHE   (struct ifbcachereq) Retrieve the maximum size of the
+                      address cache for the bridge ifbc_name.
+
+     SIOCBRDGSTO      (struct ifbcachetoreq) Set the time, in seconds, that
+                      addresses which have not been seen on the network
+                      (transmitted a packet) remain in the cache.  If the time
+                      is set to zero, no aging is performed on the address
+                      cache.  The argument structure is as follows:
+
+                            struct ifbcachetoreq {
+                                    char ifbct_name[IFNAMSIZ]; /* bridge */
+                                    u_int32_t ifbct_time;      /* time */
+                            };
+
+     SIOCBRDGGTO      (struct ifbcachetoreq) Retrieve the address cache expi
+                      ration time (see above).
+
+     SIOCBRDGFLUSH    (struct ifbreq) Flush addresses from the cache.
+                      ifbr_name contains the name of the bridge device, and
+                      ifbr_ifsflags should be set to IFBF_FLUSHALL to flush
+                      all addresses from the cache or IFBF_FLUSHDYN to flush
+                      only the dynamically learned addresses from the cache.
+
+     SIOCBRDGARL      (struct ifbrlreq) Add a filtering rule to the bridge
+                      named in ifbr_name on the interface named in
+                      ifbr_ifsname. The argument structure is as follows:
+
+                            struct ifbrlreq {
+                                    char ifbr_name[IFNAMSIZ];    /* bridge */
+                                    char ifbr_ifsname[IFNAMSIZ]; /* ifs */
+                                    u_int8_t ifbr_action;        /* handling */
+                                    u_int8_t ifbr_flags;         /* flags */
+                                    struct ether_addr ifbr_src;  /* src mac */
+                                    struct ether_addr ifbr_dst;  /* dst mac */
+                            };
+                            #define BRL_ACTION_BLOCK        0x01
+                            #define BRL_ACTION_PASS         0x02
+                            #define BRL_FLAG_IN             0x08
+                            #define BRL_FLAG_OUT            0x04
+                            #define BRL_FLAG_SRCVALID       0x02
+                            #define BRL_FLAG_DSTVALID       0x01
+
+                      Rules are applied in the order in which they were added
+                      to the bridge, and the first matching rule's action pa
+                      rameter determines the fate of the packet.  The
+                      ifbr_action parameter specifies whether a frame matching
+                      the rule is to be blocked or passed.
+
+                      If the BRL_FLAG_IN bit is set in ifbr_flags, then the
+                      rule applies to frames received by the interface.  If
+                      the BRL_FLAG_OUT bit is set, then the rule applies to
+                      frame transmitted by the interface.  At least one of
+                      BRL_FLAG_IN or BRL_FLAG_OUT must be set.
+
+                      The source ethernet address in ifbr_src is checked if
+                      the BRL_FLAG_SRCVALID bit is set in ifbr_flags. The des
+                      tination address in ifbr_dst is check if the
+                      BRL_FLAG_DSTVALID bit is set.  If neither bit is set,
+                      the rule is matches all frames.
+
+     SIOCBRDGFRL      (struct ifbrlreq) Remove all filtering rules from a
+                      bridge interface member.  ifbr_name contains the name of
+                      the bridge device, and ifbr_ifsname contains the name of
+                      the bridge member interface.
+
+     SIOCBRDGGRL      (struct ifbrlconf) Retrieve all of the rules from the
+                      bridge, ifbrl_name, for the member interface,
+                      ifbrl_ifsname.
+
+                      This request takes an ifbrlconf structure (see below) as
+                      a value result parameter.  The ifbrl_len field should be
+                      initially set to the size of the buffer pointed to by
+                      ifbrl_buf. On return, it will contain the length, in
+                      bytes, of the configuration list.  Alternatively, if the
+                      ifbrl_len passed in is set to 0, SIOCBRDGGRL will set it
+                      to the size that ifbrl_buf needs to be to fit the entire
+                      configuration list and not fill in the other parameters.
+                      As with SIOCBRDGIFS, this is useful for determining the
+                      exact size that ifbrl_buf needs to be in advance.
+
+                      The argument structure is defined as follows:
+
+                            struct ifbrlconf {
+                                    char ifbrl_name[IFNAMSIZ];   /* brdg nam */
+                                    char ifbrl_ifsname[IFNAMSIZ];/* ifs name */
+                                    u_int32_t ifbr_len;         /* buf len */
+                                    union {
+                                            caddr_t ifbrlu_buf;
+                                            struct ifbrlreq *ifbrlu_req;
+                                    } ifrl_ifbrlu;
+                            #define ifbrl_buf ifbrl_ifbrlu.ifbrlu_buf
+                            #define ifbrl_req ifbrl_ifbrlu.ifbrlu_req
+                            };
+
+
+ERRORS
+     If the ioctl(2) call fails, errno(2) is set to one of the following val
+     ues:
+
+     [ENOENT]      For an add request, this means that the named interface is
+                   not configured into the system.  For delete operation, it
+                   means that the named interface is not a member of the
+                   bridge.  For a address cache deletion, the address was not
+                   found in the table.
+
+     [ENOMEM]      Memory could not be allocated for an interface or cache en
+                   try to be added to the bridge.
+
+     [EEXIST]      The named interface is already a member of the bridge.
+
+     [EBUSY]       The named interface is already a member of another bridge.
+
+     [EINVAL]      The named interface is not an Ethernet interface or an in
+                   valid ioctl was performed on the bridge.
+
+     [ENETDOWN]    Address cache operation (flush, add, delete) on a bridge
+                   that is in the down state.
+
+     [EPERM]       Super-user privilege is required to add and delete inter
+                   faces to and from bridges and to set the bridge interface
+                   flags.
+
+     [EFAULT]      The buffer used in a SIOCBRDGIFS or SIOCBRDGRTS request
+
+                   points outside of the process's allocated address space.
+
+     [ESRCH]       No such member interface in the bridge.
+
+SEE ALSO
+     errno(2),  ioctl(2),  ip(4),  ipf(4),  netintro(4),  bridgename.if(5),
+     brconfig(8)
+
+HISTORY
+     The brconfig(8) command and the bridge(4) kernel interface first appeared
+     in
+
+AUTHOR
+     The brconfig(8) command and the bridge(4) kernel interface were written
+     by Jason L. Wright  as part of an undergraduate inde
+     pendent study at the University of North Carolina at Greensboro.
+
+BUGS
+     There is currently no loop detection.  Care must be taken to make sure
+     that loops are not created when a bridge is brought up.
+
+     Only ipf(4) input rules are checked with incoming packet; there is no
+     easy way to handle output rules.
+
+
+ + diff --git a/packages/net/tcpip/current/doc/bridge.man b/packages/net/tcpip/current/doc/bridge.man new file mode 100644 --- /dev/null +++ b/packages/net/tcpip/current/doc/bridge.man @@ -0,0 +1,314 @@ + +NAME + bridge - Ethernet bridge interface + +SYNOPSIS + pseudo-device bridge 2 + +DESCRIPTION + The bridge device creates a logical link between two or more Ethernet in + terfaces. This link between the interfaces selectively forwards frames + from each interface on the bridge to every other interface on the bridge. + A bridge can serve several services, including, isolation of traffic be + tween sets of machines so that traffic local to one set of machines is + not available on the wire of another set of machines, and it can act as a + transparent filter for ip(4) datagrams. + + The bridges provided by this interface are learning bridges with IP fil + tering, see ipf(4). In general a bridge works like a hub, forwarding + traffic from one interface to another. It differs from a hub in that it + will "learn" which machines are on each of its attached segments by ac + tively listening to incoming traffic and examining the headers of each + frame. A table is built containing the MAC address and segment to which + the MAC address is attached. This allows a bridge to be more selective + about what it forwards, which can be used to reduce traffic on a set of + segments and also to provide an IP firewall without changing the topology + of the network. + + The algorithm works as follows by default, but can be modified via + ioctl(2) or the utility brconfig(8). When a frame comes in, the origin + segment and the source address are recorded. If the bridge has no knowl + edge about where the destination is to be found, the bridge will forward + the frame to all attached segments. If the destination is known to be on + a different segment from its origin, the bridge will forward the packet + only to the destination segment. If the destination is on the same seg + ment as the origin segment, the bridge will drop the packet because the + receiver has already had a chance to see the frame. Before forwarding a + frame, the bridge will check to see if the packet contains an ip(4) data + gram; if so, the datagram is run through the ipf(4) interface so that it + can be filtered. Only the ipf(4) input rules for the source interface + are checked with the datagram; output rules have no effect. + +IOCTLS + A bridge interface responds to all of the ioctl(2) calls specific to oth + er interfaces listed in netintro(4). The following ioctl(2) calls are + specific to bridge devices. They are defined in . + + SIOCBRDGIFS (struct ifbifconf) Retrieve member interface list from a + bridge. This request takes an ifbifconf structure (see + below) as a value-result parameter. The ifbic_len field + should be initially set to the size of the buffer point + ed to by ifbic_buf. On return it will contain the + length, in bytes, of the configuration list. Alterna + tively, if the ifbic_len passed in is set to 0, + SIOCBRDGIFS will set ifbic_len to the size that + ifbic_buf needs to be to fit the entire configuration + list, and will not fill in the other parameters. This + is useful for determining the exact size that ifbic_buf + needs to be in advance. + + The argument structure is defined as follows: + + struct ifbreq { + char ifbr_name[IFNAMSIZ]; /* brdg nam */ + char ifbr_ifsname[IFNAMSIZ]; /* if name */ + u_int32_t ifbr_ifsflags; /* if flags */ + }; + + #define IFBIF_LEARNING 0x1 /* learns addrs */ + #define IFBIF_DISCOVER 0x2 /* gets fwd'd pkts */ + + struct ifbifconf { + char ifbic_name[IFNAMSIZ]; /* brdg name */ + u_int32_t ifbic_len; /* buf size */ + union { + caddr_t ifbicu_buf; /* buffer */ + struct ifbreq *ifbicu_req; + } ifbic_ifbicu; + #define ifbic_buf ifbic_ifbicu.ifbicu_buf + #define ifbic_req ifbic_ifbicu.ifbicu_req + }; + + SIOCBRDGADD (struct ifbreq) Add the interface named in ifbr_ifsname + to the bridge named in ifbr_name. + + SIOCBRDGDEL (struct ifbreq) Delete the interface named in + ifbr_ifsname from the bridge named in ifbr_name. + + SIOCBRDGSIFFLGS (struct ifbreq) Set the bridge member interface flags + for the interface named in ifbr_ifsname attached to the + bridge ifbr_name. If the flag IFBIF_LEARNING is set on + an interface, source addresses from frames received on + the interface are recorded in the address cache. If the + flag IFBIF_DISCOVER is set, the interface will receive + packets destined for unknown destinations, otherwise a + frame that has a destination not found in the address + cache is not forwarded to this interface. The default + for newly added interfaces has both flags set. If the + flag IFBIF_BLOCKNONIP is set, packets that are one of + ip(4), ip6(4), arp(4), or Reverse ARP, will not be + bridged from and to the interface. + + SIOCBRDGGIFFLGS Retrieve the bridge member interface flags for the in + terface named in ifbr_ifsname attached to the bridge + ifbr_name. + + SIOCBRDGRTS (struct ifbaconf) Retrieve the address cache of the + bridge named in ifbac_name. This request takes an + ifbaconf structure (see below) as a value result parame + ter. The ifbac_len field should be initially set to the + size of the buffer pointed to by ifbac_buf. On return, + it will contain the length, in bytes, of the configura + tion list. Alternatively, if the ifbac_len passed in is + set to 0, SIOCBRDGRTS will set it to the size that + ifbac_buf needs to be to fit the entire configuration + list and not fill in the other parameters. As with + SIOCBRDGIFS, this is useful for determining the exact + size that ifbac_buf needs to be in advance. + + The argument structure is defined as follows: + + struct ifbareq { + char ifba_name[IFNAMSIZ]; /* brdg nam */ + char ifba_ifsname[IFNAMSIZ];/* dest ifs */ + u_int8_t ifba_age; /* addr age */ + u_int8_t ifba_flags; /* addr flag */ + struct ether_addr ifba_dst; /* dst addr */ + }; + + #define IFBAF_TYPEMASK 0x03 /* addr type mask */ + #define IFBAF_DYNAMIC 0x00 /* dynamic addr */ + #define IFBAF_STATIC 0x01 /* static address */ + + struct ifbaconf { + char ifbac_name[IFNAMSIZ]; /* brdg name */ + u_int32_t ifbac_len; /* buf size */ + union { + caddr_t ifbacu_buf; /* buf */ + struct ifbareq *ifbacu_req; + } ifbac_ifbacu; + #define ifbac_buf ifbac_ifbacu.ifbacu_buf + #define ifbac_req ifbac_ifbacu.ifbacu_req + }; + Address cache entries with the type set to IFBAF_DYNAMIC + in ifba_flags are entries learned by the bridge. En + tries with the type set to IFBAF_STATIC are manually + added entries. + + SIOCBRDGSADDR (struct ifbareq) Add an entry, manually, to the address + cache for the bridge named in ifba_name. The address and + its associated interface and flags are set in the + ifba_dst, ifba_ifsname, ifba_flags fields, respectively. + + SIOCBRDGDADDR (struct ifbareq) Delete an entry from the address cache + of the bridge named in ifba_name. Entries are deleted + strictly based on the address field ifba_dst. + + SIOCBRDGSCACHE (struct ifbcachereq) Set the maximum address cache size + for the bridge named in ifbc_name to ifbc_size entries. + + The argument structure is as follows: + + struct ifbcachereq { + char ifbc_name[IFNAMSIZ]; /* bridge */ + u_int32_t ifbc_size; /* size */ + }; + + SIOCBRDGGCACHE (struct ifbcachereq) Retrieve the maximum size of the + address cache for the bridge ifbc_name. + + SIOCBRDGSTO (struct ifbcachetoreq) Set the time, in seconds, that + addresses which have not been seen on the network + (transmitted a packet) remain in the cache. If the time + is set to zero, no aging is performed on the address + cache. The argument structure is as follows: + + struct ifbcachetoreq { + char ifbct_name[IFNAMSIZ]; /* bridge */ + u_int32_t ifbct_time; /* time */ + }; + + SIOCBRDGGTO (struct ifbcachetoreq) Retrieve the address cache expi + ration time (see above). + + SIOCBRDGFLUSH (struct ifbreq) Flush addresses from the cache. + ifbr_name contains the name of the bridge device, and + ifbr_ifsflags should be set to IFBF_FLUSHALL to flush + all addresses from the cache or IFBF_FLUSHDYN to flush + only the dynamically learned addresses from the cache. + + SIOCBRDGARL (struct ifbrlreq) Add a filtering rule to the bridge + named in ifbr_name on the interface named in + ifbr_ifsname. The argument structure is as follows: + + struct ifbrlreq { + char ifbr_name[IFNAMSIZ]; /* bridge */ + char ifbr_ifsname[IFNAMSIZ]; /* ifs */ + u_int8_t ifbr_action; /* handling */ + u_int8_t ifbr_flags; /* flags */ + struct ether_addr ifbr_src; /* src mac */ + struct ether_addr ifbr_dst; /* dst mac */ + }; + #define BRL_ACTION_BLOCK 0x01 + #define BRL_ACTION_PASS 0x02 + #define BRL_FLAG_IN 0x08 + #define BRL_FLAG_OUT 0x04 + #define BRL_FLAG_SRCVALID 0x02 + #define BRL_FLAG_DSTVALID 0x01 + + Rules are applied in the order in which they were added + to the bridge, and the first matching rule's action pa + rameter determines the fate of the packet. The + ifbr_action parameter specifies whether a frame matching + the rule is to be blocked or passed. + + If the BRL_FLAG_IN bit is set in ifbr_flags, then the + rule applies to frames received by the interface. If + the BRL_FLAG_OUT bit is set, then the rule applies to + frame transmitted by the interface. At least one of + BRL_FLAG_IN or BRL_FLAG_OUT must be set. + + The source ethernet address in ifbr_src is checked if + the BRL_FLAG_SRCVALID bit is set in ifbr_flags. The des + tination address in ifbr_dst is check if the + BRL_FLAG_DSTVALID bit is set. If neither bit is set, + the rule is matches all frames. + + SIOCBRDGFRL (struct ifbrlreq) Remove all filtering rules from a + bridge interface member. ifbr_name contains the name of + the bridge device, and ifbr_ifsname contains the name of + the bridge member interface. + + SIOCBRDGGRL (struct ifbrlconf) Retrieve all of the rules from the + bridge, ifbrl_name, for the member interface, + ifbrl_ifsname. + + This request takes an ifbrlconf structure (see below) as + a value result parameter. The ifbrl_len field should be + initially set to the size of the buffer pointed to by + ifbrl_buf. On return, it will contain the length, in + bytes, of the configuration list. Alternatively, if the + ifbrl_len passed in is set to 0, SIOCBRDGGRL will set it + to the size that ifbrl_buf needs to be to fit the entire + configuration list and not fill in the other parameters. + As with SIOCBRDGIFS, this is useful for determining the + exact size that ifbrl_buf needs to be in advance. + + The argument structure is defined as follows: + + struct ifbrlconf { + char ifbrl_name[IFNAMSIZ]; /* brdg nam */ + char ifbrl_ifsname[IFNAMSIZ];/* ifs name */ + u_int32_t ifbr_len; /* buf len */ + union { + caddr_t ifbrlu_buf; + struct ifbrlreq *ifbrlu_req; + } ifrl_ifbrlu; + #define ifbrl_buf ifbrl_ifbrlu.ifbrlu_buf + #define ifbrl_req ifbrl_ifbrlu.ifbrlu_req + }; + + +ERRORS + If the ioctl(2) call fails, errno(2) is set to one of the following val + ues: + + [ENOENT] For an add request, this means that the named interface is + not configured into the system. For delete operation, it + means that the named interface is not a member of the + bridge. For a address cache deletion, the address was not + found in the table. + + [ENOMEM] Memory could not be allocated for an interface or cache en + try to be added to the bridge. + + [EEXIST] The named interface is already a member of the bridge. + + [EBUSY] The named interface is already a member of another bridge. + + [EINVAL] The named interface is not an Ethernet interface or an in + valid ioctl was performed on the bridge. + + [ENETDOWN] Address cache operation (flush, add, delete) on a bridge + that is in the down state. + + [EPERM] Super-user privilege is required to add and delete inter + faces to and from bridges and to set the bridge interface + flags. + + [EFAULT] The buffer used in a SIOCBRDGIFS or SIOCBRDGRTS request + + points outside of the process's allocated address space. + + [ESRCH] No such member interface in the bridge. + +SEE ALSO + errno(2), ioctl(2), ip(4), ipf(4), netintro(4), bridgename.if(5), + brconfig(8) + +HISTORY + The brconfig(8) command and the bridge(4) kernel interface first appeared + in + +AUTHOR + The brconfig(8) command and the bridge(4) kernel interface were written + by Jason L. Wright as part of an undergraduate inde + pendent study at the University of North Carolina at Greensboro. + +BUGS + There is currently no loop detection. Care must be taken to make sure + that loops are not created when a bridge is brought up. + + Only ipf(4) input rules are checked with incoming packet; there is no + easy way to handle output rules. + diff --git a/packages/net/tcpip/current/include/machine/limits.h b/packages/net/tcpip/current/include/machine/limits.h --- a/packages/net/tcpip/current/include/machine/limits.h +++ b/packages/net/tcpip/current/include/machine/limits.h @@ -58,6 +58,4 @@ #include // Compiler provided -#define SSIZE_MAX INT_MAX /* max value for a ssize_t */ - #endif /* _MACHINE_LIMITS_H_ */ diff --git a/packages/net/tcpip/current/include/network.h b/packages/net/tcpip/current/include/network.h --- a/packages/net/tcpip/current/include/network.h +++ b/packages/net/tcpip/current/include/network.h @@ -57,6 +57,7 @@ #define NO_LIBKERN_INLINE // Avoid kernel inline functions +#include #include #undef _KERNEL #include @@ -89,12 +90,12 @@ extern const char *eth1_name; extern void init_all_network_interfaces(void); -extern void route_reinit(void); -extern void perror(const char *); -extern int close(int); -extern int read(int, void *, int); -extern int write(int, void *, int); -extern char *inet_ntoa(struct in_addr); -extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *tv); +extern void route_reinit(void); +extern void perror(const char *); +extern int close(int); +extern ssize_t read(int, void *, size_t); +extern ssize_t write(int, const void *, size_t); +extern char *inet_ntoa(struct in_addr); +extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *tv); #endif // _NETWORK_H_ diff --git a/packages/net/tcpip/current/include/sys/bsdtypes.h b/packages/net/tcpip/current/include/sys/bsdtypes.h new file mode 100644 --- /dev/null +++ b/packages/net/tcpip/current/include/sys/bsdtypes.h @@ -0,0 +1,258 @@ +//========================================================================== +// +// include/sys/types.h +// +// +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//####BSDCOPYRIGHTBEGIN#### +// +// ------------------------------------------- +// +// Portions of this software may have been derived from OpenBSD or other sources, +// and are covered by the appropriate copyright disclaimers included herein. +// +// ------------------------------------------- +// +//####BSDCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2000-01-10 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + + +/* $OpenBSD: types.h,v 1.15 1999/02/15 18:53:57 millert Exp $ */ +/* $NetBSD: types.h,v 1.29 1996/11/15 22:48:25 jtc Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)types.h 8.4 (Berkeley) 1/21/94 + */ + +#ifndef _SYS_TYPES_H_ +#define _SYS_TYPES_H_ + +/* Machine type dependent parameters. */ +#include + +#include +#include + +#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; + +typedef unsigned char unchar; /* Sys V compatibility */ +typedef unsigned short ushort; /* Sys V compatibility */ +typedef unsigned int uint; /* Sys V compatibility */ +typedef unsigned long ulong; /* Sys V compatibility */ +#endif + +typedef u_int64_t u_quad_t; /* quads */ +typedef int64_t quad_t; +typedef quad_t * qaddr_t; + +typedef char * caddr_t; /* core address */ +typedef int32_t daddr_t; /* disk address */ +typedef u_int32_t fixpt_t; /* fixed point number */ +typedef long key_t; /* IPC key (for Sys V IPC) */ +typedef quad_t rlim_t; /* resource limit */ +typedef int32_t segsz_t; /* segment size */ +typedef int32_t swblk_t; /* swap offset */ +typedef u_int32_t useconds_t; /* microseconds */ +typedef int32_t suseconds_t; /* microseconds (signed) */ + +/* + * XPG4.2 states that inclusion of must pull these + * in and that inclusion of must pull in sa_family_t. + * We put there here because there are other headers that require + * these types and and will indirectly + * include . Thus we are compliant without too many hoops. + */ +typedef u_int32_t in_addr_t; /* base type for internet address */ +typedef u_int16_t in_port_t; /* IP port type */ +typedef u_int8_t sa_family_t; /* sockaddr address family type */ +typedef u_int32_t socklen_t; /* length type for network syscalls */ + +/* + * These belong in unistd.h, but are placed here too to ensure that + * long arguments will be promoted to off_t if the program fails to + * include that header or explicitly cast them to off_t. + */ +#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) +#ifndef _KERNEL +#include +__BEGIN_DECLS +off_t lseek __P((int, off_t, int)); +int ftruncate __P((int, off_t)); +int truncate __P((const char *, off_t)); +__END_DECLS +#endif /* !_KERNEL */ +#endif /* !defined(_POSIX_SOURCE) ... */ + +#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) +/* Major, minor numbers, dev_t's. */ +#define major(x) ((int32_t)(((u_int32_t)(x) >> 8) & 0xff)) +#define minor(x) ((int32_t)((x) & 0xff)) +#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) +#endif + +#if 0 //def _BSD_CLOCK_T_ +typedef _BSD_CLOCK_T_ clock_t; +#undef _BSD_CLOCK_T_ +#endif + +#ifndef __ECOS +#if 0 //def _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif +#endif + +#if 0 //def _BSD_SSIZE_T_ +typedef _BSD_SSIZE_T_ ssize_t; +#undef _BSD_SSIZE_T_ +#endif + +#if 0 //def _BSD_TIME_T_ +typedef _BSD_TIME_T_ time_t; +#undef _BSD_TIME_T_ +#endif + +#if 0 //def _BSD_CLOCKID_T_ +typedef _BSD_CLOCKID_T_ clockid_t; +#undef _BSD_CLOCKID_T_ +#endif + +#if 0 //def _BSD_TIMER_T_ +typedef _BSD_TIMER_T_ timer_t; +#undef _BSD_TIMER_T_ +#endif + +#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) + +#ifndef CYG_FD_SET_DEFINED + +#define NBBY 8 /* number of bits in a byte */ + +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). + * FD_SETSIZE may be defined by the user, but the default here should + * be enough for most uses. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE 256 +#endif + +typedef int32_t fd_mask; +#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ + +#ifndef howmany +#define howmany(x, y) (((x) + ((y) - 1)) / (y)) +#endif + +typedef struct fd_set { + fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; +} fd_set; + +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) +#ifdef _KERNEL +#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) +#define FD_ZERO(p) bzero(p, sizeof(*(p))) +#else +#define FD_COPY(f, t) memcpy(t, f, sizeof(*(f))) +#define FD_ZERO(p) memset(p, 0, sizeof(*(p))) +#endif + +#endif // CYG_FD_SET_DEFINED + +#if defined(__STDC__) && defined(_KERNEL) +/* + * Forward structure declarations for function prototypes. We include the + * common structures that cross subsystem boundaries here; others are mostly + * used in the same place that the structure is defined. + */ +struct proc; +struct pgrp; +struct ucred; +struct rusage; +struct file; +struct buf; +struct tty; +struct uio; +#endif + +#endif /* !defined(_POSIX_SOURCE) ... */ +#endif /* !_SYS_TYPES_H_ */ diff --git a/packages/net/tcpip/current/include/sys/kernel.h b/packages/net/tcpip/current/include/sys/kernel.h --- a/packages/net/tcpip/current/include/sys/kernel.h +++ b/packages/net/tcpip/current/include/sys/kernel.h @@ -109,7 +109,8 @@ extern int domainnamelen; extern volatile struct timeval mono_time; extern struct timeval boottime; extern struct timeval runtime; -extern volatile struct timeval time; +extern volatile struct timeval ktime; +#define time ktime extern struct timezone tz; /* XXX */ extern int tick; /* usec per tick (1000000 / hz) */ diff --git a/packages/net/tcpip/current/include/sys/select.h b/packages/net/tcpip/current/include/sys/select.h --- a/packages/net/tcpip/current/include/sys/select.h +++ b/packages/net/tcpip/current/include/sys/select.h @@ -55,6 +55,16 @@ #ifndef _SYS_SELECT_H_ #define _SYS_SELECT_H_ +#include + +#ifdef CYGPKG_IO_FILEIO + +#include + +void selwakeup __P((struct selinfo *)); + +#else + /* * Used to maintain information about processes that wish to be * notified when I/O becomes possible. @@ -66,4 +76,6 @@ struct selinfo { void selrecord __P((void *selector, struct selinfo *)); void selwakeup __P((struct selinfo *)); +#endif + #endif /* !_SYS_SELECT_H_ */ diff --git a/packages/net/tcpip/current/include/sys/time.h b/packages/net/tcpip/current/include/sys/time.h --- a/packages/net/tcpip/current/include/sys/time.h +++ b/packages/net/tcpip/current/include/sys/time.h @@ -95,6 +95,14 @@ #define _SYS_TIME_H_ #include +#include + +#if 0 //ndef __time_t_defined +typedef int time_t; +# define __time_t_defined +#endif + +#if 0 /* * Structure returned by gettimeofday(2) system call, @@ -105,6 +113,9 @@ struct timeval { long tv_usec; /* and microseconds */ }; +#endif + +#if 0 /* * Structure defined by POSIX.1b to be like a timeval. */ @@ -112,6 +123,7 @@ struct timespec { time_t tv_sec; /* seconds */ long tv_nsec; /* and nanoseconds */ }; +#endif #define TIMEVAL_TO_TIMESPEC(tv, ts) { \ (ts)->tv_sec = (tv)->tv_sec; \ @@ -215,7 +227,9 @@ struct clockinfo { #define CLOCK_PROF 2 #define TIMER_RELTIME 0x0 /* relative timer */ +#ifndef TIMER_ABSTIME #define TIMER_ABSTIME 0x1 /* absolute timer */ +#endif #if defined(_KERNEL) || defined(_STANDALONE) int itimerfix __P((struct timeval *tv)); @@ -228,7 +242,7 @@ void settime __P((struct timeval *tv)); #include #endif -#ifndef _POSIX_SOURCE +#if 0 //ndef _POSIX_SOURCE #include __BEGIN_DECLS diff --git a/packages/net/tcpip/current/src/ecos/support.c b/packages/net/tcpip/current/src/ecos/support.c --- a/packages/net/tcpip/current/src/ecos/support.c +++ b/packages/net/tcpip/current/src/ecos/support.c @@ -41,8 +41,8 @@ //========================================================================== //#####DESCRIPTIONBEGIN#### // -// Author(s): gthomas -// Contributors: gthomas +// Author(s): gthomas, hmt +// Contributors: gthomas, hmt // Date: 2000-01-10 // Purpose: // Description: @@ -61,7 +61,15 @@ #include #include #include +#include +#include +#include +#include +#include #include +#include +#include +#include #include @@ -75,11 +83,16 @@ #include +// Define table boundaries +CYG_HAL_TABLE_BEGIN( __NETDEVTAB__, netdev ); +CYG_HAL_TABLE_END( __NETDEVTAB_END__, netdev ); + // Used for system-wide "ticks per second" int hz = 100; int tick = 10000; // usec per "tick" volatile struct timeval mono_time; +volatile struct timeval ktime; // Low-level network debugging int net_debug = 0; @@ -221,6 +234,18 @@ cyg_splhigh(void) // // Prevent all other stack processing, including interrupts (DSRs), etc. // +// NB a thread in this state can tsleep(); see below. Tsleep releases and +// reclaims the locks and so on. This necessary because of the possible +// conflict where +// I splsoft +// I tsleep +// He runs, he is lower priority +// He splsofts +// He or something else awakens me +// I want to run, but he has splsoft, so I wait +// He runs and releases splsoft +// I awaken and go. + cyg_uint32 #ifdef CYGIMPL_TRACE_SPLX cyg_splsoftnet(const char *file, const int line) @@ -237,17 +262,20 @@ cyg_splsoftnet(void) if (softnet_thread == cyg_thread_self()) { // Do nothing old_ints = spl_state; - spl_state |= SPL_STATE_SOFTNET; cyg_scheduler_unlock(); return old_ints; } } - cyg_scheduler_unlock(); + // As of the new kernel, we can do this without unlocking the scheduler cyg_mutex_lock(&softnet_mutex); - cyg_scheduler_lock(); + + CYG_ASSERT( 0 == softnet_thread, "Softnet thread still set" ); + CYG_ASSERT( 0 == (spl_state & SPL_STATE_SOFTNET), "Softnet bit set" ); + softnet_thread = cyg_thread_self(); old_ints = spl_state; spl_state |= SPL_STATE_SOFTNET; + // NB we keep the sched locked here. return old_ints; } @@ -642,6 +670,7 @@ cyg_wakeup(void *chan) // returns: // 0 - event was "signalled" // ETIMEDOUT - timeout occurred +// EINTR - thread broken out of sleep // int cyg_tsleep(void *chan, int pri, char *wmesg, int timo) @@ -672,6 +701,10 @@ cyg_tsleep(void *chan, int pri, char *wm // Then we must release the 'softnet' mutex when we wait - if we have it if ( self == softnet_thread ) { + CYG_ASSERT( spl_state & SPL_STATE_SOFTNET, "Softnet bit not set" ); + // Also want to assert that the mutex is locked... + CYG_ASSERT( softnet_mutex.locked, "Softnet mutex not locked" ); + CYG_ASSERT( (cyg_handle_t)softnet_mutex.owner == self, "Softnet mutex not mine" ); softnet_thread = 0; spl_state &= ~SPL_STATE_SOFTNET; cyg_mutex_unlock( &softnet_mutex ); @@ -680,26 +713,36 @@ cyg_tsleep(void *chan, int pri, char *wm } // This part actually does the wait: - cyg_scheduler_unlock(); + // As of the new kernel, we can do this without unlocking the scheduler if (timo) { sleep_time = cyg_current_time() + timo; if (!cyg_semaphore_timed_wait(&ev->sem, sleep_time)) { - res = ETIMEDOUT; - ev->chan = 0; // Free slot + if( cyg_current_time() >= sleep_time ) + res = ETIMEDOUT; + else + res = EINTR; + ev->chan = 0; // Free slot (no signaller to free it) } } else { - cyg_semaphore_wait(&ev->sem); + if (!cyg_semaphore_wait(&ev->sem) ) { + res = EINTR; + ev->chan = 0; // Free slot (ditto) + } } - + if ( self ) { // return to previous state + // As of the new kernel, we can do this with the scheduler locked cyg_mutex_lock( &softnet_mutex ); // this might wait - cyg_scheduler_lock(); + CYG_ASSERT( 0 == softnet_thread, "Softnet thread set in tsleep" ); + CYG_ASSERT( 0 == (spl_state & SPL_STATE_SOFTNET), "Softnet bit set in tsleep" ); softnet_thread = self; // got it now... spl_state |= SPL_STATE_SOFTNET; - cyg_scheduler_unlock(); + // and leave the scheduler locked. + CYG_ASSERT( olock > 1, "Sched was not locked" ); } - if ( olock > 1 ) - cyg_scheduler_lock(); + else if ( olock == 1 ) + cyg_scheduler_unlock(); + // otherwise leave it locked, as it was on entry. return res; } @@ -795,7 +838,7 @@ cyg_net_init(void) STACK_SIZE, // Size &netint_thread_handle, // Handle &netint_thread_data // Thread data structure - ); + ); cyg_thread_resume(netint_thread_handle); // Start it // Initialize timeout support cyg_timeout_init(); @@ -824,6 +867,7 @@ cyg_net_init(void) // Start up the network processing ifinit(); domaininit(); + // Done _init = true; } @@ -895,3 +939,5 @@ void do_sched_event(__FUNCTION__, file, line, cyg_scheduler_read_lock()); } #endif // CYGIMPL_TRACE_SPLX + +// EOF support.c diff --git a/packages/net/tcpip/current/src/ecos/timeout.c b/packages/net/tcpip/current/src/ecos/timeout.c --- a/packages/net/tcpip/current/src/ecos/timeout.c +++ b/packages/net/tcpip/current/src/ecos/timeout.c @@ -41,8 +41,8 @@ //========================================================================== //#####DESCRIPTIONBEGIN#### // -// Author(s): gthomas -// Contributors: gthomas +// Author(s): gthomas, hmt +// Contributors: gthomas, hmt // Date: 1999-02-05 // Description: Simple timeout functions //####DESCRIPTIONEND#### @@ -50,6 +50,7 @@ #include #include #include +#include // Timeout support @@ -65,30 +66,55 @@ static timeout_entry timeouts[NTIMEOUTS] static cyg_handle_t timeout_alarm_handle; static cyg_alarm timeout_alarm; static cyg_int32 last_delta; +static cyg_tick_count_t last_set_time; + +extern cyg_uint32 cyg_in_softnet( void ); static void do_timeout(cyg_handle_t alarm, cyg_addrword_t data) { int i; cyg_int32 min_delta; - timeout_entry *e = timeouts; - min_delta = 0x7FFFFFFF; // Maxint - for (i = 0; i < NTIMEOUTS; i++, e++) { + timeout_entry *e; + + CYG_ASSERT( 0 < last_delta, "last_delta underflow" ); + + min_delta = last_delta; // local copy + last_delta = -1; // flag recursive call underway + + for (e = timeouts, i = 0; i < NTIMEOUTS; i++, e++) { if (e->delta) { - e->delta -= last_delta; - if (e->delta == 0) { + CYG_ASSERT( e->delta >= min_delta, "e->delta underflow" ); + e->delta -= min_delta; + if (e->delta <= 0) { // Defensive // Time for this item to 'fire' - (e->fun)(e->arg); + timeout_fun *fun = e->fun; + void *arg = e->arg; + // Call it *after* cleansing the record e->fun = 0; - } else { - if (e->delta < min_delta) min_delta = e->delta; + e->delta = 0; + (*fun)(arg); } } } + + // Now scan for a new timeout *after* running all the callbacks + // (because they can add timeouts themselves) + min_delta = 0x7FFFFFFF; // Maxint + for (e = timeouts, i = 0; i < NTIMEOUTS; i++, e++) + if (e->delta) + if (e->delta < min_delta) + min_delta = e->delta; + + CYG_ASSERT( 0 < min_delta, "min_delta underflow" ); + if (min_delta != 0x7FFFFFFF) { // Still something to do, schedule it - cyg_alarm_initialize(timeout_alarm_handle, cyg_current_time()+min_delta, 0); + last_set_time = cyg_current_time(); + cyg_alarm_initialize(timeout_alarm_handle, last_set_time+min_delta, 0); last_delta = min_delta; + } else { + last_delta = 0; // flag no activity } } @@ -96,18 +122,31 @@ cyg_uint32 timeout(timeout_fun *fun, void *arg, cyg_int32 delta) { int i; - cyg_int32 min_delta; static bool init = false; - timeout_entry *e = timeouts; + timeout_entry *e; cyg_uint32 stamp; + + CYG_ASSERT( 0 < delta, "delta is right now, or even sooner!" ); + + // this needs to be atomic wrt threads and DSRs + cyg_scheduler_lock(); + if (!init) { cyg_handle_t h; cyg_clock_to_counter(cyg_real_time_clock(), &h); cyg_alarm_create(h, do_timeout, 0, &timeout_alarm_handle, &timeout_alarm); init = true; } + + // Renormalize delta wrt the existing set alarm, if there is one + if ( last_delta > 0 ) + delta += (cyg_int32)(cyg_current_time() - last_set_time); + // So recorded_delta is set to either: + // alarm is active: delta + NOW - THEN + // alarm is inactive: delta + stamp = 0; // Assume no slots available - for (i = 0; i < NTIMEOUTS; i++, e++) { + for (e = timeouts, i = 0; i < NTIMEOUTS; i++, e++) { if ((e->delta == 0) && (e->fun == 0)) { // Free entry e->delta = delta; @@ -117,31 +156,71 @@ timeout(timeout_fun *fun, void *arg, cyg break; } } - e = timeouts; - min_delta = 0x7FFFFFFF; - for (i = 0; i < NTIMEOUTS; i++, e++) { - if (e->delta && (e->delta < min_delta)) min_delta = e->delta; + + if ( stamp && // we did add a record AND + (0 == last_delta || // alarm was inactive OR + delta < last_delta) ) { // alarm was active but later than we need + + // (if last_delta is -1, this call is recursive from the handler so + // also do nothing in that case) + + // Here, we know the new item added is sooner than that which was + // most recently set, if any, so we can just go and set it up. + if ( 0 == last_delta ) + last_set_time = cyg_current_time(); + + // So we use, to set the alarm either: + // alarm is active: (delta + NOW - THEN) + THEN + // alarm is inactive: delta + NOW + // and in either case it is true that + // (recorded_delta + last_set_time) == (delta + NOW) + cyg_alarm_initialize(timeout_alarm_handle, last_set_time+delta, 0); + last_delta = delta; } - if (min_delta != 0x7FFFFFFF) { - // Still something to do, schedule it - cyg_alarm_initialize(timeout_alarm_handle, cyg_current_time()+min_delta, 0); - last_delta = min_delta; + // Otherwise, the alarm is active, AND it is set to fire sooner than we + // require, so when it does, that will sort out calling the item we + // just added. Or we didn't actually add a record, so nothing has + // changed. + +#ifdef CYGPKG_INFRA_DEBUG + // Do some more checking akin to that in the alarm handler: + if ( last_delta != -1 ) { // not a recursive call + CYG_ASSERT( last_delta >= 0, "Bad last delta" ); + delta = 0x7fffffff; + for (e = timeouts, i = 0; i < NTIMEOUTS; i++, e++) { + if (e->delta) { + CYG_ASSERT( e->delta >= last_delta, "e->delta underflow" ); + CYG_ASSERT( last_set_time + e->delta > cyg_current_time(), + "Recorded alarm not in the future!" ); + if ( e->delta < delta ) + delta = e->delta; + } else { + CYG_ASSERT( 0 == e->fun, "Function recorded for 0 delta" ); + } + } + CYG_ASSERT( delta == last_delta, "We didn't pick the smallest delta!" ); } +#endif + + cyg_scheduler_unlock(); + return stamp; } void untimeout(timeout_fun *fun, void * arg) { - int i; - timeout_entry *e = timeouts; - - for (i = 0; i < NTIMEOUTS; i++, e++) { - if (e->delta && (e->fun == fun) && (e->arg == arg)) { + int i; + timeout_entry *e; + cyg_scheduler_lock(); + for (e = timeouts, i = 0; i < NTIMEOUTS; i++, e++) { + if (e->delta && (e->fun == fun) && (e->arg == arg)) { e->delta = 0; e->fun = 0; - return; + break; } } + cyg_scheduler_unlock(); } +// EOF timeout.c diff --git a/packages/net/tcpip/current/src/lib/bootp_support.c b/packages/net/tcpip/current/src/lib/bootp_support.c --- a/packages/net/tcpip/current/src/lib/bootp_support.c +++ b/packages/net/tcpip/current/src/lib/bootp_support.c @@ -59,6 +59,10 @@ #include +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif + // This function sets up the interface it the simplest configuration. // Just enough to broadcast a BOOTP request and get a response. // It returns 'true' if a response was obtained. @@ -178,7 +182,7 @@ do_bootp(const char *intf, struct bootp perror("SIOCGIFHWADDR"); return false; } - bootp_xmit.bp_htype = ifr.ifr_hwaddr.sa_family; + bootp_xmit.bp_htype = HTYPE_ETHERNET; bootp_xmit.bp_hlen = IFHWADDRLEN; bcopy(ifr.ifr_hwaddr.sa_data, &bootp_xmit.bp_chaddr, bootp_xmit.bp_hlen); diff --git a/packages/net/tcpip/current/src/lib/dhcp_prot.c b/packages/net/tcpip/current/src/lib/dhcp_prot.c --- a/packages/net/tcpip/current/src/lib/dhcp_prot.c +++ b/packages/net/tcpip/current/src/lib/dhcp_prot.c @@ -469,10 +469,11 @@ do_dhcp(const char *intf, struct bootp * // Fill in the BOOTP request - DHCPDISCOVER packet bzero(xmit, sizeof(*xmit)); xmit->bp_op = BOOTREQUEST; - xmit->bp_htype = ifr.ifr_hwaddr.sa_family; + xmit->bp_htype = HTYPE_ETHERNET; xmit->bp_hlen = IFHWADDRLEN; xmit->bp_xid = xid; xmit->bp_secs = 0; + xmit->bp_flags = htons(0x8000); // BROADCAST FLAG bcopy(ifr.ifr_hwaddr.sa_data, &xmit->bp_chaddr, xmit->bp_hlen); bcopy(mincookie, xmit->bp_vend, sizeof(mincookie)); @@ -566,6 +567,7 @@ do_dhcp(const char *intf, struct bootp * // Fill in the BOOTP request - DHCPREQUEST packet xmit->bp_op = BOOTREQUEST; + xmit->bp_flags = htons(0x8000); // BROADCAST FLAG set_fixed_tag( xmit, TAG_DHCP_MESS_TYPE, DHCPREQUEST, 1 ); set_fixed_tag( xmit, TAG_DHCP_MAX_MSGSZ, BP_MINPKTSZ, 2 ); @@ -680,6 +682,9 @@ do_dhcp(const char *intf, struct bootp * // Fill in the BOOTP request - DHCPREQUEST packet xmit->bp_op = BOOTREQUEST; + xmit->bp_flags = htons(0); // No BROADCAST FLAG + // Use the *client* address here: + xmit->bp_ciaddr.s_addr = xmit->bp_yiaddr.s_addr; set_fixed_tag( xmit, TAG_DHCP_MESS_TYPE, DHCPREQUEST, 1 ); set_fixed_tag( xmit, TAG_DHCP_MAX_MSGSZ, BP_MINPKTSZ, 2 ); @@ -776,6 +781,9 @@ do_dhcp(const char *intf, struct bootp * // Fill in the BOOTP request - DHCPREQUEST packet xmit->bp_op = BOOTREQUEST; + xmit->bp_flags = htons(0); // no BROADCAST FLAG + // Use the *client* address here: + xmit->bp_ciaddr.s_addr = xmit->bp_yiaddr.s_addr; set_fixed_tag( xmit, TAG_DHCP_MESS_TYPE, DHCPREQUEST, 1 ); set_fixed_tag( xmit, TAG_DHCP_MAX_MSGSZ, BP_MINPKTSZ, 2 ); @@ -905,6 +913,10 @@ do_dhcp(const char *intf, struct bootp * // NOTBOUND state. xmit->bp_op = BOOTREQUEST; + xmit->bp_flags = htons(0); // no BROADCAST FLAG + // Use the *client* address here: + xmit->bp_ciaddr.s_addr = xmit->bp_yiaddr.s_addr; + set_fixed_tag( xmit, TAG_DHCP_MESS_TYPE, DHCPRELEASE, 1 ); // Set unicast address to *server* diff --git a/packages/net/tcpip/current/src/lib/getserv.c b/packages/net/tcpip/current/src/lib/getserv.c --- a/packages/net/tcpip/current/src/lib/getserv.c +++ b/packages/net/tcpip/current/src/lib/getserv.c @@ -60,6 +60,7 @@ static struct servent services[] = { { "ftp", 0, 21, "tcp" }, { "ftp-data", 0, 20, "tcp" }, { "tftp", 0, 69, "udp" }, + { NULL, 0, 0, NULL } }; struct servent * diff --git a/packages/net/tcpip/current/src/lib/network_support.c b/packages/net/tcpip/current/src/lib/network_support.c --- a/packages/net/tcpip/current/src/lib/network_support.c +++ b/packages/net/tcpip/current/src/lib/network_support.c @@ -96,6 +96,9 @@ const char *eth1_name = "eth1"; #define _string(s) #s #define string(s) _string(s) +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif #ifdef CYGPKG_NET_NLOOP #if 0 < CYGPKG_NET_NLOOP @@ -131,8 +134,12 @@ cyg_bool_t init_loopback_interface(int l // (There is normally only 1, so it's the standard 127.0.0.1) addrp->sin_addr.s_addr = htonl((0x100 * lo) + INADDR_LOOPBACK) ; +#if CYGPKG_NET_NLOOP > 1 // Init the one we were told to sprintf(ifr.ifr_name, "lo%d", lo); +#else + strcpy(ifr.ifr_name, "lo0"); +#endif if (ioctl(s, SIOCSIFADDR, &ifr)) { perror("SIOCIFADDR"); @@ -252,6 +259,9 @@ void init_all_network_interfaces(void) { static volatile int in_init_all_network_interfaces = 0; +#ifdef CYGPKG_IO_PCMCIA + cyg_netdevtab_entry_t *t; +#endif // CYGPKG_IO_PCMCIA cyg_scheduler_lock(); while ( in_init_all_network_interfaces ) { @@ -265,6 +275,14 @@ init_all_network_interfaces(void) #ifdef CYGHWR_NET_DRIVER_ETH0 if ( ! eth0_up ) { // Make this call idempotent +#ifdef CYGPKG_IO_PCMCIA + if ((t = eth_drv_netdev("eth0")) != (cyg_netdevtab_entry_t *)NULL) { + while (t->status != CYG_NETDEVTAB_STATUS_AVAIL) { + diag_printf("... Waiting for PCMCIA device 'eth0'\n"); + cyg_thread_delay(100); + } + } +#endif // CYGPKG_IO_PCMCIA #ifdef CYGHWR_NET_DRIVER_ETH0_BOOTP // Perform a complete initialization, using BOOTP/DHCP eth0_up = true; @@ -300,6 +318,14 @@ init_all_network_interfaces(void) #endif // CYGHWR_NET_DRIVER_ETH0 #ifdef CYGHWR_NET_DRIVER_ETH1 if ( ! eth1_up ) { // Make this call idempotent +#ifdef CYGPKG_IO_PCMCIA + if ((t = eth_drv_netdev("eth1")) != (cyg_netdevtab_entry_t *)NULL) { + while (t->status != CYG_NETDEVTAB_STATUS_AVAIL) { + diag_printf("... Waiting for PCMCIA device 'eth1'\n"); + cyg_thread_delay(100); + } + } +#endif // CYGPKG_IO_PCMCIA #ifdef CYGHWR_NET_DRIVER_ETH1_BOOTP // Perform a complete initialization, using BOOTP/DHCP eth1_up = true; diff --git a/packages/net/tcpip/current/src/lib/tftp_server.c b/packages/net/tcpip/current/src/lib/tftp_server.c --- a/packages/net/tcpip/current/src/lib/tftp_server.c +++ b/packages/net/tcpip/current/src/lib/tftp_server.c @@ -42,7 +42,7 @@ //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas -// Contributors: gthomas +// Contributors: gthomas, hmt, andrew.lunn@ascom.ch (Andrew Lunn) // Date: 2000-04-06 // Purpose: // Description: @@ -71,6 +71,18 @@ struct tftp_server { struct tftpd_fileops *ops; }; +static char * errmsg[] = { + "Undefined error code", + "File not found", + "Access violation", + "Disk full or allocation exceeded", + "Illegal TFTP operation", + "Unknown transfer ID", + "File already exists", + "No such user" +}; + + // // Receive a file from the client // @@ -83,7 +95,7 @@ tftpd_write_file(struct tftp_server *ser char data_in[SEGSIZE+sizeof(struct tftphdr)]; struct tftphdr *reply = (struct tftphdr *)data_out; struct tftphdr *response = (struct tftphdr *)data_in; - int fd, block, len, ok, data_len, s; + int fd, block, len, ok, closed, data_len, s; struct timeval timeout; fd_set fds; int total_timeouts = 0; @@ -107,8 +119,8 @@ tftpd_write_file(struct tftp_server *ser } if ((fd = (server->ops->open)(hdr->th_stuff, O_WRONLY)) < 0) { reply->th_opcode = htons(ERROR); - reply->th_code = htons(ENOTFOUND); - strcpy(reply->th_msg, "Can't open file"); + reply->th_code = htons(TFTP_ENOTFOUND); + strcpy(reply->th_msg, errmsg[TFTP_ENOTFOUND]); sendto(s, reply, 4+strlen(reply->th_msg)+1, 0, (struct sockaddr *)from_addr, from_len); close(s); @@ -120,6 +132,7 @@ tftpd_write_file(struct tftp_server *ser sendto(s, reply, 4, 0, (struct sockaddr *)from_addr, from_len); block = 1; ok = true; + closed = false; while (ok) { timeout.tv_sec = TFTP_TIMEOUT_PERIOD; timeout.tv_usec = 0; @@ -151,15 +164,33 @@ tftpd_write_file(struct tftp_server *ser // File is "full" reply->th_opcode = htons(ERROR); reply->th_code = htons(TFTP_ENOSPACE); + strcpy(reply->th_msg, errmsg[TFTP_ENOSPACE]); + sendto(s, reply, 4+strlen(reply->th_msg)+1, 0, + (struct sockaddr *)from_addr, from_len); ok = false; // Give up } else { - reply->th_opcode = htons(ACK); - reply->th_block = htons(block++); - } - sendto(s, reply, 4, 0, (struct sockaddr *)from_addr, from_len); - if (data_len < (SEGSIZE+4)) { - // End of file - ok = false; + if (data_len < (SEGSIZE+4)) { + // End of file + closed = true; + ok = false; + if ((server->ops->close)(fd) == -1) { + reply->th_opcode = htons(ERROR); + reply->th_code = htons(TFTP_EACCESS); + strcpy(reply->th_msg, errmsg[TFTP_EACCESS]); + sendto(s, reply, 4+strlen(reply->th_msg)+1, 0, + (struct sockaddr *)from_addr, from_len); + } else { + reply->th_opcode = htons(ACK); + reply->th_block = htons(block++); + sendto(s, reply, 4, 0, + (struct sockaddr *)from_addr, from_len); + } + } else { + reply->th_opcode = htons(ACK); + reply->th_block = htons(block++); + sendto(s, reply, 4, 0, + (struct sockaddr *)from_addr, from_len); + } } } else { // Something is wrong - tell client last good block @@ -168,14 +199,18 @@ tftpd_write_file(struct tftp_server *ser } else { // Client has sent something bogus - bag out! reply->th_opcode = htons(ERROR); - reply->th_code = htons(TFTP_EBADOP); - sendto(s, reply, 4, 0, (struct sockaddr *)from_addr, from_len); + reply->th_code = htons(TFTP_EBADOP); + strcpy(reply->th_msg, errmsg[TFTP_EBADOP]); + sendto(s, reply, 4+strlen(reply->th_msg)+1, 0, + (struct sockaddr *)from_addr, from_len); ok = false; } } } close(s); - (server->ops->close)(fd); + if (!closed) { + (server->ops->close)(fd); + } } // @@ -214,8 +249,8 @@ tftpd_read_file(struct tftp_server *serv } if ((fd = (server->ops->open)(hdr->th_stuff, O_RDONLY)) < 0) { reply->th_opcode = htons(ERROR); - reply->th_code = htons(ENOTFOUND); - strcpy(reply->th_msg, "Can't open file"); + reply->th_code = htons(TFTP_ENOTFOUND); + strcpy(reply->th_msg, errmsg[TFTP_ENOTFOUND]); sendto(s, reply, 4+strlen(reply->th_msg)+1, 0, (struct sockaddr *)from_addr, from_len); close(s); @@ -348,8 +383,8 @@ tftpd_server(cyg_addrword_t p) diag_printf("TFTPD: bogus request %x from %s:%d\n", ntohs(hdr->th_opcode), inet_ntoa(from_addr.sin_addr), from_addr.sin_port); hdr->th_opcode = htons(ERROR); - hdr->th_code = htons(EBADOP); - strcpy(hdr->th_msg, "Illegal request/operation"); + hdr->th_code = htons(TFTP_EBADOP); + strcpy(hdr->th_msg, errmsg[TFTP_EBADOP]);; sendto(s, hdr, 4+strlen(hdr->th_msg)+1, 0, (struct sockaddr *)&from_addr, from_len); } diff --git a/packages/net/tcpip/current/src/sys/kern/sockio.c b/packages/net/tcpip/current/src/sys/kern/sockio.c new file mode 100644 --- /dev/null +++ b/packages/net/tcpip/current/src/sys/kern/sockio.c @@ -0,0 +1,976 @@ +//========================================================================== +// +// sys/kern/sockio.c +// +// Socket interface to Fileio subsystem +// +//========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//####BSDCOPYRIGHTBEGIN#### +// +// ------------------------------------------- +// +// Portions of this software may have been derived from OpenBSD or other sources, +// and are covered by the appropriate copyright disclaimers included herein. +// +// ------------------------------------------- +// +//####BSDCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 2000-06-06 +// Purpose: +// Description: +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +/* + * Copyright (c) 1982, 1986, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ +//========================================================================== + +#include +#include + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +//========================================================================== +// Forward definitions + +static int bsd_init( cyg_nstab_entry *nste ); +static int bsd_socket( cyg_nstab_entry *nste, int domain, int type, + int protocol, cyg_file *file ); + +static int bsd_bind ( cyg_file *fp, const sockaddr *sa, socklen_t len ); +static int bsd_connect ( cyg_file *fp, const sockaddr *sa, socklen_t len ); +static int bsd_accept ( cyg_file *fp, cyg_file *new_fp, + struct sockaddr *name, socklen_t *anamelen ); +static int bsd_listen ( cyg_file *fp, int len ); +static int bsd_getname ( cyg_file *fp, sockaddr *sa, socklen_t *len, int peer ); +static int bsd_shutdown ( cyg_file *fp, int flags ); +static int bsd_getsockopt( cyg_file *fp, int level, int optname, + void *optval, socklen_t *optlen); +static int bsd_setsockopt( cyg_file *fp, int level, int optname, + const void *optval, socklen_t optlen); +static int bsd_sendmsg ( cyg_file *fp, const struct msghdr *m, + int flags, ssize_t *retsize ); +static int bsd_recvmsg ( cyg_file *fp, struct msghdr *m, + socklen_t *namelen, ssize_t *retsize ); + + +// File operations +static int bsd_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +static int bsd_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio); +static int bsd_lseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence ); +static int bsd_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com, + CYG_ADDRWORD data); +static int bsd_select (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info); +static int bsd_fsync (struct CYG_FILE_TAG *fp, int mode ); +static int bsd_close (struct CYG_FILE_TAG *fp); +static int bsd_fstat (struct CYG_FILE_TAG *fp, struct stat *buf ); +static int bsd_getinfo (struct CYG_FILE_TAG *fp, int key, char *buf, int len ); +static int bsd_setinfo (struct CYG_FILE_TAG *fp, int key, char *buf, int len ); + +static int +bsd_recvit(cyg_file *fp, struct msghdr *mp, socklen_t *namelenp, ssize_t *retsize); +static int +bsd_sendit(cyg_file *fp, const struct msghdr *mp, int flags, ssize_t *retsize); + + +//========================================================================== +// Table entrys + +NSTAB_ENTRY( bsd_nste, 0, + "bsd_tcpip", + "", + 0, + bsd_init, + bsd_socket); + +struct cyg_sock_ops bsd_sockops = +{ + bsd_bind, + bsd_connect, + bsd_accept, + bsd_listen, + bsd_getname, + bsd_shutdown, + bsd_getsockopt, + bsd_setsockopt, + bsd_sendmsg, + bsd_recvmsg +}; + +cyg_fileops bsd_sock_fileops = +{ + bsd_read, + bsd_write, + bsd_lseek, + bsd_ioctl, + bsd_select, + bsd_fsync, + bsd_close, + bsd_fstat, + bsd_getinfo, + bsd_setinfo +}; + +//========================================================================== +// NStab functions + + + +// ------------------------------------------------------------------------- + +static int bsd_init( cyg_nstab_entry *nste ) +{ + // Initialization already handled via constructor + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int bsd_socket( cyg_nstab_entry *nste, int domain, int type, + int protocol, cyg_file *file ) +{ + int error = 0; + struct socket *so; + + error = socreate( domain, &so, type, protocol ); + + if( error == ENOERR ) + { + + cyg_selinit(&so->so_rcv.sb_sel); + cyg_selinit(&so->so_snd.sb_sel); + + file->f_flag |= CYG_FREAD|CYG_FWRITE; + file->f_type = CYG_FILE_TYPE_SOCKET; + file->f_ops = &bsd_sock_fileops; + file->f_offset = 0; + file->f_data = (CYG_ADDRWORD)so; + file->f_xops = (CYG_ADDRWORD)&bsd_sockops; + } + + return error; +} + + +//========================================================================== +// Sockops functions + +// ------------------------------------------------------------------------- + +static int bsd_bind ( cyg_file *fp, const sockaddr *sa, socklen_t len ) +{ + struct mbuf *nam; + int error; + + error = sockargs(&nam, (caddr_t)sa, len, MT_SONAME); + + if (error) + return (error); + + error = sobind((struct socket *)fp->f_data, nam); + + m_freem(nam); + + return error; +} + +// ------------------------------------------------------------------------- + +static int bsd_connect ( cyg_file *fp, const sockaddr *sa, socklen_t len ) +{ + register struct socket *so; + struct mbuf *nam; + int error, s; + + so = (struct socket *)fp->f_data; + + if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) + return (EALREADY); + + error = sockargs(&nam, (caddr_t)sa, len, MT_SONAME); + + if (error) + return (error); + + error = soconnect(so, nam); + if (error) + goto bad; + + if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) { + m_freem(nam); + return (EINPROGRESS); + } + + s = splsoftnet(); + while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) { + error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH, + netcon, 0); + if (error) + break; + } + + if (error == 0) { + error = so->so_error; + so->so_error = 0; + } + + splx(s); + +bad: + so->so_state &= ~SS_ISCONNECTING; + m_freem(nam); + + return error; +} + +// ------------------------------------------------------------------------- + +static int bsd_accept ( cyg_file *fp, cyg_file *new_fp, + struct sockaddr *name, socklen_t *anamelen ) +{ + struct mbuf *nam; + socklen_t namelen = 0; + int error = 0, s; + register struct socket *so; + + if( anamelen != NULL ) + namelen = *anamelen; + + s = splsoftnet(); + so = (struct socket *)fp->f_data; + + if ((so->so_options & SO_ACCEPTCONN) == 0) { + splx(s); + return (EINVAL); + } + + if ((so->so_state & SS_NBIO) && so->so_qlen == 0) { + splx(s); + return (EWOULDBLOCK); + } + + while (so->so_qlen == 0 && so->so_error == 0) { + if (so->so_state & SS_CANTRCVMORE) { + so->so_error = ECONNABORTED; + break; + } + error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH, + netcon, 0); + if (error) { + splx(s); + return (error); + } + } + + if (so->so_error) { + error = so->so_error; + so->so_error = 0; + splx(s); + return (error); + } + + { + struct socket *aso = so->so_q; + if (soqremque(aso, 1) == 0) + panic("accept"); + so = aso; + } + + cyg_selinit(&so->so_rcv.sb_sel); + cyg_selinit(&so->so_snd.sb_sel); + + new_fp->f_type = DTYPE_SOCKET; + new_fp->f_flag |= FREAD|FWRITE; + new_fp->f_offset = 0; + new_fp->f_ops = &bsd_sock_fileops; + new_fp->f_data = (CYG_ADDRWORD)so; + new_fp->f_xops = (CYG_ADDRWORD)&bsd_sockops; + + nam = m_get(M_WAIT, MT_SONAME); + (void) soaccept(so, nam); + if (name) { + if (namelen > nam->m_len) + namelen = nam->m_len; + /* SHOULD COPY OUT A CHAIN HERE */ + if ((error = copyout(mtod(nam, caddr_t), + (caddr_t)name, namelen)) == 0) + *anamelen = namelen; + } + m_freem(nam); + splx(s); + + return (error); +} + +// ------------------------------------------------------------------------- + +static int bsd_listen ( cyg_file *fp, int backlog ) +{ + return (solisten((struct socket *)fp->f_data, backlog)); +} + +// ------------------------------------------------------------------------- + +static int bsd_getname ( cyg_file *fp, sockaddr *asa, socklen_t *alen, int peer ) +{ + register struct socket *so; + struct mbuf *m; + socklen_t len = 0; + int error; + int type = peer ? PRU_PEERADDR : PRU_SOCKADDR; + + if( alen != NULL ) + len = *alen; + + so = (struct socket *)fp->f_data; + + if ( peer && (so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) + return (ENOTCONN); + + m = m_getclr(M_WAIT, MT_SONAME); + if (m == NULL) + return (ENOBUFS); + + error = (*so->so_proto->pr_usrreq)(so, type, 0, m, 0); + if (error) + goto bad; + + if (len > m->m_len) + len = m->m_len; + + error = copyout(mtod(m, caddr_t), (caddr_t)asa, len); + + if (error == 0) + *alen = len; + +bad: + m_freem(m); + + return (error); +} + +// ------------------------------------------------------------------------- + +static int bsd_shutdown ( cyg_file *fp, int how ) +{ + return (soshutdown((struct socket *)fp->f_data, how)); +} + +// ------------------------------------------------------------------------- + +static int bsd_getsockopt( cyg_file *fp, int level, int optname, + void *optval, socklen_t *optlen) +{ + struct mbuf *m = NULL; + socklen_t valsize = 0; + int error; + + if( optval != NULL && optlen != NULL ) + valsize = *optlen; + + error = sogetopt((struct socket *)fp->f_data, level, optname, &m); + + if( error == ENOERR && valsize != 0 && m != NULL) + { + if (valsize > m->m_len) + valsize = m->m_len; + + error = copyout(mtod(m, caddr_t), optval, valsize); + + if( error == ENOERR ) + *optlen = valsize; + + } + + if (m != NULL) + (void) m_free(m); + return (error); +} + +// ------------------------------------------------------------------------- + +static int bsd_setsockopt( cyg_file *fp, int level, int optname, + const void *optval, socklen_t optlen) +{ + int error; + struct mbuf *m = NULL; + + if( optlen > MCLBYTES ) + return EINVAL; + + if (optval != NULL) { + m = m_get(M_WAIT, MT_SOOPTS); + if (optlen > MLEN) { + MCLGET(m, M_DONTWAIT); + if ((m->m_flags & M_EXT) == 0) { + m_freem(m); + return (ENOBUFS); + } + } + if (m == NULL) + return (ENOBUFS); + error = copyin(optval, mtod(m, caddr_t), optlen); + if (error) { + (void) m_free(m); + return (error); + } + m->m_len = optlen; + } + + return (sosetopt((struct socket *)fp->f_data, level, optname, m)); +} + +// ------------------------------------------------------------------------- + +static int bsd_sendmsg ( cyg_file *fp, const struct msghdr *m, int flags, ssize_t *retsize ) +{ + return bsd_sendit( fp, m, flags, retsize); +} + +// ------------------------------------------------------------------------- + +static int bsd_recvmsg ( cyg_file *fp, struct msghdr *m, socklen_t *namelen, ssize_t *retsize ) +{ + return bsd_recvit( fp, m, namelen, retsize); +} + +//========================================================================== +// File system call functions + +// ------------------------------------------------------------------------- + +static int bsd_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio) +{ + return (soreceive((struct socket *)fp->f_data, (struct mbuf **)0, + uio, (struct mbuf **)0, (struct mbuf **)0, (int *)0)); +} + +// ------------------------------------------------------------------------- + +static int bsd_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio) +{ + return (sosend((struct socket *)fp->f_data, (struct mbuf *)0, + uio, (struct mbuf *)0, (struct mbuf *)0, 0)); +} + +// ------------------------------------------------------------------------- + +static int bsd_lseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence ) +{ + return ESPIPE; +} + +// ------------------------------------------------------------------------- + +static int bsd_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD cmd, + CYG_ADDRWORD data) +{ + register struct socket *so = (struct socket *)fp->f_data; + void *p = 0; + + switch (cmd) { + + case FIONBIO: + if (*(int *)data) + so->so_state |= SS_NBIO; + else + so->so_state &= ~SS_NBIO; + return (0); + + case FIOASYNC: + if (*(int *)data) { + so->so_state |= SS_ASYNC; + so->so_rcv.sb_flags |= SB_ASYNC; + so->so_snd.sb_flags |= SB_ASYNC; + } else { + so->so_state &= ~SS_ASYNC; + so->so_rcv.sb_flags &= ~SB_ASYNC; + so->so_snd.sb_flags &= ~SB_ASYNC; + } + return (0); + + case FIONREAD: + *(int *)data = so->so_rcv.sb_cc; + return (0); + + case SIOCATMARK: + *(int *)data = (so->so_state&SS_RCVATMARK) != 0; + return (0); + } + /* + * Interface/routing/protocol specific ioctls: + * interface and routing ioctls should have a + * different entry since a socket's unnecessary + */ + if (IOCGROUP(cmd) == 'i') + return (ifioctl(so, (u_long)cmd, (caddr_t)data, p)); + if (IOCGROUP(cmd) == 'r') + return (rtioctl((u_long)cmd, (caddr_t)data, p)); + return ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, + (struct mbuf *)cmd, (struct mbuf *)data, (struct mbuf *)0)); + +} + +// ------------------------------------------------------------------------- + +static int bsd_select (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info) +{ + register struct socket *so = (struct socket *)fp->f_data; + register int s = splsoftnet(); + + switch (which) { + + case FREAD: + if (soreadable(so)) { + splx(s); + return (1); + } + cyg_selrecord(info, &so->so_rcv.sb_sel); + so->so_rcv.sb_flags |= SB_SEL; + break; + + case FWRITE: + if (sowriteable(so)) { + splx(s); + return (1); + } + cyg_selrecord(info, &so->so_snd.sb_sel); + so->so_snd.sb_flags |= SB_SEL; + break; + + case 0: + if (so->so_oobmark || (so->so_state & SS_RCVATMARK)) { + splx(s); + return (1); + } + cyg_selrecord(info, &so->so_rcv.sb_sel); + so->so_rcv.sb_flags |= SB_SEL; + break; + } + splx(s); + + return ENOERR; +} + +// ------------------------------------------------------------------------- + +static int bsd_fsync (struct CYG_FILE_TAG *fp, int mode ) +{ + // FIXME: call some sort of flush IOCTL? + return 0; +} + +// ------------------------------------------------------------------------- + +static int bsd_close (struct CYG_FILE_TAG *fp) +{ + int error = 0; + + if (fp->f_data) + error = soclose((struct socket *)fp->f_data); + fp->f_data = 0; + return (error); +} + +// ------------------------------------------------------------------------- + +static int bsd_fstat (struct CYG_FILE_TAG *fp, struct stat *buf ) +{ + register struct socket *so = (struct socket *)fp->f_data; + + bzero((caddr_t)buf, sizeof (*buf)); + + // Mark socket as a fifo for now. We need to add socket types to + // sys/stat.h. + buf->st_mode = __stat_mode_FIFO; + + return ((*so->so_proto->pr_usrreq)(so, PRU_SENSE, + (struct mbuf *)buf, + (struct mbuf *)0, + (struct mbuf *)0)); +} + +// ------------------------------------------------------------------------- + +static int bsd_getinfo (struct CYG_FILE_TAG *fp, int key, char *buf, int len ) +{ + return ENOSYS; +} + +// ------------------------------------------------------------------------- + +static int bsd_setinfo (struct CYG_FILE_TAG *fp, int key, char *buf, int len ) +{ + return ENOSYS; +} + + + +//========================================================================== +// Select support + +// ------------------------------------------------------------------------- +// This function is called by the lower layers to record the +// fact that a particular 'select' event is being requested. +// + +void +selrecord(void *selector, struct selinfo *info) +{ + // Unused by this implementation +} + +// ------------------------------------------------------------------------- +// This function is called to indicate that a 'select' event +// may have occurred. +// + +void +selwakeup(struct selinfo *info) +{ + cyg_selwakeup( info ); +} + +//========================================================================== +// Misc support functions + +int +sockargs(mp, buf, buflen, type) + struct mbuf **mp; + caddr_t buf; + socklen_t buflen; + int type; +{ + register struct sockaddr *sa; + register struct mbuf *m; + int error; + + if (buflen > MLEN) { +#ifdef COMPAT_OLDSOCK + if (type == MT_SONAME && buflen <= 112) + buflen = MLEN; /* unix domain compat. hack */ + else +#endif + return (EINVAL); + } + m = m_get(M_WAIT, type); + if (m == NULL) + return (ENOBUFS); + m->m_len = buflen; + error = copyin(buf, mtod(m, caddr_t), buflen); + if (error) { + (void) m_free(m); + return (error); + } + *mp = m; + if (type == MT_SONAME) { + sa = mtod(m, struct sockaddr *); + +#if defined(COMPAT_OLDSOCK) && BYTE_ORDER != BIG_ENDIAN + if (sa->sa_family == 0 && sa->sa_len < AF_MAX) + sa->sa_family = sa->sa_len; +#endif + sa->sa_len = buflen; + } + return (0); +} + + +// ------------------------------------------------------------------------- +// bsd_recvit() +// Support for message reception. This is a lightly edited version of the +// recvit() function is uipc_syscalls.c. + +static int +bsd_recvit(cyg_file *fp, struct msghdr *mp, socklen_t *namelenp, ssize_t *retsize) +{ + struct uio auio; + register struct iovec *iov; + register int i; + size_t len; + int error; + struct mbuf *from = 0, *control = 0; + + auio.uio_iov = mp->msg_iov; + auio.uio_iovcnt = mp->msg_iovlen; + auio.uio_segflg = UIO_USERSPACE; + auio.uio_rw = UIO_READ; + auio.uio_offset = 0; /* XXX */ + auio.uio_resid = 0; + iov = mp->msg_iov; + for (i = 0; i < mp->msg_iovlen; i++, iov++) { + /* Don't allow sum > SSIZE_MAX */ + if (iov->iov_len > SSIZE_MAX || + (auio.uio_resid += iov->iov_len) > SSIZE_MAX) + return (EINVAL); + } + + len = auio.uio_resid; + error = soreceive((struct socket *)fp->f_data, &from, &auio, + NULL, mp->msg_control ? &control : NULL, + &mp->msg_flags); + if (error) { + if (auio.uio_resid != len && + (error == EINTR || error == EWOULDBLOCK)) + error = 0; + } + if (error) + goto out; + *retsize = len - auio.uio_resid; + if (mp->msg_name) { + len = mp->msg_namelen; + if (len <= 0 || from == 0) + len = 0; + else { + /* save sa_len before it is destroyed by MSG_COMPAT */ + if (len > from->m_len) + len = from->m_len; + /* else if len < from->m_len ??? */ +#ifdef COMPAT_OLDSOCK + if (mp->msg_flags & MSG_COMPAT) + mtod(from, struct osockaddr *)->sa_family = + mtod(from, struct sockaddr *)->sa_family; +#endif + error = copyout(mtod(from, caddr_t), + (caddr_t)mp->msg_name, (unsigned)len); + if (error) + goto out; + } + mp->msg_namelen = len; + if (namelenp ) { + *namelenp = len; +#ifdef COMPAT_OLDSOCK + if (mp->msg_flags & MSG_COMPAT) + error = 0; /* old recvfrom didn't check */ + else +#endif + goto out; + } + } + if (mp->msg_control) { +#ifdef COMPAT_OLDSOCK + /* + * We assume that old recvmsg calls won't receive access + * rights and other control info, esp. as control info + * is always optional and those options didn't exist in 4.3. + * If we receive rights, trim the cmsghdr; anything else + * is tossed. + */ + if (control && mp->msg_flags & MSG_COMPAT) { + if (mtod(control, struct cmsghdr *)->cmsg_level != + SOL_SOCKET || + mtod(control, struct cmsghdr *)->cmsg_type != + SCM_RIGHTS) { + mp->msg_controllen = 0; + goto out; + } + control->m_len -= sizeof (struct cmsghdr); + control->m_data += sizeof (struct cmsghdr); + } +#endif + len = mp->msg_controllen; + if (len <= 0 || control == 0) + len = 0; + else { + struct mbuf *m = control; + caddr_t p = (caddr_t)mp->msg_control; + + do { + i = m->m_len; + if (len < i) { + mp->msg_flags |= MSG_CTRUNC; + i = len; + } + error = copyout(mtod(m, caddr_t), p, + (unsigned)i); + if (m->m_next) + i = ALIGN(i); + p += i; + len -= i; + if (error != 0 || len <= 0) + break; + } while ((m = m->m_next) != NULL); + len = p - (caddr_t)mp->msg_control; + } + mp->msg_controllen = len; + } +out: + if (from) + m_freem(from); + if (control) + m_freem(control); + return (error); +} + +// ------------------------------------------------------------------------- +// sendit() +// Support for message transmission. This is a lightly edited version of the +// synonymous function is uipc_syscalls.c. + +static int +bsd_sendit(cyg_file *fp, const struct msghdr *mp, int flags, ssize_t *retsize) +{ + struct uio auio; + register struct iovec *iov; + register int i; + struct mbuf *to, *control; + int len, error; + + auio.uio_iov = mp->msg_iov; + auio.uio_iovcnt = mp->msg_iovlen; + auio.uio_segflg = UIO_USERSPACE; + auio.uio_rw = UIO_WRITE; + auio.uio_offset = 0; /* XXX */ + auio.uio_resid = 0; + iov = mp->msg_iov; + for (i = 0; i < mp->msg_iovlen; i++, iov++) { + /* Don't allow sum > SSIZE_MAX */ + if (iov->iov_len > SSIZE_MAX || + (auio.uio_resid += iov->iov_len) > SSIZE_MAX) + return (EINVAL); + } + if (mp->msg_name) { + error = sockargs(&to, mp->msg_name, mp->msg_namelen, + MT_SONAME); + if (error) + return (error); + } else + to = 0; + if (mp->msg_control) { + if (mp->msg_controllen < sizeof(struct cmsghdr) +#ifdef COMPAT_OLDSOCK + && mp->msg_flags != MSG_COMPAT +#endif + ) { + error = EINVAL; + goto bad; + } + error = sockargs(&control, mp->msg_control, + mp->msg_controllen, MT_CONTROL); + if (error) + goto bad; +#ifdef COMPAT_OLDSOCK + if (mp->msg_flags == MSG_COMPAT) { + register struct cmsghdr *cm; + + M_PREPEND(control, sizeof(*cm), M_WAIT); + if (control == 0) { + error = ENOBUFS; + goto bad; + } else { + cm = mtod(control, struct cmsghdr *); + cm->cmsg_len = control->m_len; + cm->cmsg_level = SOL_SOCKET; + cm->cmsg_type = SCM_RIGHTS; + } + } +#endif + } else + control = 0; + + len = auio.uio_resid; + error = sosend((struct socket *)fp->f_data, to, &auio, + NULL, control, flags); + if (error) { + if (auio.uio_resid != len && + (error == EINTR || error == EWOULDBLOCK)) + error = 0; +#ifndef __ECOS + if (error == EPIPE) + psignal(p, SIGPIPE); +#endif + } + if (error == 0) + *retsize = len - auio.uio_resid; +bad: + if (to) + m_freem(to); + return (error); +} + + +//========================================================================== +// End of sockio.c diff --git a/packages/net/tcpip/current/src/sys/net/if_bridge.c b/packages/net/tcpip/current/src/sys/net/if_bridge.c --- a/packages/net/tcpip/current/src/sys/net/if_bridge.c +++ b/packages/net/tcpip/current/src/sys/net/if_bridge.c @@ -281,7 +281,7 @@ bridgeattach(unused) for (i = 0; i < NBRIDGE; i++) { bridgectl[i].sc_brtmax = BRIDGE_RTABLE_MAX; - bridgectl[i].sc_brttimeout = BRIDGE_RTABLE_TIMEOUT; + bridgectl[i].sc_brttimeout = BRIDGE_RTABLE_TIMEOUT * hz; LIST_INIT(&bridgectl[i].sc_iflist); ifp = &bridgectl[i].sc_if; sprintf(ifp->if_xname, "bridge%d", i); @@ -539,13 +539,13 @@ bridge_ioctl(ifp, cmd, data) if ((error = suser(prc->p_ucred, &prc->p_acflag)) != 0) break; #endif - sc->sc_brttimeout = bcacheto->ifbct_time; + sc->sc_brttimeout = bcacheto->ifbct_time * hz; untimeout(bridge_rtage, sc); if (bcacheto->ifbct_time != 0) timeout(bridge_rtage, sc, sc->sc_brttimeout); break; case SIOCBRDGGTO: - bcacheto->ifbct_time = sc->sc_brttimeout; + bcacheto->ifbct_time = sc->sc_brttimeout / hz; break; case SIOCSIFFLAGS: if ((ifp->if_flags & IFF_UP) == IFF_UP) @@ -807,7 +807,7 @@ bridge_init(sc) splx(s); if (sc->sc_brttimeout != 0) - timeout(bridge_rtage, sc, sc->sc_brttimeout * hz); + timeout(bridge_rtage, sc, sc->sc_brttimeout); } /* @@ -1583,7 +1583,7 @@ bridge_rtage(vsc) splx(s); if (sc->sc_brttimeout != 0) - timeout(bridge_rtage, sc, sc->sc_brttimeout * hz); + timeout(bridge_rtage, sc, sc->sc_brttimeout); } /* diff --git a/packages/net/tcpip/current/src/sys/net/if_loop.c b/packages/net/tcpip/current/src/sys/net/if_loop.c --- a/packages/net/tcpip/current/src/sys/net/if_loop.c +++ b/packages/net/tcpip/current/src/sys/net/if_loop.c @@ -205,7 +205,7 @@ didn't get a copy, you may request one f #define LOMTU (32768 + MHLEN + MLEN) #endif -#ifdef __ECOS +#ifndef __ECOS #include // for 'sprintf()' #endif @@ -220,7 +220,11 @@ loopattach(n) for (i = NLOOP; i--; ) { ifp = &loif[i]; +#if !defined(__ECOS) || (CYGPKG_NET_NLOOP > 1) sprintf(ifp->if_xname, "lo%d", i); +#else + strcpy(ifp->if_xname, "lo0"); +#endif ifp->if_softc = NULL; ifp->if_mtu = LOMTU; ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; diff --git a/packages/net/tcpip/current/src/sys/netinet/ip_input.c b/packages/net/tcpip/current/src/sys/netinet/ip_input.c --- a/packages/net/tcpip/current/src/sys/netinet/ip_input.c +++ b/packages/net/tcpip/current/src/sys/netinet/ip_input.c @@ -219,15 +219,34 @@ ipq_unlock() splx(s); } +static char *ui8tod( cyg_uint8 n, char *p ) +{ + if( n > 99 ) *p++ = (n/100) + '0'; + if( n > 9 ) *p++ = ((n/10)%10) + '0'; + *p++ = (n%10) + '0'; + return p; +} + char * inet_ntoa(ina) struct in_addr ina; { static char buf[4*sizeof "123"]; + char *p = buf; unsigned char *ucp = (unsigned char *)&ina; - sprintf(buf, "%d.%d.%d.%d", ucp[0] & 0xff, ucp[1] & 0xff, - ucp[2] & 0xff, ucp[3] & 0xff); +// sprintf(buf, "%d.%d.%d.%d", ucp[0] & 0xff, ucp[1] & 0xff, +// ucp[2] & 0xff, ucp[3] & 0xff); + + p = ui8tod( ucp[0] & 0xFF, p); + *p++ = '.'; + p = ui8tod( ucp[1] & 0xFF, p); + *p++ = '.'; + p = ui8tod( ucp[2] & 0xFF, p); + *p++ = '.'; + p = ui8tod( ucp[3] & 0xFF, p); + *p++ = '\0'; + return (buf); } diff --git a/packages/net/tcpip/current/tests/ftp_test.c b/packages/net/tcpip/current/tests/ftp_test.c --- a/packages/net/tcpip/current/tests/ftp_test.c +++ b/packages/net/tcpip/current/tests/ftp_test.c @@ -55,6 +55,10 @@ #include +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif + #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000) static char stack[STACK_SIZE]; static cyg_thread thread_data; diff --git a/packages/net/tcpip/current/tests/multi_lo_select.c b/packages/net/tcpip/current/tests/multi_lo_select.c --- a/packages/net/tcpip/current/tests/multi_lo_select.c +++ b/packages/net/tcpip/current/tests/multi_lo_select.c @@ -83,6 +83,10 @@ #include +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif + #define SOURCE_PORT1 9900 #define SOURCE_PORT2 9800 // for those who listen to multiple ports #define SOURCE_PORT3 9700 // for the dummy consumers of events @@ -98,12 +102,21 @@ #define PRIO_MASTERHIGH 3 #define PRIO_MASTERLOW 25 +#ifndef CYGPKG_IO_FILEIO #if CYGPKG_IO_NFILE > 30 #define NLISTENERS 10 #else // fewer threads if not many sockets available #define NLISTENERS (CYGPKG_IO_NFILE/3) #endif +#else +#if CYGNUM_FILEIO_NFD > 30 +#define NLISTENERS 10 +#else +// fewer threads if not many sockets available +#define NLISTENERS (CYGNUM_FILEIO_NFD/3) +#endif +#endif #define NDUMMIES 10 diff --git a/packages/net/tcpip/current/tests/nc_test_master.c b/packages/net/tcpip/current/tests/nc_test_master.c --- a/packages/net/tcpip/current/tests/nc_test_master.c +++ b/packages/net/tcpip/current/tests/nc_test_master.c @@ -57,6 +57,9 @@ #include "nc_test_framework.h" #ifdef __ECOS +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000) static char stack[STACK_SIZE]; static cyg_thread thread_data; diff --git a/packages/net/tcpip/current/tests/nc_test_slave.c b/packages/net/tcpip/current/tests/nc_test_slave.c --- a/packages/net/tcpip/current/tests/nc_test_slave.c +++ b/packages/net/tcpip/current/tests/nc_test_slave.c @@ -58,6 +58,9 @@ #include #ifdef __ECOS +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000) #define MAX_LOAD_THREAD_LEVEL 20 #define MIN_LOAD_THREAD_LEVEL 0 diff --git a/packages/net/tcpip/current/tests/ping_lo_test.c b/packages/net/tcpip/current/tests/ping_lo_test.c --- a/packages/net/tcpip/current/tests/ping_lo_test.c +++ b/packages/net/tcpip/current/tests/ping_lo_test.c @@ -58,6 +58,10 @@ #include +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif + #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000) static char stack[STACK_SIZE]; static cyg_thread thread_data; diff --git a/packages/net/tcpip/current/tests/ping_test.c b/packages/net/tcpip/current/tests/ping_test.c --- a/packages/net/tcpip/current/tests/ping_test.c +++ b/packages/net/tcpip/current/tests/ping_test.c @@ -87,6 +87,10 @@ +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif + #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000) static char stack[STACK_SIZE]; static cyg_thread thread_data; diff --git a/packages/net/tcpip/current/tests/server_test.c b/packages/net/tcpip/current/tests/server_test.c --- a/packages/net/tcpip/current/tests/server_test.c +++ b/packages/net/tcpip/current/tests/server_test.c @@ -53,8 +53,13 @@ //========================================================================== // Network server test code #include +#include #include +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif + #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000) static char stack[STACK_SIZE]; static cyg_thread thread_data; @@ -108,7 +113,17 @@ server_test(struct bootp *bp) client_len = sizeof(client_addr); getpeername(client, (struct sockaddr *)&client_addr, &client_len); diag_printf("connection from %s:%d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port)); + +#ifdef CYGPKG_LIBC_STDIO sprintf(buf, "Hello %s:%d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port)); +#else + strcpy(buf, "Hello "); + strcat(buf, inet_ntoa(client_addr.sin_addr)); + strcat(buf,":"); + strcat(buf, atoi(ntohs(client_addr.sin_port))); + strcat(buf,"\n"); +#endif + write(client, buf, strlen(buf)); tv.tv_sec = 5; tv.tv_usec = 0; diff --git a/packages/net/tcpip/current/tests/socket_test.c b/packages/net/tcpip/current/tests/socket_test.c --- a/packages/net/tcpip/current/tests/socket_test.c +++ b/packages/net/tcpip/current/tests/socket_test.c @@ -56,6 +56,10 @@ #include +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif + #define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL static char stack[STACK_SIZE]; static cyg_thread thread_data; diff --git a/packages/net/tcpip/current/tests/tcp_echo.c b/packages/net/tcpip/current/tests/tcp_echo.c --- a/packages/net/tcpip/current/tests/tcp_echo.c +++ b/packages/net/tcpip/current/tests/tcp_echo.c @@ -108,6 +108,10 @@ struct test_status { long ok; }; +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif + #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000) static char stack[STACK_SIZE]; static cyg_thread thread_data; diff --git a/packages/net/tcpip/current/tests/tcp_lo_select.c b/packages/net/tcpip/current/tests/tcp_lo_select.c --- a/packages/net/tcpip/current/tests/tcp_lo_select.c +++ b/packages/net/tcpip/current/tests/tcp_lo_select.c @@ -52,6 +52,10 @@ #include +#ifndef CYGPKG_LIBC_STDIO +#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) +#endif + #define SOURCE_PORT1 9990 #define SOURCE_PORT2 9991 diff --git a/packages/redboot/current/ChangeLog b/packages/redboot/current/ChangeLog new file mode 100644 --- /dev/null +++ b/packages/redboot/current/ChangeLog @@ -0,0 +1,307 @@ +2000-08-21 Gary Thomas + + * cdl/redboot.cdl: + * src/net/pktbuf.c (MAX_PKTBUF): Add CDL configury for number + of network packet buffers. + + * src/net/net_io.c: Change config param names to enforce + layout (config fields are sorted by name). + + * src/load.c: Adapt to changes in 'parse_num'. + + * src/main.c (parse_num): Now takes additional arguments which + allow a delimiter set and returning the end of number string. + + * include/redboot.h: Augment 'parse_num' to handle strings + with more than one number, delimiters, etc. + + * src/flash.c: + * include/flash_config.h: Add support for ethernet hardware + addresses. + +2000-08-20 Gary Thomas + + * include/flash_config.h: New file - configuration data layout. + + * src/flash.c: Restructure config data to be 100% table driven. + + * include/redboot.h: + * include/net/bootp.h: + * include/net/net.h: + * include/net/tftp.h: + * include/net/tftp_support.h: New location. + + * src/printf.c: + * src/net/arp.c: + * src/net/bootp.c: + * src/net/cksum.c: + * src/net/enet.c: + * src/net/icmp.c: + * src/net/inet_addr.c: + * src/net/ip.c: + * src/net/net_io.c: + * src/net/pktbuf.c: + * src/net/tcp.c: + * src/net/tftp_client.c: + * src/net/timers.c: + * src/net/udp.c: Include files moved. + + * src/redboot.h: + * src/net/bootp.h: + * src/net/net.h: + * src/net/tftp.h: + * src/net/tftp_support.h: Files moved. + + * cdl/redboot.cdl: Move .h files to include directory. + +2000-08-16 Gary Thomas + + * src/io.c (dump_buf_with_offset): Clean up warnings. + + * src/net/net_io.c: Cosmetic - clean up TCP debug code. + + * src/main.c (cmd_search): Search for ambiguous commands was + wrong since layout change (only know the limits, don't rely + on "null" entry). + +2000-08-14 Gary Thomas + + * cdl/redboot.cdl: Support for plugin (table driven) modules. + + * src/flash.c: Lots of warning cleanups. + + * src/io.c: Fix some flash configury. + + * src/load.c: Make internal buffer unsigned so 'raw' mode + works properly. Also, support as a plugin command. + + * src/main.c: + * src/redboot.h: Add support for "tableized" entries. In + particular, commands and platform initializations can now + be handled via anonymous tables. + + * src/net/net.h: Update for changes in network init setup. + + * src/net/net_io.c: Move network initialization here. + +2000-08-07 Gary Thomas + + * src/net/net.h: + * src/redboot.h: + * src/main.c: Cosmetic [warnings] cleanups. + +2000-08-03 Gary Thomas + + * cdl/redboot.cdl: Ethernet driver now comes from common + I/O package. + + * src/io.c (verify_action): Force normal I/O (no script) + to get response. + + * src/main.c: Add script timeout to allow user to abort before + script is run on boot. + + * src/printf.c: '%p' implies zero filled long format. + + * src/flash.c: + * src/redboot.h: Add TCP socket and script timeouts. + + * src/net/net_io.c: TCP socket for debug is now configurable + and settable in FLASH. Better handling of GDB $O packets (less + latency). Additional small changes to support network debug. + +2000-07-30 Gary Thomas + + * src/flash.c: Make config data safer with a 'key'. Also, don't + erase the config data when doing a full FIS initialization. + Finally, ensure that the commands which erase data are not going + to erase the current code! + + * src/io.c (gets): Treat 'delete' char like ^H. + +2000-07-30 Gary Thomas + + * cdl/redboot.cdl: Add option for FLASH based configuration data. + + * src/flash.c: Lots of changes to support FLASH based configuration + data, including routines to read and maintain this data. + + * src/main.c: + * src/redboot.h: Many changes for FLASH configuration data support. + Also split out table driven option/parameter parsing. + + * src/io.c: Allow ^C to abort input. Fix timeout stuff to + work better while waiting for console to be discovered. + Add support for boot-time script. + + * src/load.c: Use new IP/INET address functions. + + * src/net/bootp.c: Remove force of net_debug and result print. + + * src/net/inet_addr.c: IP/INET address conversion routines. + + * src/net/net.h: Make 'net_debug' be boolean. Add IP/INET + address conversion routine prototypes. + +2000-07-29 Gary Thomas + + * src/flash.c: Misc little cleanups. + + * src/load.c: Print address range of loaded image/file. + +2000-07-29 Gary Thomas + + * src/flash.c: Add 'load' command which loads an image into RAM. + + * src/load.c: Add '-raw' switch to allow loading a file without + trying to interpret it as an executable image. + + * src/main.c: + * src/redboot.h: Make command parsing functions public. + +2000-07-29 Gary Thomas + + * src/net/bootp.c: Turn on network debug during address discovery. + (Note: this will be optional/configurable in the future). + + * src/net/eth_drv.c: Use 'net_debug' for diagnostic dumps. + + * src/redboot.h: Prototypes for new functions. + + * src/printf.c (vprintf): New function. + + * src/io.c (verify_action): New function. + + * cdl/redboot.cdl: Make FLASH support optional. + + * src/flash.c: New file - implements simple FLASH Image System. + + * src/misc_funs.c (memset): + (strcpy): New functions. + + * src/main.c: Split flash functions to separate file. + +2000-07-28 Gary Thomas + + * src/load.c: Add "-v" switch to turn on a little 'spinner' while + downloading to provide some feedback to the user. + + * src/printf.c: Use only RedBoot I/O to allow console to "float." + + * src/net/bootp.c: Force hardware type to be "original" ethernet. + + * cdl/redboot.cdl: + * src/redboot.h: + * src/main.c: + * src/io.c: + * src/net/net_io.c: Support "floating" console, chosen from + available serial I/O channels. + +2000-07-26 Gary Thomas + + * src/net/tftp_support.h: + * src/net/tftp_client.c: Add new stream oriented functions. + + * src/net/net.h: More prototypes. + + * src/redboot.h: Move support functions here. Update interfaces. + + * src/printf.c: Support %l (long) qualifier. + + * src/misc_funs.c: Misc cleanups. Add case insensitive routines. + + * src/main.c: FLASH functionality is now in it's own package. + + * src/net/eth_drv.c: + * include/eth_drv.h: Update to new interface conventions. + + * cdl/redboot.cdl: Changes for new files(s). + +2000-07-24 Gary Thomas + + * src/net/inet_addr.c: New file. Support for IP address parsing. + + * src/load.c: New file. Split out download functionality. + Restructured to support download via stream (zmodem). + + * src/misc_funs.c: Add case insensitive compare functions. + +2000-07-22 Gary Thomas + + * src/main.c (do_load): Add proper argument parsing. + +2000-07-21 Gary Thomas + + * src/io.c (gets): Treat "\n\r" and "\r\n" as exactluy "\n". This + solves problems of simply ignoring "\n" on terminals which can only + send that character while still working with telnet/TCP connections. + + * src/net/net_io.c: New file. Supports local I/O via a TCP channel. + Additional changes to support TCP channel for GDB debug I/O. + + * cdl/redboot.cdl: Clean up dependencies. Extend network configuration. + + * src/io.c (gets): Ignore blank lines which contain only '\n'. + This works fine for terminal I/O since they will have '\r' and it + allows reasonable handling when connected via telnet/TCP. + + * src/main.c: Better support for network connections. + Also some reworking of FLASH routines [will be moved later]. + More error checking and better error messages in download code. + + * src/net/net.h: Reorder 'tcp_socket' fields to enforce proper + alignment of data buffer [needs to be on dword boundary]. + + * src/net/tcp.c: Many small changes getting 'endian'-ness correct. + + * src/net/tftp_client.c (tftp_error): New function - returns a + string representing the error code [for humans]. + +2000-07-16 Gary Thomas + + * cdl/redboot.cdl: Make network support configurable/optional. + + * src/io.c: Add command line input function. + + * src/main.c: Lots of new functions, command line processing, etc. + + * src/misc_funs.c (strcmp, strncmp): New function(s). + + * src/printf.c: Add support for "%p" (pointers). + + * src/redboot.h: Expand, move global vars, here, etc. + + * src/net/eth_drv.c: Make quieter, change "no interface" string. + + * src/net/net.h (__LITTLE_ENDIAN__): Avoid redefining this on platforms + where GCC does it for us. + +2000-07-12 Gary Thomas + + * cdl/redboot.cdl: New file(s). + +//=========================================================================== +//####COPYRIGHTBEGIN#### +// +// ------------------------------------------- +// The contents of this file are subject to the Red Hat eCos Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.redhat.com/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations under +// the License. +// +// The Original Code is eCos - Embedded Configurable Operating System, +// released September 30, 1998. +// +// The Initial Developer of the Original Code is Red Hat. +// Portions created by Red Hat are +// Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// All Rights Reserved. +// ------------------------------------------- +// +//####COPYRIGHTEND#### +//=========================================================================== diff --git a/packages/redboot/current/cdl/redboot.cdl b/packages/redboot/current/cdl/redboot.cdl new file mode 100644 --- /dev/null +++ b/packages/redboot/current/cdl/redboot.cdl @@ -0,0 +1,158 @@ +# ==================================================================== +# +# redboot.cdl +# +# Redboot package configuration data +# +# ==================================================================== +#####COPYRIGHTBEGIN#### +# +# ------------------------------------------- +# The contents of this file are subject to the Red Hat eCos Public License +# Version 1.1 (the "License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.redhat.com/ +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +# License for the specific language governing rights and limitations under +# the License. +# +# The Original Code is eCos - Embedded Configurable Operating System, +# released September 30, 1998. +# +# The Initial Developer of the Original Code is Red Hat. +# Portions created by Red Hat are +# Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +# All Rights Reserved. +# ------------------------------------------- +# +#####COPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): jskov +# Original data: gthomas +# Contributors: +# Date: 1999-11-03 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== +cdl_package CYGPKG_REDBOOT { + display "Redboot ROM monitor" +# include_dir cyg/redboot + define_header redboot.h + description " + This package supports the Redboot \[stand-alone debug monitor\] + using eCos as the underlying board support mechanism." + + + # Since the CYGDAT_REDBOOT_CONSOLE_DEV setting ends up in the platform + # HAL header, we need to include that here (via hal.h). + define_proc { + puts $::cdl_header "#include " + } + + cdl_option CYGBLD_BUILD_REDBOOT { + display "Build Redboot ROM ELF image" + default_value 0 +# requires { CYG_HAL_STARTUP == "ROM" } + requires CYGPKG_INFRA + requires CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS + requires ! CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT + requires ! CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT +# requires ! CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT + + no_define + description "This option enables the building of the Redboot ELF image. + The image may require further relocation or symbol + stripping before being converted to a binary image. + This is handled by a rule in the target CDL." + + compile printf.c misc_funs.c io.c ticks.c + compile -library=libextras.a load.c + + make -priority 320 { + /bin/redboot.elf : $(PREFIX)/lib/libtarget.a main.o + @sh -c "mkdir -p $(dir $@)" + $(CC) $(LDFLAGS) -L$(PREFIX)/lib -Ttarget.ld -o $@ $^ + } + make -priority 319 { + main.o: $(REPOSITORY)/$(PACKAGE)/src/main.c $(PREFIX)/lib/libtarget.a + $(CC) -c $(INCLUDE_PATH) $(CFLAGS) -o main.o $(REPOSITORY)/$(PACKAGE)/src/main.c + } + } + + cdl_component CYGPKG_REDBOOT_NETWORKING { + display "Build Redboot ROM binary image" + flavor bool + active_if CYGBLD_BUILD_REDBOOT + default_value 1 + compile net/bootp.c net/udp.c net/ip.c net/pktbuf.c net/cksum.c + compile net/enet.c net/icmp.c net/tcp.c net/timers.c net/arp.c + compile net/tftp_client.c net/net_io.c net/inet_addr.c + description "This option includes networking support in RedBoot." + define_proc { + puts $::cdl_system_header "#define CYGNUM_HAL_VIRTUAL_VECTOR_AUX_CHANNELS 1" + } + + cdl_option CYGNUM_REDBOOT_NETWORKING_TCP_PORT { + display "TCP port to listen for incoming connections" + flavor data + default_value 9000 + description " + RedBoot will 'listen' on this port for incoming TCP connections. + This allows outside connections to be made to the platform, either + for GDB or RedBoot commands." + } + + cdl_option CYGNUM_REDBOOT_NETWORKING_MAX_PKTBUF { + display "Number of \[network\] packet buffers" + flavor data + default_value 4 + legal_values 2 to 8 + description " + RedBoot may need to buffer network data to support various connections. + This option allows control over the number of such buffered packets, + and in turn, controls the amount of memory used by RedBoot (which + is not available to user applications). Each packet buffer takes up + about 1514 bytes. Note: there is little need to make this larger + than the default." + } + } + + cdl_option CYGPKG_REDBOOT_ANY_CONSOLE { + display "Allow RedBoot to use any I/O channel for it's console." + flavor bool + default_value 1 + description " + If this option is enabled then RedBoot will attempt to use all + defined serial I/O channels for it's console device. Once input + arrives at one of these channels then the console will use only + that port." + } + + cdl_component CYGPKG_REDBOOT_FLASH { + display "Allow RedBoot to support FLASH programming" + flavor bool + default_value 1 + active_if CYGPKG_IO_FLASH + description " + If this option is enabled then RedBoot will provide commands + to manage images in FLASH memory. These images can be loaded + into memory for execution or executed in place." + compile -library=libextras.a flash.c + + cdl_option CYGSEM_REDBOOT_FLASH_CONFIG { + display "Keep RedBoot configuration data in FLASH" + flavor bool + default_value 1 + description " + When this option is enabled, RedBoot will keep configuration + data in a separate block of FLASH memory. This data will + include such items as the node IP address or startup scripts." + } + } +} + diff --git a/packages/redboot/current/doc/redboot.ebsa285 b/packages/redboot/current/doc/redboot.ebsa285 new file mode 100644 --- /dev/null +++ b/packages/redboot/current/doc/redboot.ebsa285 @@ -0,0 +1,409 @@ +RedBoot for the EBSA285 +======================= + +Target +------ + +This document describes using RedBoot with the Intel StrongARM EBSA-285 +development system and equivalents. + +Background +---------- + +RedBoot is the new debug/bootstrap environment from RedHat. It is designed +to replace the existing debug/boot tools CygMon and GDB stubs. It provides +a complete bootstrap environment, including network downloading and +debugging. Also provided is a simple flash file system for boot images. + +Some host services may be necessary in order to run RedBoot, especially the +first time. In particular: + * TFTP - RedBoot uses TFTP for downloading images. Most systems come + with this disabled, so it may be necessary to enable a TFTP server. + Also note that the files mentioned below are assumed to be in the TFTP + directory, normally "/tftpboot". + * BOOTP/DHCP - RedBoot will use BOOTP to get its network address + parameters unless setup otherwise. For the initial setup, BOOTP will + be required. + +Since RedBoot is still quite new, there are some limitations (which we expect +to remove very soon): + * The only format supported for image download is Motorola S-records. + Thus files to be downloaded would have to be converted using the + "objcopy" utility for the platform in question; for EBSA this is + arm-elf-objcopy. S-record versions of the boot images are produced as + part of the normal RedBoot build process (see below). + * Serial downloads are not supported; TFTP only in this version. + * RedBoot "chatters" somewhat about network packets that it discards; + this is to help with our debugging. + * Asynchronous interrupt (^C) of the board is not yet supported in + RedBoot. + +Notes: + * Only one network interface is used by RedBoot. This will be the first + interface found, which on the EBSA is the board in the highest numbered + PCI slot. + * In order to use GDB, each network interface needs to have two IP + addresses. One will be used for RedBoot/GDB and the other for eCos + applications. After RedBoot is installed in the flash, we use the + RedBoot configuration to force the IP address for the board's RedBoot + persona, and then BOOTP for the eCos application's IP address. + * In case of difficulties with RedBoot, it is possible to go back to the + "old way" of doing things, with built-in debug stubs and serial-only + debug and so on; that way the eCos application and its built-in GDB + stubs "takes over" the whole machine. Installing RedBoot is not a + one-way street; it can be used just as CygMon or an eCos stub ROM was. + +Building Test Cases to run with RedBoot +--------------------------------------- + +The default configuration for EBSA-285 at present always sends diagnostic +output to the serial line; to use RedBoot to channel diagnostic output to +GDB whether connected by net or serial, enable the configuration option + + CYGSEM_HAL_VIRTUAL_VECTOR_DIAG + "Do diagnostic IO via virtual vector table" + +located here in the common HAL configuration tree: + "eCos HAL" + "ROM monitor support" + "Enable use of virtual vector calling interface" + "Do diagnostic IO via virtual vector table" + +Other than that, no special configuration is required to use RedBoot. + +If you have been using built-in stubs to acquire support for thread-aware +debugging, you can still do that, but you must only use the serial device +for GDB connection and you must not enable the option mentioned above. +However, it is no longer necessary to do that to get thread-awareness; +RedBoot is thread aware. + +Installation on the Target Board +-------------------------------- + +Here's how to install RedBoot, using the redboot images you should find in + loaders/arm-ebsa285/ +in your installation directory: + 431497 Aug 9 15:28 redboot-ram.elf + 184802 Aug 9 15:28 redboot-ram.srec + 433104 Aug 9 15:29 redboot-rom.elf (this one is not used) + 194732 Aug 9 15:29 redboot-rom.srec + +Copy the two '.srec' files to /tftpboot or where-ever they have to be for +your TFTP server. + +Briefly, we use whatever boot flash image you have in place already (CygMon +or an eCos stub ROM) along with GDB, to execute a RAM based version of +RedBoot. That is used, in its command-line mode, to fetch a ROM-based boot +image of RedBoot and write it into the flash memory. "Fetching" the image +means TFTP from a server; the image must be in S-Record format. We then +reset the target, thus running the newly-installed boot image of RedBoot. +That in turn is used, in its command-line mode, to fetch a RAM-based boot +image of RedBoot and write it into a different area of the flash memory, in +order to make it easier to do the first part (running a RAM-based RedBoot +in order to update the boot block) again in future. + +Alternatively you can make a plain binary from the redboot-rom.elf and +"blow" that into the boot flash using the means of your choice, as with +previous systems. + + +1. Load a RedBoot, built for RAM startup, into RAM using existing GDB + stubs. Note: do not run it yet! + + % arm-elf-gdb -nw loaders/arm-ebsa285/redboot-ram.elf + + GNU gdb 4.18-ecos-99r1-991015 + Copyright 1998 Free Software Foundation, Inc. + GDB is free software, covered by the GNU General Public License, and you are + welcome to change it and/or distribute copies of it under certain conditions. + Type "show copying" to see the conditions. This version of GDB is supported + for customers of Cygnus Solutions. Type "show warranty" for details. + This GDB was configured as "--host=i686-pc-linux-gnu + --target=arm-elf"...(no debugging symbols found)... + (gdb) set remotebaud 38400 + (gdb) tar rem /dev/ttyS0 + Remote debugging using /dev/ttyS0 + 0x41000838 in ?? () + (gdb) load + Loading section .rom_vectors, size 0x44 lma 0x20000 + Loading section .text, size 0xf06c lma 0x20044 + Loading section .rodata, size 0x19a8 lma 0x2f0b0 + Loading section .data, size 0x474 lma 0x30a58 + Start address 0x20044 , load size 69324 + Transfer rate: 25208 bits/sec. + (gdb) detach + Ending remote debugging. + (gdb) q + +2. Execute RedBoot from RAM, and initialize the flash filing system. + Notes: the key here is the "-o" option which keeps minicom from + sending junk. + The magic phrase "$c#63" is important: you must type it in exactly + thus. It is the packet which a "continue" command in GDB would send + to the target. If you get no response, try "+$c#63" instead. + The IP and server info comes from BOOTP, which is how this RedBoot + will start up if the flash does not contain good config info. + + % minicom -o ttyS0 + + $c#63 + RedBoot(tm) debug environment - built 07:45:57, Aug 7 2000 + Copyright (C) 2000, Red Hat, Inc. + + RAM: 0x00000000-0x01000000 + FLASH: 0x41000000 - 0x41400000, 16 blocks of 0x00040000 bytes ea. + IP: 192.168.1.25, Default server: 192.168.1.101 + show tcp = 0x00030d48 + RedBoot> fi init + About to initialize [format] FLASH image system - are you sure (y/n)? y + *** Initialize FLASH Image System + Warning: device contents not erased, some blocks may not be usable + ... Erase from 0x413c0000-0x41400000: . + ... Program from 0x00fb0000-0x00fb0400 at 0x413c0000: . + + +3. Program RedBoot image into FLASH: + This expects the file redboot-rom.srec to exist in the TFTP server + space on the server that answered the BOOTP request. + + RedBoot> lo -v redboot-rom.srec -b 0x00100000 + Address offset = bf100000 + Entry point: 0x41000044, address range: 0x41000000-0x41011384 + RedBoot> fi cr RedBoot -f 0x41000000 -b 0x00100000 -l 0x20000 + An image named 'RedBoot' exists - are you sure (y/n)? y + ... Erase from 0x41000000-0x41020000: . + ... Program from 0x00100000-0x00120000 at 0x41000000: . + ... Erase from 0x413c0000-0x41400000: . + ... Program from 0x00fb0000-0x00ff0000 at 0x413c0000: . + RedBoot> + +****reset the board here, leaving your terminal program connected**** + + RedBoot(tm) debug environment - built 07:47:35, Aug 7 2000 + Copyright (C) 2000, Red Hat, Inc. + + RAM: 0x00000000-0x01000000 + FLASH: 0x41000000 - 0x41400000, 16 blocks of 0x00040000 bytes ea. + IP: 192.168.1.25, Default server: 192.168.1.101 + show tcp = 0x000082f0 + RedBoot> + + +4. Install RAM based RedBoot for backup/update: + Similar considerations apply: redboot-ram.srec must be an S-record + version of RedBoot built for RAM startup. + + RedBoot> lo -v redboot-ram.srec + Entry point: 0x00020044, address range: 0x00020000-0x00030ecc + RedBoot> fi cr RedBoot[backup] -f 0x41040000 -b 0x20000 -r 0x20000 -l 0x20000 + An image named 'RedBoot[backup]' exists - are you sure (y/n)? y + ... Erase from 0x41040000-0x41060000: . + ... Program from 0x00020000-0x00040000 at 0x41040000: . + ... Erase from 0x413c0000-0x41400000: . + ... Program from 0x00fb0000-0x00ff0000 at 0x413c0000: . + RedBoot> + + You have now updated your board completely. Phew! + + + +5. To update RedBoot with a new version of RedBoot, it is necessary to run + a RAM-based version of RedBoot which itself re-writes the ROM-based one, + because you can't re-write the code that is executing at the time. + + RedBoot> fi lo RedBoot[backup] + RedBoot> g + + + RedBoot(tm) debug environment - built 07:45:57, Aug 7 2000 + Copyright (C) 2000, Red Hat, Inc. + + RAM: 0x00000000-0x01000000 + FLASH: 0x41000000 - 0x41400000, 16 blocks of 0x00040000 bytes ea. + IP: 192.168.1.25, Default server: 192.168.1.101 + show tcp = 0x00030d48 + RedBoot> + + .. continue with step 3, using whatever your new boot image is called + in the TFTP-place, in .srec format. + + +You probably also want to set up then environment with your own IP +addresses and so on. Recall that this IP address is the one you use for +GDB to talk to the board, not the IP address which the eCos application +will take on (by BOOTP/DHCP or whatever means according to configury as +usual). + + RedBoot> fconfig + Network debug at boot time: false + Use BOOTP for network configuration: false + Local IP address: 192.168.1.25 + Default server IP address: 192.168.1.101 + GDB connection port: 1000 + Run script at boot: false + RedBoot> + + +Building RedBoot +---------------- + +To rebuild RedBoot from source, first cut out the attached configuration +export file "redboot.RAM" and save it somewhere, say /tmp/redboot.RAM + + mkdir redboot + cd redboot + ecosconfig new ebsa redboot + ecosconfig import /tmp/redboot.RAM + ecosconfig tree + make + +To build the ROM version, in a different build/config directory, just +change the startup mode (at the end of the export file) and add an enable +of CYGSEM_HAL_ROM_MONITOR, or use the attached config export redboot.ROM. + +The resulting files will be, in each of the ROM and RAM startup build +places: + 70456 ..../install/bin/redboot.bin + 433104 ..../install/bin/redboot.elf + 91407 ..../install/bin/redboot.img + 194732 ..../install/bin/redboot.srec + +The .elf and .srec files have the obvious relationship to those supplied in +the "loaders/arm-ebsa285" directory in the install. + +Here are the redboot.RAM and .ROM configuration exports: + +=========================== redboot.RAM ===================================== +cdl_savefile_version 1; +cdl_savefile_command cdl_savefile_version {}; +cdl_savefile_command cdl_savefile_command {}; +cdl_savefile_command cdl_configuration { description hardware template package }; +cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value }; + +cdl_configuration eCos { + description "" ; + hardware ebsa285 ; + template redboot ; + package -hardware CYGPKG_HAL_ARM current ; + package -hardware CYGPKG_HAL_ARM_EBSA285 current ; + package -hardware CYGPKG_IO_PCI current ; + package -hardware CYGPKG_DEVS_ETH_ARM_EBSA285 current ; + package -hardware CYGPKG_IO_SERIAL_ARM_EBSA285 current ; + package -hardware CYGPKG_DEVICES_WATCHDOG_ARM_EBSA285 current ; + package -template CYGPKG_HAL current ; + package -template CYGPKG_INFRA current ; + package -template CYGPKG_REDBOOT current ; + package CYGPKG_IO_FLASH current ; + package CYGPKG_IO_ETH_DRIVERS current ; + package CYGPKG_DEVS_FLASH_EBSA285 current ; +}; + +cdl_option CYGBLD_BUILD_GDB_STUBS { + user_value 0 +}; + +cdl_option CYGDBG_DEVS_ETH_ARM_EBSA285_CHATTER { + user_value 0 +}; + +cdl_option CYGNUM_DEVS_ETH_ARM_EBSA285_DEV_COUNT { + user_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS { + inferred_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT { + inferred_value 0 +}; + +cdl_option CYGSEM_HAL_VIRTUAL_VECTOR_DIAG { + user_value 1 +}; + +cdl_option CYGSEM_HAL_USE_ROM_MONITOR { + inferred_value 0 0 +}; + +cdl_option CYGBLD_BUILD_REDBOOT { + user_value 1 +}; + +cdl_component CYG_HAL_STARTUP { + user_value RAM +}; +=========================== redboot.RAM ===================================== +=========================== redboot.ROM ===================================== +cdl_savefile_version 1; +cdl_savefile_command cdl_savefile_version {}; +cdl_savefile_command cdl_savefile_command {}; +cdl_savefile_command cdl_configuration { description hardware template package }; +cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value }; + +cdl_configuration eCos { + description "" ; + hardware ebsa285 ; + template redboot ; + package -hardware CYGPKG_HAL_ARM current ; + package -hardware CYGPKG_HAL_ARM_EBSA285 current ; + package -hardware CYGPKG_IO_PCI current ; + package -hardware CYGPKG_DEVS_ETH_ARM_EBSA285 current ; + package -hardware CYGPKG_IO_SERIAL_ARM_EBSA285 current ; + package -hardware CYGPKG_DEVICES_WATCHDOG_ARM_EBSA285 current ; + package -template CYGPKG_HAL current ; + package -template CYGPKG_INFRA current ; + package -template CYGPKG_REDBOOT current ; + package CYGPKG_IO_FLASH current ; + package CYGPKG_IO_ETH_DRIVERS current ; + package CYGPKG_DEVS_FLASH_EBSA285 current ; +}; + +cdl_option CYGBLD_BUILD_GDB_STUBS { + user_value 0 +}; + +cdl_option CYGDBG_DEVS_ETH_ARM_EBSA285_CHATTER { + user_value 0 +}; + +cdl_option CYGNUM_DEVS_ETH_ARM_EBSA285_DEV_COUNT { + user_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS { + inferred_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT { + inferred_value 0 +}; + +cdl_option CYGSEM_HAL_VIRTUAL_VECTOR_DIAG { + user_value 1 +}; + +cdl_option CYGSEM_HAL_USE_ROM_MONITOR { + inferred_value 0 0 +}; + +cdl_option CYGBLD_BUILD_REDBOOT { + user_value 1 +}; + +cdl_component CYG_HAL_STARTUP { + user_value ROM +}; + +cdl_option CYGSEM_HAL_ROM_MONITOR { + user_value 1 +}; + +=========================== redboot.ROM ===================================== + +[end] diff --git a/packages/redboot/current/doc/redboot.edb7xxx b/packages/redboot/current/doc/redboot.edb7xxx new file mode 100644 --- /dev/null +++ b/packages/redboot/current/doc/redboot.edb7xxx @@ -0,0 +1,195 @@ +RedBoot for the EDB7xxx +======================= + +Target +------ + +This document describes using RedBoot with the Cirrus Logic ARM-based +EDB7xxx evaluation boards. + +Installation on the Target Board +-------------------------------- + +Copy the two '.srec' files to /tftpboot or where-ever they have to be for +your tftp server. + +Briefly, we use whatever boot flash image you have in place already (CygMon +or an eCos stub ROM) along with GDB, to execute a RAM based version of +RedBoot. That is used, in its command-line mode, to fetch a ROM-based boot +image of RedBoot and write it into the flash memory. "Fetching" the image +means tftp from a server; the image must be in S-Record format. We then +reset the target, thus running the newly-installed boot image of RedBoot. +That in turn is used, in its command-line mode, to fetch a RAM-based boot +image of RedBoot and write it into a different area of the flash memory, in +order to make it easier to do the first part (running a RAM-based RedBoot +in order to update the boot block) again in future. + +1. Program RedBoot image into FLASH: + + Using the 'dl_edb7xxx' tool (or it's Windows equivalent), program the + file 'edb7212_redboot_ROM.bin' into the flash. + +2. Execute RedBoot from ROM, and initialize the flash filing system. + Notes: the key here is the "-o" option which keeps minicom from + sending junk. + + % minicom -o ttyS0 + + RedBoot(tm) debug environment - built 08:36:10, Aug 15 2000 + Copyright (C) 2000, Red Hat, Inc. + + RAM: 0x00000000-0x00fd7000 + FLASH: 0xe0000000 - 0xe1000000, 128 blocks of 0x00020000 bytes ea. + IP: 192.168.1.23, Default server: 192.168.1.101 + show tcp = 0x0001ed58 + RedBoot> + + RedBoot> fi in + About to initialize [format] FLASH image system - are you sure (y/n)? y + *** Initialize FLASH Image System + Warning: device contents not erased, some blocks may not be usable + ... Erase from 0xe0fe0000-0xe1000000: . + ... Program from 0x00fa7000-0x00fa7400 at 0xe0fe0000: . + +4. Install RAM based RedBoot for backup/update: + Similar considerations apply: redboot-ram.srec must be an S-record + version of RedBoot built for RAM startup. + + RedBoot> lo -v edb7212_redboot.srec + Entry point: 0x00010044, address range: 0x00010000-0x0001ee88 + RedBoot> fi cr RedBoot[backup] -f 0xe0020000 -b 0x10000 -l 0x20000 + An image named 'RedBoot[backup]' exists - are you sure (y/n)? y + ... Erase from 0xe0020000-0xe0040000: . + ... Program from 0x00010000-0x00030000 at 0xe0020000: . + ... Erase from 0xe0fe0000-0xe1000000: . + ... Program from 0x00fa7000-0x00fc7000 at 0xe0fe0000: . + RedBoot> fi li + Name FLASH addr Mem addr Length Entry point + RedBoot 0xE0000000 0xE0000000 0x020000 0xE0000044 + RedBoot[backup] 0xE0020000 0xE0020000 0x020000 0x00010044 + RedBoot config 0xE0FC0000 0xE0FC0000 0x020000 0x00000000 + FIS directory 0xE0FE0000 0xE0FE0000 0x020000 0x00000000 + RedBoot> + + You have now updated your board completely. Phew! + + + +5. To update RedBoot with a new version of RedBoot, it is necessary to run + a RAM-based version of RedBoot which itself re-writes the ROM-based one, + because you can't re-write the code that is executing at the time. + + RedBoot> fi lo RedBoot[backup] + RedBoot> g + + + RedBoot(tm) debug environment - built 07:45:57, Aug 7 2000 + Copyright (C) 2000, Red Hat, Inc. + + RAM: 0x00000000-0x00fd7000 + FLASH: 0xe0000000 - 0xe1000000, 128 blocks of 0x00020000 bytes ea. + IP: 192.168.1.25, Default server: 192.168.1.101 + show tcp = 0x00030d48 + RedBoot> + + .. continue with step 3, using whatever your new boot image is called + in the tftp-place, in .srec format. + + +You probably also want to set up then environment with your own IP +addresses and so on. Recall that this IP address is the one you use for +GDB to talk to the board, not the IP address which the eCos application +will take on (by bootp/dhcp or whatever means according to configury as +usual). + + RedBoot> fconfig + Network debug at boot time: false + Use BOOTP for network configuration: false + Local IP address: 192.168.1.25 + Default server IP address: 192.168.1.101 + Network hardware address [MAC]: 0x08:0x88:0x12:0x34:0x56:0x79 + GDB connection port: 1000 + Run script at boot: false + RedBoot> + + +Building RedBoot +---------------- + +To rebuild RedBoot from source, first cut out the attached configuration +export file "redboot.RAM" and save it somewhere, say /tmp/redboot.RAM + + mkdir redboot + cd redboot + ecosconfig new edb7212 redboot + ecosconfig import /tmp/redboot.RAM + ecosconfig tree + make + +To build the ROM version, in a different build/config directory, just +change the startup mode (at the end of the export file). + +Here is the redboot.RAM configuration export: + +=========================== redboot.RAM ===================================== +cdl_savefile_version 1; +cdl_savefile_command cdl_savefile_version {}; +cdl_savefile_command cdl_savefile_command {}; +cdl_savefile_command cdl_configuration { description hardware template package }; +cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value }; +cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value }; + +cdl_configuration eCos { + description "" ; + hardware edb7212 ; + template redboot ; + package -hardware CYGPKG_HAL_ARM current ; + package -hardware CYGPKG_HAL_ARM_EDB7XXX current ; + package -hardware CYGPKG_DEVS_ETH_ARM_EDB7XXX current ; + package -hardware CYGPKG_IO_SERIAL_ARM_EDB7XXX current ; + package -template CYGPKG_HAL current ; + package -template CYGPKG_INFRA current ; + package -template CYGPKG_REDBOOT current ; + package CYGPKG_IO_ETH_DRIVERS current ; + package CYGPKG_IO_FLASH current ; + package CYGPKG_DEVS_FLASH_EDB7XXX current ; +}; + +cdl_option CYGBLD_BUILD_GDB_STUBS { + user_value 0 +}; + +cdl_option CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT { + user_value 0 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS { + inferred_value 1 +}; + +cdl_option CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT { + inferred_value 0 +}; + +cdl_option CYGSEM_HAL_USE_ROM_MONITOR { + inferred_value 0 0 +}; + +cdl_option CYGHWR_HAL_ARM_EDB7XXX_VARIANT { + user_value EP7212 +}; + +cdl_option CYGHWR_HAL_ARM_EDB7XXX_PROCESSOR_CLOCK { + user_value 73728 +}; + +cdl_option CYGBLD_BUILD_REDBOOT { + user_value 1 +}; + +cdl_component CYG_HAL_STARTUP { + user_value RAM +}; +=========================== redboot.RAM ===================================== + diff --git a/packages/redboot/current/doc/users_guide b/packages/redboot/current/doc/users_guide new file mode 100644 --- /dev/null +++ b/packages/redboot/current/doc/users_guide @@ -0,0 +1,292 @@ +The standard RedBoot command set is structured around the bootstrap +environment. These commands are designed to be simple to use and +remember, while still providing sufficient power and flexibility to +be useful. No attempt has been made to make RedBoot be the end-all +product. As such, things such as the debug environment are left +to other modules such as GDB stubs which are typically included in +RedBoot. + +Also, the command set may be extended on a platform basis. + +Common commands: + +The general format of commands is: + +Elements are separated by the space character. Other control characters, +such as TAB or editting keys (Insert) are not currently supported. + +Numbers, such as a memory location, may be specified in either +decimal or hexadecimal (requires a 0x prefix). + +Use the 'help' command to get limited help on command syntax. + + ======================================================================= + RedBoot> help + Display (hex dump) a range of memory + dump [] + Manage FLASH images + fis {cmds} + Manage configuration kept in FLASH memory + fconfig + Execute code at a location + go [-w ] [entry] + Help about help? + help + Load a file + load [-raw] [-b ]] + RedBoot> + ======================================================================= + +Commands may be abbreviated to any unique string. E.g. 'lo' is equivalent +to 'loa' and 'load'. + +- Download process + +Currently, download is only supported using TFTP over a network. +Files to be downloaded may be executable images or raw data. +The format of the command is: + RedBoot> load [-v] [-b ] [-r] +where: + - The name of the file on the TFTP server. Details of how + this is specified are host specific. + -v - Display a small spinner (indicator) while download in + progress. Just for feedback, especially during long loads. + -b - Specify the location in memory to load the file. Executable + images normally load at the location the file was linked for. + This option allows the file to be loaded to a specific memory + location, possibly overriding any assumed location. + -r - Download raw data. Normally, the load command is used to + load executable images into memory. This option allows for + raw data to be loaded. If this option is given, "-b" will + be required as well. + + ======================================================================= + RedBoot> lo redboot.ROM -b 0x8c400000 + Address offset = 0x0c400000 + Entry point: 0x80000000, address range: 0x80000000-0x8000fe80 + ======================================================================= + +- Flash Image System (FIS) + +If the platform has flash memory, RedBoot can use this for image storage. +Executable images, as well as data, can be stored in flash in a simple +file store. The 'fis' command is used to manipulate and maintain flash images. + +The available 'fis' commands are: + + fis init [-f] + +This command is used to initialize the Flash Image System (FIS). It should +only be executed once, when RedBoot is first installed on the hardware. +Subsequent executions will cause loss of data in the flash (previously saved +images will no longer be accessible). + +If the "-f" option is specified, all blocks of flash memory will be erased +as part of this process. + + ======================================================================= + RedBoot> fis init -f + About to initialize [format] FLASH image system - are you sure (y/n)? n + ======================================================================= + + fis list + +This command lists the images currently available in the FIS. Certain images +are used by RedBoot and have fixed names. Other images can be manipulated by +the user. + + ======================================================================= + RedBoot> fis list + Name FLASH addr Mem addr Length Entry point + RedBoot 0xA0000000 0xA0000000 0x020000 0x80000000 + RedBoot[backup] 0xA0020000 0x8C010000 0x010000 0x8C010000 + RedBoot config 0xA0FC0000 0xA0FC0000 0x020000 0x00000000 + FIS directory 0xA0FE0000 0xA0FE0000 0x020000 0x00000000 + ======================================================================= + + fis free + +This command shows which areas of the flash memory are currently not in use. +In use means that the block contains non-erased contents. Since it is possible +to force an image to be loaded at a particular flash location, this command +can be used to check whether that location is in use by any other image. + +Note: there currently is no cross-checking between actual flash contents and +the image directory. i.e. there could be a segment of flash which is not erased +that does not correspond to a named image, or vice-versa. + + ======================================================================= + RedBoot> fis free + 0xA0040000 .. 0xA07C0000 + 0xA0840000 .. 0xA0FC0000 + ======================================================================= + + fis create -b -l [-f ] [-e ] [-r ] + +This command creates an image in the FIS directory. The data for the image must +exist in RAM memory before the copy. Typically, one would use the RedBoot 'load' +command to load an image into RAM and then the 'fis create' command to write it +to flash. + +Options: + - The name of the file, as shown in the FIS directory. + -b - The location in RAM used to obtain the image *required* + -l - The length of the location *required* + -f - The location in flash for the image. If not provided, the first free + block which is large enough will be used. See 'fis free'. + -e - The execution entry address. Used if the starting address for an image + is not known, or needs to be overridden. + -r - The location in RAM when the image is loaded via 'fis load'. This only + needs to be specified for images which will eventually loaded via 'fis load'. + Fixed images, such as RedBoot itself, will not need this. + + ======================================================================= + RedBoot> fis create RedBoot -f 0xa0000000 -b 0x8c400000 -l 0x20000 + An image named 'RedBoot' exists - are you sure (y/n)? n + RedBoot> fis create junk -b 0x8c400000 -l 0x20000 + ... Erase from 0xa0040000-0xa0060000: . + ... Program from 0x8c400000-0x8c420000 at 0xa0040000: . + ... Erase from 0xa0fe0000-0xa1000000: . + ... Program from 0x8c7d0000-0x8c7f0000 at 0xa0fe0000: . + ======================================================================= + + fis load name + +This command is used to transfer an image from flash memory to RAM. Once loaded, +it may be executed using the 'go' command. + + ======================================================================= + RedBoot> fis load RedBoot[backup] + RedBoot> go + ======================================================================= + + fis delete name + +This command removes an image from the FIS. The flash memory will be erased +as part of the execution of this command, as well as removal of the name from +the FIS directory. + + ======================================================================= + RedBoot> fis list + Name FLASH addr Mem addr Length Entry point + RedBoot 0xA0000000 0xA0000000 0x020000 0x80000000 + RedBoot[backup] 0xA0020000 0x8C010000 0x020000 0x8C010000 + RedBoot config 0xA0FC0000 0xA0FC0000 0x020000 0x00000000 + FIS directory 0xA0FE0000 0xA0FE0000 0x020000 0x00000000 + junk 0xA0040000 0x8C400000 0x020000 0x80000000 + RedBoot> fis delete junk + Delete image 'junk' - are you sure (y/n)? y + ... Erase from 0xa0040000-0xa0060000: . + ... Erase from 0xa0fe0000-0xa1000000: . + ... Program from 0x8c7d0000-0x8c7f0000 at 0xa0fe0000: . + ======================================================================= + + fis erase -f -l + +This command is used to forceably erase a portion of flash memory. There is +no cross-checking to ensure that the area being erased does not correspond to +a loaded image. + + ======================================================================= + RedBoot> fis erase -f 0xa0040000 -l 0x20000 + ... Erase from 0xa0040000-0xa0060000: . + ======================================================================= + +- Persistent state [flash-based configuration] control + +Additionally, if the platform has flash memory, certain control and configuration +information used by RedBoot can be stored in flash. The details of what information +is maintained in flash differs based on the platform and the configuration. + +However, the basic operation used to maintain this information is the same. +Using the 'fconfig' command, the information may be displayed and/or changed. + +Usage: + RedBoot> fconfig [-l] +If the optional flag "-l" is specified, the configuration data is simply listed. +Otherwise, each configuration parameter will be displayed and the user given +a chance to change it. The entire value must be typed. Typing just carriage +return will leave a value unchanged. Boolean values may be entered by just the +first letter ('t' for true, 'f' for false). At any time the editting process +may be stopped by entering just a '.' (period) on the line. Entry of the character +'^' will move the editting back to the previous item. + +If any changes are made in the configuration, then the updated data will be +written back to flash. + +One item which is always present in the configuration data is the ability to +execute a script at boot/startup time. A sequence of RedBoot commands can +be entered which will be executed when the system starts up. Optionally, +a time out period can be provided which allows the user to abort the +startup script and proceed with normal command processing from the console. + + ======================================================================= + RedBoot> fconfig -l + Run script at boot: false + Use BOOTP for network configuration: false + Local IP address: 192.168.1.29 + Default server IP address: 192.168.1.101 + GDB connection port: 9000 + Network debug at boot time: false + ======================================================================= + +The following example sets a boot script and then shows it running. + ======================================================================= + RedBoot> fconfig + ^^^^^^^ + Run script at boot: false t + ^ + Boot script: + Enter script, terminate with empty line + >> fi li + ^^^^^ + >> + ^ + Boot script timeout: 0 10 + ^^ + Use BOOTP for network configuration: false . + ^ + Update RedBoot non-volatile configuration - are you sure (y/n)? y + ^ + ... Erase from 0xa0fc0000-0xa0fe0000: . + ... Program from 0x8c021f60-0x8c022360 at 0xa0fc0000: . + RedBoot> + RedBoot(tm) debug environment - built 08:22:24, Aug 23 2000 + Copyright (C) 2000, Red Hat, Inc. + + RAM: 0x8c000000-0x8c800000 + FLASH: 0xa0000000 - 0xa1000000, 128 blocks of 0x00020000 bytes ea. + Socket Communications, Inc: Low Power Ethernet CF Revision C 5V/3.3V 08/27/98 + IP: 192.168.1.29, Default server: 192.168.1.101 + == Executing boot script in 10 seconds - enter ^C to abort + RedBoot> fi li + Name FLASH addr Mem addr Length Entry point + RedBoot 0xA0000000 0xA0000000 0x020000 0x80000000 + RedBoot[backup] 0xA0020000 0x8C010000 0x020000 0x8C010000 + RedBoot config 0xA0FC0000 0xA0FC0000 0x020000 0x00000000 + FIS directory 0xA0FE0000 0xA0FE0000 0x020000 0x00000000 + RedBoot> + ^ + ======================================================================= + +Note: the '^' characters above indicate where something was entered on the +console. As you can see, the 'fi li' command at the end came from the script, +not the console. Once the script was executed, command processing reverted +to the console. + +- Program execution + +Once an image has been loaded into memory, either via the 'load' command +or the 'fis load' command, execution may be transfered to that image. +Note: the image is assumed to be a stand-alone entity, as RedBoot gives +the entire platform over to it. Typical examples would be an eCos application +or a Linux kernel. + +The format of the 'go' command is: + RedBoot> go [-w