diff --git a/newlib/libc/sys/vita/Makefile.am b/newlib/libc/sys/vita/Makefile.am index fdbae43a3e..94a5a6acd0 100755 --- a/newlib/libc/sys/vita/Makefile.am +++ b/newlib/libc/sys/vita/Makefile.am @@ -8,11 +8,17 @@ AM_CCASFLAGS = $(INCLUDES) noinst_LIBRARIES = lib.a -lib_a_SOURCES = syscalls.c sbrk.c threading.c mlock.c io.c +SOCKET_OBJS = accept.o bind.o connect.o getpeername.o getsockname.o getsockopt.o listen.o recv.o recvfrom.o recvmsg.o send.o sendto.o sendmsg.o setsockopt.o shutdown.o socket.o + +lib_a_SOURCES = syscalls.c sbrk.c threading.c mlock.c io.c socket.c +lib_a_LIBADD = ${SOCKET_OBJS} lib_a_CCASFLAGS = $(AM_CCASFLAGS) lib_a_CFLAGS = $(AM_CFLAGS) all-local: crt0.o +$(SOCKET_OBJS): socket.c + $(COMPILE) -DF_$* $< -c -o $@ + ACLOCAL_AMFLAGS = -I ../../.. -I ../../../.. CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host diff --git a/newlib/libc/sys/vita/Makefile.in b/newlib/libc/sys/vita/Makefile.in index 519baa6fb2..bd19696ceb 100644 --- a/newlib/libc/sys/vita/Makefile.in +++ b/newlib/libc/sys/vita/Makefile.in @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.12.6 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2012 Free Software Foundation, Inc. - +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -53,7 +54,7 @@ host_triplet = @host@ subdir = . DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ - $(top_srcdir)/../../../../mkinstalldirs + $(srcdir)/../../../../mkinstalldirs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../../../acinclude.m4 \ $(top_srcdir)/configure.in @@ -67,9 +68,10 @@ CONFIG_CLEAN_VPATH_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru lib_a_AR = $(AR) $(ARFLAGS) -lib_a_LIBADD = +lib_a_DEPENDENCIES = $(SOCKET_OBJS) am_lib_a_OBJECTS = lib_a-syscalls.$(OBJEXT) lib_a-sbrk.$(OBJEXT) \ - lib_a-threading.$(OBJEXT) lib_a-mlock.$(OBJEXT) lib_a-io.$(OBJEXT) + lib_a-threading.$(OBJEXT) lib_a-mlock.$(OBJEXT) \ + lib_a-io.$(OBJEXT) lib_a-socket.$(OBJEXT) lib_a_OBJECTS = $(am_lib_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = @@ -86,8 +88,6 @@ am__can_run_installinfo = \ esac ETAGS = etags CTAGS = ctags -CSCOPE = cscope -AM_RECURSIVE_TARGETS = cscope ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ @@ -182,6 +182,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -195,7 +196,9 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) AM_CCASFLAGS = $(INCLUDES) noinst_LIBRARIES = lib.a -lib_a_SOURCES = syscalls.c sbrk.c threading.c mlock.c io.c +SOCKET_OBJS = accept.o bind.o connect.o getpeername.o getsockname.o getsockopt.o listen.o recv.o recvfrom.o recvmsg.o send.o sendto.o sendmsg.o setsockopt.o shutdown.o socket.o +lib_a_SOURCES = syscalls.c sbrk.c threading.c mlock.c io.c socket.c +lib_a_LIBADD = ${SOCKET_OBJS} lib_a_CCASFLAGS = $(AM_CCASFLAGS) lib_a_CFLAGS = $(AM_CFLAGS) ACLOCAL_AMFLAGS = -I ../../.. -I ../../../.. @@ -270,12 +273,6 @@ lib_a-sbrk.o: sbrk.c lib_a-sbrk.obj: sbrk.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sbrk.obj `if test -f 'sbrk.c'; then $(CYGPATH_W) 'sbrk.c'; else $(CYGPATH_W) '$(srcdir)/sbrk.c'; fi` -lib_a-io.o: io.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-io.o `test -f 'io.c' || echo '$(srcdir)/'`io.c - -lib_a-io.obj: io.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-io.obj `if test -f 'io.c'; then $(CYGPATH_W) 'io.c'; else $(CYGPATH_W) '$(srcdir)/io.c'; fi` - lib_a-threading.o: threading.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-threading.o `test -f 'threading.c' || echo '$(srcdir)/'`threading.c @@ -288,6 +285,18 @@ lib_a-mlock.o: mlock.c lib_a-mlock.obj: mlock.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mlock.obj `if test -f 'mlock.c'; then $(CYGPATH_W) 'mlock.c'; else $(CYGPATH_W) '$(srcdir)/mlock.c'; fi` +lib_a-io.o: io.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-io.o `test -f 'io.c' || echo '$(srcdir)/'`io.c + +lib_a-io.obj: io.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-io.obj `if test -f 'io.c'; then $(CYGPATH_W) 'io.c'; else $(CYGPATH_W) '$(srcdir)/io.c'; fi` + +lib_a-socket.o: socket.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-socket.o `test -f 'socket.c' || echo '$(srcdir)/'`socket.c + +lib_a-socket.obj: socket.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-socket.obj `if test -f 'socket.c'; then $(CYGPATH_W) 'socket.c'; else $(CYGPATH_W) '$(srcdir)/socket.c'; fi` + ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -337,32 +346,8 @@ GTAGS: && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" -cscope: cscope.files - test ! -s cscope.files \ - || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) - -clean-cscope: - -rm -f cscope.files - -cscope.files: clean-cscope cscopelist - -cscopelist: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -rm -f cscope.out cscope.in.out cscope.po.out cscope.files check-am: check: check-am all-am: Makefile $(LIBRARIES) all-local @@ -470,21 +455,24 @@ uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am all-local am--refresh check check-am \ - clean clean-cscope clean-generic clean-noinstLIBRARIES cscope \ - cscopelist ctags distclean distclean-compile distclean-generic \ - distclean-tags dvi dvi-am html html-am info info-am install \ - install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ - tags uninstall uninstall-am + clean clean-generic clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-tags dvi dvi-am \ + html html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am all-local: crt0.o +$(SOCKET_OBJS): socket.c + $(COMPILE) -DF_$* $< -c -o $@ + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/newlib/libc/sys/vita/aclocal.m4 b/newlib/libc/sys/vita/aclocal.m4 index 5fb014d775..62fe272e2c 100644 --- a/newlib/libc/sys/vita/aclocal.m4 +++ b/newlib/libc/sys/vita/aclocal.m4 @@ -1,7 +1,8 @@ -# generated automatically by aclocal 1.12.6 -*- Autoconf -*- - -# Copyright (C) 1996-2012 Free Software Foundation, Inc. +# generated automatically by aclocal 1.11.6 -*- Autoconf -*- +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, +# Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -17,24 +18,27 @@ m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically 'autoreconf'.])]) +To do so, use the procedure documented by the package, typically `autoreconf'.])]) -# Copyright (C) 2002-2012 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software +# Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 1 + # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.12' +[am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.12.6], [], +m4_if([$1], [1.11.6], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -50,22 +54,24 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.12.6])dnl +[AM_AUTOMAKE_VERSION([1.11.6])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 1 + # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to -# '$srcdir', '$srcdir/..', or '$srcdir/../..'. +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and @@ -84,7 +90,7 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is '.', but things will broke when you +# harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, @@ -110,19 +116,22 @@ am_aux_dir=`cd $ac_aux_dir && pwd` # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2012 Free Software Foundation, Inc. +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 9 + # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ([2.52])dnl - m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl @@ -141,14 +150,16 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2012 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, +# 2010, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 12 -# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing @@ -158,7 +169,7 @@ fi])]) # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". +# NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was @@ -171,13 +182,12 @@ AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl -m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], - [$1], [CXX], [depcc="$CXX" am_compiler_list=], - [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], - [$1], [UPC], [depcc="$UPC" am_compiler_list=], - [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], @@ -185,8 +195,8 @@ AC_CACHE_CHECK([dependency style of $depcc], # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're @@ -226,16 +236,16 @@ AC_CACHE_CHECK([dependency style of $depcc], : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - # We check with '-c' and '-o' for the sake of the "dashmstdout" + # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in @@ -244,8 +254,8 @@ AC_CACHE_CHECK([dependency style of $depcc], test "$am__universal" = false || continue ;; nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else @@ -253,7 +263,7 @@ AC_CACHE_CHECK([dependency style of $depcc], fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has + # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} @@ -301,7 +311,7 @@ AM_CONDITIONAL([am__fastdep$1], [ # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl @@ -311,13 +321,9 @@ AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE([dependency-tracking], [dnl -AS_HELP_STRING( - [--enable-dependency-tracking], - [do not reject slow dependency extractors]) -AS_HELP_STRING( - [--disable-dependency-tracking], - [speeds up one-time build])]) +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' @@ -332,12 +338,14 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2012 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +#serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ @@ -356,7 +364,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but + # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. @@ -368,19 +376,21 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], continue fi # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. + # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` @@ -398,7 +408,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each '.P' file that we will +# is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], @@ -408,12 +418,15 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2012 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 16 + # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. @@ -458,41 +471,31 @@ AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], -[AC_DIAGNOSE([obsolete], -[$0: two- and three-arguments forms are deprecated. For more info, see: -http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation]) -m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if( - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), - [ok:ok],, +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) - AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) -AM_MISSING_PROG([AUTOCONF], [autoconf]) -AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) -AM_MISSING_PROG([AUTOHEADER], [autoheader]) -AM_MISSING_PROG([MAKEINFO], [makeinfo]) +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -AC_SUBST([mkdir_p], ['$(MKDIR_P)']) +AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl @@ -503,35 +506,28 @@ _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES([CC])], - [m4_define([AC_PROG_CC], - m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES([CXX])], - [m4_define([AC_PROG_CXX], - m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES([OBJC])], - [m4_define([AC_PROG_OBJC], - m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl -dnl Support for Objective C++ was only introduced in Autoconf 2.65, -dnl but we still cater to Autoconf 2.62. -m4_ifdef([AC_PROG_OBJCXX], -[AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], - [_AM_DEPENDENCIES([OBJCXX])], - [m4_define([AC_PROG_OBJCXX], - m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])])dnl + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl -dnl The 'parallel-tests' driver may need to know about EXEEXT, so add the -dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) -dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], @@ -559,12 +555,15 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, +# Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 1 + # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. @@ -578,14 +577,16 @@ if test x"${install_sh}" != xset; then install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi -AC_SUBST([install_sh])]) +AC_SUBST(install_sh)]) -# Copyright (C) 2003-2012 Free Software Foundation, Inc. +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 2 + # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], @@ -602,17 +603,20 @@ AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996-2012 Free Software Foundation, Inc. +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008, +# 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 5 + # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. -# Default is to disable them, unless 'enable' is passed literally. -# For symmetry, 'disable' may be passed as well. Anyway, the user +# Default is to disable them, unless `enable' is passed literally. +# For symmetry, `disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), @@ -623,11 +627,10 @@ AC_DEFUN([AM_MAINTAINER_MODE], AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], - [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], - am_maintainer_other[ make rules and dependencies not useful - (and sometimes confusing) to the casual installer])], - [USE_MAINTAINER_MODE=$enableval], - [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) +[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE @@ -639,12 +642,14 @@ AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 4 + # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. @@ -662,7 +667,7 @@ am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. +# Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include @@ -689,12 +694,15 @@ rm -f confinc confmf # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2012 Free Software Foundation, Inc. +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 6 + # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], @@ -702,6 +710,7 @@ AC_DEFUN([AM_MISSING_PROG], $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) + # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. @@ -722,18 +731,50 @@ if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= - AC_MSG_WARN(['missing' script is too old or missing]) + AC_MSG_WARN([`missing' script is too old or missing]) fi ]) +# Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, +# Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 1 + +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software +# Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 5 + # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], @@ -743,7 +784,7 @@ AC_DEFUN([_AM_MANGLE_OPTION], # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ @@ -759,16 +800,22 @@ AC_DEFUN([_AM_IF_OPTION], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2012 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 5 + # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -779,40 +826,32 @@ case `pwd` in esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; + AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac -# Do 'set' in a subshell so we don't clobber the current shell's +# Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken - alias in your environment]) - fi - if test "$[2]" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + test "$[2]" = conftest.file ) then @@ -822,58 +861,46 @@ else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi -AC_MSG_RESULT([yes]) -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi -AC_CONFIG_COMMANDS_PRE( - [AC_MSG_CHECKING([that generated files are newer than configure]) - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - AC_MSG_RESULT([done])]) -rm -f conftest.file -]) +AC_MSG_RESULT(yes)]) -# Copyright (C) 2001-2012 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 1 + # AM_PROG_INSTALL_STRIP # --------------------- -# One issue with vendor 'install' (even GNU) is that you can't +# One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in "make install-strip", and initialize +# always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2012 Free Software Foundation, Inc. +# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 3 + # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. @@ -887,16 +914,18 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2012 Free Software Foundation, Inc. +# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 2 + # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. -# FORMAT should be one of 'v7', 'ustar', or 'pax'. +# FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory @@ -919,7 +948,7 @@ AC_MSG_CHECKING([how to create a $1 tar archive]) _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of '-'. +# Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in diff --git a/newlib/libc/sys/vita/configure b/newlib/libc/sys/vita/configure index 548219857f..e9c088dfdd 100755 --- a/newlib/libc/sys/vita/configure +++ b/newlib/libc/sys/vita/configure @@ -679,6 +679,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -755,6 +756,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1007,6 +1009,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1144,7 +1155,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1297,6 +1308,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1343,13 +1355,10 @@ Optional Features: --enable-newlib-elix-level supply desired elix library level (1-4) --disable-newlib-io-float disable printf/scanf family float support --disable-newlib-supplied-syscalls disable newlib from supplying syscalls - --enable-dependency-tracking - do not reject slow dependency extractors - --disable-dependency-tracking - speeds up one-time build - --enable-maintainer-mode - enable make rules and dependencies not useful (and - sometimes confusing) to the casual installer + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer Some influential environment variables: CCAS assembler compiler command (defaults to CC) @@ -1926,7 +1935,7 @@ IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac -am__api_version='1.12' +am__api_version='1.11' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or @@ -2023,6 +2032,9 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -2033,40 +2045,32 @@ case `pwd` in esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; + as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac -# Do 'set' in a subshell so we don't clobber the current shell's +# Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error $? "ls -t appears to fail. Make sure there is not a broken - alias in your environment" "$LINENO" 5 - fi - if test "$2" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken +alias in your environment" "$LINENO" 5 + fi + test "$2" = conftest.file ) then @@ -2078,16 +2082,6 @@ Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi - -rm -f conftest.file - test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. @@ -2114,8 +2108,8 @@ if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 -$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then @@ -2127,10 +2121,10 @@ if test x"${install_sh}" != xset; then esac fi -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. +# will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. @@ -2269,6 +2263,12 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. @@ -2370,7 +2370,7 @@ am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. +# Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include @@ -2574,12 +2574,6 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -mkdir_p='$(MKDIR_P)' - # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used @@ -2654,8 +2648,8 @@ else # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're @@ -2690,16 +2684,16 @@ else : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - # We check with '-c' and '-o' for the sake of the "dashmstdout" + # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in @@ -2708,8 +2702,8 @@ else test "$am__universal" = false || continue ;; nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else @@ -2717,7 +2711,7 @@ else fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has + # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} @@ -3594,14 +3588,6 @@ if test -z "${MAY_SUPPLY_SYSCALLS_TRUE}" && test -z "${MAY_SUPPLY_SYSCALLS_FALSE as_fn_error $? "conditional \"MAY_SUPPLY_SYSCALLS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 -$as_echo_n "checking that generated files are newer than configure... " >&6; } - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 -$as_echo "done" >&6; } if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. @@ -4656,7 +4642,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;} # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but + # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. @@ -4690,19 +4676,21 @@ $as_echo X"$mf" | continue fi # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. + # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || diff --git a/newlib/libc/sys/vita/io.c b/newlib/libc/sys/vita/io.c index b4c920f826..8e6c0bb5a9 100644 --- a/newlib/libc/sys/vita/io.c +++ b/newlib/libc/sys/vita/io.c @@ -1,45 +1,202 @@ #include #include +#include +#include -extern char _newlib_fd_mutex[]; -extern int fd_to_scefd[]; +#include +#include + +#include "vitadescriptor.h" +#include "vitaglue.h" + +#define SCE_ERRNO_MASK 0xFF + +DescriptorTranslation *__vita_fdmap[MAX_OPEN_FILES]; +DescriptorTranslation __vita_fdmap_pool[MAX_OPEN_FILES]; + +SceKernelLwMutexWork _newlib_fd_mutex __attribute__ ((aligned (8))); void _init_vita_io(void) { - int ret; - - sceKernelCreateLwMutex(_newlib_fd_mutex, "fd conversion table mutex", 0, 0, 0); - - sceKernelLockLwMutex(_newlib_fd_mutex, 1, 0); - ret = sceIoOpen("tty0:", O_RDONLY, 0); - if (ret >= 0) { - fd_to_scefd[STDIN_FILENO] = ret; - } - ret = sceIoOpen("tty0:", O_WRONLY, 0); - if (ret >= 0) { - fd_to_scefd[STDOUT_FILENO] = ret; - } - ret = sceIoOpen("tty0:", O_WRONLY, 0); - if (ret >= 0) { - fd_to_scefd[STDERR_FILENO] = ret; - } - sceKernelUnlockLwMutex(_newlib_fd_mutex, 1); + int ret; + sceKernelCreateLwMutex(&_newlib_fd_mutex, "fd conversion table mutex", 0, 1, NULL); + + memset(__vita_fdmap, 0, sizeof(__vita_fdmap)); + memset(__vita_fdmap_pool, 0, sizeof(__vita_fdmap_pool)); + + // TODO: do we prefer sceKernelStdin and friends? + ret = sceIoOpen("tty0:", SCE_O_RDONLY, 0); + + if (ret >= 0) { + __vita_fdmap[STDIN_FILENO] = &__vita_fdmap_pool[STDIN_FILENO]; + __vita_fdmap[STDIN_FILENO]->sce_uid = ret; + __vita_fdmap[STDIN_FILENO]->type = VITA_DESCRIPTOR_TTY; + __vita_fdmap[STDIN_FILENO]->ref_count = 1; + } + + ret = sceIoOpen("tty0:", SCE_O_WRONLY, 0); + + if (ret >= 0) { + __vita_fdmap[STDOUT_FILENO] = &__vita_fdmap_pool[STDOUT_FILENO]; + __vita_fdmap[STDOUT_FILENO]->sce_uid = ret; + __vita_fdmap[STDOUT_FILENO]->type = VITA_DESCRIPTOR_TTY; + __vita_fdmap[STDOUT_FILENO]->ref_count = 1; + } + + ret = sceIoOpen("tty0:", SCE_O_WRONLY, 0); + + if (ret >= 0) { + __vita_fdmap[STDERR_FILENO] = &__vita_fdmap_pool[STDERR_FILENO]; + __vita_fdmap[STDERR_FILENO]->sce_uid = ret; + __vita_fdmap[STDERR_FILENO]->type = VITA_DESCRIPTOR_TTY; + __vita_fdmap[STDERR_FILENO]->ref_count = 1; + } + + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); } void _free_vita_io(void) { - sceKernelLockLwMutex(_newlib_fd_mutex, 1, 0); - if (fd_to_scefd[STDIN_FILENO]) { - sceIoClose(fd_to_scefd[STDIN_FILENO]); - fd_to_scefd[STDIN_FILENO] = 0; - } - if (fd_to_scefd[STDOUT_FILENO]) { - sceIoClose(fd_to_scefd[STDOUT_FILENO]); - fd_to_scefd[STDOUT_FILENO] = 0; - } - if (fd_to_scefd[STDERR_FILENO]) { - sceIoClose(fd_to_scefd[STDERR_FILENO]); - fd_to_scefd[STDERR_FILENO] = 0; - } - sceKernelUnlockLwMutex(_newlib_fd_mutex, 1); - - sceKernelDeleteLwMutex(_newlib_fd_mutex); + sceKernelLockLwMutex(&_newlib_fd_mutex, 1, 0); + + if (__vita_fdmap[STDIN_FILENO]) { + sceIoClose(__vita_fdmap[STDIN_FILENO]->sce_uid); + memset(__vita_fdmap[STDIN_FILENO], 0, sizeof(DescriptorTranslation)); + __vita_fdmap[STDIN_FILENO] = NULL; + } + if (__vita_fdmap[STDOUT_FILENO]) { + sceIoClose(__vita_fdmap[STDOUT_FILENO]->sce_uid); + memset(__vita_fdmap[STDOUT_FILENO], 0, sizeof(DescriptorTranslation)); + __vita_fdmap[STDOUT_FILENO] = NULL; + } + if (__vita_fdmap[STDERR_FILENO]) { + sceIoClose(__vita_fdmap[STDERR_FILENO]->sce_uid); + memset(__vita_fdmap[STDERR_FILENO], 0, sizeof(DescriptorTranslation)); + __vita_fdmap[STDERR_FILENO] = NULL; + } + + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); + sceKernelDeleteLwMutex(&_newlib_fd_mutex); +} + +int __vita_acquire_descriptor(void) +{ + int fd = -1; + int i = 0; + sceKernelLockLwMutex(&_newlib_fd_mutex, 1, 0); + + // get free descriptor + // only allocate descriptors after stdin/stdout/stderr -> aka 0/1/2 + for (fd = 3; fd < MAX_OPEN_FILES; ++fd) + { + if (__vita_fdmap[fd] == NULL) + { + // get free pool + for (i = 0; i < MAX_OPEN_FILES; ++i) + { + if (__vita_fdmap_pool[i].ref_count == 0) + { + __vita_fdmap[fd] = &__vita_fdmap_pool[i]; + __vita_fdmap[fd]->ref_count = 1; + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); + return fd; + } + } + } + } + + // no mores descriptors available... + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); + return -1; +} + +int __vita_release_descriptor(int fd) +{ + DescriptorTranslation *map = NULL; + + sceKernelLockLwMutex(&_newlib_fd_mutex, 1, 0); + + if (!is_fd_valid(fd)) + { + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); + return 0; + } + + if (__vita_fd_drop(__vita_fdmap[fd]) < 0) + { + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); + return -1; + } + + __vita_fdmap[fd] = NULL; + + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); + return 0; +} + +int __vita_descriptor_ref_count(int fd) +{ + int res = 0; + sceKernelLockLwMutex(&_newlib_fd_mutex, 1, 0); + res = __vita_fdmap[fd]->ref_count; + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); + return res; +} + +DescriptorTranslation *__vita_fd_grab(int fd) +{ + DescriptorTranslation *map = NULL; + + sceKernelLockLwMutex(&_newlib_fd_mutex, 1, 0); + + if (!is_fd_valid(fd)) + { + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); + return NULL; + } + + map = __vita_fdmap[fd]; + + if (map) + map->ref_count++; + + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); + return map; +} + +int __vita_fd_drop(DescriptorTranslation *map) +{ + sceKernelLockLwMutex(&_newlib_fd_mutex, 1, 0); + + if (map->ref_count == 1) + { + int ret = 0; + + switch (map->type) + { + case VITA_DESCRIPTOR_FILE: + case VITA_DESCRIPTOR_TTY: + { + ret = sceIoClose(map->sce_uid); + break; + } + case VITA_DESCRIPTOR_SOCKET: + if (__vita_glue_socket_close) + ret = __vita_glue_socket_close(map->sce_uid); + break; + } + + if (ret < 0) { + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); + return -(ret & SCE_ERRNO_MASK); + } + + map->ref_count--; + memset(map, 0, sizeof(DescriptorTranslation)); + } + else + { + map->ref_count--; + } + + sceKernelUnlockLwMutex(&_newlib_fd_mutex, 1); + return 0; } diff --git a/newlib/libc/sys/vita/socket.c b/newlib/libc/sys/vita/socket.c new file mode 100644 index 0000000000..3cf4871d2a --- /dev/null +++ b/newlib/libc/sys/vita/socket.c @@ -0,0 +1,466 @@ +/* + +Copyright (C) 2016, David "Davee" Morgan + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#include +#include + +#include +#include + +#include "vitadescriptor.h" + +#define SCE_ERRNO_MASK 0xFF + +static inline int is_socket_valid(int s) +{ + return (is_fd_valid(s) && (__vita_fdmap[s]->type == VITA_DESCRIPTOR_SOCKET)); +} + +#ifdef F_accept +int accept(int s, struct sockaddr *addr, socklen_t *addrlen) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetAccept(fdmap->sce_uid, (SceNetSockaddr *)addr, (unsigned int *)addrlen); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + int s2 =__vita_acquire_descriptor(); + + if (s2 < 0) + { + errno = EMFILE; + return -1; + } + + __vita_fdmap[s2]->sce_uid = res; + __vita_fdmap[s2]->type = VITA_DESCRIPTOR_SOCKET; + return s2; +} +#endif + +#ifdef F_bind +int bind(int s, const struct sockaddr *addr, socklen_t addrlen) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetBind(fdmap->sce_uid, (SceNetSockaddr *)addr, (unsigned int)addrlen); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return 0; +} +#endif + +#ifdef F_connect +int connect(int s, const struct sockaddr *addr, socklen_t addrlen) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetConnect(fdmap->sce_uid, (SceNetSockaddr *)addr, (unsigned int)addrlen); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return 0; +} +#endif + +#ifdef F_getpeername +int getpeername(int s, struct sockaddr *addr, socklen_t *addrlen) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetGetpeername(fdmap->sce_uid, (SceNetSockaddr *)addr, (unsigned int *)addrlen); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return 0; +} +#endif + +#ifdef F_getsockname +int getsockname(int s, struct sockaddr *addr, socklen_t *addrlen) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetGetsockname(fdmap->sce_uid, (SceNetSockaddr *)addr, (unsigned int *)addrlen); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return 0; +} +#endif + +#ifdef F_getsockopt +int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetGetsockopt(fdmap->sce_uid, level, optname, optval, (unsigned int *)optlen); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return 0; +} +#endif + +#ifdef F_listen +int listen(int s, int backlog) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetListen(fdmap->sce_uid, backlog); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return 0; +} +#endif + +#ifdef F_recv +ssize_t recv(int s, void *buf, size_t len, int flags) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetRecv(fdmap->sce_uid, buf, len, flags); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return res; +} +#endif + +#ifdef F_recvfrom +ssize_t recvfrom(int s, void *buf, size_t len, int flags, + struct sockaddr *src_addr, socklen_t *addrlen) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetRecvfrom(fdmap->sce_uid, buf, len, flags, (SceNetSockaddr *)src_addr, (unsigned int *)addrlen); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return res; +} +#endif + +#ifdef F_recvmsg +ssize_t recvmsg(int s, struct msghdr *msg, int flags) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetRecvmsg(fdmap->sce_uid, (SceNetMsghdr *)msg, flags); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return res; +} +#endif + +#ifdef F_send +ssize_t send(int s, const void *buf, size_t len, int flags) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetSend(fdmap->sce_uid, buf, len, flags); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return res; + +} +#endif + +#ifdef F_sendto +ssize_t sendto(int s, const void *buf, + size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetSendto(fdmap->sce_uid, buf, len, flags, (SceNetSockaddr *)dest_addr, (unsigned int)addrlen); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return res; +} +#endif + +#ifdef F_sendmsg +ssize_t sendmsg(int s, const struct msghdr *msg, int flags) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetSendmsg(fdmap->sce_uid, (const SceNetMsghdr *)msg, flags); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return res; +} +#endif + +#ifdef F_setsockopt +int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetSetsockopt(fdmap->sce_uid, level, optname, optval, optlen); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return 0; +} +#endif + +#ifdef F_shutdown +int shutdown(int s, int how) +{ + DescriptorTranslation *fdmap = __vita_fd_grab(s); + + if (!fdmap) + { + errno = EBADF; + return -1; + } + + int res = sceNetShutdown(fdmap->sce_uid, how); + + __vita_fd_drop(fdmap); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + return 0; +} +#endif + +#ifdef F_socket +int socket(int domain, int type, int protocol) +{ + int res = sceNetSocket("", domain, type, protocol); + + if (res < 0) + { + errno = res & SCE_ERRNO_MASK; + return -1; + } + + int s = __vita_acquire_descriptor(); + + if (s < 0) + { + errno = EMFILE; + return -1; + } + + __vita_fdmap[s]->sce_uid = res; + __vita_fdmap[s]->type = VITA_DESCRIPTOR_SOCKET; + return s; +} + +int __vita_glue_socket_close(SceUID scefd) +{ + return sceNetSocketClose(scefd); +} + +ssize_t __vita_glue_socket_recv(SceUID scefd, void *buf, size_t len, int flags) +{ + return sceNetRecv(scefd, buf, len, flags); +} + +ssize_t __vita_glue_socket_send(SceUID scefd, const void *buf, size_t len, int flags) +{ + return sceNetSend(scefd, buf, len, flags); +} +#endif diff --git a/newlib/libc/sys/vita/sys/socket.h b/newlib/libc/sys/vita/sys/socket.h new file mode 100644 index 0000000000..5c0898f558 --- /dev/null +++ b/newlib/libc/sys/vita/sys/socket.h @@ -0,0 +1,274 @@ +/* $NetBSD: socket.h,v 1.77 2005/11/29 03:12:16 christos Exp $ */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * 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 project 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 PROJECT 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 PROJECT 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. + */ + +/* + * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 + * 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. + * + * @(#)socket.h 8.6 (Berkeley) 5/3/95 + */ + +#ifndef _SYS_SOCKET_H_ +#define _SYS_SOCKET_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +typedef uint8_t sa_family_t; +typedef uint32_t socklen_t; + +/* + * Socket types. + */ +#define SOCK_STREAM 1 /* stream socket */ +#define SOCK_DGRAM 2 /* datagram socket */ +#define SOCK_RAW 3 /* raw-protocol interface */ +#define SOCK_RDM 4 /* reliably-delivered message */ +#define SOCK_SEQPACKET 5 /* sequenced packet stream */ + +/* + * Option flags per-socket. + */ +#define SO_DEBUG 0x0001 /* turn on debugging info recording */ +#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ +#define SO_REUSEADDR 0x0004 /* allow local address reuse */ +#define SO_KEEPALIVE 0x0008 /* keep connections alive */ +#define SO_DONTROUTE 0x0010 /* just use interface addresses */ +#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ +#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ +#define SO_LINGER 0x0080 /* linger on close if data present */ +#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ +#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ +#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ + +/* + * Additional options, not kept in so_options. + */ +#define SO_SNDBUF 0x1001 /* send buffer size */ +#define SO_RCVBUF 0x1002 /* receive buffer size */ +#define SO_SNDLOWAT 0x1003 /* send low-water mark */ +#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ +#define SO_SNDTIMEO 0x1005 /* send timeout */ +#define SO_RCVTIMEO 0x1006 /* receive timeout */ +#define SO_ERROR 0x1007 /* get error status and clear */ +#define SO_TYPE 0x1008 /* get socket type */ +#define SO_OVERFLOWED 0x1009 /* datagrams: return packets dropped */ +#define SO_NONBLOCK 0x1009 /* non-blocking I/O */ + +/* + * Structure used for manipulating linger option. + */ +struct linger { + int l_onoff; /* option on/off */ + int l_linger; /* linger time in seconds */ +}; + +/* + * Level number for (get/set)sockopt() to apply to socket itself. + */ +#define SOL_SOCKET 0xffff /* options for socket level */ + +/* + * Address families. + */ +#define AF_UNSPEC 0 /* unspecified */ +#define AF_LOCAL 1 /* local to host (pipes, portals) */ +#define AF_UNIX AF_LOCAL /* backward compatibility */ +#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ +#define AF_IMPLINK 3 /* arpanet imp addresses */ +#define AF_PUP 4 /* pup protocols: e.g. BSP */ +#define AF_CHAOS 5 /* mit CHAOS protocols */ +#define AF_NS 6 /* XEROX NS protocols */ +#define AF_ISO 7 /* ISO protocols */ +#define AF_OSI AF_ISO +#define AF_ECMA 8 /* european computer manufacturers */ +#define AF_DATAKIT 9 /* datakit protocols */ +#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ +#define AF_SNA 11 /* IBM SNA */ +#define AF_DECnet 12 /* DECnet */ +#define AF_DLI 13 /* DEC Direct data link interface */ +#define AF_LAT 14 /* LAT */ +#define AF_HYLINK 15 /* NSC Hyperchannel */ +#define AF_APPLETALK 16 /* Apple Talk */ +#define AF_ROUTE 17 /* Internal Routing Protocol */ +#define AF_LINK 18 /* Link layer interface */ +#define AF_COIP 20 /* connection-oriented IP, aka ST II */ +#define AF_CNT 21 /* Computer Network Technology */ +#define AF_IPX 23 /* Novell Internet Protocol */ +#define AF_INET6 24 /* IP version 6 */ +#define AF_ISDN 26 /* Integrated Services Digital Network*/ +#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ +#define AF_NATM 27 /* native ATM access */ +#define AF_ARP 28 /* (rev.) addr. res. prot. (RFC 826) */ +#define AF_MAX 31 + +/* + * Structure used by kernel to store most + * addresses. + */ +struct sockaddr { + uint8_t sa_len; /* total length */ + sa_family_t sa_family; /* address family */ + char sa_data[14]; /* actually longer; address value */ +}; + +/* + * Protocol families, same as address families for now. + */ +#define PF_UNSPEC AF_UNSPEC +#define PF_LOCAL AF_LOCAL +#define PF_UNIX PF_LOCAL /* backward compatibility */ +#define PF_INET AF_INET +#define PF_IMPLINK AF_IMPLINK +#define PF_PUP AF_PUP +#define PF_CHAOS AF_CHAOS +#define PF_NS AF_NS +#define PF_ISO AF_ISO +#define PF_OSI AF_ISO +#define PF_ECMA AF_ECMA +#define PF_DATAKIT AF_DATAKIT +#define PF_CCITT AF_CCITT +#define PF_SNA AF_SNA +#define PF_DECnet AF_DECnet +#define PF_DLI AF_DLI +#define PF_LAT AF_LAT +#define PF_HYLINK AF_HYLINK +#define PF_APPLETALK AF_APPLETALK +#define PF_ROUTE AF_ROUTE +#define PF_LINK AF_LINK +#if defined(_NETBSD_SOURCE) +#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ +#endif +#define PF_COIP AF_COIP +#define PF_CNT AF_CNT +#define PF_INET6 AF_INET6 +#define PF_IPX AF_IPX /* same format as AF_NS */ +#if defined(_NETBSD_SOURCE) +#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ +#define PF_PIP pseudo_AF_PIP +#endif +#define PF_ISDN AF_ISDN /* same as E164 */ +#define PF_E164 AF_E164 +#define PF_NATM AF_NATM +#define PF_ARP AF_ARP +#if defined(_NETBSD_SOURCE) +#define PF_KEY pseudo_AF_KEY /* like PF_ROUTE, only for key mgmt */ +#endif + +#define PF_MAX AF_MAX + +#define MSG_OOB 0x1 /* process out-of-band data */ +#define MSG_PEEK 0x2 /* peek at incoming message */ +#define MSG_DONTROUTE 0x4 /* send without using routing tables */ +#define MSG_EOR 0x8 /* data completes record */ +#define MSG_TRUNC 0x10 /* data discarded before delivery */ +#define MSG_CTRUNC 0x20 /* control data lost before delivery */ +#define MSG_WAITALL 0x40 /* wait for full request or error */ +#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ +#define MSG_BCAST 0x100 /* this message was rcvd using link-level brdcst */ +#define MSG_MCAST 0x200 /* this message was rcvd using link-level mcast */ + +/* + * Types of socket shutdown(2). + */ +#define SHUT_RD 0 /* Disallow further receives. */ +#define SHUT_WR 1 /* Disallow further sends. */ +#define SHUT_RDWR 2 /* Disallow further sends/receives. */ + +struct iovec { + void *iov_base; /* Base address. */ + size_t iov_len; /* Length. */ +}; + +struct msghdr { + void *msg_name; /* optional address */ + socklen_t msg_namelen; /* size of address */ + struct iovec *msg_iov; /* scatter/gather array */ + int msg_iovlen; /* # elements in msg_iov */ + void *msg_control; /* ancillary data, see below */ + socklen_t msg_controllen; /* ancillary data buffer len */ + int msg_flags; /* flags on received message */ +}; + +/* BSD-compatible socket API. */ +int accept(int, struct sockaddr * __restrict, socklen_t * __restrict); +int bind(int, const struct sockaddr *, socklen_t); +int connect(int, const struct sockaddr *, socklen_t); +int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict); +int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict); +int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict); +int listen(int, int); +ssize_t recv(int, void *, size_t, int); +ssize_t recvfrom(int, void * __restrict, size_t, int, + struct sockaddr * __restrict, socklen_t * __restrict); +ssize_t recvmsg(int s, struct msghdr *msg, int flags); +ssize_t send(int, const void *, size_t, int); +ssize_t sendto(int, const void *, + size_t, int, const struct sockaddr *, socklen_t); +ssize_t sendmsg(int s, const struct msghdr *msg, int flags); +int setsockopt(int, int, int, const void *, socklen_t); +int shutdown(int, int); +int socket(int, int, int); + +#ifdef __cplusplus +} +#endif + +#endif /* !_SYS_SOCKET_H_ */ diff --git a/newlib/libc/sys/vita/syscalls.c b/newlib/libc/sys/vita/syscalls.c index 609053f963..73246c9caa 100755 --- a/newlib/libc/sys/vita/syscalls.c +++ b/newlib/libc/sys/vita/syscalls.c @@ -8,30 +8,56 @@ #include #include -#define SCE_ERRNO_MASK 0xFF -#define MAX_OPEN_FILES 1024 +#include +#include +#include +#include + +#include + +#include + +#include "vitadescriptor.h" +#include "vitaglue.h" -int fd_to_scefd[MAX_OPEN_FILES]; -char _newlib_fd_mutex[32] __attribute__ ((aligned (8))); + +// TODO: add to SDK +int sceKernelLibcGettimeofday(struct timeval *ptimeval, void *ptimezone); + +#define SCE_ERRNO_MASK 0xFF _ssize_t _write_r(struct _reent * reent, int fd, const void *buf, size_t nbytes) { int ret; - if ((unsigned)fd > MAX_OPEN_FILES) { - reent->_errno = EINVAL; + + DescriptorTranslation *fdmap = __vita_fd_grab(fd); + + if (!fdmap) { + reent->_errno = EBADF; return -1; } - if ((fd == STDIN_FILENO || fd == STDOUT_FILENO || fd == STDERR_FILENO) - && fd_to_scefd[fd] == 0) { - ret = nbytes; - } else { - ret = sceIoWrite(fd_to_scefd[fd], buf, nbytes); + + switch (fdmap->type) + { + case VITA_DESCRIPTOR_FILE: + case VITA_DESCRIPTOR_TTY: + ret = sceIoWrite(fdmap->sce_uid, buf, nbytes); + break; + case VITA_DESCRIPTOR_SOCKET: + if (__vita_glue_socket_send) + ret = __vita_glue_socket_send(fdmap->sce_uid, buf, nbytes, 0); + break; } + + __vita_fd_drop(fdmap); + if (ret < 0) { - reent->_errno = ret & SCE_ERRNO_MASK; + if (ret != -1) + reent->_errno = ret & SCE_ERRNO_MASK; return -1; } + reent->_errno = 0; return ret; } @@ -41,21 +67,21 @@ _exit(int rc) { _free_vita_newlib(); sceKernelExitProcess(rc); + while (1); } int _close_r(struct _reent *reent, int fd) { - if ((unsigned)fd > MAX_OPEN_FILES) { - reent->_errno = EINVAL; + int res = __vita_release_descriptor(fd); + + if (res < 0) + { + reent->_errno = -res; return -1; } - reent->_errno = sceIoClose(fd_to_scefd[fd]) & SCE_ERRNO_MASK; - if (reent->_errno == 0) { - sceKernelLockLwMutex(_newlib_fd_mutex, 1, 0); - fd_to_scefd[fd] = 0; - sceKernelUnlockLwMutex(_newlib_fd_mutex, 1); - } + + reent->_errno = 0; return 0; } @@ -97,10 +123,19 @@ _gettimeofday_r(struct _reent *reent, struct timeval *ptimeval, void *ptimezone) } int -_isatty_r(struct _reent *reent, int file) +_isatty_r(struct _reent *reent, int fd) { - reent->_errno = ENOSYS; - return 0; + DescriptorTranslation *fdmap = __vita_fd_grab(fd); + + if (!fdmap) { + reent->_errno = EBADF; + return 0; + } + + int istty = fdmap->type == VITA_DESCRIPTOR_TTY; + + __vita_fd_drop(fdmap); + return istty; } int @@ -134,87 +169,109 @@ _off_t _lseek_r(struct _reent *reent, int fd, _off_t ptr, int dir) { int ret; - if ((unsigned)fd > MAX_OPEN_FILES || fd == STDIN_FILENO || fd == STDOUT_FILENO || fd == STDERR_FILENO) { - reent->_errno = EINVAL; - return -1; + DescriptorTranslation *fdmap = __vita_fd_grab(fd); + + switch (fdmap->type) + { + case VITA_DESCRIPTOR_FILE: + ret = sceIoLseek32(fdmap->sce_uid, ptr, dir); + break; + case VITA_DESCRIPTOR_TTY: + case VITA_DESCRIPTOR_SOCKET: + ret = EBADF; + break; } - ret = sceIoLseek32(fd_to_scefd[fd], ptr, dir); + + __vita_fd_drop(fdmap); + if (ret < 0) { reent->_errno = ret & SCE_ERRNO_MASK; return -1; } + return ret; } int _fcntl2sony(int flags) { int out = 0; if (flags & O_RDWR) - out |= 3; + out |= SCE_O_RDWR; else if (flags & O_WRONLY) - out |= 2; + out |= SCE_O_WRONLY; else - out |= 1; + out |= SCE_O_RDONLY; if (flags & O_NONBLOCK) - out |= 4; + out |= SCE_O_NBLOCK; if (flags & O_APPEND) - out |= 0x100; + out |= SCE_O_APPEND; if (flags & O_CREAT) - out |= 0x200; + out |= SCE_O_CREAT; if (flags & O_TRUNC) - out |= 0x400; + out |= SCE_O_TRUNC; if (flags & O_EXCL) - out |= 0x800; + out |= SCE_O_EXCL; return out; } int _open_r(struct _reent *reent, const char *file, int flags, int mode) { - int ret, i, found = 0; + int ret; flags = _fcntl2sony(flags); + ret = sceIoOpen(file, flags, 0666); if (ret < 0) { reent->_errno = ret & SCE_ERRNO_MASK; return -1; } - sceKernelLockLwMutex(_newlib_fd_mutex, 1, 0); - // skip stdin, stdout, stderr - for (i = 3; i < MAX_OPEN_FILES; ++i) - if (fd_to_scefd[i] == 0) { - found = i; - break; - } - if (!found) { - sceKernelUnlockLwMutex(_newlib_fd_mutex, 1); + + int fd = __vita_acquire_descriptor(); + + if (fd < 0) + { sceIoClose(ret); reent->_errno = EMFILE; return -1; } - fd_to_scefd[found] = ret; - sceKernelUnlockLwMutex(_newlib_fd_mutex, 1); + + __vita_fdmap[fd]->sce_uid = ret; + __vita_fdmap[fd]->type = VITA_DESCRIPTOR_FILE; + reent->_errno = 0; - return found; + return fd; } _ssize_t _read_r(struct _reent *reent, int fd, void *ptr, size_t len) { int ret; - if ((unsigned)fd > MAX_OPEN_FILES) { - reent->_errno = EINVAL; - return 01; + DescriptorTranslation *fdmap = __vita_fd_grab(fd); + + if (!fdmap) { + reent->_errno = EBADF; + return -1; } - if (fd == STDIN_FILENO || fd == STDOUT_FILENO || fd == STDERR_FILENO) { - if (fd_to_scefd[fd] == 0) { - reent->_errno = 0; - return 0; - } + + switch (fdmap->type) + { + case VITA_DESCRIPTOR_TTY: + case VITA_DESCRIPTOR_FILE: + ret = sceIoRead(fdmap->sce_uid, ptr, len); + break; + case VITA_DESCRIPTOR_SOCKET: + if (__vita_glue_socket_recv) + ret = __vita_glue_socket_recv(fdmap->sce_uid, ptr, len, 0); + break; } - ret = sceIoRead(fd_to_scefd[fd], ptr, len); + + __vita_fd_drop(fdmap); + if (ret < 0) { - reent->_errno = ret & SCE_ERRNO_MASK; + if (ret != -1) + reent->_errno = ret & SCE_ERRNO_MASK; return -1; } + reent->_errno = 0; return ret; } @@ -263,42 +320,13 @@ _times_r(struct _reent *reent, struct tms *ptms) return result; } -struct SceDateTime { - unsigned short year; - unsigned short month; - unsigned short day; - unsigned short hour; - unsigned short minute; - unsigned short second; - unsigned int microsecond; -}; - -struct SceIoStat { - int st_mode; - unsigned int st_attr; - long long st_size; - struct SceDateTime st_ctime; - struct SceDateTime st_atime; - struct SceDateTime st_mtime; - unsigned st_private[6]; -}; - -enum { - SCE_DIR = 0x1000, - SCE_REG = 0x2000, - SCE_STATFMT = 0xf000 -}; - -#define SCE_ISREG(x) (((x) & SCE_STATFMT) == SCE_REG) -#define SCE_ISDIR(x) (((x) & SCE_STATFMT) == SCE_DIR) - static void scestat_to_stat(struct SceIoStat *in, struct stat *out) { memset(out, 0, sizeof(*out)); out->st_size = in->st_size; - if (SCE_ISREG(in->st_mode)) + if (SCE_S_ISREG(in->st_mode)) out->st_mode |= _IFREG; - if (SCE_ISDIR(in->st_mode)) + if (SCE_S_ISDIR(in->st_mode)) out->st_mode |= _IFDIR; sceRtcGetTime_t(&in->st_atime, &out->st_atime); sceRtcGetTime_t(&in->st_mtime, &out->st_mtime); @@ -310,14 +338,32 @@ _fstat_r(struct _reent *reent, int fd, struct stat *st) { struct SceIoStat stat = {0}; int ret; - if ((unsigned)fd > MAX_OPEN_FILES) { - reent->_errno = EINVAL; + + DescriptorTranslation *fdmap = __vita_fd_grab(fd); + + if (!fdmap) { + reent->_errno = EBADF; return -1; } - if ((ret = sceIoGetstatByFd(fd_to_scefd[fd], &stat)) < 0) { + + switch (fdmap->type) + { + case VITA_DESCRIPTOR_TTY: + case VITA_DESCRIPTOR_FILE: + ret = sceIoGetstatByFd(fdmap->sce_uid, &stat); + break; + case VITA_DESCRIPTOR_SOCKET: + ret = EBADF; + break; + } + + __vita_fd_drop(fdmap); + + if (ret < 0) { reent->_errno = ret & SCE_ERRNO_MASK; return -1; } + scestat_to_stat(&stat, st); reent->_errno = 0; return 0; @@ -335,4 +381,4 @@ _stat_r(struct _reent *reent, const char *path, struct stat *st) scestat_to_stat(&stat, st); reent->_errno = 0; return 0; -} \ No newline at end of file +} diff --git a/newlib/libc/sys/vita/vitadescriptor.h b/newlib/libc/sys/vita/vitadescriptor.h new file mode 100644 index 0000000000..365a2d9ca6 --- /dev/null +++ b/newlib/libc/sys/vita/vitadescriptor.h @@ -0,0 +1,60 @@ +/* + +Copyright (C) 2016, David "Davee" Morgan + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef _VITADESCRIPTOR_H_ +#define _VITADESCRIPTOR_H_ + + +#define MAX_OPEN_FILES 1024 + +typedef enum +{ + VITA_DESCRIPTOR_FILE, + VITA_DESCRIPTOR_SOCKET, + VITA_DESCRIPTOR_TTY +} DescriptorTypes; + +typedef struct +{ + int sce_uid; + DescriptorTypes type; + int ref_count; +} DescriptorTranslation; + +extern DescriptorTranslation *__vita_fdmap[]; + + +int __vita_acquire_descriptor(void); +int __vita_release_descriptor(int fd); +int __vita_descriptor_ref_count(int fd); +DescriptorTranslation *__vita_fd_grab(int fd); +int __vita_fd_drop(DescriptorTranslation *fdmap); + +static inline int is_fd_valid(int fd) +{ + return (fd > 0) && (fd < MAX_OPEN_FILES) && (__vita_fdmap[fd] != NULL); +} + +#endif // _VITADESCRIPTOR_H_ + diff --git a/newlib/libc/sys/vita/vitaglue.h b/newlib/libc/sys/vita/vitaglue.h new file mode 100644 index 0000000000..69ad9e11ac --- /dev/null +++ b/newlib/libc/sys/vita/vitaglue.h @@ -0,0 +1,34 @@ +/* + +Copyright (C) 2016, David "Davee" Morgan + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef _VITAGLUE_H_ +#define _VITAGLUE_H_ + +#include + +extern int __attribute__((weak)) __vita_glue_socket_close(SceUID scefd); +extern int __attribute__((weak)) __vita_glue_socket_recv(SceUID scefd, void *buf, size_t len, int flags); +extern int __attribute__((weak)) __vita_glue_socket_send(SceUID scefd, const void *buf, size_t len, int flags); + +#endif // _VITAGLUE_H_