renamed stio to mio in source files

This commit is contained in:
2018-12-12 13:15:54 +00:00
parent daf5143ba3
commit 14dc22fd0e
41 changed files with 14130 additions and 11491 deletions

View File

@ -1,9 +1,8 @@
# Makefile.in generated by automake 1.11.6 from Makefile.am.
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# Copyright (C) 1994-2014 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.
@ -15,23 +14,61 @@
@SET_MAKE@
VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
done;; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
test $$am__dry = yes; \
}
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@ -51,10 +88,6 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = .
DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/configure ac/ar-lib \
ac/compile ac/config.guess ac/config.sub ac/depcomp \
ac/install-sh ac/ltmain.sh ac/missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
@ -64,27 +97,36 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
$(am__configure_deps) $(am__DIST_COMMON)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/lib/stio-cfg.h
CONFIG_HEADER = $(top_builddir)/lib/mio-cfg.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
install-html-recursive install-info-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@ -92,11 +134,38 @@ am__can_run_installinfo = \
esac
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
distdir dist dist-all distcheck
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
cscope distdir dist dist-all distcheck
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \
$(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \
$(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \
$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \
ac/compile ac/config.guess ac/config.sub ac/install-sh \
ac/ltmain.sh ac/missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
@ -106,6 +175,7 @@ am__remove_distdir = \
&& rm -rf "$(distdir)" \
|| { sleep 5 && rm -rf "$(distdir)"; }; \
else :; fi
am__post_remove_distdir = $(am__remove_distdir)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
@ -133,6 +203,7 @@ am__relativize = \
reldir="$$dir2"
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
DIST_TARGETS = dist-gzip
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
@ -161,7 +232,6 @@ DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
@ -185,8 +255,23 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MIO_PROJECT_AUTHOR = @MIO_PROJECT_AUTHOR@
MIO_PROJECT_URL = @MIO_PROJECT_URL@
MIO_SIZEOF_CHAR = @MIO_SIZEOF_CHAR@
MIO_SIZEOF_DOUBLE = @MIO_SIZEOF_DOUBLE@
MIO_SIZEOF_FLOAT = @MIO_SIZEOF_FLOAT@
MIO_SIZEOF_INT = @MIO_SIZEOF_INT@
MIO_SIZEOF_LONG = @MIO_SIZEOF_LONG@
MIO_SIZEOF_LONG_DOUBLE = @MIO_SIZEOF_LONG_DOUBLE@
MIO_SIZEOF_LONG_LONG = @MIO_SIZEOF_LONG_LONG@
MIO_SIZEOF_OFF64_T = @MIO_SIZEOF_OFF64_T@
MIO_SIZEOF_OFF_T = @MIO_SIZEOF_OFF_T@
MIO_SIZEOF_SHORT = @MIO_SIZEOF_SHORT@
MIO_SIZEOF_VOID_P = @MIO_SIZEOF_VOID_P@
MIO_SIZEOF_WCHAR_T = @MIO_SIZEOF_WCHAR_T@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
@ -207,30 +292,13 @@ PACKAGE_VERSION_PATCH = @PACKAGE_VERSION_PATCH@
PATH_SEPARATOR = @PATH_SEPARATOR@
QUADMATH_LIBS = @QUADMATH_LIBS@
RANLIB = @RANLIB@
RM = @RM@
RMDIR = @RMDIR@
SED = @SED@
SENDFILE_LIBS = @SENDFILE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
SSL_LIBS = @SSL_LIBS@
STIO_PROJECT_AUTHOR = @STIO_PROJECT_AUTHOR@
STIO_PROJECT_URL = @STIO_PROJECT_URL@
STIO_SIZEOF_CHAR = @STIO_SIZEOF_CHAR@
STIO_SIZEOF_DOUBLE = @STIO_SIZEOF_DOUBLE@
STIO_SIZEOF_FLOAT = @STIO_SIZEOF_FLOAT@
STIO_SIZEOF_INT = @STIO_SIZEOF_INT@
STIO_SIZEOF_LONG = @STIO_SIZEOF_LONG@
STIO_SIZEOF_LONG_DOUBLE = @STIO_SIZEOF_LONG_DOUBLE@
STIO_SIZEOF_LONG_LONG = @STIO_SIZEOF_LONG_LONG@
STIO_SIZEOF_OFF64_T = @STIO_SIZEOF_OFF64_T@
STIO_SIZEOF_OFF_T = @STIO_SIZEOF_OFF_T@
STIO_SIZEOF_SHORT = @STIO_SIZEOF_SHORT@
STIO_SIZEOF_VOID_P = @STIO_SIZEOF_VOID_P@
STIO_SIZEOF_WCHAR_T = @STIO_SIZEOF_WCHAR_T@
STRIP = @STRIP@
TRUE = @TRUE@
UNICOWS_LIBS = @UNICOWS_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
@ -278,6 +346,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -309,7 +378,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
@ -339,22 +407,25 @@ distclean-libtool:
-rm -f libtool config.lt
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@fail= failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
@ -369,57 +440,12 @@ $(RECURSIVE_TARGETS):
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
$(RECURSIVE_CLEAN_TARGETS):
@fail= failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
@ -435,12 +461,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
@ -452,15 +473,11 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
@ -469,9 +486,31 @@ GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(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: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
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
distdir: $(DISTFILES)
$(am__remove_distdir)
@ -539,40 +578,42 @@ distdir: $(DISTFILES)
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
$(am__post_remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__remove_distdir)
$(am__post_remove_distdir)
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__remove_distdir)
dist-lzma: distdir
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
$(am__remove_distdir)
$(am__post_remove_distdir)
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__remove_distdir)
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
$(am__post_remove_distdir)
dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
$(am__post_remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
$(am__post_remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist dist-all:
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
$(am__post_remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
@ -583,8 +624,6 @@ distcheck: dist
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lzma*) \
lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
*.tar.lz*) \
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
*.tar.xz*) \
@ -596,18 +635,19 @@ distcheck: dist
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod u+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod -R a-w $(distdir)
chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
&& $(am__cd) $(distdir)/_build/sub \
&& ../../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
@ -630,7 +670,7 @@ distcheck: dist
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
&& cd "$$am__cwd" \
|| exit 1
$(am__remove_distdir)
$(am__post_remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
@ -765,14 +805,13 @@ ps-am:
uninstall-am:
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
install-am install-strip tags-recursive
.MAKE: $(am__recursive_targets) install-am install-strip
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am am--refresh check check-am clean clean-generic \
clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
dist-gzip dist-lzip dist-lzma dist-shar dist-tarZ dist-xz \
dist-zip distcheck distclean distclean-generic \
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-am clean clean-cscope clean-generic \
clean-libtool cscope cscopelist-am ctags ctags-am dist \
dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \
dist-xz dist-zip distcheck distclean distclean-generic \
distclean-libtool distclean-local distclean-tags \
distcleancheck distdir distuninstallcheck dvi dvi-am html \
html-am info info-am install install-am install-data \
@ -782,8 +821,10 @@ uninstall-am:
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am
.PRECIOUS: Makefile
distclean-local:

View File

@ -4,7 +4,7 @@
me=ar-lib
scriptversion=2012-03-01.08; # UTC
# Copyright (C) 2010, 2012 Free Software Foundation, Inc.
# Copyright (C) 2010-2014 Free Software Foundation, Inc.
# Written by Peter Rosin <peda@lysator.liu.se>.
#
# This program is free software; you can redistribute it and/or modify

View File

@ -3,7 +3,7 @@
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify

488
mio/ac/config.guess vendored
View File

@ -1,14 +1,12 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012 Free Software Foundation, Inc.
# Copyright 1992-2016 Free Software Foundation, Inc.
timestamp='2012-02-10'
timestamp='2016-10-02'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@ -22,19 +20,17 @@ timestamp='2012-02-10'
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Per Bothner. Please send patches (context
# diff format) to <config-patches@gnu.org> and include a ChangeLog
# entry.
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
#
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
#
# Please send patches to <config-patches@gnu.org>.
me=`echo "$0" | sed -e 's,.*/,,'`
@ -54,9 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Copyright 1992-2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -138,6 +132,27 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "${UNAME_SYSTEM}" in
Linux|GNU|GNU/*)
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
LIBC=gnu
eval $set_cc_for_build
cat <<-EOF > $dummy.c
#include <features.h>
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
LIBC=dietlibc
#else
LIBC=gnu
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
;;
esac
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
@ -153,19 +168,29 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
/usr/sbin/$sysctl 2>/dev/null || echo unknown)`
UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
/sbin/$sysctl 2>/dev/null || \
/usr/sbin/$sysctl 2>/dev/null || \
echo unknown)`
case "${UNAME_MACHINE_ARCH}" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
earmv*)
arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
machine=${arch}${endian}-unknown
;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
# to ELF recently (or will in the future) and ABI.
case "${UNAME_MACHINE_ARCH}" in
earm*)
os=netbsdelf
;;
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
@ -182,6 +207,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
os=netbsd
;;
esac
# Determine ABI tags.
case "${UNAME_MACHINE_ARCH}" in
earm*)
expr='s/^earmv[0-9]/-eabi/;s/eb$//'
abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
;;
esac
# The OS release
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
@ -192,18 +224,26 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
release='-gnu'
;;
*)
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
echo "${machine}-${os}${release}${abi}"
exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
exit ;;
*:LibertyBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE}
exit ;;
*:ekkoBSD:*:*)
echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
exit ;;
@ -216,6 +256,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:MirBSD:*:*)
echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
exit ;;
*:Sortix:*:*)
echo ${UNAME_MACHINE}-unknown-sortix
exit ;;
alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
@ -232,42 +275,42 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
case "$ALPHA_CPU_TYPE" in
"EV4 (21064)")
UNAME_MACHINE="alpha" ;;
UNAME_MACHINE=alpha ;;
"EV4.5 (21064)")
UNAME_MACHINE="alpha" ;;
UNAME_MACHINE=alpha ;;
"LCA4 (21066/21068)")
UNAME_MACHINE="alpha" ;;
UNAME_MACHINE=alpha ;;
"EV5 (21164)")
UNAME_MACHINE="alphaev5" ;;
UNAME_MACHINE=alphaev5 ;;
"EV5.6 (21164A)")
UNAME_MACHINE="alphaev56" ;;
UNAME_MACHINE=alphaev56 ;;
"EV5.6 (21164PC)")
UNAME_MACHINE="alphapca56" ;;
UNAME_MACHINE=alphapca56 ;;
"EV5.7 (21164PC)")
UNAME_MACHINE="alphapca57" ;;
UNAME_MACHINE=alphapca57 ;;
"EV6 (21264)")
UNAME_MACHINE="alphaev6" ;;
UNAME_MACHINE=alphaev6 ;;
"EV6.7 (21264A)")
UNAME_MACHINE="alphaev67" ;;
UNAME_MACHINE=alphaev67 ;;
"EV6.8CB (21264C)")
UNAME_MACHINE="alphaev68" ;;
UNAME_MACHINE=alphaev68 ;;
"EV6.8AL (21264B)")
UNAME_MACHINE="alphaev68" ;;
UNAME_MACHINE=alphaev68 ;;
"EV6.8CX (21264D)")
UNAME_MACHINE="alphaev68" ;;
UNAME_MACHINE=alphaev68 ;;
"EV6.9A (21264/EV69A)")
UNAME_MACHINE="alphaev69" ;;
UNAME_MACHINE=alphaev69 ;;
"EV7 (21364)")
UNAME_MACHINE="alphaev7" ;;
UNAME_MACHINE=alphaev7 ;;
"EV7.9 (21364A)")
UNAME_MACHINE="alphaev79" ;;
UNAME_MACHINE=alphaev79 ;;
esac
# A Pn.n version is a patched version.
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
exitcode=$?
trap '' 0
@ -302,7 +345,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit ;;
arm:riscos:*:*|arm:RISCOS:*:*)
arm*:riscos:*:*|arm*:RISCOS:*:*)
echo arm-unknown-riscos
exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
@ -340,16 +383,16 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
eval $set_cc_for_build
SUN_ARCH="i386"
SUN_ARCH=i386
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
SUN_ARCH="x86_64"
SUN_ARCH=x86_64
fi
fi
echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
@ -374,7 +417,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
exit ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
echo m68k-sun-sunos${UNAME_RELEASE}
@ -560,8 +603,9 @@ EOF
else
IBM_ARCH=powerpc
fi
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
if [ -x /usr/bin/lslpp ] ; then
IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
@ -598,13 +642,13 @@ EOF
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
32) HP_ARCH=hppa2.0n ;;
64) HP_ARCH=hppa2.0w ;;
'') HP_ARCH=hppa2.0 ;; # HP-UX 10.20
esac ;;
esac
fi
@ -643,11 +687,11 @@ EOF
exit (0);
}
EOF
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
(CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if [ ${HP_ARCH} = "hppa2.0w" ]
if [ ${HP_ARCH} = hppa2.0w ]
then
eval $set_cc_for_build
@ -660,12 +704,12 @@ EOF
# $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
# => hppa64-hp-hpux11.23
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
grep -q __LP64__
then
HP_ARCH="hppa2.0w"
HP_ARCH=hppa2.0w
else
HP_ARCH="hppa64"
HP_ARCH=hppa64
fi
fi
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
@ -770,14 +814,14 @@ EOF
echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
@ -801,10 +845,13 @@ EOF
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit ;;
*:MINGW64*:*)
echo ${UNAME_MACHINE}-pc-mingw64
exit ;;
*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
i*:MSYS*:*)
*:MSYS*:*)
echo ${UNAME_MACHINE}-pc-msys
exit ;;
i*:windows32*:*)
@ -852,21 +899,21 @@ EOF
exit ;;
*:GNU:*:*)
# the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
aarch64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@ -879,59 +926,60 @@ EOF
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arc:Linux:*:* | arceb:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
cris:Linux:*:*)
echo ${UNAME_MACHINE}-axis-linux-gnu
echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
crisv32:Linux:*:*)
echo ${UNAME_MACHINE}-axis-linux-gnu
echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
e2k:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
frv:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
hexagon:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:Linux:*:*)
LIBC=gnu
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
echo ${UNAME_MACHINE}-pc-linux-${LIBC}
exit ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
k1om:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m32r*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build
@ -950,54 +998,69 @@ EOF
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
;;
or32:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
mips64el:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
openrisc*:Linux:*:*)
echo or1k-unknown-linux-${LIBC}
exit ;;
or32:Linux:*:* | or1k*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
echo sparc-unknown-linux-${LIBC}
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
echo hppa64-unknown-linux-${LIBC}
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) echo hppa1.1-unknown-linux-gnu ;;
PA8*) echo hppa2.0-unknown-linux-gnu ;;
*) echo hppa-unknown-linux-gnu ;;
PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
*) echo hppa-unknown-linux-${LIBC} ;;
esac
exit ;;
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu
echo powerpc64-unknown-linux-${LIBC}
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
echo powerpc-unknown-linux-${LIBC}
exit ;;
ppc64le:Linux:*:*)
echo powerpc64le-unknown-linux-${LIBC}
exit ;;
ppcle:Linux:*:*)
echo powerpcle-unknown-linux-${LIBC}
exit ;;
riscv32:Linux:*:* | riscv64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
exit ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
tile*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-gnu
echo ${UNAME_MACHINE}-dec-linux-${LIBC}
exit ;;
x86_64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-pc-linux-${LIBC}
exit ;;
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@ -1073,7 +1136,7 @@ EOF
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i586.
# Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configury will decide that
# prints for the "djgpp" host, or else GDB configure will decide that
# this is a cross-build.
echo i586-pc-msdosdjgpp
exit ;;
@ -1201,6 +1264,9 @@ EOF
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
x86_64:Haiku:*:*)
echo x86_64-unknown-haiku
exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;
@ -1219,6 +1285,9 @@ EOF
SX-8R:SUPER-UX:*:*)
echo sx8r-nec-superux${UNAME_RELEASE}
exit ;;
SX-ACE:SUPER-UX:*:*)
echo sxace-nec-superux${UNAME_RELEASE}
exit ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit ;;
@ -1227,24 +1296,36 @@ EOF
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in
i386)
eval $set_cc_for_build
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
fi
if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
UNAME_PROCESSOR="x86_64"
fi
fi ;;
unknown) UNAME_PROCESSOR=powerpc ;;
case $UNAME_PROCESSOR in
i386) UNAME_PROCESSOR=x86_64 ;;
powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac
fi
fi
elif test "$UNAME_PROCESSOR" = i386 ; then
# Avoid executing cc on OS X 10.9, as it ships with a stub
# that puts up a graphical alert prompting to install
# developer tools. Any system running Mac OS X 10.7 or
# later (Darwin 11 and later) is required to have a 64-bit
# processor. This is not true of the ARM version of Darwin
# that Apple uses in portable devices.
UNAME_PROCESSOR=x86_64
fi
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
if test "$UNAME_PROCESSOR" = x86; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
@ -1256,7 +1337,7 @@ EOF
NEO-?:NONSTOP_KERNEL:*:*)
echo neo-tandem-nsk${UNAME_RELEASE}
exit ;;
NSE-?:NONSTOP_KERNEL:*:*)
NSE-*:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
NSR-?:NONSTOP_KERNEL:*:*)
@ -1275,7 +1356,7 @@ EOF
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
if test "$cputype" = "386"; then
if test "$cputype" = 386; then
UNAME_MACHINE=i386
else
UNAME_MACHINE="$cputype"
@ -1317,7 +1398,7 @@ EOF
echo i386-pc-xenix
exit ;;
i*86:skyos:*:*)
echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'`
exit ;;
i*86:rdos:*:*)
echo ${UNAME_MACHINE}-pc-rdos
@ -1328,174 +1409,25 @@ EOF
x86_64:VMkernel:*:*)
echo ${UNAME_MACHINE}-unknown-esx
exit ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
eval $set_cc_for_build
cat >$dummy.c <<EOF
#ifdef _SEQUENT_
# include <sys/types.h>
# include <sys/utsname.h>
#endif
main ()
{
#if defined (sony)
#if defined (MIPSEB)
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
I don't know.... */
printf ("mips-sony-bsd\n"); exit (0);
#else
#include <sys/param.h>
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
#else
""
#endif
); exit (0);
#endif
#endif
#if defined (__arm) && defined (__acorn) && defined (__unix)
printf ("arm-acorn-riscix\n"); exit (0);
#endif
#if defined (hp300) && !defined (hpux)
printf ("m68k-hp-bsd\n"); exit (0);
#endif
#if defined (NeXT)
#if !defined (__ARCHITECTURE__)
#define __ARCHITECTURE__ "m68k"
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
if (version < 4)
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
else
printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
exit (0);
#endif
#if defined (MULTIMAX) || defined (n16)
#if defined (UMAXV)
printf ("ns32k-encore-sysv\n"); exit (0);
#else
#if defined (CMU)
printf ("ns32k-encore-mach\n"); exit (0);
#else
printf ("ns32k-encore-bsd\n"); exit (0);
#endif
#endif
#endif
#if defined (__386BSD__)
printf ("i386-pc-bsd\n"); exit (0);
#endif
#if defined (sequent)
#if defined (i386)
printf ("i386-sequent-dynix\n"); exit (0);
#endif
#if defined (ns32000)
printf ("ns32k-sequent-dynix\n"); exit (0);
#endif
#endif
#if defined (_SEQUENT_)
struct utsname un;
uname(&un);
if (strncmp(un.version, "V2", 2) == 0) {
printf ("i386-sequent-ptx2\n"); exit (0);
}
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
printf ("i386-sequent-ptx1\n"); exit (0);
}
printf ("i386-sequent-ptx\n"); exit (0);
#endif
#if defined (vax)
# if !defined (ultrix)
# include <sys/param.h>
# if defined (BSD)
# if BSD == 43
printf ("vax-dec-bsd4.3\n"); exit (0);
# else
# if BSD == 199006
printf ("vax-dec-bsd4.3reno\n"); exit (0);
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# endif
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# else
printf ("vax-dec-ultrix\n"); exit (0);
# endif
#endif
#if defined (alliant) && defined (i860)
printf ("i860-alliant-bsd\n"); exit (0);
#endif
exit (1);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
{ echo "$SYSTEM_NAME"; exit; }
# Apollos put the system type in the environment.
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
# Convex versions that predate uname can use getsysinfo(1)
if [ -x /usr/convex/getsysinfo ]
then
case `getsysinfo -f cpu_type` in
c1*)
echo c1-convex-bsd
exit ;;
c2*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
c34*)
echo c34-convex-bsd
exit ;;
c38*)
echo c38-convex-bsd
exit ;;
c4*)
echo c4-convex-bsd
amd64:Isilon\ OneFS:*:*)
echo x86_64-unknown-onefs
exit ;;
esac
fi
cat >&2 <<EOF
$0: unable to guess system type
This script, last modified $timestamp, has failed to recognize
the operating system you are using. It is advised that you
download the most up to date version of the config scripts from
This script (version $timestamp), has failed to recognize the
operating system you are using. If your script is old, overwrite
config.guess and config.sub with the latest versions from:
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
and
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
If the version you run ($0) is already up to date, please
send the following data and any information you think might be
pertinent to <config-patches@gnu.org> in order to provide the needed
information to handle your system.
If $0 has already been updated, send the following data and any
information you think might be pertinent to config-patches@gnu.org to
provide the necessary information to handle your system.
config.guess timestamp = $timestamp

163
mio/ac/config.sub vendored
View File

@ -1,24 +1,18 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012 Free Software Foundation, Inc.
# Copyright 1992-2016 Free Software Foundation, Inc.
timestamp='2012-04-18'
timestamp='2016-11-04'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
@ -26,11 +20,12 @@ timestamp='2012-04-18'
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted GNU ChangeLog entry.
# Please send patches to <config-patches@gnu.org>.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
@ -38,7 +33,7 @@ timestamp='2012-04-18'
# Otherwise, we print the canonical config type on stdout and succeed.
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
@ -58,8 +53,7 @@ timestamp='2012-04-18'
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION] CPU-MFR-OPSYS
$0 [OPTION] ALIAS
Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
Canonicalize a configuration name.
@ -73,9 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Copyright 1992-2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -123,9 +115,9 @@ esac
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
kopensolaris*-gnu* | cloudabi*-eabi* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
@ -156,7 +148,7 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray | -microblaze)
-apple | -axis | -knuth | -cray | -microblaze*)
os=
basic_machine=$1
;;
@ -259,21 +251,25 @@ case $basic_machine in
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
| arc | arceb \
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| ba \
| be32 | be64 \
| bfin \
| c4x | clipper \
| c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx \
| epiphany \
| fido | fr30 | frv \
| e2k | epiphany \
| fido | fr30 | frv | ft32 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| k1om \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep | metag \
| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
@ -287,26 +283,30 @@ case $basic_machine in
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa32r6 | mipsisa32r6el \
| mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64r6 | mipsisa64r6el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipsr5900 | mipsr5900el \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| moxie \
| mt \
| msp430 \
| nds32 | nds32le | nds32be \
| nios | nios2 \
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
| open8 \
| or32 \
| open8 | or1k | or1knd | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pru \
| pyramid \
| riscv32 | riscv64 \
| rl78 | rx \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
@ -314,6 +314,7 @@ case $basic_machine in
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| ubicom32 \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| visium \
| we32k \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
@ -328,7 +329,10 @@ case $basic_machine in
c6x)
basic_machine=tic6x-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
leon|leon[3-9])
basic_machine=sparc-$basic_machine
;;
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
@ -370,26 +374,29 @@ case $basic_machine in
| aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| ba-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
| clipper-* | craynv-* | cydra-* \
| c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| e2k-* | elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| k1om-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| microblaze-* | microblazeel-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
@ -403,28 +410,34 @@ case $basic_machine in
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa32r6-* | mipsisa32r6el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64r6-* | mipsisa64r6el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipsr5900-* | mipsr5900el-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nds32-* | nds32le-* | nds32be-* \
| nios-* | nios2-* \
| nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| or1k*-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pru-* \
| pyramid-* \
| riscv32-* | riscv64-* \
| rl78-* | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
| tahoe-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile*-* \
@ -432,6 +445,7 @@ case $basic_machine in
| ubicom32-* \
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
| visium-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
@ -508,6 +522,9 @@ case $basic_machine in
basic_machine=i386-pc
os=-aros
;;
asmjs)
basic_machine=asmjs-unknown
;;
aux)
basic_machine=m68k-apple
os=-aux
@ -628,6 +645,14 @@ case $basic_machine in
basic_machine=m68k-bull
os=-sysv3
;;
e500v[12])
basic_machine=powerpc-unknown
os=$os"spe"
;;
e500v[12]-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
os=$os"spe"
;;
ebmon29k)
basic_machine=a29k-amd
os=-ebmon
@ -769,6 +794,9 @@ case $basic_machine in
basic_machine=m68k-isi
os=-sysv
;;
leon-*|leon[3-9]-*)
basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
@ -788,11 +816,15 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
microblaze)
microblaze*)
basic_machine=microblaze-xilinx
;;
mingw64)
basic_machine=x86_64-pc
os=-mingw64
;;
mingw32)
basic_machine=i386-pc
basic_machine=i686-pc
os=-mingw32
;;
mingw32ce)
@ -820,6 +852,10 @@ case $basic_machine in
basic_machine=powerpc-unknown
os=-morphos
;;
moxiebox)
basic_machine=moxie-unknown
os=-moxiebox
;;
msdos)
basic_machine=i386-pc
os=-msdos
@ -828,7 +864,7 @@ case $basic_machine in
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
msys)
basic_machine=i386-pc
basic_machine=i686-pc
os=-msys
;;
mvs)
@ -996,7 +1032,7 @@ case $basic_machine in
ppc-* | ppcbe-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
ppcle | powerpclittle)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
@ -1006,7 +1042,7 @@ case $basic_machine in
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
ppc64le | powerpc64little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
@ -1019,7 +1055,11 @@ case $basic_machine in
basic_machine=i586-unknown
os=-pw32
;;
rdos)
rdos | rdos64)
basic_machine=x86_64-pc
os=-rdos
;;
rdos32)
basic_machine=i386-pc
os=-rdos
;;
@ -1346,29 +1386,30 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* \
| -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -aos* | -aros* | -cloudabi* | -sortix* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -openbsd* | -solidbsd* \
| -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
| -onefs* | -tirtos* | -phoenix* | -fuchsia*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@ -1492,9 +1533,6 @@ case $os in
-aros*)
os=-aros
;;
-kaos*)
os=-kaos
;;
-zvmoe)
os=-zvmoe
;;
@ -1503,6 +1541,8 @@ case $os in
;;
-nacl*)
;;
-ios)
;;
-none)
;;
*)
@ -1543,6 +1583,9 @@ case $basic_machine in
c4x-* | tic4x-*)
os=-coff
;;
c8051-*)
os=-elf
;;
hexagon-*)
os=-elf
;;

View File

@ -1,10 +1,9 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2012-03-27.16; # UTC
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
# 2011, 2012 Free Software Foundation, Inc.
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -57,11 +56,65 @@ EOF
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
@ -75,6 +128,9 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
@ -109,7 +165,7 @@ if test "$depmode" = msvc7msys; then
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
@ -134,8 +190,7 @@ gcc3)
done
"$@"
stat=$?
if test $stat -eq 0; then :
else
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
@ -143,13 +198,17 @@ gcc3)
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
@ -157,15 +216,14 @@ gcc)
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
@ -174,14 +232,14 @@ gcc)
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' "$nl" < "$tmpdepfile" |
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
@ -200,8 +258,7 @@ sgi)
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
@ -209,7 +266,6 @@ sgi)
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
@ -217,19 +273,15 @@ sgi)
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr "$nl" ' ' >> "$depfile"
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
@ -247,9 +299,8 @@ aix)
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
@ -262,9 +313,7 @@ aix)
"$@" -M
fi
stat=$?
if test $stat -eq 0; then :
else
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
@ -273,65 +322,113 @@ aix)
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependent.h'.
# Do two passes, one to just change these to
# '$object: dependent.h' and one to simply 'dependent.h:'.
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
# However on
# $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
# tcc 0.9.26 (FIXME still under development at the moment of writing)
# will emit a similar output, but also prepend the continuation lines
# with horizontal tabulation characters.
"$@" -MD -MF "$tmpdepfile"
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
if test $stat -eq 0; then :
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form 'foo.o: dependent.h',
# or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# '$object: dependent.h' and one to simply 'dependent.h:'.
sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \
< "$tmpdepfile" > "$depfile"
sed '
s/[ '"$tab"'][ '"$tab"']*/ /g
s/^ *//
s/ *\\*$//
s/^[^:]*: *//
/^$/d
/:$/d
s/$/ :/
' < "$tmpdepfile" >> "$depfile"
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
@ -342,9 +439,8 @@ hp2)
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
@ -355,8 +451,7 @@ hp2)
"$@" +Maked
fi
stat=$?
if test $stat -eq 0; then :
else
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
@ -366,7 +461,7 @@ hp2)
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
@ -375,7 +470,7 @@ hp2)
p
}' "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
@ -386,55 +481,40 @@ tru64)
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mechanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in $dir.libs/$base.o.d and
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
@ -446,8 +526,7 @@ msvc7)
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test "$stat" = 0; then :
else
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
@ -473,6 +552,7 @@ $ {
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
@ -524,13 +604,14 @@ dashmstdout)
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' "$nl" < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
@ -583,10 +664,12 @@ makedepend)
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
@ -622,10 +705,10 @@ cpp)
esac
done
"$@" -E |
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"

View File

@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-01-19.21; # UTC
scriptversion=2014-09-12.12; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@ -35,25 +35,21 @@ scriptversion=2011-01-19.21; # UTC
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" "" $nl"
IFS=" $tab$nl"
# set DOITPROG to echo to test this script
# Set DOITPROG to "echo" to test this script.
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
@ -68,17 +64,6 @@ mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
@ -97,7 +82,7 @@ dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@ -143,8 +128,7 @@ while test $# -ne 0; do
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
@ -155,14 +139,16 @@ while test $# -ne 0; do
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for `test' and other utilities.
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
@ -177,6 +163,16 @@ while test $# -ne 0; do
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
@ -190,7 +186,7 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
fi
shift # arg
dst_arg=$arg
# Protect names problematic for `test' and other utilities.
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
@ -202,11 +198,20 @@ if test $# -eq 0; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
@ -240,7 +245,7 @@ fi
for src
do
# Protect names problematic for `test' and other utilities.
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
@ -269,7 +274,7 @@ do
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
@ -277,33 +282,7 @@ do
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
@ -345,34 +324,41 @@ do
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
# $RANDOM is not portable (e.g. dash); use it when possible to
# lower collision chance
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
# As "mkdir -p" follows symlinks and we work in /tmp possibly; so
# create the $tmpdir first (and fail if unsuccessful) to make sure
# that nobody tries to guess the $tmpdir name.
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writeable bit of parent directory when it shouldn't.
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac;;
@ -396,14 +382,12 @@ do
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set -f
set fnord $dstdir
shift
$posix_glob set +f
set +f
IFS=$oIFS
prefixes=
@ -474,13 +458,10 @@ do
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,10 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2012-01-06.13; # UTC
scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -26,68 +25,40 @@ scriptversion=2012-01-06.13; # UTC
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
run=:
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case $1 in
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Try to run requested program, and just exit if it succeeds.
run=
# Back-compat with the calling convention used by older automake.
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
autom4te touch the output file, or create a stub one
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
\`g' are ignored when checking the name.
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
@ -99,228 +70,141 @@ Send bug reports to <bug-automake@gnu.org>."
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
esac
# normalize program name to check for.
program=`echo "$1" | sed '
# Run the given program, remember its exit status.
"$@"; st=$?
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=http://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program). This is about non-GNU programs, so use $1 not
# $program.
case $1 in
lex*|yacc*)
# Not GNU programs, they don't have --version.
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case $program in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case $f in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if test $# -ne 1; then
eval LASTARG=\${$#}
case $LASTARG in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.h
fi
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
esac
fi
if test ! -f y.tab.h; then
echo >y.tab.h
fi
if test ! -f y.tab.c; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex*|flex*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if test $# -ne 1; then
eval LASTARG=\${$#}
case $LASTARG in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" lex.yy.c
fi
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
esac
fi
if test ! -f lex.yy.c; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit $?
fi
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;;
makeinfo*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '
/^@setfilename/{
s/.* \([^ ]*\) *$/\1/
p
q
}' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
test -f $file || exit 1
touch $file
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
exit 0
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)

537
mio/aclocal.m4 vendored

File diff suppressed because it is too large Load Diff

3974
mio/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
dnl AC_PREREQ([2.67])
dnl Make sure you change the version information
dnl in include/stio/conf_*.h whenever you change the version
dnl in include/mio/conf_*.h whenever you change the version
dnl here. Those files don't depend on autoconf, thus requiring
dnl manual change.
AC_INIT([stio],[0.1.0],[Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)],[],[http://code.abiyo.net/@stio])
AC_INIT([mio],[0.1.0],[Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)],[],[http://code.abiyo.net/@mio])
AC_CONFIG_HEADER([lib/stio-cfg.h])
AC_CONFIG_HEADER([lib/mio-cfg.h])
AC_CONFIG_AUX_DIR([ac])
AC_CONFIG_MACRO_DIR([m4])
@ -14,7 +14,7 @@ dnl use CC and CPP for compilation tests with .c test programs.
AC_LANG(C)
dnl initialize automake
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AM_INIT_AUTOMAKE([-Wall -Werror subdir-objects foreign])
AM_PROG_AR
dnl enable silent rules if automake supports them.
@ -37,15 +37,7 @@ dnl determine some key programs
AC_PROG_INSTALL
AC_PROG_EGREP
AC_PROG_LN_S
dnl check other tools
AC_CHECK_TOOL(RM, rm)
AC_CHECK_TOOL(RMDIR, rmdir)
AC_CHECK_TOOL(TRUE, true)
AC_CHECK_TOOL(ECHO, echo)
dnl avoid "'/bin/rm: cannot remove `libtoolT': No such file or directory"
RM="$RM -f"
AC_PROG_SED
dnl initialize libtool
LT_INIT
@ -69,8 +61,8 @@ then
fi
dnl indicate the existence of config.h
CFLAGS="$CFLAGS -DSTIO_HAVE_CFG_H"
CXXFLAGS="$CXXFLAGS -DSTIO_HAVE_CFG_H"
CFLAGS="$CFLAGS -DMIO_HAVE_CFG_H"
CXXFLAGS="$CXXFLAGS -DMIO_HAVE_CFG_H"
dnl make visible the 64-bit interface to the file system
CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
@ -81,12 +73,19 @@ case "$host" in
*-*-mingw*|*-*-cygwin*)
#CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0400"
platform_win32=yes
platform_macosx=no
;;
*-*-darwin*)
platform_win32=no
platform_macosx=yes
;;
*)
platform_win32=no
platform_macosx=no
;;
esac
AM_CONDITIONAL(WIN32, test "x${platform_win32}" = "xyes" )
AM_CONDITIONAL(MACOSX, test "x${platform_macosx}" = "xyes" )
dnl check the math library (check if -lm is needed)
LT_LIB_M
@ -422,7 +421,7 @@ then
if test ${ac_cv_sizeof_socklen_t} -gt 0
then
AX_CHECK_SIGN([socklen_t],
[ AC_DEFINE(STIO_SOCKLEN_T_IS_SIGNED, 1, [Define if socklen_t is signed]) ],
[ AC_DEFINE(MIO_SOCKLEN_T_IS_SIGNED, 1, [Define if socklen_t is signed]) ],
[ AS_ECHO_N("") ],
[#include <winsock2.h>
#include <ws2tcpip.h>])
@ -451,7 +450,7 @@ else
if test ${ac_cv_sizeof_socklen_t} -gt 0
then
AX_CHECK_SIGN([socklen_t],
[ AC_DEFINE(STIO_SOCKLEN_T_IS_SIGNED, 1, [Define if socklen_t is signed]) ],
[ AC_DEFINE(MIO_SOCKLEN_T_IS_SIGNED, 1, [Define if socklen_t is signed]) ],
[ AS_ECHO_N("") ],
[#include <sys/socket.h>])
fi
@ -467,7 +466,7 @@ dnl so i've added this check to determine if the compiler has
dnl proper support for __int128_t.
dnl
dnl Changing ac_cv_sizeof___int128_t here doesn't corret SIZEOF___INT128_T
dnl since it's already generated. It only affects STIO_SIZEOF___INT128_T below.
dnl since it's already generated. It only affects MIO_SIZEOF___INT128_T below.
if test ${ac_cv_sizeof___int128_t} -gt 0
then
AC_MSG_CHECKING([__int128_t with %])
@ -559,72 +558,72 @@ fi
AC_SUBST(QUADMATH_LIBS)
AC_DEFINE_UNQUOTED(STIO_SIZEOF_CHAR, ${ac_cv_sizeof_char}, [sizeof(char)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_SHORT, ${ac_cv_sizeof_short}, [sizeof(short)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_INT, ${ac_cv_sizeof_int}, [sizeof(int)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_LONG, ${ac_cv_sizeof_long}, [sizeof(long)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_LONG_LONG, ${ac_cv_sizeof_long_long}, [sizeof(long long)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF___INT8, ${ac_cv_sizeof___int8}, [sizeof(__int8)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF___INT16, ${ac_cv_sizeof___int16}, [sizeof(__int16)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF___INT32, ${ac_cv_sizeof___int32}, [sizeof(__int32)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF___INT64, ${ac_cv_sizeof___int64}, [sizeof(__int64)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF___INT128, ${ac_cv_sizeof___int128}, [sizeof(__int128)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF___INT128_T, ${ac_cv_sizeof___int128_t}, [sizeof(__int128_t)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_VOID_P, ${ac_cv_sizeof_void_p}, [sizeof(void*)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_FLOAT, ${ac_cv_sizeof_float}, [sizeof(float)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_DOUBLE, ${ac_cv_sizeof_double}, [sizeof(double)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_LONG_DOUBLE, ${ac_cv_sizeof_long_double}, [sizeof(long double)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF___FLOAT128, ${ac_cv_sizeof___float128}, [sizeof(__float128)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_CHAR, ${ac_cv_sizeof_char}, [sizeof(char)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_SHORT, ${ac_cv_sizeof_short}, [sizeof(short)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_INT, ${ac_cv_sizeof_int}, [sizeof(int)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_LONG, ${ac_cv_sizeof_long}, [sizeof(long)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_LONG_LONG, ${ac_cv_sizeof_long_long}, [sizeof(long long)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF___INT8, ${ac_cv_sizeof___int8}, [sizeof(__int8)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF___INT16, ${ac_cv_sizeof___int16}, [sizeof(__int16)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF___INT32, ${ac_cv_sizeof___int32}, [sizeof(__int32)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF___INT64, ${ac_cv_sizeof___int64}, [sizeof(__int64)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF___INT128, ${ac_cv_sizeof___int128}, [sizeof(__int128)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF___INT128_T, ${ac_cv_sizeof___int128_t}, [sizeof(__int128_t)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_VOID_P, ${ac_cv_sizeof_void_p}, [sizeof(void*)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_FLOAT, ${ac_cv_sizeof_float}, [sizeof(float)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_DOUBLE, ${ac_cv_sizeof_double}, [sizeof(double)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_LONG_DOUBLE, ${ac_cv_sizeof_long_double}, [sizeof(long double)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF___FLOAT128, ${ac_cv_sizeof___float128}, [sizeof(__float128)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_WCHAR_T, ${ac_cv_sizeof_wchar_t}, [sizeof(wchar_t)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_OFF_T, ${ac_cv_sizeof_off_t}, [sizeof(off_t)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_OFF64_T, ${ac_cv_sizeof_off64_t}, [sizeof(off64_t)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_WCHAR_T, ${ac_cv_sizeof_wchar_t}, [sizeof(wchar_t)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_OFF_T, ${ac_cv_sizeof_off_t}, [sizeof(off_t)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_OFF64_T, ${ac_cv_sizeof_off64_t}, [sizeof(off64_t)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_MBSTATE_T, ${ac_cv_sizeof_mbstate_t}, [sizeof(mbstate_t)])
AC_DEFINE_UNQUOTED(STIO_MBLEN_MAX, ${ax_cv_numvalof_MB_LEN_MAX}, [MB_LEN_MAX])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_MBSTATE_T, ${ac_cv_sizeof_mbstate_t}, [sizeof(mbstate_t)])
AC_DEFINE_UNQUOTED(MIO_MBLEN_MAX, ${ax_cv_numvalof_MB_LEN_MAX}, [MB_LEN_MAX])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_STRUCT_SOCKADDR_IN, ${ac_cv_sizeof_struct_sockaddr_in}, [sizeof(struct sockaddr_in)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_STRUCT_SOCKADDR_IN6, ${ac_cv_sizeof_struct_sockaddr_in6}, [sizeof(struct sockaddr_in6)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_STRUCT_SOCKADDR_UN, ${ac_cv_sizeof_struct_sockaddr_un}, [sizeof(struct sockaddr_un)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_STRUCT_SOCKADDR_LL, ${ac_cv_sizeof_struct_sockaddr_ll}, [sizeof(struct sockaddr_ll)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_STRUCT_SOCKADDR_DL, ${ac_cv_sizeof_struct_sockaddr_dl}, [sizeof(struct sockaddr_dl)])
AC_DEFINE_UNQUOTED(STIO_SIZEOF_SOCKLEN_T, ${ac_cv_sizeof_socklen_t}, [sizeof(socklen_t)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_STRUCT_SOCKADDR_IN, ${ac_cv_sizeof_struct_sockaddr_in}, [sizeof(struct sockaddr_in)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_STRUCT_SOCKADDR_IN6, ${ac_cv_sizeof_struct_sockaddr_in6}, [sizeof(struct sockaddr_in6)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_STRUCT_SOCKADDR_UN, ${ac_cv_sizeof_struct_sockaddr_un}, [sizeof(struct sockaddr_un)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_STRUCT_SOCKADDR_LL, ${ac_cv_sizeof_struct_sockaddr_ll}, [sizeof(struct sockaddr_ll)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_STRUCT_SOCKADDR_DL, ${ac_cv_sizeof_struct_sockaddr_dl}, [sizeof(struct sockaddr_dl)])
AC_DEFINE_UNQUOTED(MIO_SIZEOF_SOCKLEN_T, ${ac_cv_sizeof_socklen_t}, [sizeof(socklen_t)])
stio_package_version_major="`echo ${PACKAGE_VERSION} | cut -d. -f1`"
stio_package_version_minor="`echo ${PACKAGE_VERSION} | cut -d. -f2`"
stio_package_version_patch="`echo ${PACKAGE_VERSION} | cut -d. -f3`"
AC_SUBST(PACKAGE_VERSION_MAJOR, ${stio_package_version_major})
AC_SUBST(PACKAGE_VERSION_MINOR, ${stio_package_version_minor})
AC_SUBST(PACKAGE_VERSION_PATCH, ${stio_package_version_patch})
mio_package_version_major="`echo ${PACKAGE_VERSION} | cut -d. -f1`"
mio_package_version_minor="`echo ${PACKAGE_VERSION} | cut -d. -f2`"
mio_package_version_patch="`echo ${PACKAGE_VERSION} | cut -d. -f3`"
AC_SUBST(PACKAGE_VERSION_MAJOR, ${mio_package_version_major})
AC_SUBST(PACKAGE_VERSION_MINOR, ${mio_package_version_minor})
AC_SUBST(PACKAGE_VERSION_PATCH, ${mio_package_version_patch})
AC_DEFINE_UNQUOTED(STIO_PACKAGE_VERSION, "${PACKAGE_VERSION}", [Package version])
dnl AC_DEFINE_UNQUOTED(STIO_PACKAGE_VERSION_MAJOR, $(echo ${VERSION} | cut -d. -f1), [Major version number])
dnl AC_DEFINE_UNQUOTED(STIO_PACKAGE_VERSION_MINOR, $(echo ${VERSION} | cut -d. -f2), [Minor version number])
dnl AC_DEFINE_UNQUOTED(STIO_PACKAGE_VERSION_PATCH, $(echo ${VERSION} | cut -d. -f3), [Patch level])
AC_DEFINE_UNQUOTED(STIO_PACKAGE_VERSION_MAJOR, ${stio_package_version_major}, [Major version number])
AC_DEFINE_UNQUOTED(STIO_PACKAGE_VERSION_MINOR, ${stio_package_version_minor}, [Minor version number])
AC_DEFINE_UNQUOTED(STIO_PACKAGE_VERSION_PATCH, ${stio_package_version_patch}, [Patch level])
AC_DEFINE_UNQUOTED(MIO_PACKAGE_VERSION, "${PACKAGE_VERSION}", [Package version])
dnl AC_DEFINE_UNQUOTED(MIO_PACKAGE_VERSION_MAJOR, $(echo ${VERSION} | cut -d. -f1), [Major version number])
dnl AC_DEFINE_UNQUOTED(MIO_PACKAGE_VERSION_MINOR, $(echo ${VERSION} | cut -d. -f2), [Minor version number])
dnl AC_DEFINE_UNQUOTED(MIO_PACKAGE_VERSION_PATCH, $(echo ${VERSION} | cut -d. -f3), [Patch level])
AC_DEFINE_UNQUOTED(MIO_PACKAGE_VERSION_MAJOR, ${mio_package_version_major}, [Major version number])
AC_DEFINE_UNQUOTED(MIO_PACKAGE_VERSION_MINOR, ${mio_package_version_minor}, [Minor version number])
AC_DEFINE_UNQUOTED(MIO_PACKAGE_VERSION_PATCH, ${mio_package_version_patch}, [Patch level])
AC_DEFINE_UNQUOTED(STIO_PACKAGE_AUTHOR,"${PACKAGE_BUGREPORT}", [Author])
AC_DEFINE_UNQUOTED(STIO_PACKAGE_NAME,"${PACKAGE_NAME}", [package name])
AC_DEFINE_UNQUOTED(STIO_PACKAGE_URL, "${PACKAGE_URL}", [Project URL])
AC_DEFINE_UNQUOTED(MIO_PACKAGE_AUTHOR,"${PACKAGE_BUGREPORT}", [Author])
AC_DEFINE_UNQUOTED(MIO_PACKAGE_NAME,"${PACKAGE_NAME}", [package name])
AC_DEFINE_UNQUOTED(MIO_PACKAGE_URL, "${PACKAGE_URL}", [Project URL])
AC_C_BIGENDIAN(
[AC_DEFINE([STIO_ENDIAN_BIG],[],[Big Endian])],
[AC_DEFINE([STIO_ENDIAN_LITTLE],[],[Little Endian])],
[AC_DEFINE([STIO_ENDIAN_UNKNOWN],[],[Unknown Endian])])
[AC_DEFINE([MIO_ENDIAN_BIG],[],[Big Endian])],
[AC_DEFINE([MIO_ENDIAN_LITTLE],[],[Little Endian])],
[AC_DEFINE([MIO_ENDIAN_UNKNOWN],[],[Unknown Endian])])
AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],[build the library in the debug mode (default. no)])],
enable_debug_is=$enableval,enable_debug_is=no)
if test "$enable_debug_is" = "yes"
then
[CFLAGS="$CFLAGS -g -D_DEBUG -UNDEBUG -DSTIO_BUILD_DEBUG -U_FORTIFY_SOURCE"]
[CXXFLAGS="$CXXFLAGS -g -D_DEBUG -UNDEBUG -DSTIO_BUILD_DEBUG -U_FORTIFY_SOURCE"]
[CFLAGS="$CFLAGS -g -D_DEBUG -UNDEBUG -DMIO_BUILD_DEBUG -U_FORTIFY_SOURCE"]
[CXXFLAGS="$CXXFLAGS -g -D_DEBUG -UNDEBUG -DMIO_BUILD_DEBUG -U_FORTIFY_SOURCE"]
AC_SUBST(BUILD_MODE, "debug")
else
[CFLAGS="$CFLAGS -DNDEBUG -U_DEBUG -DSTIO_BUILD_RELEASE -U_FORTIFY_SOURCE"]
[CXXFLAGS="$CXXFLAGS -DNDEBUG -U_DEBUG -DSTIO_BUILD_RELEASE -U_FORTIFY_SOURCE"]
[CFLAGS="$CFLAGS -DNDEBUG -U_DEBUG -DMIO_BUILD_RELEASE -U_FORTIFY_SOURCE"]
[CXXFLAGS="$CXXFLAGS -DNDEBUG -U_DEBUG -DMIO_BUILD_RELEASE -U_FORTIFY_SOURCE"]
AC_SUBST(BUILD_MODE, "release")
fi
@ -641,21 +640,21 @@ test "${ax_cv_cxx_have_std_namespace}" = "yes" || enable_cxx_is="no"
AM_CONDITIONAL(ENABLE_CXX, test "${enable_cxx_is}" = "yes" )
AC_SUBST(STIO_SIZEOF_WCHAR_T, $ac_cv_sizeof_wchar_t)
AC_SUBST(STIO_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
AC_SUBST(STIO_SIZEOF_LONG, $ac_cv_sizeof_long)
AC_SUBST(STIO_SIZEOF_INT, $ac_cv_sizeof_int)
AC_SUBST(STIO_SIZEOF_SHORT, $ac_cv_sizeof_short)
AC_SUBST(STIO_SIZEOF_CHAR, $ac_cv_sizeof_char)
AC_SUBST(STIO_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
AC_SUBST(STIO_SIZEOF_FLOAT, $ac_cv_sizeof_float)
AC_SUBST(STIO_SIZEOF_DOUBLE, $ac_cv_sizeof_double)
AC_SUBST(STIO_SIZEOF_LONG_DOUBLE, $ac_cv_sizeof_long_double)
AC_SUBST(STIO_SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
AC_SUBST(STIO_SIZEOF_OFF64_T, $ac_cv_sizeof_off64_t)
AC_SUBST(MIO_SIZEOF_WCHAR_T, $ac_cv_sizeof_wchar_t)
AC_SUBST(MIO_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
AC_SUBST(MIO_SIZEOF_LONG, $ac_cv_sizeof_long)
AC_SUBST(MIO_SIZEOF_INT, $ac_cv_sizeof_int)
AC_SUBST(MIO_SIZEOF_SHORT, $ac_cv_sizeof_short)
AC_SUBST(MIO_SIZEOF_CHAR, $ac_cv_sizeof_char)
AC_SUBST(MIO_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
AC_SUBST(MIO_SIZEOF_FLOAT, $ac_cv_sizeof_float)
AC_SUBST(MIO_SIZEOF_DOUBLE, $ac_cv_sizeof_double)
AC_SUBST(MIO_SIZEOF_LONG_DOUBLE, $ac_cv_sizeof_long_double)
AC_SUBST(MIO_SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
AC_SUBST(MIO_SIZEOF_OFF64_T, $ac_cv_sizeof_off64_t)
AC_SUBST(STIO_PROJECT_AUTHOR, "${PACKAGE_BUGREPORT}")
AC_SUBST(STIO_PROJECT_URL, "${PACKAGE_URL}")
AC_SUBST(MIO_PROJECT_AUTHOR, "${PACKAGE_BUGREPORT}")
AC_SUBST(MIO_PROJECT_URL, "${PACKAGE_URL}")
AC_CONFIG_FILES([
Makefile

View File

@ -1,2 +1,2 @@
all:
cc -g -I. -Wall -o stio main.c stio.c stio-tcp.c stio-udp.c stio-sck.c
cc -g -I. -Wall -o mio main.c mio.c mio-tcp.c mio-udp.c mio-sck.c

View File

@ -20,39 +20,39 @@ LIBADD_LIB_COMMON = $(LIBM) $(LIBLTDL)
#pkgbindir = $(bindir)
include_HEADERS = \
stio-cfg.h \
stio-cmn.h \
stio-pro.h \
stio-sck.h \
stio.h
mio-cfg.h \
mio-cmn.h \
mio-pro.h \
mio-sck.h \
mio.h
lib_LTLIBRARIES = libstio.la
libstio_la_SOURCES = \
stio-prv.h \
stio.c \
stio-pro.c \
stio-sck.c \
stio-tim.c \
stio-tmr.c \
stio-utl.c
libstio_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
libstio_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
libstio_la_LIBADD = $(LIBADD_LIB_COMMON) $(SSL_LIBS)
lib_LTLIBRARIES = libmio.la
libmio_la_SOURCES = \
mio-prv.h \
mio.c \
mio-pro.c \
mio-sck.c \
mio-tim.c \
mio-tmr.c \
mio-utl.c
libmio_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
libmio_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
libmio_la_LIBADD = $(LIBADD_LIB_COMMON) $(SSL_LIBS)
bin_PROGRAMS = stio
stio_SOURCES = main.c
stio_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
stio_LDFLAGS = $(LDFLAGS_LIB_COMMON)
stio_LDADD = $(LIBADD_LIB_COMMON) -lstio
bin_PROGRAMS = mio
mio_SOURCES = main.c
mio_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
mio_LDFLAGS = $(LDFLAGS_LIB_COMMON)
mio_LDADD = $(LIBADD_LIB_COMMON) -lmio
install-data-hook:
@echo "#ifndef _STIO_CFG_H_" > "$(DESTDIR)$(includedir)/stio-cfg.h"
@echo "#define _STIO_CFG_H_" >> "$(DESTDIR)$(includedir)/stio-cfg.h"
@$(EGREP) "#define[ ]+STIO_" "$(abs_builddir)/stio-cfg.h" >> "$(DESTDIR)$(includedir)/stio-cfg.h"
@echo "#endif" >> "$(DESTDIR)$(includedir)/stio-cfg.h"
@$(RM) "$(DESTDIR)$(includedir)/stio-cfg.h.in"
@$(SED) 's|/\*#define STIO_HAVE_CFG_H\*/|#define STIO_HAVE_CFG_H|' "$(srcdir)/stio-cmn.h" > "$(DESTDIR)$(includedir)/stio-cmn.h"
@echo "#ifndef _MIO_CFG_H_" > "$(DESTDIR)$(includedir)/mio-cfg.h"
@echo "#define _MIO_CFG_H_" >> "$(DESTDIR)$(includedir)/mio-cfg.h"
@$(EGREP) "#define[ ]+MIO_" "$(abs_builddir)/mio-cfg.h" >> "$(DESTDIR)$(includedir)/mio-cfg.h"
@echo "#endif" >> "$(DESTDIR)$(includedir)/mio-cfg.h"
@$(RM) "$(DESTDIR)$(includedir)/mio-cfg.h.in"
@$(SED) 's|/\*#define MIO_HAVE_CFG_H\*/|#define MIO_HAVE_CFG_H|' "$(srcdir)/mio-cmn.h" > "$(DESTDIR)$(includedir)/mio-cmn.h"
uninstall-hook:
@$(RM) "$(DESTDIR)$(includedir)/stio-cfg.h"
@$(RM) "$(DESTDIR)$(includedir)/mio-cfg.h"

View File

@ -1,9 +1,8 @@
# Makefile.in generated by automake 1.11.6 from Makefile.am.
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# Copyright (C) 1994-2014 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.
@ -18,23 +17,61 @@
VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
done;; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
test $$am__dry = yes; \
}
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@ -53,10 +90,8 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = stio$(EXEEXT)
bin_PROGRAMS = mio$(EXEEXT)
subdir = lib
DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/stio-cfg.h.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
@ -66,8 +101,10 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(include_HEADERS) \
$(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = stio-cfg.h
CONFIG_HEADER = mio-cfg.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@ -102,24 +139,37 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
libstio_la_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
am_libstio_la_OBJECTS = libstio_la-stio.lo libstio_la-stio-pro.lo \
libstio_la-stio-sck.lo libstio_la-stio-tim.lo \
libstio_la-stio-tmr.lo libstio_la-stio-utl.lo
libstio_la_OBJECTS = $(am_libstio_la_OBJECTS)
libmio_la_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
am_libmio_la_OBJECTS = libmio_la-mio.lo libmio_la-mio-pro.lo \
libmio_la-mio-sck.lo libmio_la-mio-tim.lo libmio_la-mio-tmr.lo \
libmio_la-mio-utl.lo
libmio_la_OBJECTS = $(am_libmio_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
libstio_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
am__v_lt_1 =
libmio_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libstio_la_LDFLAGS) $(LDFLAGS) -o $@
$(libmio_la_LDFLAGS) $(LDFLAGS) -o $@
PROGRAMS = $(bin_PROGRAMS)
am_stio_OBJECTS = stio-main.$(OBJEXT)
stio_OBJECTS = $(am_stio_OBJECTS)
stio_DEPENDENCIES = $(am__DEPENDENCIES_2)
stio_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
am_mio_OBJECTS = mio-main.$(OBJEXT)
mio_OBJECTS = $(am_mio_OBJECTS)
mio_DEPENDENCIES = $(am__DEPENDENCIES_2)
mio_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(stio_LDFLAGS) $(LDFLAGS) -o $@
$(mio_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES =
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
am__depfiles_maybe = depfiles
@ -133,9 +183,7 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@ -143,19 +191,37 @@ LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(libstio_la_SOURCES) $(stio_SOURCES)
DIST_SOURCES = $(libstio_la_SOURCES) $(stio_SOURCES)
am__v_CCLD_1 =
SOURCES = $(libmio_la_SOURCES) $(mio_SOURCES)
DIST_SOURCES = $(libmio_la_SOURCES) $(mio_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
HEADERS = $(include_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)mio-cfg.h.in
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/mio-cfg.h.in \
$(top_srcdir)/ac/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
@ -181,7 +247,6 @@ DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
@ -205,8 +270,23 @@ LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MIO_PROJECT_AUTHOR = @MIO_PROJECT_AUTHOR@
MIO_PROJECT_URL = @MIO_PROJECT_URL@
MIO_SIZEOF_CHAR = @MIO_SIZEOF_CHAR@
MIO_SIZEOF_DOUBLE = @MIO_SIZEOF_DOUBLE@
MIO_SIZEOF_FLOAT = @MIO_SIZEOF_FLOAT@
MIO_SIZEOF_INT = @MIO_SIZEOF_INT@
MIO_SIZEOF_LONG = @MIO_SIZEOF_LONG@
MIO_SIZEOF_LONG_DOUBLE = @MIO_SIZEOF_LONG_DOUBLE@
MIO_SIZEOF_LONG_LONG = @MIO_SIZEOF_LONG_LONG@
MIO_SIZEOF_OFF64_T = @MIO_SIZEOF_OFF64_T@
MIO_SIZEOF_OFF_T = @MIO_SIZEOF_OFF_T@
MIO_SIZEOF_SHORT = @MIO_SIZEOF_SHORT@
MIO_SIZEOF_VOID_P = @MIO_SIZEOF_VOID_P@
MIO_SIZEOF_WCHAR_T = @MIO_SIZEOF_WCHAR_T@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
@ -227,30 +307,13 @@ PACKAGE_VERSION_PATCH = @PACKAGE_VERSION_PATCH@
PATH_SEPARATOR = @PATH_SEPARATOR@
QUADMATH_LIBS = @QUADMATH_LIBS@
RANLIB = @RANLIB@
RM = @RM@
RMDIR = @RMDIR@
SED = @SED@
SENDFILE_LIBS = @SENDFILE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
SSL_LIBS = @SSL_LIBS@
STIO_PROJECT_AUTHOR = @STIO_PROJECT_AUTHOR@
STIO_PROJECT_URL = @STIO_PROJECT_URL@
STIO_SIZEOF_CHAR = @STIO_SIZEOF_CHAR@
STIO_SIZEOF_DOUBLE = @STIO_SIZEOF_DOUBLE@
STIO_SIZEOF_FLOAT = @STIO_SIZEOF_FLOAT@
STIO_SIZEOF_INT = @STIO_SIZEOF_INT@
STIO_SIZEOF_LONG = @STIO_SIZEOF_LONG@
STIO_SIZEOF_LONG_DOUBLE = @STIO_SIZEOF_LONG_DOUBLE@
STIO_SIZEOF_LONG_LONG = @STIO_SIZEOF_LONG_LONG@
STIO_SIZEOF_OFF64_T = @STIO_SIZEOF_OFF64_T@
STIO_SIZEOF_OFF_T = @STIO_SIZEOF_OFF_T@
STIO_SIZEOF_SHORT = @STIO_SIZEOF_SHORT@
STIO_SIZEOF_VOID_P = @STIO_SIZEOF_VOID_P@
STIO_SIZEOF_WCHAR_T = @STIO_SIZEOF_WCHAR_T@
STRIP = @STRIP@
TRUE = @TRUE@
UNICOWS_LIBS = @UNICOWS_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
@ -298,6 +361,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -325,30 +389,30 @@ LIBADD_LIB_COMMON = $(LIBM) $(LIBLTDL)
#pkglibdir = $(libdir)
#pkgbindir = $(bindir)
include_HEADERS = \
stio-cfg.h \
stio-cmn.h \
stio-pro.h \
stio-sck.h \
stio.h
mio-cfg.h \
mio-cmn.h \
mio-pro.h \
mio-sck.h \
mio.h
lib_LTLIBRARIES = libstio.la
libstio_la_SOURCES = \
stio-prv.h \
stio.c \
stio-pro.c \
stio-sck.c \
stio-tim.c \
stio-tmr.c \
stio-utl.c
lib_LTLIBRARIES = libmio.la
libmio_la_SOURCES = \
mio-prv.h \
mio.c \
mio-pro.c \
mio-sck.c \
mio-tim.c \
mio-tmr.c \
mio-utl.c
libstio_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
libstio_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
libstio_la_LIBADD = $(LIBADD_LIB_COMMON) $(SSL_LIBS)
stio_SOURCES = main.c
stio_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
stio_LDFLAGS = $(LDFLAGS_LIB_COMMON)
stio_LDADD = $(LIBADD_LIB_COMMON) -lstio
all: stio-cfg.h
libmio_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
libmio_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
libmio_la_LIBADD = $(LIBADD_LIB_COMMON) $(SSL_LIBS)
mio_SOURCES = main.c
mio_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
mio_LDFLAGS = $(LDFLAGS_LIB_COMMON)
mio_LDADD = $(LIBADD_LIB_COMMON) -lmio
all: mio-cfg.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
@ -365,7 +429,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign lib/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
@ -384,20 +447,21 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
stio-cfg.h: stamp-h1
@if test ! -f $@; then rm -f stamp-h1; else :; fi
@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
mio-cfg.h: stamp-h1
@test -f $@ || rm -f stamp-h1
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
stamp-h1: $(srcdir)/stio-cfg.h.in $(top_builddir)/config.status
stamp-h1: $(srcdir)/mio-cfg.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status lib/stio-cfg.h
$(srcdir)/stio-cfg.h.in: $(am__configure_deps)
cd $(top_builddir) && $(SHELL) ./config.status lib/mio-cfg.h
$(srcdir)/mio-cfg.h.in: $(am__configure_deps)
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f stio-cfg.h stamp-h1
-rm -f mio-cfg.h stamp-h1
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
@ -424,14 +488,17 @@ uninstall-libLTLIBRARIES:
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libstio.la: $(libstio_la_OBJECTS) $(libstio_la_DEPENDENCIES) $(EXTRA_libstio_la_DEPENDENCIES)
$(AM_V_CCLD)$(libstio_la_LINK) -rpath $(libdir) $(libstio_la_OBJECTS) $(libstio_la_LIBADD) $(LIBS)
@list='$(lib_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
libmio.la: $(libmio_la_OBJECTS) $(libmio_la_DEPENDENCIES) $(EXTRA_libmio_la_DEPENDENCIES)
$(AM_V_CCLD)$(libmio_la_LINK) -rpath $(libdir) $(libmio_la_OBJECTS) $(libmio_la_LIBADD) $(LIBS)
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
@ -441,10 +508,12 @@ install-binPROGRAMS: $(bin_PROGRAMS)
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p || test -f $$p1; \
then echo "$$p"; echo "$$p"; else :; fi; \
while read p p1; do if test -f $$p \
|| test -f $$p1 \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
@ -465,7 +534,8 @@ uninstall-binPROGRAMS:
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' `; \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(bindir)" && rm -f $$files
@ -478,9 +548,10 @@ clean-binPROGRAMS:
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
stio$(EXEEXT): $(stio_OBJECTS) $(stio_DEPENDENCIES) $(EXTRA_stio_DEPENDENCIES)
@rm -f stio$(EXEEXT)
$(AM_V_CCLD)$(stio_LINK) $(stio_OBJECTS) $(stio_LDADD) $(LIBS)
mio$(EXEEXT): $(mio_OBJECTS) $(mio_DEPENDENCIES) $(EXTRA_mio_DEPENDENCIES)
@rm -f mio$(EXEEXT)
$(AM_V_CCLD)$(mio_LINK) $(mio_OBJECTS) $(mio_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@ -488,90 +559,93 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstio_la-stio-pro.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstio_la-stio-sck.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstio_la-stio-tim.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstio_la-stio-tmr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstio_la-stio-utl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstio_la-stio.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stio-main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmio_la-mio-pro.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmio_la-mio-sck.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmio_la-mio-tim.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmio_la-mio-tmr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmio_la-mio-utl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmio_la-mio.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mio-main.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
libstio_la-stio.lo: stio.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstio_la-stio.lo -MD -MP -MF $(DEPDIR)/libstio_la-stio.Tpo -c -o libstio_la-stio.lo `test -f 'stio.c' || echo '$(srcdir)/'`stio.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstio_la-stio.Tpo $(DEPDIR)/libstio_la-stio.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stio.c' object='libstio_la-stio.lo' libtool=yes @AMDEPBACKSLASH@
libmio_la-mio.lo: mio.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmio_la-mio.lo -MD -MP -MF $(DEPDIR)/libmio_la-mio.Tpo -c -o libmio_la-mio.lo `test -f 'mio.c' || echo '$(srcdir)/'`mio.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmio_la-mio.Tpo $(DEPDIR)/libmio_la-mio.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mio.c' object='libmio_la-mio.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstio_la-stio.lo `test -f 'stio.c' || echo '$(srcdir)/'`stio.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmio_la-mio.lo `test -f 'mio.c' || echo '$(srcdir)/'`mio.c
libstio_la-stio-pro.lo: stio-pro.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstio_la-stio-pro.lo -MD -MP -MF $(DEPDIR)/libstio_la-stio-pro.Tpo -c -o libstio_la-stio-pro.lo `test -f 'stio-pro.c' || echo '$(srcdir)/'`stio-pro.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstio_la-stio-pro.Tpo $(DEPDIR)/libstio_la-stio-pro.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stio-pro.c' object='libstio_la-stio-pro.lo' libtool=yes @AMDEPBACKSLASH@
libmio_la-mio-pro.lo: mio-pro.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmio_la-mio-pro.lo -MD -MP -MF $(DEPDIR)/libmio_la-mio-pro.Tpo -c -o libmio_la-mio-pro.lo `test -f 'mio-pro.c' || echo '$(srcdir)/'`mio-pro.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmio_la-mio-pro.Tpo $(DEPDIR)/libmio_la-mio-pro.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mio-pro.c' object='libmio_la-mio-pro.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstio_la-stio-pro.lo `test -f 'stio-pro.c' || echo '$(srcdir)/'`stio-pro.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmio_la-mio-pro.lo `test -f 'mio-pro.c' || echo '$(srcdir)/'`mio-pro.c
libstio_la-stio-sck.lo: stio-sck.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstio_la-stio-sck.lo -MD -MP -MF $(DEPDIR)/libstio_la-stio-sck.Tpo -c -o libstio_la-stio-sck.lo `test -f 'stio-sck.c' || echo '$(srcdir)/'`stio-sck.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstio_la-stio-sck.Tpo $(DEPDIR)/libstio_la-stio-sck.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stio-sck.c' object='libstio_la-stio-sck.lo' libtool=yes @AMDEPBACKSLASH@
libmio_la-mio-sck.lo: mio-sck.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmio_la-mio-sck.lo -MD -MP -MF $(DEPDIR)/libmio_la-mio-sck.Tpo -c -o libmio_la-mio-sck.lo `test -f 'mio-sck.c' || echo '$(srcdir)/'`mio-sck.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmio_la-mio-sck.Tpo $(DEPDIR)/libmio_la-mio-sck.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mio-sck.c' object='libmio_la-mio-sck.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstio_la-stio-sck.lo `test -f 'stio-sck.c' || echo '$(srcdir)/'`stio-sck.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmio_la-mio-sck.lo `test -f 'mio-sck.c' || echo '$(srcdir)/'`mio-sck.c
libstio_la-stio-tim.lo: stio-tim.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstio_la-stio-tim.lo -MD -MP -MF $(DEPDIR)/libstio_la-stio-tim.Tpo -c -o libstio_la-stio-tim.lo `test -f 'stio-tim.c' || echo '$(srcdir)/'`stio-tim.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstio_la-stio-tim.Tpo $(DEPDIR)/libstio_la-stio-tim.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stio-tim.c' object='libstio_la-stio-tim.lo' libtool=yes @AMDEPBACKSLASH@
libmio_la-mio-tim.lo: mio-tim.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmio_la-mio-tim.lo -MD -MP -MF $(DEPDIR)/libmio_la-mio-tim.Tpo -c -o libmio_la-mio-tim.lo `test -f 'mio-tim.c' || echo '$(srcdir)/'`mio-tim.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmio_la-mio-tim.Tpo $(DEPDIR)/libmio_la-mio-tim.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mio-tim.c' object='libmio_la-mio-tim.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstio_la-stio-tim.lo `test -f 'stio-tim.c' || echo '$(srcdir)/'`stio-tim.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmio_la-mio-tim.lo `test -f 'mio-tim.c' || echo '$(srcdir)/'`mio-tim.c
libstio_la-stio-tmr.lo: stio-tmr.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstio_la-stio-tmr.lo -MD -MP -MF $(DEPDIR)/libstio_la-stio-tmr.Tpo -c -o libstio_la-stio-tmr.lo `test -f 'stio-tmr.c' || echo '$(srcdir)/'`stio-tmr.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstio_la-stio-tmr.Tpo $(DEPDIR)/libstio_la-stio-tmr.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stio-tmr.c' object='libstio_la-stio-tmr.lo' libtool=yes @AMDEPBACKSLASH@
libmio_la-mio-tmr.lo: mio-tmr.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmio_la-mio-tmr.lo -MD -MP -MF $(DEPDIR)/libmio_la-mio-tmr.Tpo -c -o libmio_la-mio-tmr.lo `test -f 'mio-tmr.c' || echo '$(srcdir)/'`mio-tmr.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmio_la-mio-tmr.Tpo $(DEPDIR)/libmio_la-mio-tmr.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mio-tmr.c' object='libmio_la-mio-tmr.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstio_la-stio-tmr.lo `test -f 'stio-tmr.c' || echo '$(srcdir)/'`stio-tmr.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmio_la-mio-tmr.lo `test -f 'mio-tmr.c' || echo '$(srcdir)/'`mio-tmr.c
libstio_la-stio-utl.lo: stio-utl.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstio_la-stio-utl.lo -MD -MP -MF $(DEPDIR)/libstio_la-stio-utl.Tpo -c -o libstio_la-stio-utl.lo `test -f 'stio-utl.c' || echo '$(srcdir)/'`stio-utl.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstio_la-stio-utl.Tpo $(DEPDIR)/libstio_la-stio-utl.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='stio-utl.c' object='libstio_la-stio-utl.lo' libtool=yes @AMDEPBACKSLASH@
libmio_la-mio-utl.lo: mio-utl.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmio_la-mio-utl.lo -MD -MP -MF $(DEPDIR)/libmio_la-mio-utl.Tpo -c -o libmio_la-mio-utl.lo `test -f 'mio-utl.c' || echo '$(srcdir)/'`mio-utl.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmio_la-mio-utl.Tpo $(DEPDIR)/libmio_la-mio-utl.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mio-utl.c' object='libmio_la-mio-utl.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstio_la-stio-utl.lo `test -f 'stio-utl.c' || echo '$(srcdir)/'`stio-utl.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmio_la-mio-utl.lo `test -f 'mio-utl.c' || echo '$(srcdir)/'`mio-utl.c
stio-main.o: main.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(stio_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stio-main.o -MD -MP -MF $(DEPDIR)/stio-main.Tpo -c -o stio-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/stio-main.Tpo $(DEPDIR)/stio-main.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='stio-main.o' libtool=no @AMDEPBACKSLASH@
mio-main.o: main.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mio-main.o -MD -MP -MF $(DEPDIR)/mio-main.Tpo -c -o mio-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mio-main.Tpo $(DEPDIR)/mio-main.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='mio-main.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(stio_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stio-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mio-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
stio-main.obj: main.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(stio_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stio-main.obj -MD -MP -MF $(DEPDIR)/stio-main.Tpo -c -o stio-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/stio-main.Tpo $(DEPDIR)/stio-main.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='stio-main.obj' libtool=no @AMDEPBACKSLASH@
mio-main.obj: main.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mio-main.obj -MD -MP -MF $(DEPDIR)/mio-main.Tpo -c -o mio-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mio-main.Tpo $(DEPDIR)/mio-main.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='mio-main.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(stio_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stio-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mio-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
mostlyclean-libtool:
-rm -f *.lo
@ -600,26 +674,15 @@ uninstall-includeHEADERS:
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
TAGS: $(HEADERS) $(SOURCES) stio-cfg.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) stio-cfg.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
@ -631,15 +694,11 @@ TAGS: $(HEADERS) $(SOURCES) stio-cfg.h.in $(TAGS_DEPENDENCIES) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) stio-cfg.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) stio-cfg.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
@ -648,6 +707,21 @@ GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
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
@ -684,7 +758,7 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) stio-cfg.h
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) mio-cfg.h
install-binPROGRAMS: install-libLTLIBRARIES
installdirs:
@ -797,9 +871,10 @@ uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \
$(MAKE) $(AM_MAKEFLAGS) uninstall-hook
.MAKE: all install-am install-data-am install-strip uninstall-am
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic clean-libLTLIBRARIES clean-libtool ctags \
distclean distclean-compile distclean-generic distclean-hdr \
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
clean-libtool cscopelist-am ctags ctags-am distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-data-hook install-dvi \
@ -810,21 +885,23 @@ uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-binPROGRAMS \
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \
uninstall-hook uninstall-includeHEADERS \
uninstall-libLTLIBRARIES
.PRECIOUS: Makefile
install-data-hook:
@echo "#ifndef _STIO_CFG_H_" > "$(DESTDIR)$(includedir)/stio-cfg.h"
@echo "#define _STIO_CFG_H_" >> "$(DESTDIR)$(includedir)/stio-cfg.h"
@$(EGREP) "#define[ ]+STIO_" "$(abs_builddir)/stio-cfg.h" >> "$(DESTDIR)$(includedir)/stio-cfg.h"
@echo "#endif" >> "$(DESTDIR)$(includedir)/stio-cfg.h"
@$(RM) "$(DESTDIR)$(includedir)/stio-cfg.h.in"
@$(SED) 's|/\*#define STIO_HAVE_CFG_H\*/|#define STIO_HAVE_CFG_H|' "$(srcdir)/stio-cmn.h" > "$(DESTDIR)$(includedir)/stio-cmn.h"
@echo "#ifndef _MIO_CFG_H_" > "$(DESTDIR)$(includedir)/mio-cfg.h"
@echo "#define _MIO_CFG_H_" >> "$(DESTDIR)$(includedir)/mio-cfg.h"
@$(EGREP) "#define[ ]+MIO_" "$(abs_builddir)/mio-cfg.h" >> "$(DESTDIR)$(includedir)/mio-cfg.h"
@echo "#endif" >> "$(DESTDIR)$(includedir)/mio-cfg.h"
@$(RM) "$(DESTDIR)$(includedir)/mio-cfg.h.in"
@$(SED) 's|/\*#define MIO_HAVE_CFG_H\*/|#define MIO_HAVE_CFG_H|' "$(srcdir)/mio-cmn.h" > "$(DESTDIR)$(includedir)/mio-cmn.h"
uninstall-hook:
@$(RM) "$(DESTDIR)$(includedir)/stio-cfg.h"
@$(RM) "$(DESTDIR)$(includedir)/mio-cfg.h"
# 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.

View File

@ -25,9 +25,9 @@
*/
#include <stio.h>
#include <stio-sck.h>
#include <stio-pro.h>
#include <mio.h>
#include <mio-sck.h>
#include <mio-pro.h>
#include <stdlib.h>
#include <string.h>
@ -56,21 +56,21 @@
struct mmgr_stat_t
{
stio_size_t total_count;
mio_size_t total_count;
};
typedef struct mmgr_stat_t mmgr_stat_t;
static mmgr_stat_t mmgr_stat;
static void* mmgr_alloc (stio_mmgr_t* mmgr, stio_size_t size)
static void* mmgr_alloc (mio_mmgr_t* mmgr, mio_size_t size)
{
void* x;
if (((mmgr_stat_t*)mmgr->ctx)->total_count > 300)
{
printf ("CRITICAL ERROR ---> too many heap chunks...\n");
return STIO_NULL;
return MIO_NULL;
}
x = malloc (size);
@ -78,19 +78,19 @@ printf ("CRITICAL ERROR ---> too many heap chunks...\n");
return x;
}
static void* mmgr_realloc (stio_mmgr_t* mmgr, void* ptr, stio_size_t size)
static void* mmgr_realloc (mio_mmgr_t* mmgr, void* ptr, mio_size_t size)
{
return realloc (ptr, size);
}
static void mmgr_free (stio_mmgr_t* mmgr, void* ptr)
static void mmgr_free (mio_mmgr_t* mmgr, void* ptr)
{
((mmgr_stat_t*)mmgr->ctx)->total_count--;
return free (ptr);
}
static stio_mmgr_t mmgr =
static mio_mmgr_t mmgr =
{
mmgr_alloc,
mmgr_realloc,
@ -122,31 +122,31 @@ struct tcp_server_t
};
typedef struct tcp_server_t tcp_server_t;
static void tcp_sck_on_disconnect (stio_dev_sck_t* tcp)
static void tcp_sck_on_disconnect (mio_dev_sck_t* tcp)
{
switch (STIO_DEV_SCK_GET_PROGRESS(tcp))
switch (MIO_DEV_SCK_GET_PROGRESS(tcp))
{
case STIO_DEV_SCK_CONNECTING:
case MIO_DEV_SCK_CONNECTING:
printf ("OUTGOING SESSION DISCONNECTED - FAILED TO CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->sck);
break;
case STIO_DEV_SCK_CONNECTING_SSL:
case MIO_DEV_SCK_CONNECTING_SSL:
printf ("OUTGOING SESSION DISCONNECTED - FAILED TO SSL-CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->sck);
break;
case STIO_DEV_SCK_LISTENING:
case MIO_DEV_SCK_LISTENING:
printf ("SHUTTING DOWN THE SERVER SOCKET(%d)...\n", (int)tcp->sck);
break;
case STIO_DEV_SCK_CONNECTED:
case MIO_DEV_SCK_CONNECTED:
printf ("OUTGOING CLIENT CONNECTION GOT TORN DOWN(%d).......\n", (int)tcp->sck);
break;
case STIO_DEV_SCK_ACCEPTING_SSL:
case MIO_DEV_SCK_ACCEPTING_SSL:
printf ("INCOMING SSL-ACCEPT GOT DISCONNECTED(%d) ....\n", (int)tcp->sck);
break;
case STIO_DEV_SCK_ACCEPTED:
case MIO_DEV_SCK_ACCEPTED:
printf ("INCOMING CLIENT BEING SERVED GOT DISCONNECTED(%d).......\n", (int)tcp->sck);
break;
@ -155,44 +155,44 @@ static void tcp_sck_on_disconnect (stio_dev_sck_t* tcp)
break;
}
}
static int tcp_sck_on_connect (stio_dev_sck_t* tcp)
static int tcp_sck_on_connect (mio_dev_sck_t* tcp)
{
stio_sckfam_t fam;
stio_scklen_t len;
stio_mchar_t buf1[128], buf2[128];
mio_sckfam_t fam;
mio_scklen_t len;
mio_mchar_t buf1[128], buf2[128];
memset (buf1, 0, STIO_SIZEOF(buf1));
memset (buf2, 0, STIO_SIZEOF(buf2));
memset (buf1, 0, MIO_SIZEOF(buf1));
memset (buf2, 0, MIO_SIZEOF(buf2));
stio_getsckaddrinfo (tcp->stio, &tcp->localaddr, &len, &fam);
inet_ntop (fam, tcp->localaddr.data, buf1, STIO_COUNTOF(buf1));
mio_getsckaddrinfo (tcp->mio, &tcp->localaddr, &len, &fam);
inet_ntop (fam, tcp->localaddr.data, buf1, MIO_COUNTOF(buf1));
stio_getsckaddrinfo (tcp->stio, &tcp->remoteaddr, &len, &fam);
inet_ntop (fam, tcp->remoteaddr.data, buf2, STIO_COUNTOF(buf2));
mio_getsckaddrinfo (tcp->mio, &tcp->remoteaddr, &len, &fam);
inet_ntop (fam, tcp->remoteaddr.data, buf2, MIO_COUNTOF(buf2));
if (tcp->state & STIO_DEV_SCK_CONNECTED)
if (tcp->state & MIO_DEV_SCK_CONNECTED)
{
printf ("device connected to a remote server... LOCAL %s:%d REMOTE %s:%d.", buf1, stio_getsckaddrport(&tcp->localaddr), buf2, stio_getsckaddrport(&tcp->remoteaddr));
printf ("device connected to a remote server... LOCAL %s:%d REMOTE %s:%d.", buf1, mio_getsckaddrport(&tcp->localaddr), buf2, mio_getsckaddrport(&tcp->remoteaddr));
}
else if (tcp->state & STIO_DEV_SCK_ACCEPTED)
else if (tcp->state & MIO_DEV_SCK_ACCEPTED)
{
printf ("device accepted client device... .LOCAL %s:%d REMOTE %s:%d\n", buf1, stio_getsckaddrport(&tcp->localaddr), buf2, stio_getsckaddrport(&tcp->remoteaddr));
printf ("device accepted client device... .LOCAL %s:%d REMOTE %s:%d\n", buf1, mio_getsckaddrport(&tcp->localaddr), buf2, mio_getsckaddrport(&tcp->remoteaddr));
}
return stio_dev_sck_write (tcp, "hello", 5, STIO_NULL, STIO_NULL);
return mio_dev_sck_write (tcp, "hello", 5, MIO_NULL, MIO_NULL);
}
static int tcp_sck_on_write (stio_dev_sck_t* tcp, stio_iolen_t wrlen, void* wrctx, const stio_sckaddr_t* dstaddr)
static int tcp_sck_on_write (mio_dev_sck_t* tcp, mio_iolen_t wrlen, void* wrctx, const mio_sckaddr_t* dstaddr)
{
tcp_server_t* ts;
if (wrlen <= -1)
{
printf ("SEDING TIMED OUT...........\n");
stio_dev_sck_halt(tcp);
mio_dev_sck_halt(tcp);
}
else
{
@ -200,17 +200,17 @@ else
printf (">>> SENT MESSAGE %d of length %ld\n", ts->tally, (long int)wrlen);
ts->tally++;
// if (ts->tally >= 2) stio_dev_sck_halt (tcp);
// if (ts->tally >= 2) mio_dev_sck_halt (tcp);
printf ("ENABLING READING..............................\n");
stio_dev_sck_read (tcp, 1);
mio_dev_sck_read (tcp, 1);
//stio_dev_sck_timedread (tcp, 1, 1000);
//mio_dev_sck_timedread (tcp, 1, 1000);
}
return 0;
}
static int tcp_sck_on_read (stio_dev_sck_t* tcp, const void* buf, stio_iolen_t len, const stio_sckaddr_t* srcaddr)
static int tcp_sck_on_read (mio_dev_sck_t* tcp, const void* buf, mio_iolen_t len, const mio_sckaddr_t* srcaddr)
{
int n;
@ -218,22 +218,22 @@ static int tcp_sck_on_read (stio_dev_sck_t* tcp, const void* buf, stio_iolen_t l
{
printf ("STREAM DEVICE: EOF RECEIVED...\n");
/* no outstanding request. but EOF */
stio_dev_sck_halt (tcp);
mio_dev_sck_halt (tcp);
return 0;
}
printf ("on read %d\n", (int)len);
{
stio_ntime_t tmout;
mio_ntime_t tmout;
static char a ='A';
char* xxx = malloc (1000000);
memset (xxx, a++ ,1000000);
//return stio_dev_sck_write (tcp, "HELLO", 5, STIO_NULL);
stio_inittime (&tmout, 5, 0);
n = stio_dev_sck_timedwrite (tcp, xxx, 1000000, &tmout, STIO_NULL, STIO_NULL);
//return mio_dev_sck_write (tcp, "HELLO", 5, MIO_NULL);
mio_inittime (&tmout, 5, 0);
n = mio_dev_sck_timedwrite (tcp, xxx, 1000000, &tmout, MIO_NULL, MIO_NULL);
free (xxx);
@ -242,10 +242,10 @@ free (xxx);
printf ("DISABLING READING..............................\n");
stio_dev_sck_read (tcp, 0);
mio_dev_sck_read (tcp, 0);
/* post the write finisher */
n = stio_dev_sck_write (tcp, STIO_NULL, 0, STIO_NULL, STIO_NULL);
n = mio_dev_sck_write (tcp, MIO_NULL, 0, MIO_NULL, MIO_NULL);
if (n <= -1) return -1;
return 0;
@ -255,19 +255,19 @@ printf ("DISABLING READING..............................\n");
/* ========================================================================= */
static void pro_on_close (stio_dev_pro_t* dev, stio_dev_pro_sid_t sid)
static void pro_on_close (mio_dev_pro_t* dev, mio_dev_pro_sid_t sid)
{
printf (">>>>>>>>>>>>> ON CLOSE OF SLAVE %d.\n", sid);
}
static int pro_on_read (stio_dev_pro_t* dev, const void* data, stio_iolen_t dlen, stio_dev_pro_sid_t sid)
static int pro_on_read (mio_dev_pro_t* dev, const void* data, mio_iolen_t dlen, mio_dev_pro_sid_t sid)
{
printf ("PROCESS READ DATA on SLAVE[%d]... [%.*s]\n", (int)sid, (int)dlen, (char*)data);
return 0;
}
static int pro_on_write (stio_dev_pro_t* dev, stio_iolen_t wrlen, void* wrctx)
static int pro_on_write (mio_dev_pro_t* dev, mio_iolen_t wrlen, void* wrctx)
{
printf ("PROCESS WROTE DATA...\n");
return 0;
@ -275,16 +275,16 @@ printf ("PROCESS WROTE DATA...\n");
/* ========================================================================= */
static int arp_sck_on_read (stio_dev_sck_t* dev, const void* data, stio_iolen_t dlen, const stio_sckaddr_t* srcaddr)
static int arp_sck_on_read (mio_dev_sck_t* dev, const void* data, mio_iolen_t dlen, const mio_sckaddr_t* srcaddr)
{
stio_etharp_pkt_t* eap;
mio_etharp_pkt_t* eap;
if (dlen < STIO_SIZEOF(*eap)) return 0; /* drop */
if (dlen < MIO_SIZEOF(*eap)) return 0; /* drop */
eap = (stio_etharp_pkt_t*)data;
eap = (mio_etharp_pkt_t*)data;
printf ("ARP ON IFINDEX %d OPCODE: %d", stio_getsckaddrifindex(srcaddr), ntohs(eap->arphdr.opcode));
printf ("ARP ON IFINDEX %d OPCODE: %d", mio_getsckaddrifindex(srcaddr), ntohs(eap->arphdr.opcode));
printf (" SHA: %02X:%02X:%02X:%02X:%02X:%02X", eap->arppld.sha[0], eap->arppld.sha[1], eap->arppld.sha[2], eap->arppld.sha[3], eap->arppld.sha[4], eap->arppld.sha[5]);
printf (" SPA: %d.%d.%d.%d", eap->arppld.spa[0], eap->arppld.spa[1], eap->arppld.spa[2], eap->arppld.spa[3]);
@ -294,56 +294,56 @@ static int arp_sck_on_read (stio_dev_sck_t* dev, const void* data, stio_iolen_t
return 0;
}
static int arp_sck_on_write (stio_dev_sck_t* dev, stio_iolen_t wrlen, void* wrctx, const stio_sckaddr_t* dstaddr)
static int arp_sck_on_write (mio_dev_sck_t* dev, mio_iolen_t wrlen, void* wrctx, const mio_sckaddr_t* dstaddr)
{
return 0;
}
static void arp_sck_on_disconnect (stio_dev_sck_t* dev)
static void arp_sck_on_disconnect (mio_dev_sck_t* dev)
{
printf ("SHUTTING DOWN ARP SOCKET %d...\n", dev->sck);
}
static int setup_arp_tester (stio_t* stio)
static int setup_arp_tester (mio_t* mio)
{
stio_sckaddr_t ethdst;
stio_etharp_pkt_t etharp;
stio_dev_sck_make_t sck_make;
stio_dev_sck_t* sck;
mio_sckaddr_t ethdst;
mio_etharp_pkt_t etharp;
mio_dev_sck_make_t sck_make;
mio_dev_sck_t* sck;
memset (&sck_make, 0, STIO_SIZEOF(sck_make));
sck_make.type = STIO_DEV_SCK_ARP;
//sck_make.type = STIO_DEV_SCK_ARP_DGRAM;
memset (&sck_make, 0, MIO_SIZEOF(sck_make));
sck_make.type = MIO_DEV_SCK_ARP;
//sck_make.type = MIO_DEV_SCK_ARP_DGRAM;
sck_make.on_write = arp_sck_on_write;
sck_make.on_read = arp_sck_on_read;
sck_make.on_disconnect = arp_sck_on_disconnect;
sck = stio_dev_sck_make (stio, 0, &sck_make);
sck = mio_dev_sck_make (mio, 0, &sck_make);
if (!sck)
{
printf ("Cannot make socket device\n");
return -1;
}
//stio_sckaddr_initforeth (&ethdst, if_nametoindex("enp0s25.3"), (stio_ethaddr_t*)"\xFF\xFF\xFF\xFF\xFF\xFF");
stio_sckaddr_initforeth (&ethdst, if_nametoindex("enp0s25.3"), (stio_ethaddr_t*)"\xAA\xBB\xFF\xCC\xDD\xFF");
//mio_sckaddr_initforeth (&ethdst, if_nametoindex("enp0s25.3"), (mio_ethaddr_t*)"\xFF\xFF\xFF\xFF\xFF\xFF");
mio_sckaddr_initforeth (&ethdst, if_nametoindex("enp0s25.3"), (mio_ethaddr_t*)"\xAA\xBB\xFF\xCC\xDD\xFF");
memset (&etharp, 0, sizeof(etharp));
memcpy (etharp.ethhdr.source, "\xB8\x6B\x23\x9C\x10\x76", STIO_ETHADDR_LEN);
//memcpy (etharp.ethhdr.dest, "\xFF\xFF\xFF\xFF\xFF\xFF", STIO_ETHADDR_LEN);
memcpy (etharp.ethhdr.dest, "\xAA\xBB\xFF\xCC\xDD\xFF", STIO_ETHADDR_LEN);
etharp.ethhdr.proto = STIO_CONST_HTON16(STIO_ETHHDR_PROTO_ARP);
memcpy (etharp.ethhdr.source, "\xB8\x6B\x23\x9C\x10\x76", MIO_ETHADDR_LEN);
//memcpy (etharp.ethhdr.dest, "\xFF\xFF\xFF\xFF\xFF\xFF", MIO_ETHADDR_LEN);
memcpy (etharp.ethhdr.dest, "\xAA\xBB\xFF\xCC\xDD\xFF", MIO_ETHADDR_LEN);
etharp.ethhdr.proto = MIO_CONST_HTON16(MIO_ETHHDR_PROTO_ARP);
etharp.arphdr.htype = STIO_CONST_HTON16(STIO_ARPHDR_HTYPE_ETH);
etharp.arphdr.ptype = STIO_CONST_HTON16(STIO_ARPHDR_PTYPE_IP4);
etharp.arphdr.hlen = STIO_ETHADDR_LEN;
etharp.arphdr.plen = STIO_IP4ADDR_LEN;
etharp.arphdr.opcode = STIO_CONST_HTON16(STIO_ARPHDR_OPCODE_REQUEST);
etharp.arphdr.htype = MIO_CONST_HTON16(MIO_ARPHDR_HTYPE_ETH);
etharp.arphdr.ptype = MIO_CONST_HTON16(MIO_ARPHDR_PTYPE_IP4);
etharp.arphdr.hlen = MIO_ETHADDR_LEN;
etharp.arphdr.plen = MIO_IP4ADDR_LEN;
etharp.arphdr.opcode = MIO_CONST_HTON16(MIO_ARPHDR_OPCODE_REQUEST);
memcpy (etharp.arppld.sha, "\xB8\x6B\x23\x9C\x10\x76", STIO_ETHADDR_LEN);
memcpy (etharp.arppld.sha, "\xB8\x6B\x23\x9C\x10\x76", MIO_ETHADDR_LEN);
if (stio_dev_sck_write (sck, &etharp, sizeof(etharp), NULL, &ethdst) <= -1)
//if (stio_dev_sck_write (sck, &etharp.arphdr, sizeof(etharp) - sizeof(etharp.ethhdr), NULL, &ethaddr) <= -1)
if (mio_dev_sck_write (sck, &etharp, sizeof(etharp), NULL, &ethdst) <= -1)
//if (mio_dev_sck_write (sck, &etharp.arphdr, sizeof(etharp) - sizeof(etharp.ethhdr), NULL, &ethaddr) <= -1)
{
printf ("CANNOT WRITE ARP...\n");
}
@ -356,50 +356,50 @@ static int setup_arp_tester (stio_t* stio)
struct icmpxtn_t
{
stio_uint16_t icmp_seq;
stio_tmridx_t tmout_jobidx;
mio_uint16_t icmp_seq;
mio_tmridx_t tmout_jobidx;
int reply_received;
};
typedef struct icmpxtn_t icmpxtn_t;
static int schedule_icmp_wait (stio_dev_sck_t* dev);
static int schedule_icmp_wait (mio_dev_sck_t* dev);
static void send_icmp (stio_dev_sck_t* dev, stio_uint16_t seq)
static void send_icmp (mio_dev_sck_t* dev, mio_uint16_t seq)
{
stio_sckaddr_t dstaddr;
stio_ip4addr_t ia;
stio_icmphdr_t* icmphdr;
stio_uint8_t buf[512];
mio_sckaddr_t dstaddr;
mio_ip4addr_t ia;
mio_icmphdr_t* icmphdr;
mio_uint8_t buf[512];
inet_pton (AF_INET, "192.168.1.131", &ia);
stio_sckaddr_initforip4 (&dstaddr, 0, &ia);
mio_sckaddr_initforip4 (&dstaddr, 0, &ia);
memset(buf, 0, STIO_SIZEOF(buf));
icmphdr = (stio_icmphdr_t*)buf;
icmphdr->type = STIO_ICMP_ECHO_REQUEST;
icmphdr->u.echo.id = STIO_CONST_HTON16(100);
icmphdr->u.echo.seq = stio_hton16(seq);
memset(buf, 0, MIO_SIZEOF(buf));
icmphdr = (mio_icmphdr_t*)buf;
icmphdr->type = MIO_ICMP_ECHO_REQUEST;
icmphdr->u.echo.id = MIO_CONST_HTON16(100);
icmphdr->u.echo.seq = mio_hton16(seq);
memset (&buf[STIO_SIZEOF(*icmphdr)], 'A', STIO_SIZEOF(buf) - STIO_SIZEOF(*icmphdr));
icmphdr->checksum = stio_checksumip (icmphdr, STIO_SIZEOF(buf));
memset (&buf[MIO_SIZEOF(*icmphdr)], 'A', MIO_SIZEOF(buf) - MIO_SIZEOF(*icmphdr));
icmphdr->checksum = mio_checksumip (icmphdr, MIO_SIZEOF(buf));
if (stio_dev_sck_write (dev, buf, STIO_SIZEOF(buf), NULL, &dstaddr) <= -1)
if (mio_dev_sck_write (dev, buf, MIO_SIZEOF(buf), NULL, &dstaddr) <= -1)
{
printf ("CANNOT WRITE ICMP...\n");
stio_dev_sck_halt (dev);
mio_dev_sck_halt (dev);
}
if (schedule_icmp_wait (dev) <= -1)
{
printf ("CANNOT SCHEDULE ICMP WAIT...\n");
stio_dev_sck_halt (dev);
mio_dev_sck_halt (dev);
}
}
static void on_icmp_due (stio_t* stio, const stio_ntime_t* now, stio_tmrjob_t* tmrjob)
static void on_icmp_due (mio_t* mio, const mio_ntime_t* now, mio_tmrjob_t* tmrjob)
{
stio_dev_sck_t* dev;
mio_dev_sck_t* dev;
icmpxtn_t* icmpxtn;
dev = tmrjob->ctx;
@ -413,64 +413,64 @@ static void on_icmp_due (stio_t* stio, const stio_ntime_t* now, stio_tmrjob_t* t
send_icmp (dev, ++icmpxtn->icmp_seq);
}
static int schedule_icmp_wait (stio_dev_sck_t* dev)
static int schedule_icmp_wait (mio_dev_sck_t* dev)
{
icmpxtn_t* icmpxtn;
stio_tmrjob_t tmrjob;
stio_ntime_t fire_after;
mio_tmrjob_t tmrjob;
mio_ntime_t fire_after;
icmpxtn = (icmpxtn_t*)(dev + 1);
stio_inittime (&fire_after, 2, 0);
mio_inittime (&fire_after, 2, 0);
memset (&tmrjob, 0, STIO_SIZEOF(tmrjob));
memset (&tmrjob, 0, MIO_SIZEOF(tmrjob));
tmrjob.ctx = dev;
stio_gettime (&tmrjob.when);
stio_addtime (&tmrjob.when, &fire_after, &tmrjob.when);
mio_gettime (&tmrjob.when);
mio_addtime (&tmrjob.when, &fire_after, &tmrjob.when);
tmrjob.handler = on_icmp_due;
tmrjob.idxptr = &icmpxtn->tmout_jobidx;
assert (icmpxtn->tmout_jobidx == STIO_TMRIDX_INVALID);
assert (icmpxtn->tmout_jobidx == MIO_TMRIDX_INVALID);
return (stio_instmrjob (dev->stio, &tmrjob) == STIO_TMRIDX_INVALID)? -1: 0;
return (mio_instmrjob (dev->mio, &tmrjob) == MIO_TMRIDX_INVALID)? -1: 0;
}
static int icmp_sck_on_read (stio_dev_sck_t* dev, const void* data, stio_iolen_t dlen, const stio_sckaddr_t* srcaddr)
static int icmp_sck_on_read (mio_dev_sck_t* dev, const void* data, mio_iolen_t dlen, const mio_sckaddr_t* srcaddr)
{
icmpxtn_t* icmpxtn;
stio_iphdr_t* iphdr;
stio_icmphdr_t* icmphdr;
mio_iphdr_t* iphdr;
mio_icmphdr_t* icmphdr;
/* when received, the data contains the IP header.. */
icmpxtn = (icmpxtn_t*)(dev + 1);
if (dlen < STIO_SIZEOF(*iphdr) + STIO_SIZEOF(*icmphdr))
if (dlen < MIO_SIZEOF(*iphdr) + MIO_SIZEOF(*icmphdr))
{
printf ("INVALID ICMP PACKET.. TOO SHORT...%d\n", (int)dlen);
}
else
{
/* TODO: consider IP options... */
iphdr = (stio_iphdr_t*)data;
iphdr = (mio_iphdr_t*)data;
if (iphdr->ihl * 4 + STIO_SIZEOF(*icmphdr) > dlen)
if (iphdr->ihl * 4 + MIO_SIZEOF(*icmphdr) > dlen)
{
printf ("INVALID ICMP PACKET.. WRONG IHL...%d\n", (int)iphdr->ihl * 4);
}
else
{
icmphdr = (stio_icmphdr_t*)((stio_uint8_t*)data + (iphdr->ihl * 4));
icmphdr = (mio_icmphdr_t*)((mio_uint8_t*)data + (iphdr->ihl * 4));
/* TODO: check srcaddr against target */
if (icmphdr->type == STIO_ICMP_ECHO_REPLY &&
stio_ntoh16(icmphdr->u.echo.seq) == icmpxtn->icmp_seq) /* TODO: more check.. echo.id.. */
if (icmphdr->type == MIO_ICMP_ECHO_REPLY &&
mio_ntoh16(icmphdr->u.echo.seq) == icmpxtn->icmp_seq) /* TODO: more check.. echo.id.. */
{
icmpxtn->reply_received = 1;
printf ("ICMP REPLY RECEIVED...ID %d SEQ %d\n", (int)stio_ntoh16(icmphdr->u.echo.id), (int)stio_ntoh16(icmphdr->u.echo.seq));
printf ("ICMP REPLY RECEIVED...ID %d SEQ %d\n", (int)mio_ntoh16(icmphdr->u.echo.id), (int)mio_ntoh16(icmphdr->u.echo.seq));
}
else
{
printf ("GARBAGE ICMP PACKET...LEN %d SEQ %d,%d\n", (int)dlen, (int)icmpxtn->icmp_seq, (int)stio_ntoh16(icmphdr->u.echo.seq));
printf ("GARBAGE ICMP PACKET...LEN %d SEQ %d,%d\n", (int)dlen, (int)icmpxtn->icmp_seq, (int)mio_ntoh16(icmphdr->u.echo.seq));
}
}
}
@ -478,7 +478,7 @@ static int icmp_sck_on_read (stio_dev_sck_t* dev, const void* data, stio_iolen_t
}
static int icmp_sck_on_write (stio_dev_sck_t* dev, stio_iolen_t wrlen, void* wrctx, const stio_sckaddr_t* dstaddr)
static int icmp_sck_on_write (mio_dev_sck_t* dev, mio_iolen_t wrlen, void* wrctx, const mio_sckaddr_t* dstaddr)
{
/*icmpxtn_t* icmpxtn;
@ -487,34 +487,34 @@ static int icmp_sck_on_write (stio_dev_sck_t* dev, stio_iolen_t wrlen, void* wrc
return 0;
}
static void icmp_sck_on_disconnect (stio_dev_sck_t* dev)
static void icmp_sck_on_disconnect (mio_dev_sck_t* dev)
{
icmpxtn_t* icmpxtn;
icmpxtn = (icmpxtn_t*)(dev + 1);
printf ("SHUTTING DOWN ICMP SOCKET %d...\n", dev->sck);
if (icmpxtn->tmout_jobidx != STIO_TMRIDX_INVALID)
if (icmpxtn->tmout_jobidx != MIO_TMRIDX_INVALID)
{
stio_deltmrjob (dev->stio, icmpxtn->tmout_jobidx);
icmpxtn->tmout_jobidx = STIO_TMRIDX_INVALID;
mio_deltmrjob (dev->mio, icmpxtn->tmout_jobidx);
icmpxtn->tmout_jobidx = MIO_TMRIDX_INVALID;
}
}
static int setup_ping4_tester (stio_t* stio)
static int setup_ping4_tester (mio_t* mio)
{
stio_dev_sck_make_t sck_make;
stio_dev_sck_t* sck;
mio_dev_sck_make_t sck_make;
mio_dev_sck_t* sck;
icmpxtn_t* icmpxtn;
memset (&sck_make, 0, STIO_SIZEOF(sck_make));
sck_make.type = STIO_DEV_SCK_ICMP4;
memset (&sck_make, 0, MIO_SIZEOF(sck_make));
sck_make.type = MIO_DEV_SCK_ICMP4;
sck_make.on_write = icmp_sck_on_write;
sck_make.on_read = icmp_sck_on_read;
sck_make.on_disconnect = icmp_sck_on_disconnect;
sck = stio_dev_sck_make (stio, STIO_SIZEOF(icmpxtn_t), &sck_make);
sck = mio_dev_sck_make (mio, MIO_SIZEOF(icmpxtn_t), &sck_make);
if (!sck)
{
printf ("Cannot make ICMP4 socket device\n");
@ -522,10 +522,10 @@ static int setup_ping4_tester (stio_t* stio)
}
icmpxtn = (icmpxtn_t*)(sck + 1);
icmpxtn->tmout_jobidx = STIO_TMRIDX_INVALID;
icmpxtn->tmout_jobidx = MIO_TMRIDX_INVALID;
icmpxtn->icmp_seq = 0;
/*TODO: stio_dev_sck_setbroadcast (sck, 1);*/
/*TODO: mio_dev_sck_setbroadcast (sck, 1);*/
send_icmp (sck, ++icmpxtn->icmp_seq);
@ -535,25 +535,25 @@ static int setup_ping4_tester (stio_t* stio)
/* ========================================================================= */
static stio_t* g_stio;
static mio_t* g_mio;
static void handle_signal (int sig)
{
if (g_stio) stio_stop (g_stio, STIO_STOPREQ_TERMINATION);
if (g_mio) mio_stop (g_mio, MIO_STOPREQ_TERMINATION);
}
int main ()
{
int i;
stio_t* stio;
stio_dev_sck_t* tcp[3];
mio_t* mio;
mio_dev_sck_t* tcp[3];
struct sigaction sigact;
stio_dev_sck_connect_t tcp_conn;
stio_dev_sck_listen_t tcp_lstn;
stio_dev_sck_bind_t tcp_bind;
stio_dev_sck_make_t tcp_make;
mio_dev_sck_connect_t tcp_conn;
mio_dev_sck_listen_t tcp_lstn;
mio_dev_sck_bind_t tcp_bind;
mio_dev_sck_make_t tcp_make;
tcp_server_t* ts;
@ -562,35 +562,35 @@ int main ()
SSL_library_init ();
#endif
stio = stio_open (&mmgr, 0, 512, STIO_NULL);
if (!stio)
mio = mio_open (&mmgr, 0, 512, MIO_NULL);
if (!mio)
{
printf ("Cannot open stio\n");
printf ("Cannot open mio\n");
return -1;
}
g_stio = stio;
g_mio = mio;
memset (&sigact, 0, STIO_SIZEOF(sigact));
memset (&sigact, 0, MIO_SIZEOF(sigact));
sigact.sa_flags = SA_RESTART;
sigact.sa_handler = handle_signal;
sigaction (SIGINT, &sigact, STIO_NULL);
sigaction (SIGINT, &sigact, MIO_NULL);
memset (&sigact, 0, STIO_SIZEOF(sigact));
memset (&sigact, 0, MIO_SIZEOF(sigact));
sigact.sa_handler = SIG_IGN;
sigaction (SIGPIPE, &sigact, STIO_NULL);
sigaction (SIGPIPE, &sigact, MIO_NULL);
/*
memset (&sigact, 0, STIO_SIZEOF(sigact));
memset (&sigact, 0, MIO_SIZEOF(sigact));
sigact.sa_handler = SIG_IGN;
sigaction (SIGCHLD, &sigact, STIO_NULL);
sigaction (SIGCHLD, &sigact, MIO_NULL);
*/
/*memset (&sin, 0, STIO_SIZEOF(sin));
/*memset (&sin, 0, MIO_SIZEOF(sin));
sin.sin_family = AF_INET;
sin.sin_port = htons(1234); */
/*
udp = (stio_dev_udp_t*)stio_makedev (stio, STIO_SIZEOF(*udp), &udp_mth, &udp_evcb, &sin);
udp = (mio_dev_udp_t*)mio_makedev (mio, MIO_SIZEOF(*udp), &udp_mth, &udp_evcb, &sin);
if (!udp)
{
printf ("Cannot make udp\n");
@ -598,12 +598,12 @@ int main ()
}
*/
memset (&tcp_make, 0, STIO_SIZEOF(&tcp_make));
tcp_make.type = STIO_DEV_SCK_TCP4;
memset (&tcp_make, 0, MIO_SIZEOF(&tcp_make));
tcp_make.type = MIO_DEV_SCK_TCP4;
tcp_make.on_write = tcp_sck_on_write;
tcp_make.on_read = tcp_sck_on_read;
tcp_make.on_disconnect = tcp_sck_on_disconnect;
tcp[0] = stio_dev_sck_make (stio, STIO_SIZEOF(tcp_server_t), &tcp_make);
tcp[0] = mio_dev_sck_make (mio, MIO_SIZEOF(tcp_server_t), &tcp_make);
if (!tcp[0])
{
printf ("Cannot make tcp\n");
@ -614,29 +614,29 @@ int main ()
ts->tally = 0;
memset (&tcp_conn, 0, STIO_SIZEOF(tcp_conn));
memset (&tcp_conn, 0, MIO_SIZEOF(tcp_conn));
{
in_addr_t ia = inet_addr("192.168.1.119");
stio_sckaddr_initforip4 (&tcp_conn.remoteaddr, 9999, (stio_ip4addr_t*)&ia);
mio_sckaddr_initforip4 (&tcp_conn.remoteaddr, 9999, (mio_ip4addr_t*)&ia);
}
stio_inittime (&tcp_conn.connect_tmout, 5, 0);
mio_inittime (&tcp_conn.connect_tmout, 5, 0);
tcp_conn.on_connect = tcp_sck_on_connect;
tcp_conn.options = STIO_DEV_SCK_CONNECT_SSL;
if (stio_dev_sck_connect (tcp[0], &tcp_conn) <= -1)
tcp_conn.options = MIO_DEV_SCK_CONNECT_SSL;
if (mio_dev_sck_connect (tcp[0], &tcp_conn) <= -1)
{
printf ("stio_dev_sck_connect() failed....\n");
printf ("mio_dev_sck_connect() failed....\n");
/* carry on regardless of failure */
}
/* -------------------------------------------------------------- */
memset (&tcp_make, 0, STIO_SIZEOF(&tcp_make));
tcp_make.type = STIO_DEV_SCK_TCP4;
memset (&tcp_make, 0, MIO_SIZEOF(&tcp_make));
tcp_make.type = MIO_DEV_SCK_TCP4;
tcp_make.on_write = tcp_sck_on_write;
tcp_make.on_read = tcp_sck_on_read;
tcp_make.on_disconnect = tcp_sck_on_disconnect;
tcp[1] = stio_dev_sck_make (stio, STIO_SIZEOF(tcp_server_t), &tcp_make);
tcp[1] = mio_dev_sck_make (mio, MIO_SIZEOF(tcp_server_t), &tcp_make);
if (!tcp[1])
{
printf ("Cannot make tcp\n");
@ -645,33 +645,33 @@ int main ()
ts = (tcp_server_t*)(tcp[1] + 1);
ts->tally = 0;
memset (&tcp_bind, 0, STIO_SIZEOF(tcp_bind));
stio_sckaddr_initforip4 (&tcp_bind.localaddr, 1234, STIO_NULL);
tcp_bind.options = STIO_DEV_SCK_BIND_REUSEADDR;
memset (&tcp_bind, 0, MIO_SIZEOF(tcp_bind));
mio_sckaddr_initforip4 (&tcp_bind.localaddr, 1234, MIO_NULL);
tcp_bind.options = MIO_DEV_SCK_BIND_REUSEADDR;
if (stio_dev_sck_bind (tcp[1],&tcp_bind) <= -1)
if (mio_dev_sck_bind (tcp[1],&tcp_bind) <= -1)
{
printf ("stio_dev_sck_bind() failed....\n");
printf ("mio_dev_sck_bind() failed....\n");
goto oops;
}
tcp_lstn.backlogs = 100;
tcp_lstn.on_connect = tcp_sck_on_connect;
if (stio_dev_sck_listen (tcp[1], &tcp_lstn) <= -1)
if (mio_dev_sck_listen (tcp[1], &tcp_lstn) <= -1)
{
printf ("stio_dev_sck_listen() failed....\n");
printf ("mio_dev_sck_listen() failed....\n");
goto oops;
}
/* -------------------------------------------------------------- */
memset (&tcp_make, 0, STIO_SIZEOF(&tcp_make));
tcp_make.type = STIO_DEV_SCK_TCP4;
memset (&tcp_make, 0, MIO_SIZEOF(&tcp_make));
tcp_make.type = MIO_DEV_SCK_TCP4;
tcp_make.on_write = tcp_sck_on_write;
tcp_make.on_read = tcp_sck_on_read;
tcp_make.on_disconnect = tcp_sck_on_disconnect;
tcp[2] = stio_dev_sck_make (stio, STIO_SIZEOF(tcp_server_t), &tcp_make);
tcp[2] = mio_dev_sck_make (mio, MIO_SIZEOF(tcp_server_t), &tcp_make);
if (!tcp[2])
{
printf ("Cannot make tcp\n");
@ -680,40 +680,40 @@ int main ()
ts = (tcp_server_t*)(tcp[2] + 1);
ts->tally = 0;
memset (&tcp_bind, 0, STIO_SIZEOF(tcp_bind));
stio_sckaddr_initforip4 (&tcp_bind.localaddr, 1235, STIO_NULL);
tcp_bind.options = STIO_DEV_SCK_BIND_REUSEADDR | /*STIO_DEV_SCK_BIND_REUSEPORT |*/ STIO_DEV_SCK_BIND_SSL;
tcp_bind.ssl_certfile = STIO_MT("localhost.crt");
tcp_bind.ssl_keyfile = STIO_MT("localhost.key");
stio_inittime (&tcp_bind.accept_tmout, 5, 1);
memset (&tcp_bind, 0, MIO_SIZEOF(tcp_bind));
mio_sckaddr_initforip4 (&tcp_bind.localaddr, 1235, MIO_NULL);
tcp_bind.options = MIO_DEV_SCK_BIND_REUSEADDR | /*MIO_DEV_SCK_BIND_REUSEPORT |*/ MIO_DEV_SCK_BIND_SSL;
tcp_bind.ssl_certfile = MIO_MT("localhost.crt");
tcp_bind.ssl_keyfile = MIO_MT("localhost.key");
mio_inittime (&tcp_bind.accept_tmout, 5, 1);
if (stio_dev_sck_bind (tcp[2],&tcp_bind) <= -1)
if (mio_dev_sck_bind (tcp[2],&tcp_bind) <= -1)
{
printf ("stio_dev_sck_bind() failed....\n");
printf ("mio_dev_sck_bind() failed....\n");
goto oops;
}
tcp_lstn.backlogs = 100;
tcp_lstn.on_connect = tcp_sck_on_connect;
if (stio_dev_sck_listen (tcp[2], &tcp_lstn) <= -1)
if (mio_dev_sck_listen (tcp[2], &tcp_lstn) <= -1)
{
printf ("stio_dev_sck_listen() failed....\n");
printf ("mio_dev_sck_listen() failed....\n");
goto oops;
}
//stio_dev_sck_sendfile (tcp[2], fd, offset, count);
//mio_dev_sck_sendfile (tcp[2], fd, offset, count);
if (setup_arp_tester(stio) <= -1) goto oops;
if (setup_ping4_tester(stio) <= -1) goto oops;
if (setup_arp_tester(mio) <= -1) goto oops;
if (setup_ping4_tester(mio) <= -1) goto oops;
for (i = 0; i < 5; i++)
{
stio_dev_pro_t* pro;
stio_dev_pro_make_t pro_make;
mio_dev_pro_t* pro;
mio_dev_pro_make_t pro_make;
memset (&pro_make, 0, STIO_SIZEOF(pro_make));
pro_make.flags = STIO_DEV_PRO_READOUT | STIO_DEV_PRO_READERR | STIO_DEV_PRO_WRITEIN /*| STIO_DEV_PRO_FORGET_CHILD*/;
memset (&pro_make, 0, MIO_SIZEOF(pro_make));
pro_make.flags = MIO_DEV_PRO_READOUT | MIO_DEV_PRO_READERR | MIO_DEV_PRO_WRITEIN /*| MIO_DEV_PRO_FORGET_CHILD*/;
//pro_make.cmd = "/bin/ls -laF /usr/bin";
//pro_make.cmd = "/bin/ls -laF";
pro_make.cmd = "./a";
@ -721,24 +721,24 @@ for (i = 0; i < 5; i++)
pro_make.on_write = pro_on_write;
pro_make.on_close = pro_on_close;
pro = stio_dev_pro_make (stio, 0, &pro_make);
pro = mio_dev_pro_make (mio, 0, &pro_make);
if (!pro)
{
printf ("CANNOT CREATE PROCESS PIPE\n");
goto oops;
}
stio_dev_pro_write (pro, "MY STIO LIBRARY\n", 16, STIO_NULL);
//stio_dev_pro_killchild (pro);
//stio_dev_pro_close (pro, STIO_DEV_PRO_IN);
//stio_dev_pro_close (pro, STIO_DEV_PRO_OUT);
//stio_dev_pro_close (pro, STIO_DEV_PRO_ERR);
mio_dev_pro_write (pro, "MY MIO LIBRARY\n", 16, MIO_NULL);
//mio_dev_pro_killchild (pro);
//mio_dev_pro_close (pro, MIO_DEV_PRO_IN);
//mio_dev_pro_close (pro, MIO_DEV_PRO_OUT);
//mio_dev_pro_close (pro, MIO_DEV_PRO_ERR);
}
stio_loop (stio);
mio_loop (mio);
g_stio = STIO_NULL;
stio_close (stio);
g_mio = MIO_NULL;
mio_close (mio);
#if defined(USE_SSL)
cleanup_openssl ();
#endif
@ -746,8 +746,8 @@ for (i = 0; i < 5; i++)
return 0;
oops:
g_stio = STIO_NULL;
stio_close (stio);
g_mio = MIO_NULL;
mio_close (mio);
#if defined(USE_SSL)
cleanup_openssl ();
#endif

569
mio/lib/mio-cmn.h Normal file
View File

@ -0,0 +1,569 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 AUTHOR 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.
*/
#ifndef _MIO_CMN_H_
#define _MIO_CMN_H_
/* WARNING: NEVER CHANGE/DELETE THE FOLLOWING MIO_HAVE_CFG_H DEFINITION.
* IT IS USED FOR DEPLOYMENT BY MAKEFILE.AM */
/*#define MIO_HAVE_CFG_H*/
#if defined(MIO_HAVE_CFG_H)
# include "mio-cfg.h"
#elif defined(_WIN32)
# include "mio-msw.h"
#elif defined(__OS2__)
# include "mio-os2.h"
#elif defined(__MSDOS__)
# include "mio-dos.h"
#elif defined(macintosh)
# include "mio-mac.h" /* class mac os */
#else
# error UNSUPPORTED SYSTEM
#endif
#if defined(EMSCRIPTEN)
# if defined(MIO_SIZEOF___INT128)
# undef MIO_SIZEOF___INT128
# define MIO_SIZEOF___INT128 0
# endif
# if defined(MIO_SIZEOF_LONG) && defined(MIO_SIZEOF_INT) && (MIO_SIZEOF_LONG > MIO_SIZEOF_INT)
/* autoconf doesn't seem to match actual emscripten */
# undef MIO_SIZEOF_LONG
# define MIO_SIZEOF_LONG MIO_SIZEOF_INT
# endif
#endif
/* =========================================================================
* PRIMITIVE TYPE DEFINTIONS
* ========================================================================= */
/* mio_int8_t */
#if defined(MIO_SIZEOF_CHAR) && (MIO_SIZEOF_CHAR == 1)
# define MIO_HAVE_UINT8_T
# define MIO_HAVE_INT8_T
typedef unsigned char mio_uint8_t;
typedef signed char mio_int8_t;
#elif defined(MIO_SIZEOF___INT8) && (MIO_SIZEOF___INT8 == 1)
# define MIO_HAVE_UINT8_T
# define MIO_HAVE_INT8_T
typedef unsigned __int8 mio_uint8_t;
typedef signed __int8 mio_int8_t;
#elif defined(MIO_SIZEOF___INT8_T) && (MIO_SIZEOF___INT8_T == 1)
# define MIO_HAVE_UINT8_T
# define MIO_HAVE_INT8_T
typedef unsigned __int8_t mio_uint8_t;
typedef signed __int8_t mio_int8_t;
#else
# define MIO_HAVE_UINT8_T
# define MIO_HAVE_INT8_T
typedef unsigned char mio_uint8_t;
typedef signed char mio_int8_t;
#endif
/* mio_int16_t */
#if defined(MIO_SIZEOF_SHORT) && (MIO_SIZEOF_SHORT == 2)
# define MIO_HAVE_UINT16_T
# define MIO_HAVE_INT16_T
typedef unsigned short int mio_uint16_t;
typedef signed short int mio_int16_t;
#elif defined(MIO_SIZEOF___INT16) && (MIO_SIZEOF___INT16 == 2)
# define MIO_HAVE_UINT16_T
# define MIO_HAVE_INT16_T
typedef unsigned __int16 mio_uint16_t;
typedef signed __int16 mio_int16_t;
#elif defined(MIO_SIZEOF___INT16_T) && (MIO_SIZEOF___INT16_T == 2)
# define MIO_HAVE_UINT16_T
# define MIO_HAVE_INT16_T
typedef unsigned __int16_t mio_uint16_t;
typedef signed __int16_t mio_int16_t;
#else
# define MIO_HAVE_UINT16_T
# define MIO_HAVE_INT16_T
typedef unsigned short int mio_uint16_t;
typedef signed short int mio_int16_t;
#endif
/* mio_int32_t */
#if defined(MIO_SIZEOF_INT) && (MIO_SIZEOF_INT == 4)
# define MIO_HAVE_UINT32_T
# define MIO_HAVE_INT32_T
typedef unsigned int mio_uint32_t;
typedef signed int mio_int32_t;
#elif defined(MIO_SIZEOF_LONG) && (MIO_SIZEOF_LONG == 4)
# define MIO_HAVE_UINT32_T
# define MIO_HAVE_INT32_T
typedef unsigned long mio_uint32_t;
typedef signed long mio_int32_t;
#elif defined(MIO_SIZEOF___INT32) && (MIO_SIZEOF___INT32 == 4)
# define MIO_HAVE_UINT32_T
# define MIO_HAVE_INT32_T
typedef unsigned __int32 mio_uint32_t;
typedef signed __int32 mio_int32_t;
#elif defined(MIO_SIZEOF___INT32_T) && (MIO_SIZEOF___INT32_T == 4)
# define MIO_HAVE_UINT32_T
# define MIO_HAVE_INT32_T
typedef unsigned __int32_t mio_uint32_t;
typedef signed __int32_t mio_int32_t;
#elif defined(__MSDOS__)
# define MIO_HAVE_UINT32_T
# define MIO_HAVE_INT32_T
typedef unsigned long int mio_uint32_t;
typedef signed long int mio_int32_t;
#else
# define MIO_HAVE_UINT32_T
# define MIO_HAVE_INT32_T
typedef unsigned int mio_uint32_t;
typedef signed int mio_int32_t;
#endif
/* mio_int64_t */
#if defined(MIO_SIZEOF_INT) && (MIO_SIZEOF_INT == 8)
# define MIO_HAVE_UINT64_T
# define MIO_HAVE_INT64_T
typedef unsigned int mio_uint64_t;
typedef signed int mio_int64_t;
#elif defined(MIO_SIZEOF_LONG) && (MIO_SIZEOF_LONG == 8)
# define MIO_HAVE_UINT64_T
# define MIO_HAVE_INT64_T
typedef unsigned long mio_uint64_t;
typedef signed long mio_int64_t;
#elif defined(MIO_SIZEOF_LONG_LONG) && (MIO_SIZEOF_LONG_LONG == 8)
# define MIO_HAVE_UINT64_T
# define MIO_HAVE_INT64_T
typedef unsigned long long mio_uint64_t;
typedef signed long long mio_int64_t;
#elif defined(MIO_SIZEOF___INT64) && (MIO_SIZEOF___INT64 == 8)
# define MIO_HAVE_UINT64_T
# define MIO_HAVE_INT64_T
typedef unsigned __int64 mio_uint64_t;
typedef signed __int64 mio_int64_t;
#elif defined(MIO_SIZEOF___INT64_T) && (MIO_SIZEOF___INT64_T == 8)
# define MIO_HAVE_UINT64_T
# define MIO_HAVE_INT64_T
typedef unsigned __int64_t mio_uint64_t;
typedef signed __int64_t mio_int64_t;
#elif defined(_WIN64) || defined(_WIN32)
# define MIO_HAVE_UINT64_T
# define MIO_HAVE_INT64_T
typedef unsigned __int64 mio_uint64_t;
typedef signed __int64 mio_int64_t;
#else
/* no 64-bit integer */
#endif
/* mio_int128_t */
#if defined(MIO_SIZEOF_INT) && (MIO_SIZEOF_INT == 16)
# define MIO_HAVE_UINT128_T
# define MIO_HAVE_INT128_T
typedef unsigned int mio_uint128_t;
typedef signed int mio_int128_t;
#elif defined(MIO_SIZEOF_LONG) && (MIO_SIZEOF_LONG == 16)
# define MIO_HAVE_UINT128_T
# define MIO_HAVE_INT128_T
typedef unsigned long mio_uint128_t;
typedef signed long mio_int128_t;
#elif defined(MIO_SIZEOF_LONG_LONG) && (MIO_SIZEOF_LONG_LONG == 16)
# define MIO_HAVE_UINT128_T
# define MIO_HAVE_INT128_T
typedef unsigned long long mio_uint128_t;
typedef signed long long mio_int128_t;
#elif defined(MIO_SIZEOF___INT128) && (MIO_SIZEOF___INT128 == 16)
# define MIO_HAVE_UINT128_T
# define MIO_HAVE_INT128_T
typedef unsigned __int128 mio_uint128_t;
typedef signed __int128 mio_int128_t;
#elif defined(MIO_SIZEOF___INT128_T) && (MIO_SIZEOF___INT128_T == 16)
# define MIO_HAVE_UINT128_T
# define MIO_HAVE_INT128_T
#if defined(__clang__)
typedef __uint128_t mio_uint128_t;
typedef __int128_t mio_int128_t;
#else
typedef unsigned __int128_t mio_uint128_t;
typedef signed __int128_t mio_int128_t;
#endif
#else
/* no 128-bit integer */
#endif
#if defined(MIO_HAVE_UINT8_T) && (MIO_SIZEOF_VOID_P == 1)
# error UNSUPPORTED POINTER SIZE
#elif defined(MIO_HAVE_UINT16_T) && (MIO_SIZEOF_VOID_P == 2)
typedef mio_uint16_t mio_uintptr_t;
typedef mio_int16_t mio_intptr_t;
typedef mio_uint8_t mio_ushortptr_t;
typedef mio_int8_t mio_shortptr_t;
#elif defined(MIO_HAVE_UINT32_T) && (MIO_SIZEOF_VOID_P == 4)
typedef mio_uint32_t mio_uintptr_t;
typedef mio_int32_t mio_intptr_t;
typedef mio_uint16_t mio_ushortptr_t;
typedef mio_int16_t mio_shortptr_t;
#elif defined(MIO_HAVE_UINT64_T) && (MIO_SIZEOF_VOID_P == 8)
typedef mio_uint64_t mio_uintptr_t;
typedef mio_int64_t mio_intptr_t;
typedef mio_uint32_t mio_ushortptr_t;
typedef mio_int32_t mio_shortptr_t;
#elif defined(MIO_HAVE_UINT128_T) && (MIO_SIZEOF_VOID_P == 16)
typedef mio_uint128_t mio_uintptr_t;
typedef mio_int128_t mio_intptr_t;
typedef mio_uint64_t mio_ushortptr_t;
typedef mio_int64_t mio_shortptr_t;
#else
# error UNKNOWN POINTER SIZE
#endif
#define MIO_SIZEOF_INTPTR_T MIO_SIZEOF_VOID_P
#define MIO_SIZEOF_UINTPTR_T MIO_SIZEOF_VOID_P
#define MIO_SIZEOF_SHORTPTR_T (MIO_SIZEOF_VOID_P / 2)
#define MIO_SIZEOF_USHORTPTR_T (MIO_SIZEOF_VOID_P / 2)
#if defined(MIO_HAVE_INT128_T)
# define MIO_SIZEOF_INTMAX_T 16
# define MIO_SIZEOF_UINTMAX_T 16
typedef mio_int128_t mio_intmax_t;
typedef mio_uint128_t mio_uintmax_t;
#elif defined(MIO_HAVE_INT64_T)
# define MIO_SIZEOF_INTMAX_T 8
# define MIO_SIZEOF_UINTMAX_T 8
typedef mio_int64_t mio_intmax_t;
typedef mio_uint64_t mio_uintmax_t;
#elif defined(MIO_HAVE_INT32_T)
# define MIO_SIZEOF_INTMAX_T 4
# define MIO_SIZEOF_UINTMAX_T 4
typedef mio_int32_t mio_intmax_t;
typedef mio_uint32_t mio_uintmax_t;
#elif defined(MIO_HAVE_INT16_T)
# define MIO_SIZEOF_INTMAX_T 2
# define MIO_SIZEOF_UINTMAX_T 2
typedef mio_int16_t mio_intmax_t;
typedef mio_uint16_t mio_uintmax_t;
#elif defined(MIO_HAVE_INT8_T)
# define MIO_SIZEOF_INTMAX_T 1
# define MIO_SIZEOF_UINTMAX_T 1
typedef mio_int8_t mio_intmax_t;
typedef mio_uint8_t mio_uintmax_t;
#else
# error UNKNOWN INTMAX SIZE
#endif
/* =========================================================================
* BASIC MIO TYPES
* =========================================================================*/
typedef mio_uint8_t mio_byte_t;
typedef mio_uintptr_t mio_size_t;
typedef char mio_mchar_t;
typedef int mio_mcint_t;
#define MIO_MT(x) (x)
/* =========================================================================
* PRIMITIVE MACROS
* ========================================================================= */
#define MIO_SIZEOF(x) (sizeof(x))
#define MIO_COUNTOF(x) (sizeof(x) / sizeof(x[0]))
/**
* The MIO_OFFSETOF() macro returns the offset of a field from the beginning
* of a structure.
*/
#define MIO_OFFSETOF(type,member) ((mio_uintptr_t)&((type*)0)->member)
/**
* The MIO_ALIGNOF() macro returns the alignment size of a structure.
* Note that this macro may not work reliably depending on the type given.
*/
#define MIO_ALIGNOF(type) MIO_OFFSETOF(struct { mio_uint8_t d1; type d2; }, d2)
/*(sizeof(struct { mio_uint8_t d1; type d2; }) - sizeof(type))*/
/**
* Round up a positive integer to the nearest multiple of 'align'
*/
#define MIO_ALIGNTO(num,align) ((((num) + (align) - 1) / (align)) * (align))
#if 0
/**
* Round up a number, both positive and negative, to the nearest multiple of 'align'
*/
#define MIO_ALIGNTO(num,align) ((((num) + (num >= 0? 1: -1) * (align) - 1) / (align)) * (align))
#endif
/**
* Round up a positive integer to to the nearest multiple of 'align' which
* should be a multiple of a power of 2
*/
#define MIO_ALIGNTO_POW2(num,align) ((((num) + (align) - 1)) & ~((align) - 1))
#if defined(__cplusplus)
# if (__cplusplus >= 201103L) /* C++11 */
# define MIO_NULL nullptr
# else
# define MIO_NULL (0)
# endif
#else
# define MIO_NULL ((void*)0)
#endif
/* make a bit mask that can mask off low n bits */
#define MIO_LBMASK(type,n) (~(~((type)0) << (n)))
#define MIO_LBMASK_SAFE(type,n) (((n) < MIO_SIZEOF(type) * 8)? MIO_LBMASK(type,n): ~(type)0)
/* make a bit mask that can mask off hig n bits */
#define MIO_HBMASK(type,n) (~(~((type)0) >> (n)))
#define MIO_HBMASK_SAFE(type,n) (((n) < MIO_SIZEOF(type) * 8)? MIO_HBMASK(type,n): ~(type)0)
/* get 'length' bits starting from the bit at the 'offset' */
#define MIO_GETBITS(type,value,offset,length) \
((((type)(value)) >> (offset)) & MIO_LBMASK(type,length))
#define MIO_SETBITS(type,value,offset,length,bits) \
(value = (((type)(value)) | (((bits) & MIO_LBMASK(type,length)) << (offset))))
/**
* The MIO_BITS_MAX() macros calculates the maximum value that the 'nbits'
* bits of an unsigned integer of the given 'type' can hold.
* \code
* printf ("%u", MIO_BITS_MAX(unsigned int, 5));
* \endcode
*/
/*#define MIO_BITS_MAX(type,nbits) ((((type)1) << (nbits)) - 1)*/
#define MIO_BITS_MAX(type,nbits) ((~(type)0) >> (MIO_SIZEOF(type) * 8 - (nbits)))
/* =========================================================================
* MMGR
* ========================================================================= */
typedef struct mio_mmgr_t mio_mmgr_t;
/**
* allocate a memory chunk of the size \a n.
* \return pointer to a memory chunk on success, #MIO_NULL on failure.
*/
typedef void* (*mio_mmgr_alloc_t) (mio_mmgr_t* mmgr, mio_size_t n);
/**
* resize a memory chunk pointed to by \a ptr to the size \a n.
* \return pointer to a memory chunk on success, #MIO_NULL on failure.
*/
typedef void* (*mio_mmgr_realloc_t) (mio_mmgr_t* mmgr, void* ptr, mio_size_t n);
/**
* free a memory chunk pointed to by \a ptr.
*/
typedef void (*mio_mmgr_free_t) (mio_mmgr_t* mmgr, void* ptr);
/**
* The mio_mmgr_t type defines the memory management interface.
* As the type is merely a structure, it is just used as a single container
* for memory management functions with a pointer to user-defined data.
* The user-defined data pointer \a ctx is passed to each memory management
* function whenever it is called. You can allocate, reallocate, and free
* a memory chunk.
*
* For example, a mio_xxx_open() function accepts a pointer of the mio_mmgr_t
* type and the xxx object uses it to manage dynamic data within the object.
*/
struct mio_mmgr_t
{
mio_mmgr_alloc_t alloc; /**< allocation function */
mio_mmgr_realloc_t realloc; /**< resizing function */
mio_mmgr_free_t free; /**< disposal function */
void* ctx; /**< user-defined data pointer */
};
/**
* The MIO_MMGR_ALLOC() macro allocates a memory block of the \a size bytes
* using the \a mmgr memory manager.
*/
#define MIO_MMGR_ALLOC(mmgr,size) ((mmgr)->alloc(mmgr,size))
/**
* The MIO_MMGR_REALLOC() macro resizes a memory block pointed to by \a ptr
* to the \a size bytes using the \a mmgr memory manager.
*/
#define MIO_MMGR_REALLOC(mmgr,ptr,size) ((mmgr)->realloc(mmgr,ptr,size))
/**
* The MIO_MMGR_FREE() macro deallocates the memory block pointed to by \a ptr.
*/
#define MIO_MMGR_FREE(mmgr,ptr) ((mmgr)->free(mmgr,ptr))
/* =========================================================================
* MACROS THAT CHANGES THE BEHAVIORS OF THE C COMPILER/LINKER
* =========================================================================*/
#if defined(_WIN32) || (defined(__WATCOMC__) && !defined(__WINDOWS_386__))
# define MIO_IMPORT __declspec(dllimport)
# define MIO_EXPORT __declspec(dllexport)
# define MIO_PRIVATE
#elif defined(__GNUC__) && (__GNUC__>=4)
# define MIO_IMPORT __attribute__((visibility("default")))
# define MIO_EXPORT __attribute__((visibility("default")))
# define MIO_PRIVATE __attribute__((visibility("hidden")))
/*# define MIO_PRIVATE __attribute__((visibility("internal")))*/
#else
# define MIO_IMPORT
# define MIO_EXPORT
# define MIO_PRIVATE
#endif
#if defined(__STDC_VERSION__) && (__STDC_VERSION__>=199901L)
# define MIO_INLINE inline
# define MIO_HAVE_INLINE
#elif defined(__GNUC__) && defined(__GNUC_GNU_INLINE__)
/* gcc disables inline when -std=c89 or -ansi is used.
* so use __inline__ supported by gcc regardless of the options */
# define MIO_INLINE /*extern*/ __inline__
# define MIO_HAVE_INLINE
#else
# define MIO_INLINE
# undef MIO_HAVE_INLINE
#endif
/**
* The MIO_TYPE_IS_SIGNED() macro determines if a type is signed.
* \code
* printf ("%d\n", (int)MIO_TYPE_IS_SIGNED(int));
* printf ("%d\n", (int)MIO_TYPE_IS_SIGNED(unsigned int));
* \endcode
*/
#define MIO_TYPE_IS_SIGNED(type) (((type)0) > ((type)-1))
/**
* The MIO_TYPE_IS_SIGNED() macro determines if a type is unsigned.
* \code
* printf ("%d\n", MIO_TYPE_IS_UNSIGNED(int));
* printf ("%d\n", MIO_TYPE_IS_UNSIGNED(unsigned int));
* \endcode
*/
#define MIO_TYPE_IS_UNSIGNED(type) (((type)0) < ((type)-1))
#define MIO_TYPE_SIGNED_MAX(type) \
((type)~((type)1 << ((type)MIO_SIZEOF(type) * 8 - 1)))
#define MIO_TYPE_UNSIGNED_MAX(type) ((type)(~(type)0))
#define MIO_TYPE_SIGNED_MIN(type) \
((type)((type)1 << ((type)MIO_SIZEOF(type) * 8 - 1)))
#define MIO_TYPE_UNSIGNED_MIN(type) ((type)0)
#define MIO_TYPE_MAX(type) \
((MIO_TYPE_IS_SIGNED(type)? MIO_TYPE_SIGNED_MAX(type): MIO_TYPE_UNSIGNED_MAX(type)))
#define MIO_TYPE_MIN(type) \
((MIO_TYPE_IS_SIGNED(type)? MIO_TYPE_SIGNED_MIN(type): MIO_TYPE_UNSIGNED_MIN(type)))
/* =========================================================================
* COMPILER FEATURE TEST MACROS
* =========================================================================*/
#if defined(__has_builtin)
#if __has_builtin(__builtin_ctz)
#define MIO_HAVE_BUILTIN_CTZ
#endif
#if __has_builtin(__builtin_uadd_overflow)
#define MIO_HAVE_BUILTIN_UADD_OVERFLOW
#endif
#if __has_builtin(__builtin_uaddl_overflow)
#define MIO_HAVE_BUILTIN_UADDL_OVERFLOW
#endif
#if __has_builtin(__builtin_uaddll_overflow)
#define MIO_HAVE_BUILTIN_UADDLL_OVERFLOW
#endif
#if __has_builtin(__builtin_umul_overflow)
#define MIO_HAVE_BUILTIN_UMUL_OVERFLOW
#endif
#if __has_builtin(__builtin_umull_overflow)
#define MIO_HAVE_BUILTIN_UMULL_OVERFLOW
#endif
#if __has_builtin(__builtin_umulll_overflow)
#define MIO_HAVE_BUILTIN_UMULLL_OVERFLOW
#endif
#if __has_builtin(__builtin_sadd_overflow)
#define MIO_HAVE_BUILTIN_SADD_OVERFLOW
#endif
#if __has_builtin(__builtin_saddl_overflow)
#define MIO_HAVE_BUILTIN_SADDL_OVERFLOW
#endif
#if __has_builtin(__builtin_saddll_overflow)
#define MIO_HAVE_BUILTIN_SADDLL_OVERFLOW
#endif
#if __has_builtin(__builtin_smul_overflow)
#define MIO_HAVE_BUILTIN_SMUL_OVERFLOW
#endif
#if __has_builtin(__builtin_smull_overflow)
#define MIO_HAVE_BUILTIN_SMULL_OVERFLOW
#endif
#if __has_builtin(__builtin_smulll_overflow)
#define MIO_HAVE_BUILTIN_SMULLL_OVERFLOW
#endif
#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#define MIO_HAVE_BUILTIN_CTZ
#endif
#if (__GNUC__ >= 5)
#define MIO_HAVE_BUILTIN_UADD_OVERFLOW
#define MIO_HAVE_BUILTIN_UADDL_OVERFLOW
#define MIO_HAVE_BUILTIN_UADDLL_OVERFLOW
#define MIO_HAVE_BUILTIN_UMUL_OVERFLOW
#define MIO_HAVE_BUILTIN_UMULL_OVERFLOW
#define MIO_HAVE_BUILTIN_UMULLL_OVERFLOW
#define MIO_HAVE_BUILTIN_SADD_OVERFLOW
#define MIO_HAVE_BUILTIN_SADDL_OVERFLOW
#define MIO_HAVE_BUILTIN_SADDLL_OVERFLOW
#define MIO_HAVE_BUILTIN_SMUL_OVERFLOW
#define MIO_HAVE_BUILTIN_SMULL_OVERFLOW
#define MIO_HAVE_BUILTIN_SMULLL_OVERFLOW
#endif
#endif
/*
#if !defined(__has_builtin)
#define __has_builtin(x) 0
#endif
#if !defined(__is_identifier)
#define __is_identifier(x) 0
#endif
#if !defined(__has_attribute)
#define __has_attribute(x) 0
#endif
*/
#endif

846
mio/lib/mio-pro.c Normal file
View File

@ -0,0 +1,846 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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 "mio-pro.h"
#include "mio-prv.h"
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/wait.h>
/* ========================================================================= */
struct slave_info_t
{
mio_dev_pro_make_t* mi;
mio_syshnd_t pfd;
int dev_capa;
mio_dev_pro_sid_t id;
};
typedef struct slave_info_t slave_info_t;
static mio_dev_pro_slave_t* make_slave (mio_t* mio, slave_info_t* si);
/* ========================================================================= */
struct param_t
{
mio_mchar_t* mcmd;
mio_mchar_t* fixed_argv[4];
mio_mchar_t** argv;
};
typedef struct param_t param_t;
static void free_param (mio_t* mio, param_t* param)
{
if (param->argv && param->argv != param->fixed_argv)
MIO_MMGR_FREE (mio->mmgr, param->argv);
if (param->mcmd) MIO_MMGR_FREE (mio->mmgr, param->mcmd);
MIO_MEMSET (param, 0, MIO_SIZEOF(*param));
}
static int make_param (mio_t* mio, const mio_mchar_t* cmd, int flags, param_t* param)
{
int fcnt = 0;
mio_mchar_t* mcmd = MIO_NULL;
MIO_MEMSET (param, 0, MIO_SIZEOF(*param));
if (flags & MIO_DEV_PRO_SHELL)
{
mcmd = (mio_mchar_t*)cmd;
param->argv = param->fixed_argv;
param->argv[0] = MIO_MT("/bin/sh");
param->argv[1] = MIO_MT("-c");
param->argv[2] = mcmd;
param->argv[3] = MIO_NULL;
}
else
{
int i;
mio_mchar_t** argv;
mio_mchar_t* mcmdptr;
mcmd = mio_mbsdup (mio, cmd);
if (!mcmd) goto oops;
fcnt = mio_mbsspl (mcmd, MIO_MT(""), MIO_MT('\"'), MIO_MT('\"'), MIO_MT('\\'));
if (fcnt <= 0)
{
/* no field or an error */
mio->errnum = MIO_EINVAL;
goto oops;
}
if (fcnt < MIO_COUNTOF(param->fixed_argv))
{
param->argv = param->fixed_argv;
}
else
{
param->argv = MIO_MMGR_ALLOC (mio->mmgr, (fcnt + 1) * MIO_SIZEOF(argv[0]));
if (param->argv == MIO_NULL)
{
mio->errnum = MIO_ENOMEM;
goto oops;
}
}
mcmdptr = mcmd;
for (i = 0; i < fcnt; i++)
{
param->argv[i] = mcmdptr;
while (*mcmdptr != MIO_MT('\0')) mcmdptr++;
mcmdptr++;
}
param->argv[i] = MIO_NULL;
}
if (mcmd && mcmd != (mio_mchar_t*)cmd) param->mcmd = mcmd;
return 0;
oops:
if (mcmd && mcmd != cmd) MIO_MMGR_FREE (mio->mmgr, mcmd);
return -1;
}
static pid_t standard_fork_and_exec (mio_t* mio, int pfds[], int flags, param_t* param)
{
pid_t pid;
pid = fork ();
if (pid == -1)
{
mio->errnum = mio_syserrtoerrnum(errno);
return -1;
}
if (pid == 0)
{
/* slave process */
mio_syshnd_t devnull = MIO_SYSHND_INVALID;
/* TODO: close all uneeded fds */
if (flags & MIO_DEV_PRO_WRITEIN)
{
/* slave should read */
close (pfds[1]);
pfds[1] = MIO_SYSHND_INVALID;
/* let the pipe be standard input */
if (dup2 (pfds[0], 0) <= -1) goto slave_oops;
close (pfds[0]);
pfds[0] = MIO_SYSHND_INVALID;
}
if (flags & MIO_DEV_PRO_READOUT)
{
/* slave should write */
close (pfds[2]);
pfds[2] = MIO_SYSHND_INVALID;
if (dup2(pfds[3], 1) == -1) goto slave_oops;
if (flags & MIO_DEV_PRO_ERRTOOUT)
{
if (dup2(pfds[3], 2) == -1) goto slave_oops;
}
close (pfds[3]);
pfds[3] = MIO_SYSHND_INVALID;
}
if (flags & MIO_DEV_PRO_READERR)
{
close (pfds[4]);
pfds[4] = MIO_SYSHND_INVALID;
if (dup2(pfds[5], 2) == -1) goto slave_oops;
if (flags & MIO_DEV_PRO_OUTTOERR)
{
if (dup2(pfds[5], 1) == -1) goto slave_oops;
}
close (pfds[5]);
pfds[5] = MIO_SYSHND_INVALID;
}
if ((flags & MIO_DEV_PRO_INTONUL) ||
(flags & MIO_DEV_PRO_OUTTONUL) ||
(flags & MIO_DEV_PRO_ERRTONUL))
{
#if defined(O_LARGEFILE)
devnull = open (MIO_MT("/dev/null"), O_RDWR | O_LARGEFILE, 0);
#else
devnull = open (MIO_MT("/dev/null"), O_RDWR, 0);
#endif
if (devnull == MIO_SYSHND_INVALID) goto slave_oops;
}
execv (param->argv[0], param->argv);
/* if exec fails, free 'param' parameter which is an inherited pointer */
free_param (mio, param);
slave_oops:
if (devnull != MIO_SYSHND_INVALID) close(devnull);
_exit (128);
}
/* parent process */
return pid;
}
static int dev_pro_make_master (mio_dev_t* dev, void* ctx)
{
mio_dev_pro_t* rdev = (mio_dev_pro_t*)dev;
mio_dev_pro_make_t* info = (mio_dev_pro_make_t*)ctx;
mio_syshnd_t pfds[6];
int i, minidx = -1, maxidx = -1;
param_t param;
pid_t pid;
if (info->flags & MIO_DEV_PRO_WRITEIN)
{
if (pipe(&pfds[0]) == -1)
{
dev->mio->errnum = mio_syserrtoerrnum(errno);
goto oops;
}
minidx = 0; maxidx = 1;
}
if (info->flags & MIO_DEV_PRO_READOUT)
{
if (pipe(&pfds[2]) == -1)
{
dev->mio->errnum = mio_syserrtoerrnum(errno);
goto oops;
}
if (minidx == -1) minidx = 2;
maxidx = 3;
}
if (info->flags & MIO_DEV_PRO_READERR)
{
if (pipe(&pfds[4]) == -1)
{
dev->mio->errnum = mio_syserrtoerrnum(errno);
goto oops;
}
if (minidx == -1) minidx = 4;
maxidx = 5;
}
if (maxidx == -1)
{
dev->mio->errnum = MIO_EINVAL;
goto oops;
}
if (make_param (rdev->mio, info->cmd, info->flags, &param) <= -1) goto oops;
/* TODO: more advanced fork and exec .. */
pid = standard_fork_and_exec (rdev->mio, pfds, info->flags, &param);
if (pid <= -1)
{
free_param (rdev->mio, &param);
goto oops;
}
free_param (rdev->mio, &param);
rdev->child_pid = pid;
/* this is the parent process */
if (info->flags & MIO_DEV_PRO_WRITEIN)
{
/*
* 012345
* rw----
* X
* WRITE => 1
*/
close (pfds[0]);
pfds[0] = MIO_SYSHND_INVALID;
if (mio_makesyshndasync (dev->mio, pfds[1]) <= -1) goto oops;
}
if (info->flags & MIO_DEV_PRO_READOUT)
{
/*
* 012345
* --rw--
* X
* READ => 2
*/
close (pfds[3]);
pfds[3] = MIO_SYSHND_INVALID;
if (mio_makesyshndasync (dev->mio, pfds[2]) <= -1) goto oops;
}
if (info->flags & MIO_DEV_PRO_READERR)
{
/*
* 012345
* ----rw
* X
* READ => 4
*/
close (pfds[5]);
pfds[5] = MIO_SYSHND_INVALID;
if (mio_makesyshndasync (dev->mio, pfds[4]) <= -1) goto oops;
}
if (pfds[1] != MIO_SYSHND_INVALID)
{
/* hand over pfds[2] to the first slave device */
slave_info_t si;
si.mi = info;
si.pfd = pfds[1];
si.dev_capa = MIO_DEV_CAPA_OUT | MIO_DEV_CAPA_OUT_QUEUED | MIO_DEV_CAPA_STREAM;
si.id = MIO_DEV_PRO_IN;
rdev->slave[MIO_DEV_PRO_IN] = make_slave (dev->mio, &si);
if (!rdev->slave[MIO_DEV_PRO_IN]) goto oops;
pfds[1] = MIO_SYSHND_INVALID;
rdev->slave_count++;
}
if (pfds[2] != MIO_SYSHND_INVALID)
{
/* hand over pfds[2] to the first slave device */
slave_info_t si;
si.mi = info;
si.pfd = pfds[2];
si.dev_capa = MIO_DEV_CAPA_IN | MIO_DEV_CAPA_STREAM;
si.id = MIO_DEV_PRO_OUT;
rdev->slave[MIO_DEV_PRO_OUT] = make_slave (dev->mio, &si);
if (!rdev->slave[MIO_DEV_PRO_OUT]) goto oops;
pfds[2] = MIO_SYSHND_INVALID;
rdev->slave_count++;
}
if (pfds[4] != MIO_SYSHND_INVALID)
{
/* hand over pfds[4] to the second slave device */
slave_info_t si;
si.mi = info;
si.pfd = pfds[4];
si.dev_capa = MIO_DEV_CAPA_IN | MIO_DEV_CAPA_STREAM;
si.id = MIO_DEV_PRO_ERR;
rdev->slave[MIO_DEV_PRO_ERR] = make_slave (dev->mio, &si);
if (!rdev->slave[MIO_DEV_PRO_ERR]) goto oops;
pfds[4] = MIO_SYSHND_INVALID;
rdev->slave_count++;
}
for (i = 0; i < MIO_COUNTOF(rdev->slave); i++)
{
if (rdev->slave[i]) rdev->slave[i]->master = rdev;
}
rdev->dev_capa = MIO_DEV_CAPA_VIRTUAL; /* the master device doesn't perform I/O */
rdev->flags = info->flags;
rdev->on_read = info->on_read;
rdev->on_write = info->on_write;
rdev->on_close = info->on_close;
return 0;
oops:
for (i = minidx; i < maxidx; i++)
{
if (pfds[i] != MIO_SYSHND_INVALID) close (pfds[i]);
}
if (rdev->mcmd)
{
MIO_MMGR_FREE (rdev->mio->mmgr, rdev->mcmd);
free_param (rdev->mio, &param);
}
for (i = MIO_COUNTOF(rdev->slave); i > 0; )
{
i--;
if (rdev->slave[i])
{
mio_killdev (rdev->mio, (mio_dev_t*)rdev->slave[i]);
rdev->slave[i] = MIO_NULL;
}
}
rdev->slave_count = 0;
return -1;
}
static int dev_pro_make_slave (mio_dev_t* dev, void* ctx)
{
mio_dev_pro_slave_t* rdev = (mio_dev_pro_slave_t*)dev;
slave_info_t* si = (slave_info_t*)ctx;
rdev->dev_capa = si->dev_capa;
rdev->id = si->id;
rdev->pfd = si->pfd;
/* keep rdev->master to MIO_NULL. it's set to the right master
* device in dev_pro_make() */
return 0;
}
static int dev_pro_kill_master (mio_dev_t* dev, int force)
{
mio_dev_pro_t* rdev = (mio_dev_pro_t*)dev;
int i, status;
pid_t wpid;
if (rdev->slave_count > 0)
{
for (i = 0; i < MIO_COUNTOF(rdev->slave); i++)
{
if (rdev->slave[i])
{
mio_dev_pro_slave_t* sdev = rdev->slave[i];
/* nullify the pointer to the slave device
* before calling mio_killdev() on the slave device.
* the slave device can check this pointer to tell from
* self-initiated termination or master-driven termination */
rdev->slave[i] = MIO_NULL;
mio_killdev (rdev->mio, (mio_dev_t*)sdev);
}
}
}
if (rdev->child_pid >= 0)
{
if (!(rdev->flags & MIO_DEV_PRO_FORGET_CHILD))
{
int killed = 0;
await_child:
wpid = waitpid (rdev->child_pid, &status, WNOHANG);
if (wpid == 0)
{
if (force && !killed)
{
if (!(rdev->flags & MIO_DEV_PRO_FORGET_DIEHARD_CHILD))
{
kill (rdev->child_pid, SIGKILL);
killed = 1;
goto await_child;
}
}
else
{
/* child process is still alive */
rdev->mio->errnum = MIO_EAGAIN;
return -1; /* call me again */
}
}
/* wpid == rdev->child_pid => full success
* wpid == -1 && errno == ECHILD => no such process. it's waitpid()'ed by some other part of the program?
* other cases ==> can't really handle properly. forget it by returning success
* no need not worry about EINTR because errno can't have the value when WNOHANG is set.
*/
}
printf (">>>>>>>>>>>>>>>>>>> REAPED CHILD %d\n", (int)rdev->child_pid);
rdev->child_pid = -1;
}
if (rdev->on_close) rdev->on_close (rdev, MIO_DEV_PRO_MASTER);
return 0;
}
static int dev_pro_kill_slave (mio_dev_t* dev, int force)
{
mio_dev_pro_slave_t* rdev = (mio_dev_pro_slave_t*)dev;
if (rdev->master)
{
mio_dev_pro_t* master;
master = rdev->master;
rdev->master = MIO_NULL;
/* indicate EOF */
if (master->on_close) master->on_close (master, rdev->id);
MIO_ASSERT (master->slave_count > 0);
master->slave_count--;
if (master->slave[rdev->id])
{
/* this call is started by the slave device itself.
* if this is the last slave, kill the master also */
if (master->slave_count <= 0)
{
mio_killdev (rdev->mio, (mio_dev_t*)master);
/* the master pointer is not valid from this point onwards
* as the actual master device object is freed in mio_killdev() */
}
}
else
{
/* this call is initiated by this slave device itself.
* if it were by the master device, it would be MIO_NULL as
* nullified by the dev_pro_kill() */
master->slave[rdev->id] = MIO_NULL;
}
}
if (rdev->pfd != MIO_SYSHND_INVALID)
{
close (rdev->pfd);
rdev->pfd = MIO_SYSHND_INVALID;
}
return 0;
}
static int dev_pro_read_slave (mio_dev_t* dev, void* buf, mio_iolen_t* len, mio_devaddr_t* srcaddr)
{
mio_dev_pro_slave_t* pro = (mio_dev_pro_slave_t*)dev;
ssize_t x;
x = read (pro->pfd, buf, *len);
if (x <= -1)
{
if (errno == EINPROGRESS || errno == EWOULDBLOCK || errno == EAGAIN) return 0; /* no data available */
if (errno == EINTR) return 0;
pro->mio->errnum = mio_syserrtoerrnum(errno);
return -1;
}
*len = x;
return 1;
}
static int dev_pro_write_slave (mio_dev_t* dev, const void* data, mio_iolen_t* len, const mio_devaddr_t* dstaddr)
{
mio_dev_pro_slave_t* pro = (mio_dev_pro_slave_t*)dev;
ssize_t x;
x = write (pro->pfd, data, *len);
if (x <= -1)
{
if (errno == EINPROGRESS || errno == EWOULDBLOCK || errno == EAGAIN) return 0; /* no data can be written */
if (errno == EINTR) return 0;
pro->mio->errnum = mio_syserrtoerrnum(errno);
return -1;
}
*len = x;
return 1;
}
static mio_syshnd_t dev_pro_getsyshnd (mio_dev_t* dev)
{
return MIO_SYSHND_INVALID;
}
static mio_syshnd_t dev_pro_getsyshnd_slave (mio_dev_t* dev)
{
mio_dev_pro_slave_t* pro = (mio_dev_pro_slave_t*)dev;
return (mio_syshnd_t)pro->pfd;
}
static int dev_pro_ioctl (mio_dev_t* dev, int cmd, void* arg)
{
mio_dev_pro_t* rdev = (mio_dev_pro_t*)dev;
switch (cmd)
{
case MIO_DEV_PRO_CLOSE:
{
mio_dev_pro_sid_t sid = *(mio_dev_pro_sid_t*)arg;
if (sid < MIO_DEV_PRO_IN || sid > MIO_DEV_PRO_ERR)
{
rdev->mio->errnum = MIO_EINVAL;
return -1;
}
if (rdev->slave[sid])
{
/* unlike dev_pro_kill_master(), i don't nullify rdev->slave[sid].
* so i treat the closing ioctl as if it's a kill request
* initiated by the slave device itself. */
mio_killdev (rdev->mio, (mio_dev_t*)rdev->slave[sid]);
}
return 0;
}
case MIO_DEV_PRO_KILL_CHILD:
if (rdev->child_pid >= 0)
{
if (kill (rdev->child_pid, SIGKILL) == -1)
{
rdev->mio->errnum = mio_syserrtoerrnum(errno);
return -1;
}
}
return 0;
default:
dev->mio->errnum = MIO_EINVAL;
return -1;
}
}
static mio_dev_mth_t dev_pro_methods =
{
dev_pro_make_master,
dev_pro_kill_master,
dev_pro_getsyshnd,
MIO_NULL,
MIO_NULL,
dev_pro_ioctl
};
static mio_dev_mth_t dev_pro_methods_slave =
{
dev_pro_make_slave,
dev_pro_kill_slave,
dev_pro_getsyshnd_slave,
dev_pro_read_slave,
dev_pro_write_slave,
dev_pro_ioctl
};
/* ========================================================================= */
static int pro_ready (mio_dev_t* dev, int events)
{
/* virtual device. no I/O */
dev->mio->errnum = MIO_EINTERN;
return -1;
}
static int pro_on_read (mio_dev_t* dev, const void* data, mio_iolen_t len, const mio_devaddr_t* srcaddr)
{
/* virtual device. no I/O */
dev->mio->errnum = MIO_EINTERN;
return -1;
}
static int pro_on_write (mio_dev_t* dev, mio_iolen_t wrlen, void* wrctx, const mio_devaddr_t* dstaddr)
{
/* virtual device. no I/O */
dev->mio->errnum = MIO_EINTERN;
return -1;
}
static mio_dev_evcb_t dev_pro_event_callbacks =
{
pro_ready,
pro_on_read,
pro_on_write
};
/* ========================================================================= */
static int pro_ready_slave (mio_dev_t* dev, int events)
{
mio_dev_pro_t* pro = (mio_dev_pro_t*)dev;
if (events & MIO_DEV_EVENT_ERR)
{
pro->mio->errnum = MIO_EDEVERR;
return -1;
}
if (events & MIO_DEV_EVENT_HUP)
{
if (events & (MIO_DEV_EVENT_PRI | MIO_DEV_EVENT_IN | MIO_DEV_EVENT_OUT))
{
/* probably half-open? */
return 1;
}
pro->mio->errnum = MIO_EDEVHUP;
return -1;
}
return 1; /* the device is ok. carry on reading or writing */
}
static int pro_on_read_slave_out (mio_dev_t* dev, const void* data, mio_iolen_t len, const mio_devaddr_t* srcaddr)
{
mio_dev_pro_slave_t* pro = (mio_dev_pro_slave_t*)dev;
return pro->master->on_read (pro->master, data, len, MIO_DEV_PRO_OUT);
}
static int pro_on_read_slave_err (mio_dev_t* dev, const void* data, mio_iolen_t len, const mio_devaddr_t* srcaddr)
{
mio_dev_pro_slave_t* pro = (mio_dev_pro_slave_t*)dev;
return pro->master->on_read (pro->master, data, len, MIO_DEV_PRO_ERR);
}
static int pro_on_write_slave (mio_dev_t* dev, mio_iolen_t wrlen, void* wrctx, const mio_devaddr_t* dstaddr)
{
mio_dev_pro_slave_t* pro = (mio_dev_pro_slave_t*)dev;
return pro->master->on_write (pro->master, wrlen, wrctx);
}
static mio_dev_evcb_t dev_pro_event_callbacks_slave_in =
{
pro_ready_slave,
MIO_NULL,
pro_on_write_slave
};
static mio_dev_evcb_t dev_pro_event_callbacks_slave_out =
{
pro_ready_slave,
pro_on_read_slave_out,
MIO_NULL
};
static mio_dev_evcb_t dev_pro_event_callbacks_slave_err =
{
pro_ready_slave,
pro_on_read_slave_err,
MIO_NULL
};
/* ========================================================================= */
static mio_dev_pro_slave_t* make_slave (mio_t* mio, slave_info_t* si)
{
switch (si->id)
{
case MIO_DEV_PRO_IN:
return (mio_dev_pro_slave_t*)mio_makedev (
mio, MIO_SIZEOF(mio_dev_pro_t),
&dev_pro_methods_slave, &dev_pro_event_callbacks_slave_in, si);
case MIO_DEV_PRO_OUT:
return (mio_dev_pro_slave_t*)mio_makedev (
mio, MIO_SIZEOF(mio_dev_pro_t),
&dev_pro_methods_slave, &dev_pro_event_callbacks_slave_out, si);
case MIO_DEV_PRO_ERR:
return (mio_dev_pro_slave_t*)mio_makedev (
mio, MIO_SIZEOF(mio_dev_pro_t),
&dev_pro_methods_slave, &dev_pro_event_callbacks_slave_err, si);
default:
mio->errnum = MIO_EINVAL;
return MIO_NULL;
}
}
mio_dev_pro_t* mio_dev_pro_make (mio_t* mio, mio_size_t xtnsize, const mio_dev_pro_make_t* info)
{
return (mio_dev_pro_t*)mio_makedev (
mio, MIO_SIZEOF(mio_dev_pro_t) + xtnsize,
&dev_pro_methods, &dev_pro_event_callbacks, (void*)info);
}
void mio_dev_pro_kill (mio_dev_pro_t* dev)
{
mio_killdev (dev->mio, (mio_dev_t*)dev);
}
int mio_dev_pro_write (mio_dev_pro_t* dev, const void* data, mio_iolen_t dlen, void* wrctx)
{
if (dev->slave[0])
{
return mio_dev_write ((mio_dev_t*)dev->slave[0], data, dlen, wrctx, MIO_NULL);
}
else
{
dev->mio->errnum = MIO_ENOCAPA; /* TODO: is it the right error number? */
return -1;
}
}
int mio_dev_pro_timedwrite (mio_dev_pro_t* dev, const void* data, mio_iolen_t dlen, const mio_ntime_t* tmout, void* wrctx)
{
if (dev->slave[0])
{
return mio_dev_timedwrite ((mio_dev_t*)dev->slave[0], data, dlen, tmout, wrctx, MIO_NULL);
}
else
{
dev->mio->errnum = MIO_ENOCAPA; /* TODO: is it the right error number? */
return -1;
}
}
int mio_dev_pro_close (mio_dev_pro_t* dev, mio_dev_pro_sid_t sid)
{
return mio_dev_ioctl ((mio_dev_t*)dev, MIO_DEV_PRO_CLOSE, &sid);
}
int mio_dev_pro_killchild (mio_dev_pro_t* dev)
{
return mio_dev_ioctl ((mio_dev_t*)dev, MIO_DEV_PRO_KILL_CHILD, MIO_NULL);
}
#if 0
mio_dev_pro_t* mio_dev_pro_getdev (mio_dev_pro_t* pro, mio_dev_pro_sid_t sid)
{
switch (type)
{
case MIO_DEV_PRO_IN:
return XXX;
case MIO_DEV_PRO_OUT:
return XXX;
case MIO_DEV_PRO_ERR:
return XXX;
}
pro->dev->mio = MIO_EINVAL;
return MIO_NULL;
}
#endif

164
mio/lib/mio-pro.h Normal file
View File

@ -0,0 +1,164 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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.
*/
#ifndef _MIO_PRO_H_
#define _MIO_PRO_H_
#include <mio.h>
enum mio_dev_pro_sid_t
{
MIO_DEV_PRO_MASTER = -1,
MIO_DEV_PRO_IN = 0,
MIO_DEV_PRO_OUT = 1,
MIO_DEV_PRO_ERR = 2
};
typedef enum mio_dev_pro_sid_t mio_dev_pro_sid_t;
typedef struct mio_dev_pro_t mio_dev_pro_t;
typedef struct mio_dev_pro_slave_t mio_dev_pro_slave_t;
typedef int (*mio_dev_pro_on_read_t) (mio_dev_pro_t* dev, const void* data, mio_iolen_t len, mio_dev_pro_sid_t sid);
typedef int (*mio_dev_pro_on_write_t) (mio_dev_pro_t* dev, mio_iolen_t wrlen, void* wrctx);
typedef void (*mio_dev_pro_on_close_t) (mio_dev_pro_t* dev, mio_dev_pro_sid_t sid);
struct mio_dev_pro_t
{
MIO_DEV_HEADERS;
int flags;
mio_intptr_t child_pid;
mio_dev_pro_slave_t* slave[3];
int slave_count;
mio_dev_pro_on_read_t on_read;
mio_dev_pro_on_write_t on_write;
mio_dev_pro_on_close_t on_close;
mio_mchar_t* mcmd;
};
struct mio_dev_pro_slave_t
{
MIO_DEV_HEADERS;
mio_dev_pro_sid_t id;
mio_syshnd_t pfd;
mio_dev_pro_t* master; /* parent device */
};
enum mio_dev_pro_make_flag_t
{
MIO_DEV_PRO_WRITEIN = (1 << 0),
MIO_DEV_PRO_READOUT = (1 << 1),
MIO_DEV_PRO_READERR = (1 << 2),
MIO_DEV_PRO_ERRTOOUT = (1 << 3),
MIO_DEV_PRO_OUTTOERR = (1 << 4),
MIO_DEV_PRO_INTONUL = (1 << 5),
MIO_DEV_PRO_OUTTONUL = (1 << 6),
MIO_DEV_PRO_ERRTONUL = (1 << 7),
STUO_DEV_PRO_DROPIN = (1 << 8),
STUO_DEV_PRO_DROPOUT = (1 << 9),
STUO_DEV_PRO_DROPERR = (1 << 10),
MIO_DEV_PRO_SHELL = (1 << 13),
/* perform no waitpid() on a child process upon device destruction.
* you should set this flag if your application has automatic child
* process reaping enabled. for instance, SIGCHLD is set to SIG_IGN
* on POSIX.1-2001 compliant systems */
MIO_DEV_PRO_FORGET_CHILD = (1 << 14),
MIO_DEV_PRO_FORGET_DIEHARD_CHILD = (1 << 15)
};
typedef enum mio_dev_pro_make_flag_t mio_dev_pro_make_flag_t;
typedef struct mio_dev_pro_make_t mio_dev_pro_make_t;
struct mio_dev_pro_make_t
{
int flags; /**< bitwise-ORed of mio_dev_pro_make_flag_t enumerators */
const void* cmd;
mio_dev_pro_on_write_t on_write; /* mandatory */
mio_dev_pro_on_read_t on_read; /* mandatory */
mio_dev_pro_on_close_t on_close; /* optional */
};
enum mio_dev_pro_ioctl_cmd_t
{
MIO_DEV_PRO_CLOSE,
MIO_DEV_PRO_KILL_CHILD
};
typedef enum mio_dev_pro_ioctl_cmd_t mio_dev_pro_ioctl_cmd_t;
#ifdef __cplusplus
extern "C" {
#endif
MIO_EXPORT mio_dev_pro_t* mio_dev_pro_make (
mio_t* mio,
mio_size_t xtnsize,
const mio_dev_pro_make_t* data
);
MIO_EXPORT void mio_dev_pro_kill (
mio_dev_pro_t* pro
);
MIO_EXPORT int mio_dev_pro_write (
mio_dev_pro_t* pro,
const void* data,
mio_iolen_t len,
void* wrctx
);
MIO_EXPORT int mio_dev_pro_timedwrite (
mio_dev_pro_t* pro,
const void* data,
mio_iolen_t len,
const mio_ntime_t* tmout,
void* wrctx
);
MIO_EXPORT int mio_dev_pro_close (
mio_dev_pro_t* pro,
mio_dev_pro_sid_t sid
);
MIO_EXPORT int mio_dev_pro_killchild (
mio_dev_pro_t* pro
);
#ifdef __cplusplus
}
#endif
#endif

204
mio/lib/mio-prv.h Normal file
View File

@ -0,0 +1,204 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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.
*/
#ifndef _MIO_PRV_H_
#define _MIO_PRV_H_
#include "mio.h"
/*TODO: redefine and remove these */
#include <assert.h>
#include <string.h>
#include <stdio.h>
/*TODO: redefine these */
#define MIO_MEMSET(dst,byte,count) memset(dst,byte,count)
#define MIO_MEMCPY(dst,src,count) memcpy(dst,src,count)
#define MIO_MEMMOVE(dst,src,count) memmove(dst,src,count)
#define MIO_MEMCMP(dst,src,count) memcmp(dst,src,count)
#define MIO_ASSERT assert
typedef struct mio_mux_t mio_mux_t;
struct mio_t
{
mio_mmgr_t* mmgr;
mio_errnum_t errnum;
mio_stopreq_t stopreq; /* stop request to abort mio_loop() */
struct
{
mio_dev_t* head;
mio_dev_t* tail;
} actdev; /* active devices */
struct
{
mio_dev_t* head;
mio_dev_t* tail;
} hltdev; /* halted devices */
struct
{
mio_dev_t* head;
mio_dev_t* tail;
} zmbdev; /* zombie devices */
mio_uint8_t bigbuf[65535]; /* TODO: make this dynamic depending on devices added. device may indicate a buffer size required??? */
unsigned int renew_watch: 1;
unsigned int in_exec: 1;
struct
{
mio_size_t capa;
mio_size_t size;
mio_tmrjob_t* jobs;
} tmr;
/* platform specific fields below */
#if defined(_WIN32)
HANDLE iocp;
#else
mio_mux_t* mux;
#endif
};
#define MIO_EPOCH_YEAR (1970)
#define MIO_EPOCH_MON (1)
#define MIO_EPOCH_DAY (1)
#define MIO_EPOCH_WDAY (4)
/* windows specific epoch time */
#define MIO_EPOCH_YEAR_WIN (1601)
#define MIO_EPOCH_MON_WIN (1)
#define MIO_EPOCH_DAY_WIN (1)
#define MIO_DAYS_PER_WEEK (7)
#define MIO_MONS_PER_YEAR (12)
#define MIO_HOURS_PER_DAY (24)
#define MIO_MINS_PER_HOUR (60)
#define MIO_MINS_PER_DAY (MIO_MINS_PER_HOUR*MIO_HOURS_PER_DAY)
#define MIO_SECS_PER_MIN (60)
#define MIO_SECS_PER_HOUR (MIO_SECS_PER_MIN*MIO_MINS_PER_HOUR)
#define MIO_SECS_PER_DAY (MIO_SECS_PER_MIN*MIO_MINS_PER_DAY)
#define MIO_MSECS_PER_SEC (1000)
#define MIO_MSECS_PER_MIN (MIO_MSECS_PER_SEC*MIO_SECS_PER_MIN)
#define MIO_MSECS_PER_HOUR (MIO_MSECS_PER_SEC*MIO_SECS_PER_HOUR)
#define MIO_MSECS_PER_DAY (MIO_MSECS_PER_SEC*MIO_SECS_PER_DAY)
#define MIO_USECS_PER_MSEC (1000)
#define MIO_NSECS_PER_USEC (1000)
#define MIO_NSECS_PER_MSEC (MIO_NSECS_PER_USEC*MIO_USECS_PER_MSEC)
#define MIO_USECS_PER_SEC (MIO_USECS_PER_MSEC*MIO_MSECS_PER_SEC)
#define MIO_NSECS_PER_SEC (MIO_NSECS_PER_USEC*MIO_USECS_PER_MSEC*MIO_MSECS_PER_SEC)
#define MIO_SECNSEC_TO_MSEC(sec,nsec) \
(((mio_intptr_t)(sec) * MIO_MSECS_PER_SEC) + ((mio_intptr_t)(nsec) / MIO_NSECS_PER_MSEC))
#define MIO_SECNSEC_TO_USEC(sec,nsec) \
(((mio_intptr_t)(sec) * MIO_USECS_PER_SEC) + ((mio_intptr_t)(nsec) / MIO_NSECS_PER_USEC))
#define MIO_SEC_TO_MSEC(sec) ((sec) * MIO_MSECS_PER_SEC)
#define MIO_MSEC_TO_SEC(sec) ((sec) / MIO_MSECS_PER_SEC)
#define MIO_USEC_TO_NSEC(usec) ((usec) * MIO_NSECS_PER_USEC)
#define MIO_NSEC_TO_USEC(nsec) ((nsec) / MIO_NSECS_PER_USEC)
#define MIO_MSEC_TO_NSEC(msec) ((msec) * MIO_NSECS_PER_MSEC)
#define MIO_NSEC_TO_MSEC(nsec) ((nsec) / MIO_NSECS_PER_MSEC)
#define MIO_SEC_TO_NSEC(sec) ((sec) * MIO_NSECS_PER_SEC)
#define MIO_NSEC_TO_SEC(nsec) ((nsec) / MIO_NSECS_PER_SEC)
#define MIO_SEC_TO_USEC(sec) ((sec) * MIO_USECS_PER_SEC)
#define MIO_USEC_TO_SEC(usec) ((usec) / MIO_USECS_PER_SEC)
#ifdef __cplusplus
extern "C" {
#endif
int mio_makesyshndasync (
mio_t* mio,
mio_syshnd_t hnd
);
mio_errnum_t mio_syserrtoerrnum (
int no
);
mio_mchar_t* mio_mbsdup (
mio_t* mio,
const mio_mchar_t* src
);
mio_size_t mio_mbscpy (
mio_mchar_t* buf,
const mio_mchar_t* str
);
int mio_mbsspltrn (
mio_mchar_t* s,
const mio_mchar_t* delim,
mio_mchar_t lquote,
mio_mchar_t rquote,
mio_mchar_t escape,
const mio_mchar_t* trset
);
int mio_mbsspl (
mio_mchar_t* s,
const mio_mchar_t* delim,
mio_mchar_t lquote,
mio_mchar_t rquote,
mio_mchar_t escape
);
void mio_cleartmrjobs (
mio_t* mio
);
void mio_firetmrjobs (
mio_t* mio,
const mio_ntime_t* tmbase,
mio_size_t* firecnt
);
int mio_gettmrtmout (
mio_t* mio,
const mio_ntime_t* tmbase,
mio_ntime_t* tmout
);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

600
mio/lib/mio-sck.h Normal file
View File

@ -0,0 +1,600 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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.
*/
#ifndef _MIO_SCK_H_
#define _MIO_SCK_H_
#include <mio.h>
/* ========================================================================= */
/* TOOD: move these to a separte file */
#define MIO_ETHHDR_PROTO_IP4 0x0800
#define MIO_ETHHDR_PROTO_ARP 0x0806
#define MIO_ETHHDR_PROTO_8021Q 0x8100 /* 802.1Q VLAN */
#define MIO_ETHHDR_PROTO_IP6 0x86DD
#define MIO_ARPHDR_OPCODE_REQUEST 1
#define MIO_ARPHDR_OPCODE_REPLY 2
#define MIO_ARPHDR_HTYPE_ETH 0x0001
#define MIO_ARPHDR_PTYPE_IP4 0x0800
#define MIO_ETHADDR_LEN 6
#define MIO_IP4ADDR_LEN 4
#define MIO_IP6ADDR_LEN 16
#if defined(__GNUC__)
# define MIO_PACKED __attribute__((__packed__))
#else
# define MIO_PACKED
# MIO_PACK_PUSH pack(push)
# MIO_PACK_PUSH pack(push)
# MIO_PACK(x) pack(x)
#endif
#if defined(__GNUC__)
/* nothing */
#else
#pragma pack(push)
#pragma pack(1)
#endif
struct MIO_PACKED mio_ethaddr_t
{
mio_uint8_t v[MIO_ETHADDR_LEN];
};
typedef struct mio_ethaddr_t mio_ethaddr_t;
struct MIO_PACKED mio_ip4addr_t
{
mio_uint8_t v[MIO_IP4ADDR_LEN];
};
typedef struct mio_ip4addr_t mio_ip4addr_t;
struct MIO_PACKED mio_ip6addr_t
{
mio_uint8_t v[MIO_IP6ADDR_LEN];
};
typedef struct mio_ip6addr_t mio_ip6addr_t;
struct MIO_PACKED mio_ethhdr_t
{
mio_uint8_t dest[MIO_ETHADDR_LEN];
mio_uint8_t source[MIO_ETHADDR_LEN];
mio_uint16_t proto;
};
typedef struct mio_ethhdr_t mio_ethhdr_t;
struct MIO_PACKED mio_arphdr_t
{
mio_uint16_t htype; /* hardware type (ethernet: 0x0001) */
mio_uint16_t ptype; /* protocol type (ipv4: 0x0800) */
mio_uint8_t hlen; /* hardware address length (ethernet: 6) */
mio_uint8_t plen; /* protocol address length (ipv4 :4) */
mio_uint16_t opcode; /* operation code */
};
typedef struct mio_arphdr_t mio_arphdr_t;
/* arp payload for ipv4 over ethernet */
struct MIO_PACKED mio_etharp_t
{
mio_uint8_t sha[MIO_ETHADDR_LEN]; /* source hardware address */
mio_uint8_t spa[MIO_IP4ADDR_LEN]; /* source protocol address */
mio_uint8_t tha[MIO_ETHADDR_LEN]; /* target hardware address */
mio_uint8_t tpa[MIO_IP4ADDR_LEN]; /* target protocol address */
};
typedef struct mio_etharp_t mio_etharp_t;
struct MIO_PACKED mio_etharp_pkt_t
{
mio_ethhdr_t ethhdr;
mio_arphdr_t arphdr;
mio_etharp_t arppld;
};
typedef struct mio_etharp_pkt_t mio_etharp_pkt_t;
struct mio_iphdr_t
{
#if defined(MIO_ENDIAN_LITTLE)
mio_uint8_t ihl:4;
mio_uint8_t version:4;
#elif defined(MIO_ENDIAN_BIG)
mio_uint8_t version:4;
mio_uint8_t ihl:4;
#else
# UNSUPPORTED ENDIAN
#endif
mio_int8_t tos;
mio_int16_t tot_len;
mio_int16_t id;
mio_int16_t frag_off;
mio_int8_t ttl;
mio_int8_t protocol;
mio_int16_t check;
mio_int32_t saddr;
mio_int32_t daddr;
/*The options start here. */
};
typedef struct mio_iphdr_t mio_iphdr_t;
struct MIO_PACKED mio_icmphdr_t
{
mio_uint8_t type; /* message type */
mio_uint8_t code; /* subcode */
mio_uint16_t checksum;
union
{
struct
{
mio_uint16_t id;
mio_uint16_t seq;
} echo;
mio_uint32_t gateway;
struct
{
mio_uint16_t frag_unused;
mio_uint16_t mtu;
} frag; /* path mut discovery */
} u;
};
typedef struct mio_icmphdr_t mio_icmphdr_t;
#if defined(__GNUC__)
/* nothing */
#else
#pragma pack(pop)
#endif
/* ICMP types */
#define MIO_ICMP_ECHO_REPLY 0
#define MIO_ICMP_UNREACH 3 /* destination unreachable */
#define MIO_ICMP_SOURCE_QUENCE 4
#define MIO_ICMP_REDIRECT 5
#define MIO_ICMP_ECHO_REQUEST 8
#define MIO_ICMP_TIME_EXCEEDED 11
#define MIO_ICMP_PARAM_PROBLEM 12
#define MIO_ICMP_TIMESTAMP_REQUEST 13
#define MIO_ICMP_TIMESTAMP_REPLY 14
#define MIO_ICMP_INFO_REQUEST 15
#define MIO_ICMP_INFO_REPLY 16
#define MIO_ICMP_ADDR_MASK_REQUEST 17
#define MIO_ICMP_ADDR_MASK_REPLY 18
/* Subcode for MIO_ICMP_UNREACH */
#define MIO_ICMP_UNREACH_NET 0
#define MIO_ICMP_UNREACH_HOST 1
#define MIO_ICMP_UNREACH_PROTOCOL 2
#define MIO_ICMP_UNREACH_PORT 3
#define MIO_ICMP_UNREACH_FRAG_NEEDED 4
/* Subcode for MIO_ICMP_REDIRECT */
#define MIO_ICMP_REDIRECT_NET 0
#define MIO_ICMP_REDIRECT_HOST 1
#define MIO_ICMP_REDIRECT_NETTOS 2
#define MIO_ICMP_REDIRECT_HOSTTOS 3
/* Subcode for MIO_ICMP_TIME_EXCEEDED */
#define MIO_ICMP_TIME_EXCEEDED_TTL 0
#define MIO_ICMP_TIME_EXCEEDED_FRAGTIME 1
/* ========================================================================= */
typedef int mio_sckfam_t;
struct mio_sckaddr_t
{
mio_sckfam_t family;
mio_uint8_t data[128]; /* TODO: use the actual sockaddr size */
};
typedef struct mio_sckaddr_t mio_sckaddr_t;
#if (MIO_SIZEOF_SOCKLEN_T == MIO_SIZEOF_INT)
#if defined(MIO_SOCKLEN_T_IS_SIGNED)
typedef int mio_scklen_t;
#else
typedef unsigned int mio_scklen_t;
#endif
#elif (MIO_SIZEOF_SOCKLEN_T == MIO_SIZEOF_LONG)
#if defined(MIO_SOCKLEN_T_IS_SIGNED)
typedef long mio_scklen_t;
#else
typedef unsigned long mio_scklen_t;
#endif
#else
typedef int mio_scklen_t;
#endif
#if defined(_WIN32)
# define MIO_IOCP_KEY 1
/*
typedef HANDLE mio_syshnd_t;
typedef SOCKET mio_sckhnd_t;
# define MIO_SCKHND_INVALID (INVALID_SOCKET)
*/
typedef mio_uintptr_t qse_sckhnd_t;
# define MIO_SCKHND_INVALID (~(qse_sck_hnd_t)0)
#else
typedef int mio_sckhnd_t;
# define MIO_SCKHND_INVALID (-1)
#endif
/* ========================================================================= */
enum mio_dev_sck_ioctl_cmd_t
{
MIO_DEV_SCK_BIND,
MIO_DEV_SCK_CONNECT,
MIO_DEV_SCK_LISTEN
};
typedef enum mio_dev_sck_ioctl_cmd_t mio_dev_sck_ioctl_cmd_t;
#define MIO_DEV_SCK_SET_PROGRESS(dev,bit) do { \
(dev)->state &= ~MIO_DEV_SCK_ALL_PROGRESS_BITS; \
(dev)->state |= (bit); \
} while(0)
#define MIO_DEV_SCK_GET_PROGRESS(dev) ((dev)->state & MIO_DEV_SCK_ALL_PROGRESS_BITS)
enum mio_dev_sck_state_t
{
/* the following items(progress bits) are mutually exclusive */
MIO_DEV_SCK_CONNECTING = (1 << 0),
MIO_DEV_SCK_CONNECTING_SSL = (1 << 1),
MIO_DEV_SCK_CONNECTED = (1 << 2),
MIO_DEV_SCK_LISTENING = (1 << 3),
MIO_DEV_SCK_ACCEPTING_SSL = (1 << 4),
MIO_DEV_SCK_ACCEPTED = (1 << 5),
/* the following items can be bitwise-ORed with an exclusive item above */
MIO_DEV_SCK_INTERCEPTED = (1 << 15),
/* convenience bit masks */
MIO_DEV_SCK_ALL_PROGRESS_BITS = (MIO_DEV_SCK_CONNECTING |
MIO_DEV_SCK_CONNECTING_SSL |
MIO_DEV_SCK_CONNECTED |
MIO_DEV_SCK_LISTENING |
MIO_DEV_SCK_ACCEPTING_SSL |
MIO_DEV_SCK_ACCEPTED)
};
typedef enum mio_dev_sck_state_t mio_dev_sck_state_t;
typedef struct mio_dev_sck_t mio_dev_sck_t;
typedef int (*mio_dev_sck_on_read_t) (
mio_dev_sck_t* dev,
const void* data,
mio_iolen_t dlen,
const mio_sckaddr_t* srcaddr
);
typedef int (*mio_dev_sck_on_write_t) (
mio_dev_sck_t* dev,
mio_iolen_t wrlen,
void* wrctx,
const mio_sckaddr_t* dstaddr
);
typedef void (*mio_dev_sck_on_disconnect_t) (
mio_dev_sck_t* dev
);
typedef int (*mio_dev_sck_on_connect_t) (
mio_dev_sck_t* dev
);
enum mio_dev_sck_type_t
{
MIO_DEV_SCK_TCP4,
MIO_DEV_SCK_TCP6,
MIO_DEV_SCK_UPD4,
MIO_DEV_SCK_UDP6,
/* ARP at the ethernet layer */
MIO_DEV_SCK_ARP,
MIO_DEV_SCK_ARP_DGRAM,
/* ICMP at the IPv4 layer */
MIO_DEV_SCK_ICMP4,
/* ICMP at the IPv6 layer */
MIO_DEV_SCK_ICMP6
#if 0
MIO_DEV_SCK_RAW, /* raw L2-level packet */
#endif
};
typedef enum mio_dev_sck_type_t mio_dev_sck_type_t;
typedef struct mio_dev_sck_make_t mio_dev_sck_make_t;
struct mio_dev_sck_make_t
{
mio_dev_sck_type_t type;
mio_dev_sck_on_write_t on_write;
mio_dev_sck_on_read_t on_read;
mio_dev_sck_on_disconnect_t on_disconnect;
};
enum mio_dev_sck_bind_option_t
{
MIO_DEV_SCK_BIND_BROADCAST = (1 << 0),
MIO_DEV_SCK_BIND_REUSEADDR = (1 << 1),
MIO_DEV_SCK_BIND_REUSEPORT = (1 << 2),
MIO_DEV_SCK_BIND_TRANSPARENT = (1 << 3),
/* TODO: more options --- SO_RCVBUF, SO_SNDBUF, SO_RCVTIMEO, SO_SNDTIMEO, SO_KEEPALIVE */
/* BINDTODEVICE??? */
MIO_DEV_SCK_BIND_SSL = (1 << 15)
};
typedef enum mio_dev_sck_bind_option_t mio_dev_sck_bind_option_t;
typedef struct mio_dev_sck_bind_t mio_dev_sck_bind_t;
struct mio_dev_sck_bind_t
{
int options;
mio_sckaddr_t localaddr;
/* TODO: add device name for BIND_TO_DEVICE */
const mio_mchar_t* ssl_certfile;
const mio_mchar_t* ssl_keyfile;
mio_ntime_t accept_tmout;
};
enum mio_def_sck_connect_option_t
{
MIO_DEV_SCK_CONNECT_SSL = (1 << 15)
};
typedef enum mio_dev_sck_connect_option_t mio_dev_sck_connect_option_t;
typedef struct mio_dev_sck_connect_t mio_dev_sck_connect_t;
struct mio_dev_sck_connect_t
{
int options;
mio_sckaddr_t remoteaddr;
mio_ntime_t connect_tmout;
mio_dev_sck_on_connect_t on_connect;
};
typedef struct mio_dev_sck_listen_t mio_dev_sck_listen_t;
struct mio_dev_sck_listen_t
{
int backlogs;
mio_dev_sck_on_connect_t on_connect; /* optional, but new connections are dropped immediately without this */
};
typedef struct mio_dev_sck_accept_t mio_dev_sck_accept_t;
struct mio_dev_sck_accept_t
{
mio_syshnd_t sck;
/* TODO: add timeout */
mio_sckaddr_t remoteaddr;
};
struct mio_dev_sck_t
{
MIO_DEV_HEADERS;
mio_dev_sck_type_t type;
mio_sckhnd_t sck;
int state;
/* remote peer address for a stateful stream socket. valid if one of the
* followings is set in state:
* MIO_DEV_TCP_ACCEPTING_SSL
* MIO_DEV_TCP_ACCEPTED
* MIO_DEV_TCP_CONNECTED
* MIO_DEV_TCP_CONNECTING
* MIO_DEV_TCP_CONNECTING_SSL
*
* also used as a placeholder to store source address for
* a stateless socket */
mio_sckaddr_t remoteaddr;
/* local socket address */
mio_sckaddr_t localaddr;
/* original destination address */
mio_sckaddr_t orgdstaddr;
mio_dev_sck_on_write_t on_write;
mio_dev_sck_on_read_t on_read;
/* return 0 on succes, -1 on failure.
* called on a new tcp device for an accepted client or
* on a tcp device conntected to a remote server */
mio_dev_sck_on_connect_t on_connect;
mio_dev_sck_on_disconnect_t on_disconnect;
/* timer job index for handling
* - connect() timeout for a connecting socket.
* - SSL_accept() timeout for a socket accepting SSL */
mio_tmridx_t tmrjob_index;
/* connect timeout, ssl-connect timeout, ssl-accept timeout.
* it denotes timeout duration under some circumstances
* or an absolute expiry time under some other circumstances. */
mio_ntime_t tmout;
void* ssl_ctx;
void* ssl;
};
#ifdef __cplusplus
extern "C" {
#endif
MIO_EXPORT mio_sckhnd_t mio_openasyncsck (
mio_t* mio,
int domain,
int type,
int proto
);
MIO_EXPORT void mio_closeasyncsck (
mio_t* mio,
mio_sckhnd_t sck
);
MIO_EXPORT int mio_makesckasync (
mio_t* mio,
mio_sckhnd_t sck
);
MIO_EXPORT int mio_getsckaddrinfo (
mio_t* mio,
const mio_sckaddr_t* addr,
mio_scklen_t* len,
mio_sckfam_t* family
);
/*
* The mio_getsckaddrport() function returns the port number of a socket
* address in the host byte order. If the address doesn't support the port
* number, it returns 0.
*/
MIO_EXPORT mio_uint16_t mio_getsckaddrport (
const mio_sckaddr_t* addr
);
/*
* The mio_getsckaddrifindex() function returns an interface number.
* If the address doesn't support the interface number, it returns 0. */
MIO_EXPORT int mio_getsckaddrifindex (
const mio_sckaddr_t* addr
);
MIO_EXPORT void mio_sckaddr_initforip4 (
mio_sckaddr_t* sckaddr,
mio_uint16_t port,
mio_ip4addr_t* ip4addr
);
MIO_EXPORT void mio_sckaddr_initforip6 (
mio_sckaddr_t* sckaddr,
mio_uint16_t port,
mio_ip6addr_t* ip6addr
);
MIO_EXPORT void mio_sckaddr_initforeth (
mio_sckaddr_t* sckaddr,
int ifindex,
mio_ethaddr_t* ethaddr
);
/* ========================================================================= */
MIO_EXPORT mio_dev_sck_t* mio_dev_sck_make (
mio_t* mio,
mio_size_t xtnsize,
const mio_dev_sck_make_t* info
);
MIO_EXPORT int mio_dev_sck_bind (
mio_dev_sck_t* dev,
mio_dev_sck_bind_t* info
);
MIO_EXPORT int mio_dev_sck_connect (
mio_dev_sck_t* dev,
mio_dev_sck_connect_t* info
);
MIO_EXPORT int mio_dev_sck_listen (
mio_dev_sck_t* dev,
mio_dev_sck_listen_t* info
);
MIO_EXPORT int mio_dev_sck_write (
mio_dev_sck_t* dev,
const void* data,
mio_iolen_t len,
void* wrctx,
const mio_sckaddr_t* dstaddr
);
MIO_EXPORT int mio_dev_sck_timedwrite (
mio_dev_sck_t* dev,
const void* data,
mio_iolen_t len,
const mio_ntime_t* tmout,
void* wrctx,
const mio_sckaddr_t* dstaddr
);
#if defined(MIO_HAVE_INLINE)
static MIO_INLINE void mio_dev_sck_halt (mio_dev_sck_t* sck)
{
mio_dev_halt ((mio_dev_t*)sck);
}
static MIO_INLINE int mio_dev_sck_read (mio_dev_sck_t* sck, int enabled)
{
return mio_dev_read ((mio_dev_t*)sck, enabled);
}
#else
#define mio_dev_sck_halt(sck) mio_dev_halt((mio_dev_t*)sck)
#define mio_dev_sck_read(sck,enabled) mio_dev_read((mio_dev_t*)sck, enabled)
#endif
MIO_EXPORT mio_uint16_t mio_checksumip (
const void* hdr,
mio_size_t len
);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -24,7 +24,7 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "stio-prv.h"
#include "mio-prv.h"
#if defined(_WIN32)
# include <windows.h>
@ -48,12 +48,12 @@
#endif
#if defined(_WIN32)
#define EPOCH_DIFF_YEARS (STIO_EPOCH_YEAR-STIO_EPOCH_YEAR_WIN)
#define EPOCH_DIFF_DAYS ((stio_intptr_t)EPOCH_DIFF_YEARS*365+EPOCH_DIFF_YEARS/4-3)
#define EPOCH_DIFF_SECS ((stio_intptr_t)EPOCH_DIFF_DAYS*24*60*60)
#define EPOCH_DIFF_YEARS (MIO_EPOCH_YEAR-MIO_EPOCH_YEAR_WIN)
#define EPOCH_DIFF_DAYS ((mio_intptr_t)EPOCH_DIFF_YEARS*365+EPOCH_DIFF_YEARS/4-3)
#define EPOCH_DIFF_SECS ((mio_intptr_t)EPOCH_DIFF_DAYS*24*60*60)
#endif
void stio_gettime (stio_ntime_t* t)
void mio_gettime (mio_ntime_t* t)
{
#if defined(_WIN32)
SYSTEMTIME st;
@ -72,13 +72,13 @@ void stio_gettime (stio_ntime_t* t)
li.HighPart = ft.dwHighDateTime;
/* li.QuadPart is in the 100-nanosecond intervals */
t->sec = (li.QuadPart / (STIO_NSECS_PER_SEC / 100)) - EPOCH_DIFF_SECS;
t->nsec = (li.QuadPart % (STIO_NSECS_PER_SEC / 100)) * 100;
t->sec = (li.QuadPart / (MIO_NSECS_PER_SEC / 100)) - EPOCH_DIFF_SECS;
t->nsec = (li.QuadPart % (MIO_NSECS_PER_SEC / 100)) * 100;
#elif defined(__OS2__)
DATETIME dt;
stio_btime_t bt;
mio_btime_t bt;
/* Can I use DosQuerySysInfo(QSV_TIME_LOW) and
* DosQuerySysInfo(QSV_TIME_HIGH) for this instead?
@ -88,7 +88,7 @@ void stio_gettime (stio_ntime_t* t)
DosGetDateTime (&dt);
/* DosGetDateTime() never fails. it always returns NO_ERROR */
bt.year = dt.year - STIO_BTIME_YEAR_BASE;
bt.year = dt.year - MIO_BTIME_YEAR_BASE;
bt.mon = dt.month - 1;
bt.mday = dt.day;
bt.hour = dt.hours;
@ -97,14 +97,14 @@ void stio_gettime (stio_ntime_t* t)
/*bt.msec = dt.hundredths * 10;*/
bt.isdst = -1; /* determine dst for me */
if (stio_timelocal (&bt, t) <= -1)
if (mio_timelocal (&bt, t) <= -1)
{
t->sec = time (STIO_NULL);
t->sec = time (MIO_NULL);
t->nsec = 0;
}
else
{
t->nsec = STIO_MSEC_TO_NSEC(dt.hundredths * 10);
t->nsec = MIO_MSEC_TO_NSEC(dt.hundredths * 10);
}
return 0;
@ -112,12 +112,12 @@ void stio_gettime (stio_ntime_t* t)
struct dostime_t dt;
struct dosdate_t dd;
stio_btime_t bt;
mio_btime_t bt;
_dos_gettime (&dt);
_dos_getdate (&dd);
bt.year = dd.year - STIO_BTIME_YEAR_BASE;
bt.year = dd.year - MIO_BTIME_YEAR_BASE;
bt.mon = dd.month - 1;
bt.mday = dd.day;
bt.hour = dt.hour;
@ -126,14 +126,14 @@ void stio_gettime (stio_ntime_t* t)
/*bt.msec = dt.hsecond * 10; */
bt.isdst = -1; /* determine dst for me */
if (stio_timelocal (&bt, t) <= -1)
if (mio_timelocal (&bt, t) <= -1)
{
t->sec = time (STIO_NULL);
t->sec = time (MIO_NULL);
t->nsec = 0;
}
else
{
t->nsec = STIO_MSEC_TO_NSEC(dt.hsecond * 10);
t->nsec = MIO_MSEC_TO_NSEC(dt.hsecond * 10);
}
#elif defined(macintosh)
@ -150,11 +150,11 @@ void stio_gettime (stio_ntime_t* t)
{
#if defined(HAVE_GETTIMEOFDAY)
struct timeval tv;
gettimeofday (&tv, STIO_NULL);
gettimeofday (&tv, MIO_NULL);
t->sec = tv.tv_sec;
t->nsec = STIO_USEC_TO_NSEC(tv.tv_usec);
t->nsec = MIO_USEC_TO_NSEC(tv.tv_usec);
#else
t->sec = time (STIO_NULL);
t->sec = time (MIO_NULL);
t->nsec = 0;
#endif
}
@ -164,35 +164,35 @@ void stio_gettime (stio_ntime_t* t)
#elif defined(HAVE_GETTIMEOFDAY)
struct timeval tv;
gettimeofday (&tv, STIO_NULL);
gettimeofday (&tv, MIO_NULL);
t->sec = tv.tv_sec;
t->nsec = STIO_USEC_TO_NSEC(tv.tv_usec);
t->nsec = MIO_USEC_TO_NSEC(tv.tv_usec);
#else
t->sec = time (STIO_NULL);
t->sec = time (MIO_NULL);
t->nsec = 0;
#endif
}
void stio_addtime (const stio_ntime_t* x, const stio_ntime_t* y, stio_ntime_t* z)
void mio_addtime (const mio_ntime_t* x, const mio_ntime_t* y, mio_ntime_t* z)
{
STIO_ASSERT (x->nsec >= 0 && x->nsec < STIO_NSECS_PER_SEC);
STIO_ASSERT (y->nsec >= 0 && y->nsec < STIO_NSECS_PER_SEC);
MIO_ASSERT (x->nsec >= 0 && x->nsec < MIO_NSECS_PER_SEC);
MIO_ASSERT (y->nsec >= 0 && y->nsec < MIO_NSECS_PER_SEC);
z->sec = x->sec + y->sec;
z->nsec = x->nsec + y->nsec;
if (z->nsec >= STIO_NSECS_PER_SEC)
if (z->nsec >= MIO_NSECS_PER_SEC)
{
z->sec = z->sec + 1;
z->nsec = z->nsec - STIO_NSECS_PER_SEC;
z->nsec = z->nsec - MIO_NSECS_PER_SEC;
}
}
void stio_subtime (const stio_ntime_t* x, const stio_ntime_t* y, stio_ntime_t* z)
void mio_subtime (const mio_ntime_t* x, const mio_ntime_t* y, mio_ntime_t* z)
{
STIO_ASSERT (x->nsec >= 0 && x->nsec < STIO_NSECS_PER_SEC);
STIO_ASSERT (y->nsec >= 0 && y->nsec < STIO_NSECS_PER_SEC);
MIO_ASSERT (x->nsec >= 0 && x->nsec < MIO_NSECS_PER_SEC);
MIO_ASSERT (y->nsec >= 0 && y->nsec < MIO_NSECS_PER_SEC);
z->sec = x->sec - y->sec;
z->nsec = x->nsec - y->nsec;
@ -200,6 +200,6 @@ void stio_subtime (const stio_ntime_t* x, const stio_ntime_t* y, stio_ntime_t* z
if (z->nsec < 0)
{
z->sec = z->sec - 1;
z->nsec = z->nsec + STIO_NSECS_PER_SEC;
z->nsec = z->nsec + MIO_NSECS_PER_SEC;
}
}

234
mio/lib/mio-tmr.c Normal file
View File

@ -0,0 +1,234 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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 "mio-prv.h"
#define HEAP_PARENT(x) (((x) - 1) / 2)
#define HEAP_LEFT(x) ((x) * 2 + 1)
#define HEAP_RIGHT(x) ((x) * 2 + 2)
#define YOUNGER_THAN(x,y) (mio_cmptime(&(x)->when, &(y)->when) < 0)
void mio_cleartmrjobs (mio_t* mio)
{
while (mio->tmr.size > 0) mio_deltmrjob (mio, 0);
}
static mio_tmridx_t sift_up (mio_t* mio, mio_tmridx_t index, int notify)
{
mio_tmridx_t parent;
parent = HEAP_PARENT(index);
if (index > 0 && YOUNGER_THAN(&mio->tmr.jobs[index], &mio->tmr.jobs[parent]))
{
mio_tmrjob_t item;
item = mio->tmr.jobs[index];
do
{
/* move down the parent to my current position */
mio->tmr.jobs[index] = mio->tmr.jobs[parent];
if (mio->tmr.jobs[index].idxptr) *mio->tmr.jobs[index].idxptr = index;
/* traverse up */
index = parent;
parent = HEAP_PARENT(parent);
}
while (index > 0 && YOUNGER_THAN(&item, &mio->tmr.jobs[parent]));
mio->tmr.jobs[index] = item;
if (mio->tmr.jobs[index].idxptr) *mio->tmr.jobs[index].idxptr = index;
}
return index;
}
static mio_tmridx_t sift_down (mio_t* mio, mio_tmridx_t index, int notify)
{
mio_size_t base = mio->tmr.size / 2;
if (index < base) /* at least 1 child is under the 'index' position */
{
mio_tmrjob_t item;
item = mio->tmr.jobs[index];
do
{
mio_tmridx_t left, right, younger;
left = HEAP_LEFT(index);
right = HEAP_RIGHT(index);
if (right < mio->tmr.size && YOUNGER_THAN(&mio->tmr.jobs[right], &mio->tmr.jobs[left]))
{
younger = right;
}
else
{
younger = left;
}
if (YOUNGER_THAN(&item, &mio->tmr.jobs[younger])) break;
mio->tmr.jobs[index] = mio->tmr.jobs[younger];
if (mio->tmr.jobs[index].idxptr) *mio->tmr.jobs[index].idxptr = index;
index = younger;
}
while (index < base);
mio->tmr.jobs[index] = item;
if (mio->tmr.jobs[index].idxptr) *mio->tmr.jobs[index].idxptr = index;
}
return index;
}
void mio_deltmrjob (mio_t* mio, mio_tmridx_t index)
{
mio_tmrjob_t item;
MIO_ASSERT (index < mio->tmr.size);
item = mio->tmr.jobs[index];
if (mio->tmr.jobs[index].idxptr) *mio->tmr.jobs[index].idxptr = MIO_TMRIDX_INVALID;
mio->tmr.size = mio->tmr.size - 1;
if (mio->tmr.size > 0 && index != mio->tmr.size)
{
mio->tmr.jobs[index] = mio->tmr.jobs[mio->tmr.size];
if (mio->tmr.jobs[index].idxptr) *mio->tmr.jobs[index].idxptr = index;
YOUNGER_THAN(&mio->tmr.jobs[index], &item)? sift_up(mio, index, 1): sift_down(mio, index, 1);
}
}
mio_tmridx_t mio_instmrjob (mio_t* mio, const mio_tmrjob_t* job)
{
mio_tmridx_t index = mio->tmr.size;
if (index >= mio->tmr.capa)
{
mio_tmrjob_t* tmp;
mio_size_t new_capa;
MIO_ASSERT (mio->tmr.capa >= 1);
new_capa = mio->tmr.capa * 2;
tmp = (mio_tmrjob_t*)MIO_MMGR_REALLOC (mio->mmgr, mio->tmr.jobs, new_capa * MIO_SIZEOF(*tmp));
if (tmp == MIO_NULL)
{
mio->errnum = MIO_ENOMEM;
return MIO_TMRIDX_INVALID;
}
mio->tmr.jobs = tmp;
mio->tmr.capa = new_capa;
}
mio->tmr.size = mio->tmr.size + 1;
mio->tmr.jobs[index] = *job;
if (mio->tmr.jobs[index].idxptr) *mio->tmr.jobs[index].idxptr = index;
return sift_up (mio, index, 0);
}
mio_tmridx_t mio_updtmrjob (mio_t* mio, mio_tmridx_t index, const mio_tmrjob_t* job)
{
mio_tmrjob_t item;
item = mio->tmr.jobs[index];
mio->tmr.jobs[index] = *job;
if (mio->tmr.jobs[index].idxptr) *mio->tmr.jobs[index].idxptr = index;
return YOUNGER_THAN(job, &item)? sift_up (mio, index, 0): sift_down (mio, index, 0);
}
void mio_firetmrjobs (mio_t* mio, const mio_ntime_t* tm, mio_size_t* firecnt)
{
mio_ntime_t now;
mio_tmrjob_t tmrjob;
mio_size_t count = 0;
/* if the current time is not specified, get it from the system */
if (tm) now = *tm;
else mio_gettime (&now);
while (mio->tmr.size > 0)
{
if (mio_cmptime(&mio->tmr.jobs[0].when, &now) > 0) break;
tmrjob = mio->tmr.jobs[0]; /* copy the scheduled job */
mio_deltmrjob (mio, 0); /* deschedule the job */
count++;
tmrjob.handler (mio, &now, &tmrjob); /* then fire the job */
}
if (firecnt) *firecnt = count;
}
int mio_gettmrtmout (mio_t* mio, const mio_ntime_t* tm, mio_ntime_t* tmout)
{
mio_ntime_t now;
/* time-out can't be calculated when there's no job scheduled */
if (mio->tmr.size <= 0)
{
mio->errnum = MIO_ENOENT;
return -1;
}
/* if the current time is not specified, get it from the system */
if (tm) now = *tm;
else mio_gettime (&now);
mio_subtime (&mio->tmr.jobs[0].when, &now, tmout);
if (tmout->sec < 0) mio_cleartime (tmout);
return 0;
}
mio_tmrjob_t* mio_gettmrjob (mio_t* mio, mio_tmridx_t index)
{
if (index < 0 || index >= mio->tmr.size)
{
mio->errnum = MIO_ENOENT;
return MIO_NULL;
}
return &mio->tmr.jobs[index];
}
int mio_gettmrjobdeadline (mio_t* mio, mio_tmridx_t index, mio_ntime_t* deadline)
{
if (index < 0 || index >= mio->tmr.size)
{
mio->errnum = MIO_ENOENT;
return -1;
}
*deadline = mio->tmr.jobs[index].when;
return 0;
}

524
mio/lib/mio-utl.c Normal file
View File

@ -0,0 +1,524 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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 "mio-prv.h"
/* ========================================================================= */
#if defined(MIO_HAVE_UINT16_T)
mio_uint16_t mio_ntoh16 (mio_uint16_t x)
{
#if defined(MIO_ENDIAN_BIG)
return x;
#elif defined(MIO_ENDIAN_LITTLE)
mio_uint8_t* c = (mio_uint8_t*)&x;
return (mio_uint16_t)(
((mio_uint16_t)c[0] << 8) |
((mio_uint16_t)c[1] << 0));
#else
# error Unknown endian
#endif
}
mio_uint16_t mio_hton16 (mio_uint16_t x)
{
#if defined(MIO_ENDIAN_BIG)
return x;
#elif defined(MIO_ENDIAN_LITTLE)
mio_uint8_t* c = (mio_uint8_t*)&x;
return (mio_uint16_t)(
((mio_uint16_t)c[0] << 8) |
((mio_uint16_t)c[1] << 0));
#else
# error Unknown endian
#endif
}
#endif
/* ========================================================================= */
#if defined(MIO_HAVE_UINT32_T)
mio_uint32_t mio_ntoh32 (mio_uint32_t x)
{
#if defined(MIO_ENDIAN_BIG)
return x;
#elif defined(MIO_ENDIAN_LITTLE)
mio_uint8_t* c = (mio_uint8_t*)&x;
return (mio_uint32_t)(
((mio_uint32_t)c[0] << 24) |
((mio_uint32_t)c[1] << 16) |
((mio_uint32_t)c[2] << 8) |
((mio_uint32_t)c[3] << 0));
#else
# error Unknown endian
#endif
}
mio_uint32_t mio_hton32 (mio_uint32_t x)
{
#if defined(MIO_ENDIAN_BIG)
return x;
#elif defined(MIO_ENDIAN_LITTLE)
mio_uint8_t* c = (mio_uint8_t*)&x;
return (mio_uint32_t)(
((mio_uint32_t)c[0] << 24) |
((mio_uint32_t)c[1] << 16) |
((mio_uint32_t)c[2] << 8) |
((mio_uint32_t)c[3] << 0));
#else
# error Unknown endian
#endif
}
#endif
/* ========================================================================= */
#if defined(MIO_HAVE_UINT64_T)
mio_uint64_t mio_ntoh64 (mio_uint64_t x)
{
#if defined(MIO_ENDIAN_BIG)
return x;
#elif defined(MIO_ENDIAN_LITTLE)
mio_uint8_t* c = (mio_uint8_t*)&x;
return (mio_uint64_t)(
((mio_uint64_t)c[0] << 56) |
((mio_uint64_t)c[1] << 48) |
((mio_uint64_t)c[2] << 40) |
((mio_uint64_t)c[3] << 32) |
((mio_uint64_t)c[4] << 24) |
((mio_uint64_t)c[5] << 16) |
((mio_uint64_t)c[6] << 8) |
((mio_uint64_t)c[7] << 0));
#else
# error Unknown endian
#endif
}
mio_uint64_t mio_hton64 (mio_uint64_t x)
{
#if defined(MIO_ENDIAN_BIG)
return x;
#elif defined(MIO_ENDIAN_LITTLE)
mio_uint8_t* c = (mio_uint8_t*)&x;
return (mio_uint64_t)(
((mio_uint64_t)c[0] << 56) |
((mio_uint64_t)c[1] << 48) |
((mio_uint64_t)c[2] << 40) |
((mio_uint64_t)c[3] << 32) |
((mio_uint64_t)c[4] << 24) |
((mio_uint64_t)c[5] << 16) |
((mio_uint64_t)c[6] << 8) |
((mio_uint64_t)c[7] << 0));
#else
# error Unknown endian
#endif
}
#endif
/* ========================================================================= */
#if defined(MIO_HAVE_UINT128_T)
mio_uint128_t mio_ntoh128 (mio_uint128_t x)
{
#if defined(MIO_ENDIAN_BIG)
return x;
#elif defined(MIO_ENDIAN_LITTLE)
mio_uint8_t* c = (mio_uint8_t*)&x;
return (mio_uint128_t)(
((mio_uint128_t)c[0] << 120) |
((mio_uint128_t)c[1] << 112) |
((mio_uint128_t)c[2] << 104) |
((mio_uint128_t)c[3] << 96) |
((mio_uint128_t)c[4] << 88) |
((mio_uint128_t)c[5] << 80) |
((mio_uint128_t)c[6] << 72) |
((mio_uint128_t)c[7] << 64) |
((mio_uint128_t)c[8] << 56) |
((mio_uint128_t)c[9] << 48) |
((mio_uint128_t)c[10] << 40) |
((mio_uint128_t)c[11] << 32) |
((mio_uint128_t)c[12] << 24) |
((mio_uint128_t)c[13] << 16) |
((mio_uint128_t)c[14] << 8) |
((mio_uint128_t)c[15] << 0));
#else
# error Unknown endian
#endif
}
mio_uint128_t mio_hton128 (mio_uint128_t x)
{
#if defined(MIO_ENDIAN_BIG)
return x;
#elif defined(MIO_ENDIAN_LITTLE)
mio_uint8_t* c = (mio_uint8_t*)&x;
return (mio_uint128_t)(
((mio_uint128_t)c[0] << 120) |
((mio_uint128_t)c[1] << 112) |
((mio_uint128_t)c[2] << 104) |
((mio_uint128_t)c[3] << 96) |
((mio_uint128_t)c[4] << 88) |
((mio_uint128_t)c[5] << 80) |
((mio_uint128_t)c[6] << 72) |
((mio_uint128_t)c[7] << 64) |
((mio_uint128_t)c[8] << 56) |
((mio_uint128_t)c[9] << 48) |
((mio_uint128_t)c[10] << 40) |
((mio_uint128_t)c[11] << 32) |
((mio_uint128_t)c[12] << 24) |
((mio_uint128_t)c[13] << 16) |
((mio_uint128_t)c[14] << 8) |
((mio_uint128_t)c[15] << 0));
#else
# error Unknown endian
#endif
}
#endif
/* ========================================================================= */
#define IS_MSPACE(x) ((x) == MIO_MT(' ') || (x) == MIO_MT('\t') || (x) == MIO_MT('\n') || (x) == MIO_MT('\r'))
mio_mchar_t* mio_mbsdup (mio_t* mio, const mio_mchar_t* src)
{
mio_mchar_t* dst;
mio_size_t len;
dst = (mio_mchar_t*)src;
while (*dst != MIO_MT('\0')) dst++;
len = dst - src;
dst = MIO_MMGR_ALLOC (mio->mmgr, (len + 1) * MIO_SIZEOF(*src));
if (!dst)
{
mio->errnum = MIO_ENOMEM;
return MIO_NULL;
}
MIO_MEMCPY (dst, src, (len + 1) * MIO_SIZEOF(*src));
return dst;
}
mio_size_t mio_mbscpy (mio_mchar_t* buf, const mio_mchar_t* str)
{
mio_mchar_t* org = buf;
while ((*buf++ = *str++) != MIO_MT('\0'));
return buf - org - 1;
}
int mio_mbsspltrn (
mio_mchar_t* s, const mio_mchar_t* delim,
mio_mchar_t lquote, mio_mchar_t rquote,
mio_mchar_t escape, const mio_mchar_t* trset)
{
mio_mchar_t* p = s, *d;
mio_mchar_t* sp = MIO_NULL, * ep = MIO_NULL;
int delim_mode;
int cnt = 0;
if (delim == MIO_NULL) delim_mode = 0;
else
{
delim_mode = 1;
for (d = (mio_mchar_t*)delim; *d != MIO_MT('\0'); d++)
if (!IS_MSPACE(*d)) delim_mode = 2;
}
if (delim_mode == 0)
{
/* skip preceding space characters */
while (IS_MSPACE(*p)) p++;
/* when 0 is given as "delim", it has an effect of cutting
preceding and trailing space characters off "s". */
if (lquote != MIO_MT('\0') && *p == lquote)
{
mio_mbscpy (p, p + 1);
for (;;)
{
if (*p == MIO_MT('\0')) return -1;
if (escape != MIO_MT('\0') && *p == escape)
{
if (trset != MIO_NULL && p[1] != MIO_MT('\0'))
{
const mio_mchar_t* ep = trset;
while (*ep != MIO_MT('\0'))
{
if (p[1] == *ep++)
{
p[1] = *ep;
break;
}
}
}
mio_mbscpy (p, p + 1);
}
else
{
if (*p == rquote)
{
p++;
break;
}
}
if (sp == 0) sp = p;
ep = p;
p++;
}
while (IS_MSPACE(*p)) p++;
if (*p != MIO_MT('\0')) return -1;
if (sp == 0 && ep == 0) s[0] = MIO_MT('\0');
else
{
ep[1] = MIO_MT('\0');
if (s != (mio_mchar_t*)sp) mio_mbscpy (s, sp);
cnt++;
}
}
else
{
while (*p)
{
if (!IS_MSPACE(*p))
{
if (sp == 0) sp = p;
ep = p;
}
p++;
}
if (sp == 0 && ep == 0) s[0] = MIO_MT('\0');
else
{
ep[1] = MIO_MT('\0');
if (s != (mio_mchar_t*)sp) mio_mbscpy (s, sp);
cnt++;
}
}
}
else if (delim_mode == 1)
{
mio_mchar_t* o;
while (*p)
{
o = p;
while (IS_MSPACE(*p)) p++;
if (o != p) { mio_mbscpy (o, p); p = o; }
if (lquote != MIO_MT('\0') && *p == lquote)
{
mio_mbscpy (p, p + 1);
for (;;)
{
if (*p == MIO_MT('\0')) return -1;
if (escape != MIO_MT('\0') && *p == escape)
{
if (trset != MIO_NULL && p[1] != MIO_MT('\0'))
{
const mio_mchar_t* ep = trset;
while (*ep != MIO_MT('\0'))
{
if (p[1] == *ep++)
{
p[1] = *ep;
break;
}
}
}
mio_mbscpy (p, p + 1);
}
else
{
if (*p == rquote)
{
*p++ = MIO_MT('\0');
cnt++;
break;
}
}
p++;
}
}
else
{
o = p;
for (;;)
{
if (*p == MIO_MT('\0'))
{
if (o != p) cnt++;
break;
}
if (IS_MSPACE (*p))
{
*p++ = MIO_MT('\0');
cnt++;
break;
}
p++;
}
}
}
}
else /* if (delim_mode == 2) */
{
mio_mchar_t* o;
int ok;
while (*p != MIO_MT('\0'))
{
o = p;
while (IS_MSPACE(*p)) p++;
if (o != p) { mio_mbscpy (o, p); p = o; }
if (lquote != MIO_MT('\0') && *p == lquote)
{
mio_mbscpy (p, p + 1);
for (;;)
{
if (*p == MIO_MT('\0')) return -1;
if (escape != MIO_MT('\0') && *p == escape)
{
if (trset != MIO_NULL && p[1] != MIO_MT('\0'))
{
const mio_mchar_t* ep = trset;
while (*ep != MIO_MT('\0'))
{
if (p[1] == *ep++)
{
p[1] = *ep;
break;
}
}
}
mio_mbscpy (p, p + 1);
}
else
{
if (*p == rquote)
{
*p++ = MIO_MT('\0');
cnt++;
break;
}
}
p++;
}
ok = 0;
while (IS_MSPACE(*p)) p++;
if (*p == MIO_MT('\0')) ok = 1;
for (d = (mio_mchar_t*)delim; *d != MIO_MT('\0'); d++)
{
if (*p == *d)
{
ok = 1;
mio_mbscpy (p, p + 1);
break;
}
}
if (ok == 0) return -1;
}
else
{
o = p; sp = ep = 0;
for (;;)
{
if (*p == MIO_MT('\0'))
{
if (ep)
{
ep[1] = MIO_MT('\0');
p = &ep[1];
}
cnt++;
break;
}
for (d = (mio_mchar_t*)delim; *d != MIO_MT('\0'); d++)
{
if (*p == *d)
{
if (sp == MIO_NULL)
{
mio_mbscpy (o, p); p = o;
*p++ = MIO_MT('\0');
}
else
{
mio_mbscpy (&ep[1], p);
mio_mbscpy (o, sp);
o[ep - sp + 1] = MIO_MT('\0');
p = &o[ep - sp + 2];
}
cnt++;
/* last empty field after delim */
if (*p == MIO_MT('\0')) cnt++;
goto exit_point;
}
}
if (!IS_MSPACE (*p))
{
if (sp == MIO_NULL) sp = p;
ep = p;
}
p++;
}
exit_point:
;
}
}
}
return cnt;
}
int mio_mbsspl (
mio_mchar_t* s, const mio_mchar_t* delim,
mio_mchar_t lquote, mio_mchar_t rquote, mio_mchar_t escape)
{
return mio_mbsspltrn (s, delim, lquote, rquote, escape, MIO_NULL);
}

File diff suppressed because it is too large Load Diff

554
mio/lib/mio.h Normal file
View File

@ -0,0 +1,554 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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.
*/
#ifndef _MIO_H_
#define _MIO_H_
#include <mio-cmn.h>
/**
* The mio_ntime_t type defines a numeric time type expressed in the
* number of milliseconds since the Epoch (00:00:00 UTC, Jan 1, 1970).
*/
typedef struct mio_ntime_t mio_ntime_t;
struct mio_ntime_t
{
mio_intptr_t sec;
mio_int32_t nsec; /* nanoseconds */
};
#if defined(_WIN32)
typedef mio_uintptr_t qse_syshnd_t;
#define MIO_SYSHND_INVALID (~(mio_uintptr_t)0)
#else
typedef int mio_syshnd_t;
#define MIO_SYSHND_INVALID (-1)
#endif
typedef struct mio_devaddr_t mio_devaddr_t;
struct mio_devaddr_t
{
int len;
void* ptr;
};
#define MIO_CONST_SWAP16(x) \
((mio_uint16_t)((((mio_uint16_t)(x) & (mio_uint16_t)0x00ffU) << 8) | \
(((mio_uint16_t)(x) & (mio_uint16_t)0xff00U) >> 8) ))
#define MIO_CONST_SWAP32(x) \
((mio_uint32_t)((((mio_uint32_t)(x) & (mio_uint32_t)0x000000ffUL) << 24) | \
(((mio_uint32_t)(x) & (mio_uint32_t)0x0000ff00UL) << 8) | \
(((mio_uint32_t)(x) & (mio_uint32_t)0x00ff0000UL) >> 8) | \
(((mio_uint32_t)(x) & (mio_uint32_t)0xff000000UL) >> 24) ))
#if defined(MIO_ENDIAN_LITTLE)
# define MIO_CONST_NTOH16(x) MIO_CONST_SWAP16(x)
# define MIO_CONST_HTON16(x) MIO_CONST_SWAP16(x)
# define MIO_CONST_NTOH32(x) MIO_CONST_SWAP32(x)
# define MIO_CONST_HTON32(x) MIO_CONST_SWAP32(x)
#elif defined(MIO_ENDIAN_BIG)
# define MIO_CONST_NTOH16(x) (x)
# define MIO_CONST_HTON16(x) (x)
# define MIO_CONST_NTOH32(x) (x)
# define MIO_CONST_HTON32(x) (x)
#else
# error UNKNOWN ENDIAN
#endif
/* ========================================================================= */
typedef struct mio_t mio_t;
typedef struct mio_dev_t mio_dev_t;
typedef struct mio_dev_mth_t mio_dev_mth_t;
typedef struct mio_dev_evcb_t mio_dev_evcb_t;
typedef struct mio_wq_t mio_wq_t;
typedef mio_intptr_t mio_iolen_t; /* NOTE: this is a signed type */
enum mio_errnum_t
{
MIO_ENOERR,
MIO_ENOIMPL,
MIO_ESYSERR,
MIO_EINTERN,
MIO_ENOMEM,
MIO_EINVAL,
MIO_EEXIST,
MIO_ENOENT,
MIO_ENOSUP, /* not supported */
MIO_EMFILE, /* too many open files */
MIO_ENFILE,
MIO_EAGAIN,
MIO_ECONRF, /* connection refused */
MIO_ECONRS, /* connection reset */
MIO_ENOCAPA, /* no capability */
MIO_ETMOUT, /* timed out */
MIO_EPERM, /* operation not permitted */
MIO_EDEVMAKE,
MIO_EDEVERR,
MIO_EDEVHUP
};
typedef enum mio_errnum_t mio_errnum_t;
enum mio_stopreq_t
{
MIO_STOPREQ_NONE = 0,
MIO_STOPREQ_TERMINATION,
MIO_STOPREQ_WATCHER_ERROR
};
typedef enum mio_stopreq_t mio_stopreq_t;
/* ========================================================================= */
#define MIO_TMRIDX_INVALID ((mio_tmridx_t)-1)
typedef mio_size_t mio_tmridx_t;
typedef struct mio_tmrjob_t mio_tmrjob_t;
typedef void (*mio_tmrjob_handler_t) (
mio_t* mio,
const mio_ntime_t* now,
mio_tmrjob_t* tmrjob
);
struct mio_tmrjob_t
{
void* ctx;
mio_ntime_t when;
mio_tmrjob_handler_t handler;
mio_tmridx_t* idxptr; /* pointer to the index holder */
};
/* ========================================================================= */
struct mio_dev_mth_t
{
/* ------------------------------------------------------------------ */
/* mandatory. called in mio_makedev() */
int (*make) (mio_dev_t* dev, void* ctx);
/* ------------------------------------------------------------------ */
/* mandatory. called in mio_killdev(). also called in mio_makedev() upon
* failure after make() success.
*
* when 'force' is 0, the return value of -1 causes the device to be a
* zombie. the kill method is called periodically on a zombie device
* until the method returns 0.
*
* when 'force' is 1, the called should not return -1. If it does, the
* method is called once more only with the 'force' value of 2.
*
* when 'force' is 2, the device is destroyed regardless of the return value.
*/
int (*kill) (mio_dev_t* dev, int force);
/* ------------------------------------------------------------------ */
mio_syshnd_t (*getsyshnd) (mio_dev_t* dev); /* mandatory. called in mio_makedev() after successful make() */
/* ------------------------------------------------------------------ */
/* return -1 on failure, 0 if no data is availble, 1 otherwise.
* when returning 1, *len must be sent to the length of data read.
* if *len is set to 0, it's treated as EOF. */
int (*read) (mio_dev_t* dev, void* data, mio_iolen_t* len, mio_devaddr_t* srcaddr);
/* ------------------------------------------------------------------ */
int (*write) (mio_dev_t* dev, const void* data, mio_iolen_t* len, const mio_devaddr_t* dstaddr);
/* ------------------------------------------------------------------ */
int (*ioctl) (mio_dev_t* dev, int cmd, void* arg);
};
struct mio_dev_evcb_t
{
/* return -1 on failure. 0 or 1 on success.
* when 0 is returned, it doesn't attempt to perform actual I/O.
* when 1 is returned, it attempts to perform actual I/O. */
int (*ready) (mio_dev_t* dev, int events);
/* return -1 on failure, 0 or 1 on success.
* when 0 is returned, the main loop stops the attempt to read more data.
* when 1 is returned, the main loop attempts to read more data without*/
int (*on_read) (mio_dev_t* dev, const void* data, mio_iolen_t len, const mio_devaddr_t* srcaddr);
/* return -1 on failure, 0 on success.
* wrlen is the length of data written. it is the length of the originally
* posted writing request for a stream device. For a non stream device, it
* may be shorter than the originally posted length. */
int (*on_write) (mio_dev_t* dev, mio_iolen_t wrlen, void* wrctx, const mio_devaddr_t* dstaddr);
};
struct mio_wq_t
{
mio_wq_t* next;
mio_wq_t* prev;
mio_iolen_t olen; /* original data length */
mio_uint8_t* ptr; /* pointer to data */
mio_iolen_t len; /* remaining data length */
void* ctx;
mio_dev_t* dev; /* back-pointer to the device */
mio_tmridx_t tmridx;
mio_devaddr_t dstaddr;
};
#define MIO_WQ_INIT(wq) ((wq)->next = (wq)->prev = (wq))
#define MIO_WQ_TAIL(wq) ((wq)->prev)
#define MIO_WQ_HEAD(wq) ((wq)->next)
#define MIO_WQ_ISEMPTY(wq) (MIO_WQ_HEAD(wq) == (wq))
#define MIO_WQ_ISNODE(wq,x) ((wq) != (x))
#define MIO_WQ_ISHEAD(wq,x) (MIO_WQ_HEAD(wq) == (x))
#define MIO_WQ_ISTAIL(wq,x) (MIO_WQ_TAIL(wq) == (x))
#define MIO_WQ_NEXT(x) ((x)->next)
#define MIO_WQ_PREV(x) ((x)->prev)
#define MIO_WQ_LINK(p,x,n) do { \
mio_wq_t* pp = (p), * nn = (n); \
(x)->prev = (p); \
(x)->next = (n); \
nn->prev = (x); \
pp->next = (x); \
} while (0)
#define MIO_WQ_UNLINK(x) do { \
mio_wq_t* pp = (x)->prev, * nn = (x)->next; \
nn->prev = pp; pp->next = nn; \
} while (0)
#define MIO_WQ_REPL(o,n) do { \
mio_wq_t* oo = (o), * nn = (n); \
nn->next = oo->next; \
nn->next->prev = nn; \
nn->prev = oo->prev; \
nn->prev->next = nn; \
} while (0)
/* insert an item at the back of the queue */
/*#define MIO_WQ_ENQ(wq,x) MIO_WQ_LINK(MIO_WQ_TAIL(wq), x, MIO_WQ_TAIL(wq)->next)*/
#define MIO_WQ_ENQ(wq,x) MIO_WQ_LINK(MIO_WQ_TAIL(wq), x, wq)
/* remove an item in the front from the queue */
#define MIO_WQ_DEQ(wq) MIO_WQ_UNLINK(MIO_WQ_HEAD(wq))
#define MIO_DEV_HEADERS \
mio_t* mio; \
mio_size_t dev_size; \
int dev_capa; \
mio_dev_mth_t* dev_mth; \
mio_dev_evcb_t* dev_evcb; \
mio_wq_t wq; \
mio_dev_t* dev_prev; \
mio_dev_t* dev_next
struct mio_dev_t
{
MIO_DEV_HEADERS;
};
enum mio_dev_capa_t
{
MIO_DEV_CAPA_VIRTUAL = (1 << 0),
MIO_DEV_CAPA_IN = (1 << 1),
MIO_DEV_CAPA_OUT = (1 << 2),
/* #MIO_DEV_CAPA_PRI is meaningful only if #MIO_DEV_CAPA_IN is set */
MIO_DEV_CAPA_PRI = (1 << 3),
MIO_DEV_CAPA_STREAM = (1 << 4),
MIO_DEV_CAPA_OUT_QUEUED = (1 << 5),
/* internal use only. never set this bit to the dev_capa field */
MIO_DEV_CAPA_IN_DISABLED = (1 << 9),
MIO_DEV_CAPA_IN_CLOSED = (1 << 10),
MIO_DEV_CAPA_OUT_CLOSED = (1 << 11),
MIO_DEV_CAPA_IN_WATCHED = (1 << 12),
MIO_DEV_CAPA_OUT_WATCHED = (1 << 13),
MIO_DEV_CAPA_PRI_WATCHED = (1 << 14), /**< can be set only if MIO_DEV_CAPA_IN_WATCHED is set */
MIO_DEV_CAPA_ACTIVE = (1 << 15),
MIO_DEV_CAPA_HALTED = (1 << 16),
MIO_DEV_CAPA_ZOMBIE = (1 << 17)
};
typedef enum mio_dev_capa_t mio_dev_capa_t;
enum mio_dev_watch_cmd_t
{
MIO_DEV_WATCH_START,
MIO_DEV_WATCH_UPDATE,
MIO_DEV_WATCH_RENEW, /* automatic update */
MIO_DEV_WATCH_STOP
};
typedef enum mio_dev_watch_cmd_t mio_dev_watch_cmd_t;
enum mio_dev_event_t
{
MIO_DEV_EVENT_IN = (1 << 0),
MIO_DEV_EVENT_OUT = (1 << 1),
MIO_DEV_EVENT_PRI = (1 << 2),
MIO_DEV_EVENT_HUP = (1 << 3),
MIO_DEV_EVENT_ERR = (1 << 4)
};
typedef enum mio_dev_event_t mio_dev_event_t;
/* ========================================================================= */
#ifdef __cplusplus
extern "C" {
#endif
MIO_EXPORT mio_t* mio_open (
mio_mmgr_t* mmgr,
mio_size_t xtnsize,
mio_size_t tmrcapa, /**< initial timer capacity */
mio_errnum_t* errnum
);
MIO_EXPORT void mio_close (
mio_t* mio
);
MIO_EXPORT int mio_init (
mio_t* mio,
mio_mmgr_t* mmgr,
mio_size_t tmrcapa
);
MIO_EXPORT void mio_fini (
mio_t* mio
);
MIO_EXPORT int mio_exec (
mio_t* mio
);
MIO_EXPORT int mio_loop (
mio_t* mio
);
MIO_EXPORT void mio_stop (
mio_t* mio,
mio_stopreq_t stopreq
);
MIO_EXPORT mio_dev_t* mio_makedev (
mio_t* mio,
mio_size_t dev_size,
mio_dev_mth_t* dev_mth,
mio_dev_evcb_t* dev_evcb,
void* make_ctx
);
MIO_EXPORT void mio_killdev (
mio_t* mio,
mio_dev_t* dev
);
MIO_EXPORT int mio_dev_ioctl (
mio_dev_t* dev,
int cmd,
void* arg
);
MIO_EXPORT int mio_dev_watch (
mio_dev_t* dev,
mio_dev_watch_cmd_t cmd,
/** 0 or bitwise-ORed of #MIO_DEV_EVENT_IN and #MIO_DEV_EVENT_OUT */
int events
);
MIO_EXPORT int mio_dev_read (
mio_dev_t* dev,
int enabled
);
/**
* The mio_dev_write() function posts a writing request.
* It attempts to write data immediately if there is no pending requests.
* If writing fails, it returns -1. If writing succeeds, it calls the
* on_write callback. If the callback fails, it returns -1. If the callback
* succeeds, it returns 1. If no immediate writing is possible, the request
* is enqueued to a pending request list. If enqueing gets successful,
* it returns 0. otherwise it returns -1.
*/
MIO_EXPORT int mio_dev_write (
mio_dev_t* dev,
const void* data,
mio_iolen_t len,
void* wrctx,
const mio_devaddr_t* dstaddr
);
MIO_EXPORT int mio_dev_timedwrite (
mio_dev_t* dev,
const void* data,
mio_iolen_t len,
const mio_ntime_t* tmout,
void* wrctx,
const mio_devaddr_t* dstaddr
);
MIO_EXPORT void mio_dev_halt (
mio_dev_t* dev
);
/* ========================================================================= */
#define mio_inittime(x,s,ns) (((x)->sec = (s)), ((x)->nsec = (ns)))
#define mio_cleartime(x) mio_inittime(x,0,0)
#define mio_cmptime(x,y) \
(((x)->sec == (y)->sec)? ((x)->nsec - (y)->nsec): \
((x)->sec - (y)->sec))
/* if time has been normalized properly, nsec must be equal to or
* greater than 0. */
#define mio_isnegtime(x) ((x)->sec < 0)
#define mio_ispostime(x) ((x)->sec > 0 || ((x)->sec == 0 && (x)->nsec > 0))
#define mio_iszerotime(x) ((x)->sec == 0 && (x)->nsec == 0)
/**
* The mio_gettime() function gets the current time.
*/
MIO_EXPORT void mio_gettime (
mio_ntime_t* nt
);
/**
* The mio_addtime() function adds x and y and stores the result in z
*/
MIO_EXPORT void mio_addtime (
const mio_ntime_t* x,
const mio_ntime_t* y,
mio_ntime_t* z
);
/**
* The mio_subtime() function subtract y from x and stores the result in z.
*/
MIO_EXPORT void mio_subtime (
const mio_ntime_t* x,
const mio_ntime_t* y,
mio_ntime_t* z
);
/**
* The mio_instmrjob() function schedules a new event.
*
* \return #MIO_TMRIDX_INVALID on failure, valid index on success.
*/
MIO_EXPORT mio_tmridx_t mio_instmrjob (
mio_t* mio,
const mio_tmrjob_t* job
);
MIO_EXPORT mio_tmridx_t mio_updtmrjob (
mio_t* mio,
mio_tmridx_t index,
const mio_tmrjob_t* job
);
MIO_EXPORT void mio_deltmrjob (
mio_t* mio,
mio_tmridx_t index
);
/**
* The mio_gettmrjob() function returns the
* pointer to the registered event at the given index.
*/
MIO_EXPORT mio_tmrjob_t* mio_gettmrjob (
mio_t* mio,
mio_tmridx_t index
);
MIO_EXPORT int mio_gettmrjobdeadline (
mio_t* mio,
mio_tmridx_t index,
mio_ntime_t* deadline
);
/* ========================================================================= */
#if defined(MIO_HAVE_UINT16_T)
MIO_EXPORT mio_uint16_t mio_ntoh16 (
mio_uint16_t x
);
MIO_EXPORT mio_uint16_t mio_hton16 (
mio_uint16_t x
);
#endif
#if defined(MIO_HAVE_UINT32_T)
MIO_EXPORT mio_uint32_t mio_ntoh32 (
mio_uint32_t x
);
MIO_EXPORT mio_uint32_t mio_hton32 (
mio_uint32_t x
);
#endif
#if defined(MIO_HAVE_UINT64_T)
MIO_EXPORT mio_uint64_t mio_ntoh64 (
mio_uint64_t x
);
MIO_EXPORT mio_uint64_t mio_hton64 (
mio_uint64_t x
);
#endif
#if defined(MIO_HAVE_UINT128_T)
MIO_EXPORT mio_uint128_t mio_ntoh128 (
mio_uint128_t x
);
MIO_EXPORT mio_uint128_t mio_hton128 (
mio_uint128_t x
);
#endif
/* ========================================================================= */
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,4 +1,4 @@
/* lib/stio-cfg.h.in. Generated from configure.ac by autoheader. */
/* lib/mio-cfg.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
@ -830,118 +830,118 @@
#undef STDC_HEADERS
/* Big Endian */
#undef STIO_ENDIAN_BIG
#undef MIO_ENDIAN_BIG
/* Little Endian */
#undef STIO_ENDIAN_LITTLE
#undef MIO_ENDIAN_LITTLE
/* Unknown Endian */
#undef STIO_ENDIAN_UNKNOWN
#undef MIO_ENDIAN_UNKNOWN
/* MB_LEN_MAX */
#undef STIO_MBLEN_MAX
#undef MIO_MBLEN_MAX
/* Author */
#undef STIO_PACKAGE_AUTHOR
#undef MIO_PACKAGE_AUTHOR
/* package name */
#undef STIO_PACKAGE_NAME
#undef MIO_PACKAGE_NAME
/* Project URL */
#undef STIO_PACKAGE_URL
#undef MIO_PACKAGE_URL
/* Package version */
#undef STIO_PACKAGE_VERSION
#undef MIO_PACKAGE_VERSION
/* Major version number */
#undef STIO_PACKAGE_VERSION_MAJOR
#undef MIO_PACKAGE_VERSION_MAJOR
/* Minor version number */
#undef STIO_PACKAGE_VERSION_MINOR
#undef MIO_PACKAGE_VERSION_MINOR
/* Patch level */
#undef STIO_PACKAGE_VERSION_PATCH
#undef MIO_PACKAGE_VERSION_PATCH
/* sizeof(char) */
#undef STIO_SIZEOF_CHAR
#undef MIO_SIZEOF_CHAR
/* sizeof(double) */
#undef STIO_SIZEOF_DOUBLE
#undef MIO_SIZEOF_DOUBLE
/* sizeof(float) */
#undef STIO_SIZEOF_FLOAT
#undef MIO_SIZEOF_FLOAT
/* sizeof(int) */
#undef STIO_SIZEOF_INT
#undef MIO_SIZEOF_INT
/* sizeof(long) */
#undef STIO_SIZEOF_LONG
#undef MIO_SIZEOF_LONG
/* sizeof(long double) */
#undef STIO_SIZEOF_LONG_DOUBLE
#undef MIO_SIZEOF_LONG_DOUBLE
/* sizeof(long long) */
#undef STIO_SIZEOF_LONG_LONG
#undef MIO_SIZEOF_LONG_LONG
/* sizeof(mbstate_t) */
#undef STIO_SIZEOF_MBSTATE_T
#undef MIO_SIZEOF_MBSTATE_T
/* sizeof(off64_t) */
#undef STIO_SIZEOF_OFF64_T
#undef MIO_SIZEOF_OFF64_T
/* sizeof(off_t) */
#undef STIO_SIZEOF_OFF_T
#undef MIO_SIZEOF_OFF_T
/* sizeof(short) */
#undef STIO_SIZEOF_SHORT
#undef MIO_SIZEOF_SHORT
/* sizeof(socklen_t) */
#undef STIO_SIZEOF_SOCKLEN_T
#undef MIO_SIZEOF_SOCKLEN_T
/* sizeof(struct sockaddr_dl) */
#undef STIO_SIZEOF_STRUCT_SOCKADDR_DL
#undef MIO_SIZEOF_STRUCT_SOCKADDR_DL
/* sizeof(struct sockaddr_in) */
#undef STIO_SIZEOF_STRUCT_SOCKADDR_IN
#undef MIO_SIZEOF_STRUCT_SOCKADDR_IN
/* sizeof(struct sockaddr_in6) */
#undef STIO_SIZEOF_STRUCT_SOCKADDR_IN6
#undef MIO_SIZEOF_STRUCT_SOCKADDR_IN6
/* sizeof(struct sockaddr_ll) */
#undef STIO_SIZEOF_STRUCT_SOCKADDR_LL
#undef MIO_SIZEOF_STRUCT_SOCKADDR_LL
/* sizeof(struct sockaddr_un) */
#undef STIO_SIZEOF_STRUCT_SOCKADDR_UN
#undef MIO_SIZEOF_STRUCT_SOCKADDR_UN
/* sizeof(void*) */
#undef STIO_SIZEOF_VOID_P
#undef MIO_SIZEOF_VOID_P
/* sizeof(wchar_t) */
#undef STIO_SIZEOF_WCHAR_T
#undef MIO_SIZEOF_WCHAR_T
/* sizeof(__float128) */
#undef STIO_SIZEOF___FLOAT128
#undef MIO_SIZEOF___FLOAT128
/* sizeof(__int128) */
#undef STIO_SIZEOF___INT128
#undef MIO_SIZEOF___INT128
/* sizeof(__int128_t) */
#undef STIO_SIZEOF___INT128_T
#undef MIO_SIZEOF___INT128_T
/* sizeof(__int16) */
#undef STIO_SIZEOF___INT16
#undef MIO_SIZEOF___INT16
/* sizeof(__int32) */
#undef STIO_SIZEOF___INT32
#undef MIO_SIZEOF___INT32
/* sizeof(__int64) */
#undef STIO_SIZEOF___INT64
#undef MIO_SIZEOF___INT64
/* sizeof(__int8) */
#undef STIO_SIZEOF___INT8
#undef MIO_SIZEOF___INT8
/* Define if socklen_t is signed */
#undef STIO_SOCKLEN_T_IS_SIGNED
#undef MIO_SOCKLEN_T_IS_SIGNED
/* Version number of package */
#undef VERSION

View File

@ -1,569 +0,0 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 AUTHOR 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.
*/
#ifndef _STIO_CMN_H_
#define _STIO_CMN_H_
/* WARNING: NEVER CHANGE/DELETE THE FOLLOWING STIO_HAVE_CFG_H DEFINITION.
* IT IS USED FOR DEPLOYMENT BY MAKEFILE.AM */
/*#define STIO_HAVE_CFG_H*/
#if defined(STIO_HAVE_CFG_H)
# include "stio-cfg.h"
#elif defined(_WIN32)
# include "stio-msw.h"
#elif defined(__OS2__)
# include "stio-os2.h"
#elif defined(__MSDOS__)
# include "stio-dos.h"
#elif defined(macintosh)
# include "stio-mac.h" /* class mac os */
#else
# error UNSUPPORTED SYSTEM
#endif
#if defined(EMSCRIPTEN)
# if defined(STIO_SIZEOF___INT128)
# undef STIO_SIZEOF___INT128
# define STIO_SIZEOF___INT128 0
# endif
# if defined(STIO_SIZEOF_LONG) && defined(STIO_SIZEOF_INT) && (STIO_SIZEOF_LONG > STIO_SIZEOF_INT)
/* autoconf doesn't seem to match actual emscripten */
# undef STIO_SIZEOF_LONG
# define STIO_SIZEOF_LONG STIO_SIZEOF_INT
# endif
#endif
/* =========================================================================
* PRIMITIVE TYPE DEFINTIONS
* ========================================================================= */
/* stio_int8_t */
#if defined(STIO_SIZEOF_CHAR) && (STIO_SIZEOF_CHAR == 1)
# define STIO_HAVE_UINT8_T
# define STIO_HAVE_INT8_T
typedef unsigned char stio_uint8_t;
typedef signed char stio_int8_t;
#elif defined(STIO_SIZEOF___INT8) && (STIO_SIZEOF___INT8 == 1)
# define STIO_HAVE_UINT8_T
# define STIO_HAVE_INT8_T
typedef unsigned __int8 stio_uint8_t;
typedef signed __int8 stio_int8_t;
#elif defined(STIO_SIZEOF___INT8_T) && (STIO_SIZEOF___INT8_T == 1)
# define STIO_HAVE_UINT8_T
# define STIO_HAVE_INT8_T
typedef unsigned __int8_t stio_uint8_t;
typedef signed __int8_t stio_int8_t;
#else
# define STIO_HAVE_UINT8_T
# define STIO_HAVE_INT8_T
typedef unsigned char stio_uint8_t;
typedef signed char stio_int8_t;
#endif
/* stio_int16_t */
#if defined(STIO_SIZEOF_SHORT) && (STIO_SIZEOF_SHORT == 2)
# define STIO_HAVE_UINT16_T
# define STIO_HAVE_INT16_T
typedef unsigned short int stio_uint16_t;
typedef signed short int stio_int16_t;
#elif defined(STIO_SIZEOF___INT16) && (STIO_SIZEOF___INT16 == 2)
# define STIO_HAVE_UINT16_T
# define STIO_HAVE_INT16_T
typedef unsigned __int16 stio_uint16_t;
typedef signed __int16 stio_int16_t;
#elif defined(STIO_SIZEOF___INT16_T) && (STIO_SIZEOF___INT16_T == 2)
# define STIO_HAVE_UINT16_T
# define STIO_HAVE_INT16_T
typedef unsigned __int16_t stio_uint16_t;
typedef signed __int16_t stio_int16_t;
#else
# define STIO_HAVE_UINT16_T
# define STIO_HAVE_INT16_T
typedef unsigned short int stio_uint16_t;
typedef signed short int stio_int16_t;
#endif
/* stio_int32_t */
#if defined(STIO_SIZEOF_INT) && (STIO_SIZEOF_INT == 4)
# define STIO_HAVE_UINT32_T
# define STIO_HAVE_INT32_T
typedef unsigned int stio_uint32_t;
typedef signed int stio_int32_t;
#elif defined(STIO_SIZEOF_LONG) && (STIO_SIZEOF_LONG == 4)
# define STIO_HAVE_UINT32_T
# define STIO_HAVE_INT32_T
typedef unsigned long stio_uint32_t;
typedef signed long stio_int32_t;
#elif defined(STIO_SIZEOF___INT32) && (STIO_SIZEOF___INT32 == 4)
# define STIO_HAVE_UINT32_T
# define STIO_HAVE_INT32_T
typedef unsigned __int32 stio_uint32_t;
typedef signed __int32 stio_int32_t;
#elif defined(STIO_SIZEOF___INT32_T) && (STIO_SIZEOF___INT32_T == 4)
# define STIO_HAVE_UINT32_T
# define STIO_HAVE_INT32_T
typedef unsigned __int32_t stio_uint32_t;
typedef signed __int32_t stio_int32_t;
#elif defined(__MSDOS__)
# define STIO_HAVE_UINT32_T
# define STIO_HAVE_INT32_T
typedef unsigned long int stio_uint32_t;
typedef signed long int stio_int32_t;
#else
# define STIO_HAVE_UINT32_T
# define STIO_HAVE_INT32_T
typedef unsigned int stio_uint32_t;
typedef signed int stio_int32_t;
#endif
/* stio_int64_t */
#if defined(STIO_SIZEOF_INT) && (STIO_SIZEOF_INT == 8)
# define STIO_HAVE_UINT64_T
# define STIO_HAVE_INT64_T
typedef unsigned int stio_uint64_t;
typedef signed int stio_int64_t;
#elif defined(STIO_SIZEOF_LONG) && (STIO_SIZEOF_LONG == 8)
# define STIO_HAVE_UINT64_T
# define STIO_HAVE_INT64_T
typedef unsigned long stio_uint64_t;
typedef signed long stio_int64_t;
#elif defined(STIO_SIZEOF_LONG_LONG) && (STIO_SIZEOF_LONG_LONG == 8)
# define STIO_HAVE_UINT64_T
# define STIO_HAVE_INT64_T
typedef unsigned long long stio_uint64_t;
typedef signed long long stio_int64_t;
#elif defined(STIO_SIZEOF___INT64) && (STIO_SIZEOF___INT64 == 8)
# define STIO_HAVE_UINT64_T
# define STIO_HAVE_INT64_T
typedef unsigned __int64 stio_uint64_t;
typedef signed __int64 stio_int64_t;
#elif defined(STIO_SIZEOF___INT64_T) && (STIO_SIZEOF___INT64_T == 8)
# define STIO_HAVE_UINT64_T
# define STIO_HAVE_INT64_T
typedef unsigned __int64_t stio_uint64_t;
typedef signed __int64_t stio_int64_t;
#elif defined(_WIN64) || defined(_WIN32)
# define STIO_HAVE_UINT64_T
# define STIO_HAVE_INT64_T
typedef unsigned __int64 stio_uint64_t;
typedef signed __int64 stio_int64_t;
#else
/* no 64-bit integer */
#endif
/* stio_int128_t */
#if defined(STIO_SIZEOF_INT) && (STIO_SIZEOF_INT == 16)
# define STIO_HAVE_UINT128_T
# define STIO_HAVE_INT128_T
typedef unsigned int stio_uint128_t;
typedef signed int stio_int128_t;
#elif defined(STIO_SIZEOF_LONG) && (STIO_SIZEOF_LONG == 16)
# define STIO_HAVE_UINT128_T
# define STIO_HAVE_INT128_T
typedef unsigned long stio_uint128_t;
typedef signed long stio_int128_t;
#elif defined(STIO_SIZEOF_LONG_LONG) && (STIO_SIZEOF_LONG_LONG == 16)
# define STIO_HAVE_UINT128_T
# define STIO_HAVE_INT128_T
typedef unsigned long long stio_uint128_t;
typedef signed long long stio_int128_t;
#elif defined(STIO_SIZEOF___INT128) && (STIO_SIZEOF___INT128 == 16)
# define STIO_HAVE_UINT128_T
# define STIO_HAVE_INT128_T
typedef unsigned __int128 stio_uint128_t;
typedef signed __int128 stio_int128_t;
#elif defined(STIO_SIZEOF___INT128_T) && (STIO_SIZEOF___INT128_T == 16)
# define STIO_HAVE_UINT128_T
# define STIO_HAVE_INT128_T
#if defined(__clang__)
typedef __uint128_t stio_uint128_t;
typedef __int128_t stio_int128_t;
#else
typedef unsigned __int128_t stio_uint128_t;
typedef signed __int128_t stio_int128_t;
#endif
#else
/* no 128-bit integer */
#endif
#if defined(STIO_HAVE_UINT8_T) && (STIO_SIZEOF_VOID_P == 1)
# error UNSUPPORTED POINTER SIZE
#elif defined(STIO_HAVE_UINT16_T) && (STIO_SIZEOF_VOID_P == 2)
typedef stio_uint16_t stio_uintptr_t;
typedef stio_int16_t stio_intptr_t;
typedef stio_uint8_t stio_ushortptr_t;
typedef stio_int8_t stio_shortptr_t;
#elif defined(STIO_HAVE_UINT32_T) && (STIO_SIZEOF_VOID_P == 4)
typedef stio_uint32_t stio_uintptr_t;
typedef stio_int32_t stio_intptr_t;
typedef stio_uint16_t stio_ushortptr_t;
typedef stio_int16_t stio_shortptr_t;
#elif defined(STIO_HAVE_UINT64_T) && (STIO_SIZEOF_VOID_P == 8)
typedef stio_uint64_t stio_uintptr_t;
typedef stio_int64_t stio_intptr_t;
typedef stio_uint32_t stio_ushortptr_t;
typedef stio_int32_t stio_shortptr_t;
#elif defined(STIO_HAVE_UINT128_T) && (STIO_SIZEOF_VOID_P == 16)
typedef stio_uint128_t stio_uintptr_t;
typedef stio_int128_t stio_intptr_t;
typedef stio_uint64_t stio_ushortptr_t;
typedef stio_int64_t stio_shortptr_t;
#else
# error UNKNOWN POINTER SIZE
#endif
#define STIO_SIZEOF_INTPTR_T STIO_SIZEOF_VOID_P
#define STIO_SIZEOF_UINTPTR_T STIO_SIZEOF_VOID_P
#define STIO_SIZEOF_SHORTPTR_T (STIO_SIZEOF_VOID_P / 2)
#define STIO_SIZEOF_USHORTPTR_T (STIO_SIZEOF_VOID_P / 2)
#if defined(STIO_HAVE_INT128_T)
# define STIO_SIZEOF_INTMAX_T 16
# define STIO_SIZEOF_UINTMAX_T 16
typedef stio_int128_t stio_intmax_t;
typedef stio_uint128_t stio_uintmax_t;
#elif defined(STIO_HAVE_INT64_T)
# define STIO_SIZEOF_INTMAX_T 8
# define STIO_SIZEOF_UINTMAX_T 8
typedef stio_int64_t stio_intmax_t;
typedef stio_uint64_t stio_uintmax_t;
#elif defined(STIO_HAVE_INT32_T)
# define STIO_SIZEOF_INTMAX_T 4
# define STIO_SIZEOF_UINTMAX_T 4
typedef stio_int32_t stio_intmax_t;
typedef stio_uint32_t stio_uintmax_t;
#elif defined(STIO_HAVE_INT16_T)
# define STIO_SIZEOF_INTMAX_T 2
# define STIO_SIZEOF_UINTMAX_T 2
typedef stio_int16_t stio_intmax_t;
typedef stio_uint16_t stio_uintmax_t;
#elif defined(STIO_HAVE_INT8_T)
# define STIO_SIZEOF_INTMAX_T 1
# define STIO_SIZEOF_UINTMAX_T 1
typedef stio_int8_t stio_intmax_t;
typedef stio_uint8_t stio_uintmax_t;
#else
# error UNKNOWN INTMAX SIZE
#endif
/* =========================================================================
* BASIC STIO TYPES
* =========================================================================*/
typedef stio_uint8_t stio_byte_t;
typedef stio_uintptr_t stio_size_t;
typedef char stio_mchar_t;
typedef int stio_mcint_t;
#define STIO_MT(x) (x)
/* =========================================================================
* PRIMITIVE MACROS
* ========================================================================= */
#define STIO_SIZEOF(x) (sizeof(x))
#define STIO_COUNTOF(x) (sizeof(x) / sizeof(x[0]))
/**
* The STIO_OFFSETOF() macro returns the offset of a field from the beginning
* of a structure.
*/
#define STIO_OFFSETOF(type,member) ((stio_uintptr_t)&((type*)0)->member)
/**
* The STIO_ALIGNOF() macro returns the alignment size of a structure.
* Note that this macro may not work reliably depending on the type given.
*/
#define STIO_ALIGNOF(type) STIO_OFFSETOF(struct { stio_uint8_t d1; type d2; }, d2)
/*(sizeof(struct { stio_uint8_t d1; type d2; }) - sizeof(type))*/
/**
* Round up a positive integer to the nearest multiple of 'align'
*/
#define STIO_ALIGNTO(num,align) ((((num) + (align) - 1) / (align)) * (align))
#if 0
/**
* Round up a number, both positive and negative, to the nearest multiple of 'align'
*/
#define STIO_ALIGNTO(num,align) ((((num) + (num >= 0? 1: -1) * (align) - 1) / (align)) * (align))
#endif
/**
* Round up a positive integer to to the nearest multiple of 'align' which
* should be a multiple of a power of 2
*/
#define STIO_ALIGNTO_POW2(num,align) ((((num) + (align) - 1)) & ~((align) - 1))
#if defined(__cplusplus)
# if (__cplusplus >= 201103L) /* C++11 */
# define STIO_NULL nullptr
# else
# define STIO_NULL (0)
# endif
#else
# define STIO_NULL ((void*)0)
#endif
/* make a bit mask that can mask off low n bits */
#define STIO_LBMASK(type,n) (~(~((type)0) << (n)))
#define STIO_LBMASK_SAFE(type,n) (((n) < STIO_SIZEOF(type) * 8)? STIO_LBMASK(type,n): ~(type)0)
/* make a bit mask that can mask off hig n bits */
#define STIO_HBMASK(type,n) (~(~((type)0) >> (n)))
#define STIO_HBMASK_SAFE(type,n) (((n) < STIO_SIZEOF(type) * 8)? STIO_HBMASK(type,n): ~(type)0)
/* get 'length' bits starting from the bit at the 'offset' */
#define STIO_GETBITS(type,value,offset,length) \
((((type)(value)) >> (offset)) & STIO_LBMASK(type,length))
#define STIO_SETBITS(type,value,offset,length,bits) \
(value = (((type)(value)) | (((bits) & STIO_LBMASK(type,length)) << (offset))))
/**
* The STIO_BITS_MAX() macros calculates the maximum value that the 'nbits'
* bits of an unsigned integer of the given 'type' can hold.
* \code
* printf ("%u", STIO_BITS_MAX(unsigned int, 5));
* \endcode
*/
/*#define STIO_BITS_MAX(type,nbits) ((((type)1) << (nbits)) - 1)*/
#define STIO_BITS_MAX(type,nbits) ((~(type)0) >> (STIO_SIZEOF(type) * 8 - (nbits)))
/* =========================================================================
* MMGR
* ========================================================================= */
typedef struct stio_mmgr_t stio_mmgr_t;
/**
* allocate a memory chunk of the size \a n.
* \return pointer to a memory chunk on success, #STIO_NULL on failure.
*/
typedef void* (*stio_mmgr_alloc_t) (stio_mmgr_t* mmgr, stio_size_t n);
/**
* resize a memory chunk pointed to by \a ptr to the size \a n.
* \return pointer to a memory chunk on success, #STIO_NULL on failure.
*/
typedef void* (*stio_mmgr_realloc_t) (stio_mmgr_t* mmgr, void* ptr, stio_size_t n);
/**
* free a memory chunk pointed to by \a ptr.
*/
typedef void (*stio_mmgr_free_t) (stio_mmgr_t* mmgr, void* ptr);
/**
* The stio_mmgr_t type defines the memory management interface.
* As the type is merely a structure, it is just used as a single container
* for memory management functions with a pointer to user-defined data.
* The user-defined data pointer \a ctx is passed to each memory management
* function whenever it is called. You can allocate, reallocate, and free
* a memory chunk.
*
* For example, a stio_xxx_open() function accepts a pointer of the stio_mmgr_t
* type and the xxx object uses it to manage dynamic data within the object.
*/
struct stio_mmgr_t
{
stio_mmgr_alloc_t alloc; /**< allocation function */
stio_mmgr_realloc_t realloc; /**< resizing function */
stio_mmgr_free_t free; /**< disposal function */
void* ctx; /**< user-defined data pointer */
};
/**
* The STIO_MMGR_ALLOC() macro allocates a memory block of the \a size bytes
* using the \a mmgr memory manager.
*/
#define STIO_MMGR_ALLOC(mmgr,size) ((mmgr)->alloc(mmgr,size))
/**
* The STIO_MMGR_REALLOC() macro resizes a memory block pointed to by \a ptr
* to the \a size bytes using the \a mmgr memory manager.
*/
#define STIO_MMGR_REALLOC(mmgr,ptr,size) ((mmgr)->realloc(mmgr,ptr,size))
/**
* The STIO_MMGR_FREE() macro deallocates the memory block pointed to by \a ptr.
*/
#define STIO_MMGR_FREE(mmgr,ptr) ((mmgr)->free(mmgr,ptr))
/* =========================================================================
* MACROS THAT CHANGES THE BEHAVIORS OF THE C COMPILER/LINKER
* =========================================================================*/
#if defined(_WIN32) || (defined(__WATCOMC__) && !defined(__WINDOWS_386__))
# define STIO_IMPORT __declspec(dllimport)
# define STIO_EXPORT __declspec(dllexport)
# define STIO_PRIVATE
#elif defined(__GNUC__) && (__GNUC__>=4)
# define STIO_IMPORT __attribute__((visibility("default")))
# define STIO_EXPORT __attribute__((visibility("default")))
# define STIO_PRIVATE __attribute__((visibility("hidden")))
/*# define STIO_PRIVATE __attribute__((visibility("internal")))*/
#else
# define STIO_IMPORT
# define STIO_EXPORT
# define STIO_PRIVATE
#endif
#if defined(__STDC_VERSION__) && (__STDC_VERSION__>=199901L)
# define STIO_INLINE inline
# define STIO_HAVE_INLINE
#elif defined(__GNUC__) && defined(__GNUC_GNU_INLINE__)
/* gcc disables inline when -std=c89 or -ansi is used.
* so use __inline__ supported by gcc regardless of the options */
# define STIO_INLINE /*extern*/ __inline__
# define STIO_HAVE_INLINE
#else
# define STIO_INLINE
# undef STIO_HAVE_INLINE
#endif
/**
* The STIO_TYPE_IS_SIGNED() macro determines if a type is signed.
* \code
* printf ("%d\n", (int)STIO_TYPE_IS_SIGNED(int));
* printf ("%d\n", (int)STIO_TYPE_IS_SIGNED(unsigned int));
* \endcode
*/
#define STIO_TYPE_IS_SIGNED(type) (((type)0) > ((type)-1))
/**
* The STIO_TYPE_IS_SIGNED() macro determines if a type is unsigned.
* \code
* printf ("%d\n", STIO_TYPE_IS_UNSIGNED(int));
* printf ("%d\n", STIO_TYPE_IS_UNSIGNED(unsigned int));
* \endcode
*/
#define STIO_TYPE_IS_UNSIGNED(type) (((type)0) < ((type)-1))
#define STIO_TYPE_SIGNED_MAX(type) \
((type)~((type)1 << ((type)STIO_SIZEOF(type) * 8 - 1)))
#define STIO_TYPE_UNSIGNED_MAX(type) ((type)(~(type)0))
#define STIO_TYPE_SIGNED_MIN(type) \
((type)((type)1 << ((type)STIO_SIZEOF(type) * 8 - 1)))
#define STIO_TYPE_UNSIGNED_MIN(type) ((type)0)
#define STIO_TYPE_MAX(type) \
((STIO_TYPE_IS_SIGNED(type)? STIO_TYPE_SIGNED_MAX(type): STIO_TYPE_UNSIGNED_MAX(type)))
#define STIO_TYPE_MIN(type) \
((STIO_TYPE_IS_SIGNED(type)? STIO_TYPE_SIGNED_MIN(type): STIO_TYPE_UNSIGNED_MIN(type)))
/* =========================================================================
* COMPILER FEATURE TEST MACROS
* =========================================================================*/
#if defined(__has_builtin)
#if __has_builtin(__builtin_ctz)
#define STIO_HAVE_BUILTIN_CTZ
#endif
#if __has_builtin(__builtin_uadd_overflow)
#define STIO_HAVE_BUILTIN_UADD_OVERFLOW
#endif
#if __has_builtin(__builtin_uaddl_overflow)
#define STIO_HAVE_BUILTIN_UADDL_OVERFLOW
#endif
#if __has_builtin(__builtin_uaddll_overflow)
#define STIO_HAVE_BUILTIN_UADDLL_OVERFLOW
#endif
#if __has_builtin(__builtin_umul_overflow)
#define STIO_HAVE_BUILTIN_UMUL_OVERFLOW
#endif
#if __has_builtin(__builtin_umull_overflow)
#define STIO_HAVE_BUILTIN_UMULL_OVERFLOW
#endif
#if __has_builtin(__builtin_umulll_overflow)
#define STIO_HAVE_BUILTIN_UMULLL_OVERFLOW
#endif
#if __has_builtin(__builtin_sadd_overflow)
#define STIO_HAVE_BUILTIN_SADD_OVERFLOW
#endif
#if __has_builtin(__builtin_saddl_overflow)
#define STIO_HAVE_BUILTIN_SADDL_OVERFLOW
#endif
#if __has_builtin(__builtin_saddll_overflow)
#define STIO_HAVE_BUILTIN_SADDLL_OVERFLOW
#endif
#if __has_builtin(__builtin_smul_overflow)
#define STIO_HAVE_BUILTIN_SMUL_OVERFLOW
#endif
#if __has_builtin(__builtin_smull_overflow)
#define STIO_HAVE_BUILTIN_SMULL_OVERFLOW
#endif
#if __has_builtin(__builtin_smulll_overflow)
#define STIO_HAVE_BUILTIN_SMULLL_OVERFLOW
#endif
#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#define STIO_HAVE_BUILTIN_CTZ
#endif
#if (__GNUC__ >= 5)
#define STIO_HAVE_BUILTIN_UADD_OVERFLOW
#define STIO_HAVE_BUILTIN_UADDL_OVERFLOW
#define STIO_HAVE_BUILTIN_UADDLL_OVERFLOW
#define STIO_HAVE_BUILTIN_UMUL_OVERFLOW
#define STIO_HAVE_BUILTIN_UMULL_OVERFLOW
#define STIO_HAVE_BUILTIN_UMULLL_OVERFLOW
#define STIO_HAVE_BUILTIN_SADD_OVERFLOW
#define STIO_HAVE_BUILTIN_SADDL_OVERFLOW
#define STIO_HAVE_BUILTIN_SADDLL_OVERFLOW
#define STIO_HAVE_BUILTIN_SMUL_OVERFLOW
#define STIO_HAVE_BUILTIN_SMULL_OVERFLOW
#define STIO_HAVE_BUILTIN_SMULLL_OVERFLOW
#endif
#endif
/*
#if !defined(__has_builtin)
#define __has_builtin(x) 0
#endif
#if !defined(__is_identifier)
#define __is_identifier(x) 0
#endif
#if !defined(__has_attribute)
#define __has_attribute(x) 0
#endif
*/
#endif

View File

@ -1,846 +0,0 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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 "stio-pro.h"
#include "stio-prv.h"
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/wait.h>
/* ========================================================================= */
struct slave_info_t
{
stio_dev_pro_make_t* mi;
stio_syshnd_t pfd;
int dev_capa;
stio_dev_pro_sid_t id;
};
typedef struct slave_info_t slave_info_t;
static stio_dev_pro_slave_t* make_slave (stio_t* stio, slave_info_t* si);
/* ========================================================================= */
struct param_t
{
stio_mchar_t* mcmd;
stio_mchar_t* fixed_argv[4];
stio_mchar_t** argv;
};
typedef struct param_t param_t;
static void free_param (stio_t* stio, param_t* param)
{
if (param->argv && param->argv != param->fixed_argv)
STIO_MMGR_FREE (stio->mmgr, param->argv);
if (param->mcmd) STIO_MMGR_FREE (stio->mmgr, param->mcmd);
STIO_MEMSET (param, 0, STIO_SIZEOF(*param));
}
static int make_param (stio_t* stio, const stio_mchar_t* cmd, int flags, param_t* param)
{
int fcnt = 0;
stio_mchar_t* mcmd = STIO_NULL;
STIO_MEMSET (param, 0, STIO_SIZEOF(*param));
if (flags & STIO_DEV_PRO_SHELL)
{
mcmd = (stio_mchar_t*)cmd;
param->argv = param->fixed_argv;
param->argv[0] = STIO_MT("/bin/sh");
param->argv[1] = STIO_MT("-c");
param->argv[2] = mcmd;
param->argv[3] = STIO_NULL;
}
else
{
int i;
stio_mchar_t** argv;
stio_mchar_t* mcmdptr;
mcmd = stio_mbsdup (stio, cmd);
if (!mcmd) goto oops;
fcnt = stio_mbsspl (mcmd, STIO_MT(""), STIO_MT('\"'), STIO_MT('\"'), STIO_MT('\\'));
if (fcnt <= 0)
{
/* no field or an error */
stio->errnum = STIO_EINVAL;
goto oops;
}
if (fcnt < STIO_COUNTOF(param->fixed_argv))
{
param->argv = param->fixed_argv;
}
else
{
param->argv = STIO_MMGR_ALLOC (stio->mmgr, (fcnt + 1) * STIO_SIZEOF(argv[0]));
if (param->argv == STIO_NULL)
{
stio->errnum = STIO_ENOMEM;
goto oops;
}
}
mcmdptr = mcmd;
for (i = 0; i < fcnt; i++)
{
param->argv[i] = mcmdptr;
while (*mcmdptr != STIO_MT('\0')) mcmdptr++;
mcmdptr++;
}
param->argv[i] = STIO_NULL;
}
if (mcmd && mcmd != (stio_mchar_t*)cmd) param->mcmd = mcmd;
return 0;
oops:
if (mcmd && mcmd != cmd) STIO_MMGR_FREE (stio->mmgr, mcmd);
return -1;
}
static pid_t standard_fork_and_exec (stio_t* stio, int pfds[], int flags, param_t* param)
{
pid_t pid;
pid = fork ();
if (pid == -1)
{
stio->errnum = stio_syserrtoerrnum(errno);
return -1;
}
if (pid == 0)
{
/* slave process */
stio_syshnd_t devnull = STIO_SYSHND_INVALID;
/* TODO: close all uneeded fds */
if (flags & STIO_DEV_PRO_WRITEIN)
{
/* slave should read */
close (pfds[1]);
pfds[1] = STIO_SYSHND_INVALID;
/* let the pipe be standard input */
if (dup2 (pfds[0], 0) <= -1) goto slave_oops;
close (pfds[0]);
pfds[0] = STIO_SYSHND_INVALID;
}
if (flags & STIO_DEV_PRO_READOUT)
{
/* slave should write */
close (pfds[2]);
pfds[2] = STIO_SYSHND_INVALID;
if (dup2(pfds[3], 1) == -1) goto slave_oops;
if (flags & STIO_DEV_PRO_ERRTOOUT)
{
if (dup2(pfds[3], 2) == -1) goto slave_oops;
}
close (pfds[3]);
pfds[3] = STIO_SYSHND_INVALID;
}
if (flags & STIO_DEV_PRO_READERR)
{
close (pfds[4]);
pfds[4] = STIO_SYSHND_INVALID;
if (dup2(pfds[5], 2) == -1) goto slave_oops;
if (flags & STIO_DEV_PRO_OUTTOERR)
{
if (dup2(pfds[5], 1) == -1) goto slave_oops;
}
close (pfds[5]);
pfds[5] = STIO_SYSHND_INVALID;
}
if ((flags & STIO_DEV_PRO_INTONUL) ||
(flags & STIO_DEV_PRO_OUTTONUL) ||
(flags & STIO_DEV_PRO_ERRTONUL))
{
#if defined(O_LARGEFILE)
devnull = open (STIO_MT("/dev/null"), O_RDWR | O_LARGEFILE, 0);
#else
devnull = open (STIO_MT("/dev/null"), O_RDWR, 0);
#endif
if (devnull == STIO_SYSHND_INVALID) goto slave_oops;
}
execv (param->argv[0], param->argv);
/* if exec fails, free 'param' parameter which is an inherited pointer */
free_param (stio, param);
slave_oops:
if (devnull != STIO_SYSHND_INVALID) close(devnull);
_exit (128);
}
/* parent process */
return pid;
}
static int dev_pro_make_master (stio_dev_t* dev, void* ctx)
{
stio_dev_pro_t* rdev = (stio_dev_pro_t*)dev;
stio_dev_pro_make_t* info = (stio_dev_pro_make_t*)ctx;
stio_syshnd_t pfds[6];
int i, minidx = -1, maxidx = -1;
param_t param;
pid_t pid;
if (info->flags & STIO_DEV_PRO_WRITEIN)
{
if (pipe(&pfds[0]) == -1)
{
dev->stio->errnum = stio_syserrtoerrnum(errno);
goto oops;
}
minidx = 0; maxidx = 1;
}
if (info->flags & STIO_DEV_PRO_READOUT)
{
if (pipe(&pfds[2]) == -1)
{
dev->stio->errnum = stio_syserrtoerrnum(errno);
goto oops;
}
if (minidx == -1) minidx = 2;
maxidx = 3;
}
if (info->flags & STIO_DEV_PRO_READERR)
{
if (pipe(&pfds[4]) == -1)
{
dev->stio->errnum = stio_syserrtoerrnum(errno);
goto oops;
}
if (minidx == -1) minidx = 4;
maxidx = 5;
}
if (maxidx == -1)
{
dev->stio->errnum = STIO_EINVAL;
goto oops;
}
if (make_param (rdev->stio, info->cmd, info->flags, &param) <= -1) goto oops;
/* TODO: more advanced fork and exec .. */
pid = standard_fork_and_exec (rdev->stio, pfds, info->flags, &param);
if (pid <= -1)
{
free_param (rdev->stio, &param);
goto oops;
}
free_param (rdev->stio, &param);
rdev->child_pid = pid;
/* this is the parent process */
if (info->flags & STIO_DEV_PRO_WRITEIN)
{
/*
* 012345
* rw----
* X
* WRITE => 1
*/
close (pfds[0]);
pfds[0] = STIO_SYSHND_INVALID;
if (stio_makesyshndasync (dev->stio, pfds[1]) <= -1) goto oops;
}
if (info->flags & STIO_DEV_PRO_READOUT)
{
/*
* 012345
* --rw--
* X
* READ => 2
*/
close (pfds[3]);
pfds[3] = STIO_SYSHND_INVALID;
if (stio_makesyshndasync (dev->stio, pfds[2]) <= -1) goto oops;
}
if (info->flags & STIO_DEV_PRO_READERR)
{
/*
* 012345
* ----rw
* X
* READ => 4
*/
close (pfds[5]);
pfds[5] = STIO_SYSHND_INVALID;
if (stio_makesyshndasync (dev->stio, pfds[4]) <= -1) goto oops;
}
if (pfds[1] != STIO_SYSHND_INVALID)
{
/* hand over pfds[2] to the first slave device */
slave_info_t si;
si.mi = info;
si.pfd = pfds[1];
si.dev_capa = STIO_DEV_CAPA_OUT | STIO_DEV_CAPA_OUT_QUEUED | STIO_DEV_CAPA_STREAM;
si.id = STIO_DEV_PRO_IN;
rdev->slave[STIO_DEV_PRO_IN] = make_slave (dev->stio, &si);
if (!rdev->slave[STIO_DEV_PRO_IN]) goto oops;
pfds[1] = STIO_SYSHND_INVALID;
rdev->slave_count++;
}
if (pfds[2] != STIO_SYSHND_INVALID)
{
/* hand over pfds[2] to the first slave device */
slave_info_t si;
si.mi = info;
si.pfd = pfds[2];
si.dev_capa = STIO_DEV_CAPA_IN | STIO_DEV_CAPA_STREAM;
si.id = STIO_DEV_PRO_OUT;
rdev->slave[STIO_DEV_PRO_OUT] = make_slave (dev->stio, &si);
if (!rdev->slave[STIO_DEV_PRO_OUT]) goto oops;
pfds[2] = STIO_SYSHND_INVALID;
rdev->slave_count++;
}
if (pfds[4] != STIO_SYSHND_INVALID)
{
/* hand over pfds[4] to the second slave device */
slave_info_t si;
si.mi = info;
si.pfd = pfds[4];
si.dev_capa = STIO_DEV_CAPA_IN | STIO_DEV_CAPA_STREAM;
si.id = STIO_DEV_PRO_ERR;
rdev->slave[STIO_DEV_PRO_ERR] = make_slave (dev->stio, &si);
if (!rdev->slave[STIO_DEV_PRO_ERR]) goto oops;
pfds[4] = STIO_SYSHND_INVALID;
rdev->slave_count++;
}
for (i = 0; i < STIO_COUNTOF(rdev->slave); i++)
{
if (rdev->slave[i]) rdev->slave[i]->master = rdev;
}
rdev->dev_capa = STIO_DEV_CAPA_VIRTUAL; /* the master device doesn't perform I/O */
rdev->flags = info->flags;
rdev->on_read = info->on_read;
rdev->on_write = info->on_write;
rdev->on_close = info->on_close;
return 0;
oops:
for (i = minidx; i < maxidx; i++)
{
if (pfds[i] != STIO_SYSHND_INVALID) close (pfds[i]);
}
if (rdev->mcmd)
{
STIO_MMGR_FREE (rdev->stio->mmgr, rdev->mcmd);
free_param (rdev->stio, &param);
}
for (i = STIO_COUNTOF(rdev->slave); i > 0; )
{
i--;
if (rdev->slave[i])
{
stio_killdev (rdev->stio, (stio_dev_t*)rdev->slave[i]);
rdev->slave[i] = STIO_NULL;
}
}
rdev->slave_count = 0;
return -1;
}
static int dev_pro_make_slave (stio_dev_t* dev, void* ctx)
{
stio_dev_pro_slave_t* rdev = (stio_dev_pro_slave_t*)dev;
slave_info_t* si = (slave_info_t*)ctx;
rdev->dev_capa = si->dev_capa;
rdev->id = si->id;
rdev->pfd = si->pfd;
/* keep rdev->master to STIO_NULL. it's set to the right master
* device in dev_pro_make() */
return 0;
}
static int dev_pro_kill_master (stio_dev_t* dev, int force)
{
stio_dev_pro_t* rdev = (stio_dev_pro_t*)dev;
int i, status;
pid_t wpid;
if (rdev->slave_count > 0)
{
for (i = 0; i < STIO_COUNTOF(rdev->slave); i++)
{
if (rdev->slave[i])
{
stio_dev_pro_slave_t* sdev = rdev->slave[i];
/* nullify the pointer to the slave device
* before calling stio_killdev() on the slave device.
* the slave device can check this pointer to tell from
* self-initiated termination or master-driven termination */
rdev->slave[i] = STIO_NULL;
stio_killdev (rdev->stio, (stio_dev_t*)sdev);
}
}
}
if (rdev->child_pid >= 0)
{
if (!(rdev->flags & STIO_DEV_PRO_FORGET_CHILD))
{
int killed = 0;
await_child:
wpid = waitpid (rdev->child_pid, &status, WNOHANG);
if (wpid == 0)
{
if (force && !killed)
{
if (!(rdev->flags & STIO_DEV_PRO_FORGET_DIEHARD_CHILD))
{
kill (rdev->child_pid, SIGKILL);
killed = 1;
goto await_child;
}
}
else
{
/* child process is still alive */
rdev->stio->errnum = STIO_EAGAIN;
return -1; /* call me again */
}
}
/* wpid == rdev->child_pid => full success
* wpid == -1 && errno == ECHILD => no such process. it's waitpid()'ed by some other part of the program?
* other cases ==> can't really handle properly. forget it by returning success
* no need not worry about EINTR because errno can't have the value when WNOHANG is set.
*/
}
printf (">>>>>>>>>>>>>>>>>>> REAPED CHILD %d\n", (int)rdev->child_pid);
rdev->child_pid = -1;
}
if (rdev->on_close) rdev->on_close (rdev, STIO_DEV_PRO_MASTER);
return 0;
}
static int dev_pro_kill_slave (stio_dev_t* dev, int force)
{
stio_dev_pro_slave_t* rdev = (stio_dev_pro_slave_t*)dev;
if (rdev->master)
{
stio_dev_pro_t* master;
master = rdev->master;
rdev->master = STIO_NULL;
/* indicate EOF */
if (master->on_close) master->on_close (master, rdev->id);
STIO_ASSERT (master->slave_count > 0);
master->slave_count--;
if (master->slave[rdev->id])
{
/* this call is started by the slave device itself.
* if this is the last slave, kill the master also */
if (master->slave_count <= 0)
{
stio_killdev (rdev->stio, (stio_dev_t*)master);
/* the master pointer is not valid from this point onwards
* as the actual master device object is freed in stio_killdev() */
}
}
else
{
/* this call is initiated by this slave device itself.
* if it were by the master device, it would be STIO_NULL as
* nullified by the dev_pro_kill() */
master->slave[rdev->id] = STIO_NULL;
}
}
if (rdev->pfd != STIO_SYSHND_INVALID)
{
close (rdev->pfd);
rdev->pfd = STIO_SYSHND_INVALID;
}
return 0;
}
static int dev_pro_read_slave (stio_dev_t* dev, void* buf, stio_iolen_t* len, stio_devaddr_t* srcaddr)
{
stio_dev_pro_slave_t* pro = (stio_dev_pro_slave_t*)dev;
ssize_t x;
x = read (pro->pfd, buf, *len);
if (x <= -1)
{
if (errno == EINPROGRESS || errno == EWOULDBLOCK || errno == EAGAIN) return 0; /* no data available */
if (errno == EINTR) return 0;
pro->stio->errnum = stio_syserrtoerrnum(errno);
return -1;
}
*len = x;
return 1;
}
static int dev_pro_write_slave (stio_dev_t* dev, const void* data, stio_iolen_t* len, const stio_devaddr_t* dstaddr)
{
stio_dev_pro_slave_t* pro = (stio_dev_pro_slave_t*)dev;
ssize_t x;
x = write (pro->pfd, data, *len);
if (x <= -1)
{
if (errno == EINPROGRESS || errno == EWOULDBLOCK || errno == EAGAIN) return 0; /* no data can be written */
if (errno == EINTR) return 0;
pro->stio->errnum = stio_syserrtoerrnum(errno);
return -1;
}
*len = x;
return 1;
}
static stio_syshnd_t dev_pro_getsyshnd (stio_dev_t* dev)
{
return STIO_SYSHND_INVALID;
}
static stio_syshnd_t dev_pro_getsyshnd_slave (stio_dev_t* dev)
{
stio_dev_pro_slave_t* pro = (stio_dev_pro_slave_t*)dev;
return (stio_syshnd_t)pro->pfd;
}
static int dev_pro_ioctl (stio_dev_t* dev, int cmd, void* arg)
{
stio_dev_pro_t* rdev = (stio_dev_pro_t*)dev;
switch (cmd)
{
case STIO_DEV_PRO_CLOSE:
{
stio_dev_pro_sid_t sid = *(stio_dev_pro_sid_t*)arg;
if (sid < STIO_DEV_PRO_IN || sid > STIO_DEV_PRO_ERR)
{
rdev->stio->errnum = STIO_EINVAL;
return -1;
}
if (rdev->slave[sid])
{
/* unlike dev_pro_kill_master(), i don't nullify rdev->slave[sid].
* so i treat the closing ioctl as if it's a kill request
* initiated by the slave device itself. */
stio_killdev (rdev->stio, (stio_dev_t*)rdev->slave[sid]);
}
return 0;
}
case STIO_DEV_PRO_KILL_CHILD:
if (rdev->child_pid >= 0)
{
if (kill (rdev->child_pid, SIGKILL) == -1)
{
rdev->stio->errnum = stio_syserrtoerrnum(errno);
return -1;
}
}
return 0;
default:
dev->stio->errnum = STIO_EINVAL;
return -1;
}
}
static stio_dev_mth_t dev_pro_methods =
{
dev_pro_make_master,
dev_pro_kill_master,
dev_pro_getsyshnd,
STIO_NULL,
STIO_NULL,
dev_pro_ioctl
};
static stio_dev_mth_t dev_pro_methods_slave =
{
dev_pro_make_slave,
dev_pro_kill_slave,
dev_pro_getsyshnd_slave,
dev_pro_read_slave,
dev_pro_write_slave,
dev_pro_ioctl
};
/* ========================================================================= */
static int pro_ready (stio_dev_t* dev, int events)
{
/* virtual device. no I/O */
dev->stio->errnum = STIO_EINTERN;
return -1;
}
static int pro_on_read (stio_dev_t* dev, const void* data, stio_iolen_t len, const stio_devaddr_t* srcaddr)
{
/* virtual device. no I/O */
dev->stio->errnum = STIO_EINTERN;
return -1;
}
static int pro_on_write (stio_dev_t* dev, stio_iolen_t wrlen, void* wrctx, const stio_devaddr_t* dstaddr)
{
/* virtual device. no I/O */
dev->stio->errnum = STIO_EINTERN;
return -1;
}
static stio_dev_evcb_t dev_pro_event_callbacks =
{
pro_ready,
pro_on_read,
pro_on_write
};
/* ========================================================================= */
static int pro_ready_slave (stio_dev_t* dev, int events)
{
stio_dev_pro_t* pro = (stio_dev_pro_t*)dev;
if (events & STIO_DEV_EVENT_ERR)
{
pro->stio->errnum = STIO_EDEVERR;
return -1;
}
if (events & STIO_DEV_EVENT_HUP)
{
if (events & (STIO_DEV_EVENT_PRI | STIO_DEV_EVENT_IN | STIO_DEV_EVENT_OUT))
{
/* probably half-open? */
return 1;
}
pro->stio->errnum = STIO_EDEVHUP;
return -1;
}
return 1; /* the device is ok. carry on reading or writing */
}
static int pro_on_read_slave_out (stio_dev_t* dev, const void* data, stio_iolen_t len, const stio_devaddr_t* srcaddr)
{
stio_dev_pro_slave_t* pro = (stio_dev_pro_slave_t*)dev;
return pro->master->on_read (pro->master, data, len, STIO_DEV_PRO_OUT);
}
static int pro_on_read_slave_err (stio_dev_t* dev, const void* data, stio_iolen_t len, const stio_devaddr_t* srcaddr)
{
stio_dev_pro_slave_t* pro = (stio_dev_pro_slave_t*)dev;
return pro->master->on_read (pro->master, data, len, STIO_DEV_PRO_ERR);
}
static int pro_on_write_slave (stio_dev_t* dev, stio_iolen_t wrlen, void* wrctx, const stio_devaddr_t* dstaddr)
{
stio_dev_pro_slave_t* pro = (stio_dev_pro_slave_t*)dev;
return pro->master->on_write (pro->master, wrlen, wrctx);
}
static stio_dev_evcb_t dev_pro_event_callbacks_slave_in =
{
pro_ready_slave,
STIO_NULL,
pro_on_write_slave
};
static stio_dev_evcb_t dev_pro_event_callbacks_slave_out =
{
pro_ready_slave,
pro_on_read_slave_out,
STIO_NULL
};
static stio_dev_evcb_t dev_pro_event_callbacks_slave_err =
{
pro_ready_slave,
pro_on_read_slave_err,
STIO_NULL
};
/* ========================================================================= */
static stio_dev_pro_slave_t* make_slave (stio_t* stio, slave_info_t* si)
{
switch (si->id)
{
case STIO_DEV_PRO_IN:
return (stio_dev_pro_slave_t*)stio_makedev (
stio, STIO_SIZEOF(stio_dev_pro_t),
&dev_pro_methods_slave, &dev_pro_event_callbacks_slave_in, si);
case STIO_DEV_PRO_OUT:
return (stio_dev_pro_slave_t*)stio_makedev (
stio, STIO_SIZEOF(stio_dev_pro_t),
&dev_pro_methods_slave, &dev_pro_event_callbacks_slave_out, si);
case STIO_DEV_PRO_ERR:
return (stio_dev_pro_slave_t*)stio_makedev (
stio, STIO_SIZEOF(stio_dev_pro_t),
&dev_pro_methods_slave, &dev_pro_event_callbacks_slave_err, si);
default:
stio->errnum = STIO_EINVAL;
return STIO_NULL;
}
}
stio_dev_pro_t* stio_dev_pro_make (stio_t* stio, stio_size_t xtnsize, const stio_dev_pro_make_t* info)
{
return (stio_dev_pro_t*)stio_makedev (
stio, STIO_SIZEOF(stio_dev_pro_t) + xtnsize,
&dev_pro_methods, &dev_pro_event_callbacks, (void*)info);
}
void stio_dev_pro_kill (stio_dev_pro_t* dev)
{
stio_killdev (dev->stio, (stio_dev_t*)dev);
}
int stio_dev_pro_write (stio_dev_pro_t* dev, const void* data, stio_iolen_t dlen, void* wrctx)
{
if (dev->slave[0])
{
return stio_dev_write ((stio_dev_t*)dev->slave[0], data, dlen, wrctx, STIO_NULL);
}
else
{
dev->stio->errnum = STIO_ENOCAPA; /* TODO: is it the right error number? */
return -1;
}
}
int stio_dev_pro_timedwrite (stio_dev_pro_t* dev, const void* data, stio_iolen_t dlen, const stio_ntime_t* tmout, void* wrctx)
{
if (dev->slave[0])
{
return stio_dev_timedwrite ((stio_dev_t*)dev->slave[0], data, dlen, tmout, wrctx, STIO_NULL);
}
else
{
dev->stio->errnum = STIO_ENOCAPA; /* TODO: is it the right error number? */
return -1;
}
}
int stio_dev_pro_close (stio_dev_pro_t* dev, stio_dev_pro_sid_t sid)
{
return stio_dev_ioctl ((stio_dev_t*)dev, STIO_DEV_PRO_CLOSE, &sid);
}
int stio_dev_pro_killchild (stio_dev_pro_t* dev)
{
return stio_dev_ioctl ((stio_dev_t*)dev, STIO_DEV_PRO_KILL_CHILD, STIO_NULL);
}
#if 0
stio_dev_pro_t* stio_dev_pro_getdev (stio_dev_pro_t* pro, stio_dev_pro_sid_t sid)
{
switch (type)
{
case STIO_DEV_PRO_IN:
return XXX;
case STIO_DEV_PRO_OUT:
return XXX;
case STIO_DEV_PRO_ERR:
return XXX;
}
pro->dev->stio = STIO_EINVAL;
return STIO_NULL;
}
#endif

View File

@ -1,164 +0,0 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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.
*/
#ifndef _STIO_PRO_H_
#define _STIO_PRO_H_
#include <stio.h>
enum stio_dev_pro_sid_t
{
STIO_DEV_PRO_MASTER = -1,
STIO_DEV_PRO_IN = 0,
STIO_DEV_PRO_OUT = 1,
STIO_DEV_PRO_ERR = 2
};
typedef enum stio_dev_pro_sid_t stio_dev_pro_sid_t;
typedef struct stio_dev_pro_t stio_dev_pro_t;
typedef struct stio_dev_pro_slave_t stio_dev_pro_slave_t;
typedef int (*stio_dev_pro_on_read_t) (stio_dev_pro_t* dev, const void* data, stio_iolen_t len, stio_dev_pro_sid_t sid);
typedef int (*stio_dev_pro_on_write_t) (stio_dev_pro_t* dev, stio_iolen_t wrlen, void* wrctx);
typedef void (*stio_dev_pro_on_close_t) (stio_dev_pro_t* dev, stio_dev_pro_sid_t sid);
struct stio_dev_pro_t
{
STIO_DEV_HEADERS;
int flags;
stio_intptr_t child_pid;
stio_dev_pro_slave_t* slave[3];
int slave_count;
stio_dev_pro_on_read_t on_read;
stio_dev_pro_on_write_t on_write;
stio_dev_pro_on_close_t on_close;
stio_mchar_t* mcmd;
};
struct stio_dev_pro_slave_t
{
STIO_DEV_HEADERS;
stio_dev_pro_sid_t id;
stio_syshnd_t pfd;
stio_dev_pro_t* master; /* parent device */
};
enum stio_dev_pro_make_flag_t
{
STIO_DEV_PRO_WRITEIN = (1 << 0),
STIO_DEV_PRO_READOUT = (1 << 1),
STIO_DEV_PRO_READERR = (1 << 2),
STIO_DEV_PRO_ERRTOOUT = (1 << 3),
STIO_DEV_PRO_OUTTOERR = (1 << 4),
STIO_DEV_PRO_INTONUL = (1 << 5),
STIO_DEV_PRO_OUTTONUL = (1 << 6),
STIO_DEV_PRO_ERRTONUL = (1 << 7),
STUO_DEV_PRO_DROPIN = (1 << 8),
STUO_DEV_PRO_DROPOUT = (1 << 9),
STUO_DEV_PRO_DROPERR = (1 << 10),
STIO_DEV_PRO_SHELL = (1 << 13),
/* perform no waitpid() on a child process upon device destruction.
* you should set this flag if your application has automatic child
* process reaping enabled. for instance, SIGCHLD is set to SIG_IGN
* on POSIX.1-2001 compliant systems */
STIO_DEV_PRO_FORGET_CHILD = (1 << 14),
STIO_DEV_PRO_FORGET_DIEHARD_CHILD = (1 << 15)
};
typedef enum stio_dev_pro_make_flag_t stio_dev_pro_make_flag_t;
typedef struct stio_dev_pro_make_t stio_dev_pro_make_t;
struct stio_dev_pro_make_t
{
int flags; /**< bitwise-ORed of stio_dev_pro_make_flag_t enumerators */
const void* cmd;
stio_dev_pro_on_write_t on_write; /* mandatory */
stio_dev_pro_on_read_t on_read; /* mandatory */
stio_dev_pro_on_close_t on_close; /* optional */
};
enum stio_dev_pro_ioctl_cmd_t
{
STIO_DEV_PRO_CLOSE,
STIO_DEV_PRO_KILL_CHILD
};
typedef enum stio_dev_pro_ioctl_cmd_t stio_dev_pro_ioctl_cmd_t;
#ifdef __cplusplus
extern "C" {
#endif
STIO_EXPORT stio_dev_pro_t* stio_dev_pro_make (
stio_t* stio,
stio_size_t xtnsize,
const stio_dev_pro_make_t* data
);
STIO_EXPORT void stio_dev_pro_kill (
stio_dev_pro_t* pro
);
STIO_EXPORT int stio_dev_pro_write (
stio_dev_pro_t* pro,
const void* data,
stio_iolen_t len,
void* wrctx
);
STIO_EXPORT int stio_dev_pro_timedwrite (
stio_dev_pro_t* pro,
const void* data,
stio_iolen_t len,
const stio_ntime_t* tmout,
void* wrctx
);
STIO_EXPORT int stio_dev_pro_close (
stio_dev_pro_t* pro,
stio_dev_pro_sid_t sid
);
STIO_EXPORT int stio_dev_pro_killchild (
stio_dev_pro_t* pro
);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,204 +0,0 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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.
*/
#ifndef _STIO_PRV_H_
#define _STIO_PRV_H_
#include "stio.h"
/*TODO: redefine and remove these */
#include <assert.h>
#include <string.h>
#include <stdio.h>
/*TODO: redefine these */
#define STIO_MEMSET(dst,byte,count) memset(dst,byte,count)
#define STIO_MEMCPY(dst,src,count) memcpy(dst,src,count)
#define STIO_MEMMOVE(dst,src,count) memmove(dst,src,count)
#define STIO_MEMCMP(dst,src,count) memcmp(dst,src,count)
#define STIO_ASSERT assert
typedef struct stio_mux_t stio_mux_t;
struct stio_t
{
stio_mmgr_t* mmgr;
stio_errnum_t errnum;
stio_stopreq_t stopreq; /* stop request to abort stio_loop() */
struct
{
stio_dev_t* head;
stio_dev_t* tail;
} actdev; /* active devices */
struct
{
stio_dev_t* head;
stio_dev_t* tail;
} hltdev; /* halted devices */
struct
{
stio_dev_t* head;
stio_dev_t* tail;
} zmbdev; /* zombie devices */
stio_uint8_t bigbuf[65535]; /* TODO: make this dynamic depending on devices added. device may indicate a buffer size required??? */
unsigned int renew_watch: 1;
unsigned int in_exec: 1;
struct
{
stio_size_t capa;
stio_size_t size;
stio_tmrjob_t* jobs;
} tmr;
/* platform specific fields below */
#if defined(_WIN32)
HANDLE iocp;
#else
stio_mux_t* mux;
#endif
};
#define STIO_EPOCH_YEAR (1970)
#define STIO_EPOCH_MON (1)
#define STIO_EPOCH_DAY (1)
#define STIO_EPOCH_WDAY (4)
/* windows specific epoch time */
#define STIO_EPOCH_YEAR_WIN (1601)
#define STIO_EPOCH_MON_WIN (1)
#define STIO_EPOCH_DAY_WIN (1)
#define STIO_DAYS_PER_WEEK (7)
#define STIO_MONS_PER_YEAR (12)
#define STIO_HOURS_PER_DAY (24)
#define STIO_MINS_PER_HOUR (60)
#define STIO_MINS_PER_DAY (STIO_MINS_PER_HOUR*STIO_HOURS_PER_DAY)
#define STIO_SECS_PER_MIN (60)
#define STIO_SECS_PER_HOUR (STIO_SECS_PER_MIN*STIO_MINS_PER_HOUR)
#define STIO_SECS_PER_DAY (STIO_SECS_PER_MIN*STIO_MINS_PER_DAY)
#define STIO_MSECS_PER_SEC (1000)
#define STIO_MSECS_PER_MIN (STIO_MSECS_PER_SEC*STIO_SECS_PER_MIN)
#define STIO_MSECS_PER_HOUR (STIO_MSECS_PER_SEC*STIO_SECS_PER_HOUR)
#define STIO_MSECS_PER_DAY (STIO_MSECS_PER_SEC*STIO_SECS_PER_DAY)
#define STIO_USECS_PER_MSEC (1000)
#define STIO_NSECS_PER_USEC (1000)
#define STIO_NSECS_PER_MSEC (STIO_NSECS_PER_USEC*STIO_USECS_PER_MSEC)
#define STIO_USECS_PER_SEC (STIO_USECS_PER_MSEC*STIO_MSECS_PER_SEC)
#define STIO_NSECS_PER_SEC (STIO_NSECS_PER_USEC*STIO_USECS_PER_MSEC*STIO_MSECS_PER_SEC)
#define STIO_SECNSEC_TO_MSEC(sec,nsec) \
(((stio_intptr_t)(sec) * STIO_MSECS_PER_SEC) + ((stio_intptr_t)(nsec) / STIO_NSECS_PER_MSEC))
#define STIO_SECNSEC_TO_USEC(sec,nsec) \
(((stio_intptr_t)(sec) * STIO_USECS_PER_SEC) + ((stio_intptr_t)(nsec) / STIO_NSECS_PER_USEC))
#define STIO_SEC_TO_MSEC(sec) ((sec) * STIO_MSECS_PER_SEC)
#define STIO_MSEC_TO_SEC(sec) ((sec) / STIO_MSECS_PER_SEC)
#define STIO_USEC_TO_NSEC(usec) ((usec) * STIO_NSECS_PER_USEC)
#define STIO_NSEC_TO_USEC(nsec) ((nsec) / STIO_NSECS_PER_USEC)
#define STIO_MSEC_TO_NSEC(msec) ((msec) * STIO_NSECS_PER_MSEC)
#define STIO_NSEC_TO_MSEC(nsec) ((nsec) / STIO_NSECS_PER_MSEC)
#define STIO_SEC_TO_NSEC(sec) ((sec) * STIO_NSECS_PER_SEC)
#define STIO_NSEC_TO_SEC(nsec) ((nsec) / STIO_NSECS_PER_SEC)
#define STIO_SEC_TO_USEC(sec) ((sec) * STIO_USECS_PER_SEC)
#define STIO_USEC_TO_SEC(usec) ((usec) / STIO_USECS_PER_SEC)
#ifdef __cplusplus
extern "C" {
#endif
int stio_makesyshndasync (
stio_t* stio,
stio_syshnd_t hnd
);
stio_errnum_t stio_syserrtoerrnum (
int no
);
stio_mchar_t* stio_mbsdup (
stio_t* stio,
const stio_mchar_t* src
);
stio_size_t stio_mbscpy (
stio_mchar_t* buf,
const stio_mchar_t* str
);
int stio_mbsspltrn (
stio_mchar_t* s,
const stio_mchar_t* delim,
stio_mchar_t lquote,
stio_mchar_t rquote,
stio_mchar_t escape,
const stio_mchar_t* trset
);
int stio_mbsspl (
stio_mchar_t* s,
const stio_mchar_t* delim,
stio_mchar_t lquote,
stio_mchar_t rquote,
stio_mchar_t escape
);
void stio_cleartmrjobs (
stio_t* stio
);
void stio_firetmrjobs (
stio_t* stio,
const stio_ntime_t* tmbase,
stio_size_t* firecnt
);
int stio_gettmrtmout (
stio_t* stio,
const stio_ntime_t* tmbase,
stio_ntime_t* tmout
);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,600 +0,0 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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.
*/
#ifndef _STIO_SCK_H_
#define _STIO_SCK_H_
#include <stio.h>
/* ========================================================================= */
/* TOOD: move these to a separte file */
#define STIO_ETHHDR_PROTO_IP4 0x0800
#define STIO_ETHHDR_PROTO_ARP 0x0806
#define STIO_ETHHDR_PROTO_8021Q 0x8100 /* 802.1Q VLAN */
#define STIO_ETHHDR_PROTO_IP6 0x86DD
#define STIO_ARPHDR_OPCODE_REQUEST 1
#define STIO_ARPHDR_OPCODE_REPLY 2
#define STIO_ARPHDR_HTYPE_ETH 0x0001
#define STIO_ARPHDR_PTYPE_IP4 0x0800
#define STIO_ETHADDR_LEN 6
#define STIO_IP4ADDR_LEN 4
#define STIO_IP6ADDR_LEN 16
#if defined(__GNUC__)
# define STIO_PACKED __attribute__((__packed__))
#else
# define STIO_PACKED
# STIO_PACK_PUSH pack(push)
# STIO_PACK_PUSH pack(push)
# STIO_PACK(x) pack(x)
#endif
#if defined(__GNUC__)
/* nothing */
#else
#pragma pack(push)
#pragma pack(1)
#endif
struct STIO_PACKED stio_ethaddr_t
{
stio_uint8_t v[STIO_ETHADDR_LEN];
};
typedef struct stio_ethaddr_t stio_ethaddr_t;
struct STIO_PACKED stio_ip4addr_t
{
stio_uint8_t v[STIO_IP4ADDR_LEN];
};
typedef struct stio_ip4addr_t stio_ip4addr_t;
struct STIO_PACKED stio_ip6addr_t
{
stio_uint8_t v[STIO_IP6ADDR_LEN];
};
typedef struct stio_ip6addr_t stio_ip6addr_t;
struct STIO_PACKED stio_ethhdr_t
{
stio_uint8_t dest[STIO_ETHADDR_LEN];
stio_uint8_t source[STIO_ETHADDR_LEN];
stio_uint16_t proto;
};
typedef struct stio_ethhdr_t stio_ethhdr_t;
struct STIO_PACKED stio_arphdr_t
{
stio_uint16_t htype; /* hardware type (ethernet: 0x0001) */
stio_uint16_t ptype; /* protocol type (ipv4: 0x0800) */
stio_uint8_t hlen; /* hardware address length (ethernet: 6) */
stio_uint8_t plen; /* protocol address length (ipv4 :4) */
stio_uint16_t opcode; /* operation code */
};
typedef struct stio_arphdr_t stio_arphdr_t;
/* arp payload for ipv4 over ethernet */
struct STIO_PACKED stio_etharp_t
{
stio_uint8_t sha[STIO_ETHADDR_LEN]; /* source hardware address */
stio_uint8_t spa[STIO_IP4ADDR_LEN]; /* source protocol address */
stio_uint8_t tha[STIO_ETHADDR_LEN]; /* target hardware address */
stio_uint8_t tpa[STIO_IP4ADDR_LEN]; /* target protocol address */
};
typedef struct stio_etharp_t stio_etharp_t;
struct STIO_PACKED stio_etharp_pkt_t
{
stio_ethhdr_t ethhdr;
stio_arphdr_t arphdr;
stio_etharp_t arppld;
};
typedef struct stio_etharp_pkt_t stio_etharp_pkt_t;
struct stio_iphdr_t
{
#if defined(STIO_ENDIAN_LITTLE)
stio_uint8_t ihl:4;
stio_uint8_t version:4;
#elif defined(STIO_ENDIAN_BIG)
stio_uint8_t version:4;
stio_uint8_t ihl:4;
#else
# UNSUPPORTED ENDIAN
#endif
stio_int8_t tos;
stio_int16_t tot_len;
stio_int16_t id;
stio_int16_t frag_off;
stio_int8_t ttl;
stio_int8_t protocol;
stio_int16_t check;
stio_int32_t saddr;
stio_int32_t daddr;
/*The options start here. */
};
typedef struct stio_iphdr_t stio_iphdr_t;
struct STIO_PACKED stio_icmphdr_t
{
stio_uint8_t type; /* message type */
stio_uint8_t code; /* subcode */
stio_uint16_t checksum;
union
{
struct
{
stio_uint16_t id;
stio_uint16_t seq;
} echo;
stio_uint32_t gateway;
struct
{
stio_uint16_t frag_unused;
stio_uint16_t mtu;
} frag; /* path mut discovery */
} u;
};
typedef struct stio_icmphdr_t stio_icmphdr_t;
#if defined(__GNUC__)
/* nothing */
#else
#pragma pack(pop)
#endif
/* ICMP types */
#define STIO_ICMP_ECHO_REPLY 0
#define STIO_ICMP_UNREACH 3 /* destination unreachable */
#define STIO_ICMP_SOURCE_QUENCE 4
#define STIO_ICMP_REDIRECT 5
#define STIO_ICMP_ECHO_REQUEST 8
#define STIO_ICMP_TIME_EXCEEDED 11
#define STIO_ICMP_PARAM_PROBLEM 12
#define STIO_ICMP_TIMESTAMP_REQUEST 13
#define STIO_ICMP_TIMESTAMP_REPLY 14
#define STIO_ICMP_INFO_REQUEST 15
#define STIO_ICMP_INFO_REPLY 16
#define STIO_ICMP_ADDR_MASK_REQUEST 17
#define STIO_ICMP_ADDR_MASK_REPLY 18
/* Subcode for STIO_ICMP_UNREACH */
#define STIO_ICMP_UNREACH_NET 0
#define STIO_ICMP_UNREACH_HOST 1
#define STIO_ICMP_UNREACH_PROTOCOL 2
#define STIO_ICMP_UNREACH_PORT 3
#define STIO_ICMP_UNREACH_FRAG_NEEDED 4
/* Subcode for STIO_ICMP_REDIRECT */
#define STIO_ICMP_REDIRECT_NET 0
#define STIO_ICMP_REDIRECT_HOST 1
#define STIO_ICMP_REDIRECT_NETTOS 2
#define STIO_ICMP_REDIRECT_HOSTTOS 3
/* Subcode for STIO_ICMP_TIME_EXCEEDED */
#define STIO_ICMP_TIME_EXCEEDED_TTL 0
#define STIO_ICMP_TIME_EXCEEDED_FRAGTIME 1
/* ========================================================================= */
typedef int stio_sckfam_t;
struct stio_sckaddr_t
{
stio_sckfam_t family;
stio_uint8_t data[128]; /* TODO: use the actual sockaddr size */
};
typedef struct stio_sckaddr_t stio_sckaddr_t;
#if (STIO_SIZEOF_SOCKLEN_T == STIO_SIZEOF_INT)
#if defined(STIO_SOCKLEN_T_IS_SIGNED)
typedef int stio_scklen_t;
#else
typedef unsigned int stio_scklen_t;
#endif
#elif (STIO_SIZEOF_SOCKLEN_T == STIO_SIZEOF_LONG)
#if defined(STIO_SOCKLEN_T_IS_SIGNED)
typedef long stio_scklen_t;
#else
typedef unsigned long stio_scklen_t;
#endif
#else
typedef int stio_scklen_t;
#endif
#if defined(_WIN32)
# define STIO_IOCP_KEY 1
/*
typedef HANDLE stio_syshnd_t;
typedef SOCKET stio_sckhnd_t;
# define STIO_SCKHND_INVALID (INVALID_SOCKET)
*/
typedef stio_uintptr_t qse_sckhnd_t;
# define STIO_SCKHND_INVALID (~(qse_sck_hnd_t)0)
#else
typedef int stio_sckhnd_t;
# define STIO_SCKHND_INVALID (-1)
#endif
/* ========================================================================= */
enum stio_dev_sck_ioctl_cmd_t
{
STIO_DEV_SCK_BIND,
STIO_DEV_SCK_CONNECT,
STIO_DEV_SCK_LISTEN
};
typedef enum stio_dev_sck_ioctl_cmd_t stio_dev_sck_ioctl_cmd_t;
#define STIO_DEV_SCK_SET_PROGRESS(dev,bit) do { \
(dev)->state &= ~STIO_DEV_SCK_ALL_PROGRESS_BITS; \
(dev)->state |= (bit); \
} while(0)
#define STIO_DEV_SCK_GET_PROGRESS(dev) ((dev)->state & STIO_DEV_SCK_ALL_PROGRESS_BITS)
enum stio_dev_sck_state_t
{
/* the following items(progress bits) are mutually exclusive */
STIO_DEV_SCK_CONNECTING = (1 << 0),
STIO_DEV_SCK_CONNECTING_SSL = (1 << 1),
STIO_DEV_SCK_CONNECTED = (1 << 2),
STIO_DEV_SCK_LISTENING = (1 << 3),
STIO_DEV_SCK_ACCEPTING_SSL = (1 << 4),
STIO_DEV_SCK_ACCEPTED = (1 << 5),
/* the following items can be bitwise-ORed with an exclusive item above */
STIO_DEV_SCK_INTERCEPTED = (1 << 15),
/* convenience bit masks */
STIO_DEV_SCK_ALL_PROGRESS_BITS = (STIO_DEV_SCK_CONNECTING |
STIO_DEV_SCK_CONNECTING_SSL |
STIO_DEV_SCK_CONNECTED |
STIO_DEV_SCK_LISTENING |
STIO_DEV_SCK_ACCEPTING_SSL |
STIO_DEV_SCK_ACCEPTED)
};
typedef enum stio_dev_sck_state_t stio_dev_sck_state_t;
typedef struct stio_dev_sck_t stio_dev_sck_t;
typedef int (*stio_dev_sck_on_read_t) (
stio_dev_sck_t* dev,
const void* data,
stio_iolen_t dlen,
const stio_sckaddr_t* srcaddr
);
typedef int (*stio_dev_sck_on_write_t) (
stio_dev_sck_t* dev,
stio_iolen_t wrlen,
void* wrctx,
const stio_sckaddr_t* dstaddr
);
typedef void (*stio_dev_sck_on_disconnect_t) (
stio_dev_sck_t* dev
);
typedef int (*stio_dev_sck_on_connect_t) (
stio_dev_sck_t* dev
);
enum stio_dev_sck_type_t
{
STIO_DEV_SCK_TCP4,
STIO_DEV_SCK_TCP6,
STIO_DEV_SCK_UPD4,
STIO_DEV_SCK_UDP6,
/* ARP at the ethernet layer */
STIO_DEV_SCK_ARP,
STIO_DEV_SCK_ARP_DGRAM,
/* ICMP at the IPv4 layer */
STIO_DEV_SCK_ICMP4,
/* ICMP at the IPv6 layer */
STIO_DEV_SCK_ICMP6
#if 0
STIO_DEV_SCK_RAW, /* raw L2-level packet */
#endif
};
typedef enum stio_dev_sck_type_t stio_dev_sck_type_t;
typedef struct stio_dev_sck_make_t stio_dev_sck_make_t;
struct stio_dev_sck_make_t
{
stio_dev_sck_type_t type;
stio_dev_sck_on_write_t on_write;
stio_dev_sck_on_read_t on_read;
stio_dev_sck_on_disconnect_t on_disconnect;
};
enum stio_dev_sck_bind_option_t
{
STIO_DEV_SCK_BIND_BROADCAST = (1 << 0),
STIO_DEV_SCK_BIND_REUSEADDR = (1 << 1),
STIO_DEV_SCK_BIND_REUSEPORT = (1 << 2),
STIO_DEV_SCK_BIND_TRANSPARENT = (1 << 3),
/* TODO: more options --- SO_RCVBUF, SO_SNDBUF, SO_RCVTIMEO, SO_SNDTIMEO, SO_KEEPALIVE */
/* BINDTODEVICE??? */
STIO_DEV_SCK_BIND_SSL = (1 << 15)
};
typedef enum stio_dev_sck_bind_option_t stio_dev_sck_bind_option_t;
typedef struct stio_dev_sck_bind_t stio_dev_sck_bind_t;
struct stio_dev_sck_bind_t
{
int options;
stio_sckaddr_t localaddr;
/* TODO: add device name for BIND_TO_DEVICE */
const stio_mchar_t* ssl_certfile;
const stio_mchar_t* ssl_keyfile;
stio_ntime_t accept_tmout;
};
enum stio_def_sck_connect_option_t
{
STIO_DEV_SCK_CONNECT_SSL = (1 << 15)
};
typedef enum stio_dev_sck_connect_option_t stio_dev_sck_connect_option_t;
typedef struct stio_dev_sck_connect_t stio_dev_sck_connect_t;
struct stio_dev_sck_connect_t
{
int options;
stio_sckaddr_t remoteaddr;
stio_ntime_t connect_tmout;
stio_dev_sck_on_connect_t on_connect;
};
typedef struct stio_dev_sck_listen_t stio_dev_sck_listen_t;
struct stio_dev_sck_listen_t
{
int backlogs;
stio_dev_sck_on_connect_t on_connect; /* optional, but new connections are dropped immediately without this */
};
typedef struct stio_dev_sck_accept_t stio_dev_sck_accept_t;
struct stio_dev_sck_accept_t
{
stio_syshnd_t sck;
/* TODO: add timeout */
stio_sckaddr_t remoteaddr;
};
struct stio_dev_sck_t
{
STIO_DEV_HEADERS;
stio_dev_sck_type_t type;
stio_sckhnd_t sck;
int state;
/* remote peer address for a stateful stream socket. valid if one of the
* followings is set in state:
* STIO_DEV_TCP_ACCEPTING_SSL
* STIO_DEV_TCP_ACCEPTED
* STIO_DEV_TCP_CONNECTED
* STIO_DEV_TCP_CONNECTING
* STIO_DEV_TCP_CONNECTING_SSL
*
* also used as a placeholder to store source address for
* a stateless socket */
stio_sckaddr_t remoteaddr;
/* local socket address */
stio_sckaddr_t localaddr;
/* original destination address */
stio_sckaddr_t orgdstaddr;
stio_dev_sck_on_write_t on_write;
stio_dev_sck_on_read_t on_read;
/* return 0 on succes, -1 on failure.
* called on a new tcp device for an accepted client or
* on a tcp device conntected to a remote server */
stio_dev_sck_on_connect_t on_connect;
stio_dev_sck_on_disconnect_t on_disconnect;
/* timer job index for handling
* - connect() timeout for a connecting socket.
* - SSL_accept() timeout for a socket accepting SSL */
stio_tmridx_t tmrjob_index;
/* connect timeout, ssl-connect timeout, ssl-accept timeout.
* it denotes timeout duration under some circumstances
* or an absolute expiry time under some other circumstances. */
stio_ntime_t tmout;
void* ssl_ctx;
void* ssl;
};
#ifdef __cplusplus
extern "C" {
#endif
STIO_EXPORT stio_sckhnd_t stio_openasyncsck (
stio_t* stio,
int domain,
int type,
int proto
);
STIO_EXPORT void stio_closeasyncsck (
stio_t* stio,
stio_sckhnd_t sck
);
STIO_EXPORT int stio_makesckasync (
stio_t* stio,
stio_sckhnd_t sck
);
STIO_EXPORT int stio_getsckaddrinfo (
stio_t* stio,
const stio_sckaddr_t* addr,
stio_scklen_t* len,
stio_sckfam_t* family
);
/*
* The stio_getsckaddrport() function returns the port number of a socket
* address in the host byte order. If the address doesn't support the port
* number, it returns 0.
*/
STIO_EXPORT stio_uint16_t stio_getsckaddrport (
const stio_sckaddr_t* addr
);
/*
* The stio_getsckaddrifindex() function returns an interface number.
* If the address doesn't support the interface number, it returns 0. */
STIO_EXPORT int stio_getsckaddrifindex (
const stio_sckaddr_t* addr
);
STIO_EXPORT void stio_sckaddr_initforip4 (
stio_sckaddr_t* sckaddr,
stio_uint16_t port,
stio_ip4addr_t* ip4addr
);
STIO_EXPORT void stio_sckaddr_initforip6 (
stio_sckaddr_t* sckaddr,
stio_uint16_t port,
stio_ip6addr_t* ip6addr
);
STIO_EXPORT void stio_sckaddr_initforeth (
stio_sckaddr_t* sckaddr,
int ifindex,
stio_ethaddr_t* ethaddr
);
/* ========================================================================= */
STIO_EXPORT stio_dev_sck_t* stio_dev_sck_make (
stio_t* stio,
stio_size_t xtnsize,
const stio_dev_sck_make_t* info
);
STIO_EXPORT int stio_dev_sck_bind (
stio_dev_sck_t* dev,
stio_dev_sck_bind_t* info
);
STIO_EXPORT int stio_dev_sck_connect (
stio_dev_sck_t* dev,
stio_dev_sck_connect_t* info
);
STIO_EXPORT int stio_dev_sck_listen (
stio_dev_sck_t* dev,
stio_dev_sck_listen_t* info
);
STIO_EXPORT int stio_dev_sck_write (
stio_dev_sck_t* dev,
const void* data,
stio_iolen_t len,
void* wrctx,
const stio_sckaddr_t* dstaddr
);
STIO_EXPORT int stio_dev_sck_timedwrite (
stio_dev_sck_t* dev,
const void* data,
stio_iolen_t len,
const stio_ntime_t* tmout,
void* wrctx,
const stio_sckaddr_t* dstaddr
);
#if defined(STIO_HAVE_INLINE)
static STIO_INLINE void stio_dev_sck_halt (stio_dev_sck_t* sck)
{
stio_dev_halt ((stio_dev_t*)sck);
}
static STIO_INLINE int stio_dev_sck_read (stio_dev_sck_t* sck, int enabled)
{
return stio_dev_read ((stio_dev_t*)sck, enabled);
}
#else
#define stio_dev_sck_halt(sck) stio_dev_halt((stio_dev_t*)sck)
#define stio_dev_sck_read(sck,enabled) stio_dev_read((stio_dev_t*)sck, enabled)
#endif
STIO_EXPORT stio_uint16_t stio_checksumip (
const void* hdr,
stio_size_t len
);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,234 +0,0 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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 "stio-prv.h"
#define HEAP_PARENT(x) (((x) - 1) / 2)
#define HEAP_LEFT(x) ((x) * 2 + 1)
#define HEAP_RIGHT(x) ((x) * 2 + 2)
#define YOUNGER_THAN(x,y) (stio_cmptime(&(x)->when, &(y)->when) < 0)
void stio_cleartmrjobs (stio_t* stio)
{
while (stio->tmr.size > 0) stio_deltmrjob (stio, 0);
}
static stio_tmridx_t sift_up (stio_t* stio, stio_tmridx_t index, int notify)
{
stio_tmridx_t parent;
parent = HEAP_PARENT(index);
if (index > 0 && YOUNGER_THAN(&stio->tmr.jobs[index], &stio->tmr.jobs[parent]))
{
stio_tmrjob_t item;
item = stio->tmr.jobs[index];
do
{
/* move down the parent to my current position */
stio->tmr.jobs[index] = stio->tmr.jobs[parent];
if (stio->tmr.jobs[index].idxptr) *stio->tmr.jobs[index].idxptr = index;
/* traverse up */
index = parent;
parent = HEAP_PARENT(parent);
}
while (index > 0 && YOUNGER_THAN(&item, &stio->tmr.jobs[parent]));
stio->tmr.jobs[index] = item;
if (stio->tmr.jobs[index].idxptr) *stio->tmr.jobs[index].idxptr = index;
}
return index;
}
static stio_tmridx_t sift_down (stio_t* stio, stio_tmridx_t index, int notify)
{
stio_size_t base = stio->tmr.size / 2;
if (index < base) /* at least 1 child is under the 'index' position */
{
stio_tmrjob_t item;
item = stio->tmr.jobs[index];
do
{
stio_tmridx_t left, right, younger;
left = HEAP_LEFT(index);
right = HEAP_RIGHT(index);
if (right < stio->tmr.size && YOUNGER_THAN(&stio->tmr.jobs[right], &stio->tmr.jobs[left]))
{
younger = right;
}
else
{
younger = left;
}
if (YOUNGER_THAN(&item, &stio->tmr.jobs[younger])) break;
stio->tmr.jobs[index] = stio->tmr.jobs[younger];
if (stio->tmr.jobs[index].idxptr) *stio->tmr.jobs[index].idxptr = index;
index = younger;
}
while (index < base);
stio->tmr.jobs[index] = item;
if (stio->tmr.jobs[index].idxptr) *stio->tmr.jobs[index].idxptr = index;
}
return index;
}
void stio_deltmrjob (stio_t* stio, stio_tmridx_t index)
{
stio_tmrjob_t item;
STIO_ASSERT (index < stio->tmr.size);
item = stio->tmr.jobs[index];
if (stio->tmr.jobs[index].idxptr) *stio->tmr.jobs[index].idxptr = STIO_TMRIDX_INVALID;
stio->tmr.size = stio->tmr.size - 1;
if (stio->tmr.size > 0 && index != stio->tmr.size)
{
stio->tmr.jobs[index] = stio->tmr.jobs[stio->tmr.size];
if (stio->tmr.jobs[index].idxptr) *stio->tmr.jobs[index].idxptr = index;
YOUNGER_THAN(&stio->tmr.jobs[index], &item)? sift_up(stio, index, 1): sift_down(stio, index, 1);
}
}
stio_tmridx_t stio_instmrjob (stio_t* stio, const stio_tmrjob_t* job)
{
stio_tmridx_t index = stio->tmr.size;
if (index >= stio->tmr.capa)
{
stio_tmrjob_t* tmp;
stio_size_t new_capa;
STIO_ASSERT (stio->tmr.capa >= 1);
new_capa = stio->tmr.capa * 2;
tmp = (stio_tmrjob_t*)STIO_MMGR_REALLOC (stio->mmgr, stio->tmr.jobs, new_capa * STIO_SIZEOF(*tmp));
if (tmp == STIO_NULL)
{
stio->errnum = STIO_ENOMEM;
return STIO_TMRIDX_INVALID;
}
stio->tmr.jobs = tmp;
stio->tmr.capa = new_capa;
}
stio->tmr.size = stio->tmr.size + 1;
stio->tmr.jobs[index] = *job;
if (stio->tmr.jobs[index].idxptr) *stio->tmr.jobs[index].idxptr = index;
return sift_up (stio, index, 0);
}
stio_tmridx_t stio_updtmrjob (stio_t* stio, stio_tmridx_t index, const stio_tmrjob_t* job)
{
stio_tmrjob_t item;
item = stio->tmr.jobs[index];
stio->tmr.jobs[index] = *job;
if (stio->tmr.jobs[index].idxptr) *stio->tmr.jobs[index].idxptr = index;
return YOUNGER_THAN(job, &item)? sift_up (stio, index, 0): sift_down (stio, index, 0);
}
void stio_firetmrjobs (stio_t* stio, const stio_ntime_t* tm, stio_size_t* firecnt)
{
stio_ntime_t now;
stio_tmrjob_t tmrjob;
stio_size_t count = 0;
/* if the current time is not specified, get it from the system */
if (tm) now = *tm;
else stio_gettime (&now);
while (stio->tmr.size > 0)
{
if (stio_cmptime(&stio->tmr.jobs[0].when, &now) > 0) break;
tmrjob = stio->tmr.jobs[0]; /* copy the scheduled job */
stio_deltmrjob (stio, 0); /* deschedule the job */
count++;
tmrjob.handler (stio, &now, &tmrjob); /* then fire the job */
}
if (firecnt) *firecnt = count;
}
int stio_gettmrtmout (stio_t* stio, const stio_ntime_t* tm, stio_ntime_t* tmout)
{
stio_ntime_t now;
/* time-out can't be calculated when there's no job scheduled */
if (stio->tmr.size <= 0)
{
stio->errnum = STIO_ENOENT;
return -1;
}
/* if the current time is not specified, get it from the system */
if (tm) now = *tm;
else stio_gettime (&now);
stio_subtime (&stio->tmr.jobs[0].when, &now, tmout);
if (tmout->sec < 0) stio_cleartime (tmout);
return 0;
}
stio_tmrjob_t* stio_gettmrjob (stio_t* stio, stio_tmridx_t index)
{
if (index < 0 || index >= stio->tmr.size)
{
stio->errnum = STIO_ENOENT;
return STIO_NULL;
}
return &stio->tmr.jobs[index];
}
int stio_gettmrjobdeadline (stio_t* stio, stio_tmridx_t index, stio_ntime_t* deadline)
{
if (index < 0 || index >= stio->tmr.size)
{
stio->errnum = STIO_ENOENT;
return -1;
}
*deadline = stio->tmr.jobs[index].when;
return 0;
}

View File

@ -1,524 +0,0 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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 "stio-prv.h"
/* ========================================================================= */
#if defined(STIO_HAVE_UINT16_T)
stio_uint16_t stio_ntoh16 (stio_uint16_t x)
{
#if defined(STIO_ENDIAN_BIG)
return x;
#elif defined(STIO_ENDIAN_LITTLE)
stio_uint8_t* c = (stio_uint8_t*)&x;
return (stio_uint16_t)(
((stio_uint16_t)c[0] << 8) |
((stio_uint16_t)c[1] << 0));
#else
# error Unknown endian
#endif
}
stio_uint16_t stio_hton16 (stio_uint16_t x)
{
#if defined(STIO_ENDIAN_BIG)
return x;
#elif defined(STIO_ENDIAN_LITTLE)
stio_uint8_t* c = (stio_uint8_t*)&x;
return (stio_uint16_t)(
((stio_uint16_t)c[0] << 8) |
((stio_uint16_t)c[1] << 0));
#else
# error Unknown endian
#endif
}
#endif
/* ========================================================================= */
#if defined(STIO_HAVE_UINT32_T)
stio_uint32_t stio_ntoh32 (stio_uint32_t x)
{
#if defined(STIO_ENDIAN_BIG)
return x;
#elif defined(STIO_ENDIAN_LITTLE)
stio_uint8_t* c = (stio_uint8_t*)&x;
return (stio_uint32_t)(
((stio_uint32_t)c[0] << 24) |
((stio_uint32_t)c[1] << 16) |
((stio_uint32_t)c[2] << 8) |
((stio_uint32_t)c[3] << 0));
#else
# error Unknown endian
#endif
}
stio_uint32_t stio_hton32 (stio_uint32_t x)
{
#if defined(STIO_ENDIAN_BIG)
return x;
#elif defined(STIO_ENDIAN_LITTLE)
stio_uint8_t* c = (stio_uint8_t*)&x;
return (stio_uint32_t)(
((stio_uint32_t)c[0] << 24) |
((stio_uint32_t)c[1] << 16) |
((stio_uint32_t)c[2] << 8) |
((stio_uint32_t)c[3] << 0));
#else
# error Unknown endian
#endif
}
#endif
/* ========================================================================= */
#if defined(STIO_HAVE_UINT64_T)
stio_uint64_t stio_ntoh64 (stio_uint64_t x)
{
#if defined(STIO_ENDIAN_BIG)
return x;
#elif defined(STIO_ENDIAN_LITTLE)
stio_uint8_t* c = (stio_uint8_t*)&x;
return (stio_uint64_t)(
((stio_uint64_t)c[0] << 56) |
((stio_uint64_t)c[1] << 48) |
((stio_uint64_t)c[2] << 40) |
((stio_uint64_t)c[3] << 32) |
((stio_uint64_t)c[4] << 24) |
((stio_uint64_t)c[5] << 16) |
((stio_uint64_t)c[6] << 8) |
((stio_uint64_t)c[7] << 0));
#else
# error Unknown endian
#endif
}
stio_uint64_t stio_hton64 (stio_uint64_t x)
{
#if defined(STIO_ENDIAN_BIG)
return x;
#elif defined(STIO_ENDIAN_LITTLE)
stio_uint8_t* c = (stio_uint8_t*)&x;
return (stio_uint64_t)(
((stio_uint64_t)c[0] << 56) |
((stio_uint64_t)c[1] << 48) |
((stio_uint64_t)c[2] << 40) |
((stio_uint64_t)c[3] << 32) |
((stio_uint64_t)c[4] << 24) |
((stio_uint64_t)c[5] << 16) |
((stio_uint64_t)c[6] << 8) |
((stio_uint64_t)c[7] << 0));
#else
# error Unknown endian
#endif
}
#endif
/* ========================================================================= */
#if defined(STIO_HAVE_UINT128_T)
stio_uint128_t stio_ntoh128 (stio_uint128_t x)
{
#if defined(STIO_ENDIAN_BIG)
return x;
#elif defined(STIO_ENDIAN_LITTLE)
stio_uint8_t* c = (stio_uint8_t*)&x;
return (stio_uint128_t)(
((stio_uint128_t)c[0] << 120) |
((stio_uint128_t)c[1] << 112) |
((stio_uint128_t)c[2] << 104) |
((stio_uint128_t)c[3] << 96) |
((stio_uint128_t)c[4] << 88) |
((stio_uint128_t)c[5] << 80) |
((stio_uint128_t)c[6] << 72) |
((stio_uint128_t)c[7] << 64) |
((stio_uint128_t)c[8] << 56) |
((stio_uint128_t)c[9] << 48) |
((stio_uint128_t)c[10] << 40) |
((stio_uint128_t)c[11] << 32) |
((stio_uint128_t)c[12] << 24) |
((stio_uint128_t)c[13] << 16) |
((stio_uint128_t)c[14] << 8) |
((stio_uint128_t)c[15] << 0));
#else
# error Unknown endian
#endif
}
stio_uint128_t stio_hton128 (stio_uint128_t x)
{
#if defined(STIO_ENDIAN_BIG)
return x;
#elif defined(STIO_ENDIAN_LITTLE)
stio_uint8_t* c = (stio_uint8_t*)&x;
return (stio_uint128_t)(
((stio_uint128_t)c[0] << 120) |
((stio_uint128_t)c[1] << 112) |
((stio_uint128_t)c[2] << 104) |
((stio_uint128_t)c[3] << 96) |
((stio_uint128_t)c[4] << 88) |
((stio_uint128_t)c[5] << 80) |
((stio_uint128_t)c[6] << 72) |
((stio_uint128_t)c[7] << 64) |
((stio_uint128_t)c[8] << 56) |
((stio_uint128_t)c[9] << 48) |
((stio_uint128_t)c[10] << 40) |
((stio_uint128_t)c[11] << 32) |
((stio_uint128_t)c[12] << 24) |
((stio_uint128_t)c[13] << 16) |
((stio_uint128_t)c[14] << 8) |
((stio_uint128_t)c[15] << 0));
#else
# error Unknown endian
#endif
}
#endif
/* ========================================================================= */
#define IS_MSPACE(x) ((x) == STIO_MT(' ') || (x) == STIO_MT('\t') || (x) == STIO_MT('\n') || (x) == STIO_MT('\r'))
stio_mchar_t* stio_mbsdup (stio_t* stio, const stio_mchar_t* src)
{
stio_mchar_t* dst;
stio_size_t len;
dst = (stio_mchar_t*)src;
while (*dst != STIO_MT('\0')) dst++;
len = dst - src;
dst = STIO_MMGR_ALLOC (stio->mmgr, (len + 1) * STIO_SIZEOF(*src));
if (!dst)
{
stio->errnum = STIO_ENOMEM;
return STIO_NULL;
}
STIO_MEMCPY (dst, src, (len + 1) * STIO_SIZEOF(*src));
return dst;
}
stio_size_t stio_mbscpy (stio_mchar_t* buf, const stio_mchar_t* str)
{
stio_mchar_t* org = buf;
while ((*buf++ = *str++) != STIO_MT('\0'));
return buf - org - 1;
}
int stio_mbsspltrn (
stio_mchar_t* s, const stio_mchar_t* delim,
stio_mchar_t lquote, stio_mchar_t rquote,
stio_mchar_t escape, const stio_mchar_t* trset)
{
stio_mchar_t* p = s, *d;
stio_mchar_t* sp = STIO_NULL, * ep = STIO_NULL;
int delim_mode;
int cnt = 0;
if (delim == STIO_NULL) delim_mode = 0;
else
{
delim_mode = 1;
for (d = (stio_mchar_t*)delim; *d != STIO_MT('\0'); d++)
if (!IS_MSPACE(*d)) delim_mode = 2;
}
if (delim_mode == 0)
{
/* skip preceding space characters */
while (IS_MSPACE(*p)) p++;
/* when 0 is given as "delim", it has an effect of cutting
preceding and trailing space characters off "s". */
if (lquote != STIO_MT('\0') && *p == lquote)
{
stio_mbscpy (p, p + 1);
for (;;)
{
if (*p == STIO_MT('\0')) return -1;
if (escape != STIO_MT('\0') && *p == escape)
{
if (trset != STIO_NULL && p[1] != STIO_MT('\0'))
{
const stio_mchar_t* ep = trset;
while (*ep != STIO_MT('\0'))
{
if (p[1] == *ep++)
{
p[1] = *ep;
break;
}
}
}
stio_mbscpy (p, p + 1);
}
else
{
if (*p == rquote)
{
p++;
break;
}
}
if (sp == 0) sp = p;
ep = p;
p++;
}
while (IS_MSPACE(*p)) p++;
if (*p != STIO_MT('\0')) return -1;
if (sp == 0 && ep == 0) s[0] = STIO_MT('\0');
else
{
ep[1] = STIO_MT('\0');
if (s != (stio_mchar_t*)sp) stio_mbscpy (s, sp);
cnt++;
}
}
else
{
while (*p)
{
if (!IS_MSPACE(*p))
{
if (sp == 0) sp = p;
ep = p;
}
p++;
}
if (sp == 0 && ep == 0) s[0] = STIO_MT('\0');
else
{
ep[1] = STIO_MT('\0');
if (s != (stio_mchar_t*)sp) stio_mbscpy (s, sp);
cnt++;
}
}
}
else if (delim_mode == 1)
{
stio_mchar_t* o;
while (*p)
{
o = p;
while (IS_MSPACE(*p)) p++;
if (o != p) { stio_mbscpy (o, p); p = o; }
if (lquote != STIO_MT('\0') && *p == lquote)
{
stio_mbscpy (p, p + 1);
for (;;)
{
if (*p == STIO_MT('\0')) return -1;
if (escape != STIO_MT('\0') && *p == escape)
{
if (trset != STIO_NULL && p[1] != STIO_MT('\0'))
{
const stio_mchar_t* ep = trset;
while (*ep != STIO_MT('\0'))
{
if (p[1] == *ep++)
{
p[1] = *ep;
break;
}
}
}
stio_mbscpy (p, p + 1);
}
else
{
if (*p == rquote)
{
*p++ = STIO_MT('\0');
cnt++;
break;
}
}
p++;
}
}
else
{
o = p;
for (;;)
{
if (*p == STIO_MT('\0'))
{
if (o != p) cnt++;
break;
}
if (IS_MSPACE (*p))
{
*p++ = STIO_MT('\0');
cnt++;
break;
}
p++;
}
}
}
}
else /* if (delim_mode == 2) */
{
stio_mchar_t* o;
int ok;
while (*p != STIO_MT('\0'))
{
o = p;
while (IS_MSPACE(*p)) p++;
if (o != p) { stio_mbscpy (o, p); p = o; }
if (lquote != STIO_MT('\0') && *p == lquote)
{
stio_mbscpy (p, p + 1);
for (;;)
{
if (*p == STIO_MT('\0')) return -1;
if (escape != STIO_MT('\0') && *p == escape)
{
if (trset != STIO_NULL && p[1] != STIO_MT('\0'))
{
const stio_mchar_t* ep = trset;
while (*ep != STIO_MT('\0'))
{
if (p[1] == *ep++)
{
p[1] = *ep;
break;
}
}
}
stio_mbscpy (p, p + 1);
}
else
{
if (*p == rquote)
{
*p++ = STIO_MT('\0');
cnt++;
break;
}
}
p++;
}
ok = 0;
while (IS_MSPACE(*p)) p++;
if (*p == STIO_MT('\0')) ok = 1;
for (d = (stio_mchar_t*)delim; *d != STIO_MT('\0'); d++)
{
if (*p == *d)
{
ok = 1;
stio_mbscpy (p, p + 1);
break;
}
}
if (ok == 0) return -1;
}
else
{
o = p; sp = ep = 0;
for (;;)
{
if (*p == STIO_MT('\0'))
{
if (ep)
{
ep[1] = STIO_MT('\0');
p = &ep[1];
}
cnt++;
break;
}
for (d = (stio_mchar_t*)delim; *d != STIO_MT('\0'); d++)
{
if (*p == *d)
{
if (sp == STIO_NULL)
{
stio_mbscpy (o, p); p = o;
*p++ = STIO_MT('\0');
}
else
{
stio_mbscpy (&ep[1], p);
stio_mbscpy (o, sp);
o[ep - sp + 1] = STIO_MT('\0');
p = &o[ep - sp + 2];
}
cnt++;
/* last empty field after delim */
if (*p == STIO_MT('\0')) cnt++;
goto exit_point;
}
}
if (!IS_MSPACE (*p))
{
if (sp == STIO_NULL) sp = p;
ep = p;
}
p++;
}
exit_point:
;
}
}
}
return cnt;
}
int stio_mbsspl (
stio_mchar_t* s, const stio_mchar_t* delim,
stio_mchar_t lquote, stio_mchar_t rquote, stio_mchar_t escape)
{
return stio_mbsspltrn (s, delim, lquote, rquote, escape, STIO_NULL);
}

View File

@ -1,554 +0,0 @@
/*
* $Id$
*
Copyright (c) 2015-2016 Chung, Hyung-Hwan. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR 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.
*/
#ifndef _STIO_H_
#define _STIO_H_
#include <stio-cmn.h>
/**
* The stio_ntime_t type defines a numeric time type expressed in the
* number of milliseconds since the Epoch (00:00:00 UTC, Jan 1, 1970).
*/
typedef struct stio_ntime_t stio_ntime_t;
struct stio_ntime_t
{
stio_intptr_t sec;
stio_int32_t nsec; /* nanoseconds */
};
#if defined(_WIN32)
typedef stio_uintptr_t qse_syshnd_t;
#define STIO_SYSHND_INVALID (~(stio_uintptr_t)0)
#else
typedef int stio_syshnd_t;
#define STIO_SYSHND_INVALID (-1)
#endif
typedef struct stio_devaddr_t stio_devaddr_t;
struct stio_devaddr_t
{
int len;
void* ptr;
};
#define STIO_CONST_SWAP16(x) \
((stio_uint16_t)((((stio_uint16_t)(x) & (stio_uint16_t)0x00ffU) << 8) | \
(((stio_uint16_t)(x) & (stio_uint16_t)0xff00U) >> 8) ))
#define STIO_CONST_SWAP32(x) \
((stio_uint32_t)((((stio_uint32_t)(x) & (stio_uint32_t)0x000000ffUL) << 24) | \
(((stio_uint32_t)(x) & (stio_uint32_t)0x0000ff00UL) << 8) | \
(((stio_uint32_t)(x) & (stio_uint32_t)0x00ff0000UL) >> 8) | \
(((stio_uint32_t)(x) & (stio_uint32_t)0xff000000UL) >> 24) ))
#if defined(STIO_ENDIAN_LITTLE)
# define STIO_CONST_NTOH16(x) STIO_CONST_SWAP16(x)
# define STIO_CONST_HTON16(x) STIO_CONST_SWAP16(x)
# define STIO_CONST_NTOH32(x) STIO_CONST_SWAP32(x)
# define STIO_CONST_HTON32(x) STIO_CONST_SWAP32(x)
#elif defined(STIO_ENDIAN_BIG)
# define STIO_CONST_NTOH16(x) (x)
# define STIO_CONST_HTON16(x) (x)
# define STIO_CONST_NTOH32(x) (x)
# define STIO_CONST_HTON32(x) (x)
#else
# error UNKNOWN ENDIAN
#endif
/* ========================================================================= */
typedef struct stio_t stio_t;
typedef struct stio_dev_t stio_dev_t;
typedef struct stio_dev_mth_t stio_dev_mth_t;
typedef struct stio_dev_evcb_t stio_dev_evcb_t;
typedef struct stio_wq_t stio_wq_t;
typedef stio_intptr_t stio_iolen_t; /* NOTE: this is a signed type */
enum stio_errnum_t
{
STIO_ENOERR,
STIO_ENOIMPL,
STIO_ESYSERR,
STIO_EINTERN,
STIO_ENOMEM,
STIO_EINVAL,
STIO_EEXIST,
STIO_ENOENT,
STIO_ENOSUP, /* not supported */
STIO_EMFILE, /* too many open files */
STIO_ENFILE,
STIO_EAGAIN,
STIO_ECONRF, /* connection refused */
STIO_ECONRS, /* connection reset */
STIO_ENOCAPA, /* no capability */
STIO_ETMOUT, /* timed out */
STIO_EPERM, /* operation not permitted */
STIO_EDEVMAKE,
STIO_EDEVERR,
STIO_EDEVHUP
};
typedef enum stio_errnum_t stio_errnum_t;
enum stio_stopreq_t
{
STIO_STOPREQ_NONE = 0,
STIO_STOPREQ_TERMINATION,
STIO_STOPREQ_WATCHER_ERROR
};
typedef enum stio_stopreq_t stio_stopreq_t;
/* ========================================================================= */
#define STIO_TMRIDX_INVALID ((stio_tmridx_t)-1)
typedef stio_size_t stio_tmridx_t;
typedef struct stio_tmrjob_t stio_tmrjob_t;
typedef void (*stio_tmrjob_handler_t) (
stio_t* stio,
const stio_ntime_t* now,
stio_tmrjob_t* tmrjob
);
struct stio_tmrjob_t
{
void* ctx;
stio_ntime_t when;
stio_tmrjob_handler_t handler;
stio_tmridx_t* idxptr; /* pointer to the index holder */
};
/* ========================================================================= */
struct stio_dev_mth_t
{
/* ------------------------------------------------------------------ */
/* mandatory. called in stio_makedev() */
int (*make) (stio_dev_t* dev, void* ctx);
/* ------------------------------------------------------------------ */
/* mandatory. called in stio_killdev(). also called in stio_makedev() upon
* failure after make() success.
*
* when 'force' is 0, the return value of -1 causes the device to be a
* zombie. the kill method is called periodically on a zombie device
* until the method returns 0.
*
* when 'force' is 1, the called should not return -1. If it does, the
* method is called once more only with the 'force' value of 2.
*
* when 'force' is 2, the device is destroyed regardless of the return value.
*/
int (*kill) (stio_dev_t* dev, int force);
/* ------------------------------------------------------------------ */
stio_syshnd_t (*getsyshnd) (stio_dev_t* dev); /* mandatory. called in stio_makedev() after successful make() */
/* ------------------------------------------------------------------ */
/* return -1 on failure, 0 if no data is availble, 1 otherwise.
* when returning 1, *len must be sent to the length of data read.
* if *len is set to 0, it's treated as EOF. */
int (*read) (stio_dev_t* dev, void* data, stio_iolen_t* len, stio_devaddr_t* srcaddr);
/* ------------------------------------------------------------------ */
int (*write) (stio_dev_t* dev, const void* data, stio_iolen_t* len, const stio_devaddr_t* dstaddr);
/* ------------------------------------------------------------------ */
int (*ioctl) (stio_dev_t* dev, int cmd, void* arg);
};
struct stio_dev_evcb_t
{
/* return -1 on failure. 0 or 1 on success.
* when 0 is returned, it doesn't attempt to perform actual I/O.
* when 1 is returned, it attempts to perform actual I/O. */
int (*ready) (stio_dev_t* dev, int events);
/* return -1 on failure, 0 or 1 on success.
* when 0 is returned, the main loop stops the attempt to read more data.
* when 1 is returned, the main loop attempts to read more data without*/
int (*on_read) (stio_dev_t* dev, const void* data, stio_iolen_t len, const stio_devaddr_t* srcaddr);
/* return -1 on failure, 0 on success.
* wrlen is the length of data written. it is the length of the originally
* posted writing request for a stream device. For a non stream device, it
* may be shorter than the originally posted length. */
int (*on_write) (stio_dev_t* dev, stio_iolen_t wrlen, void* wrctx, const stio_devaddr_t* dstaddr);
};
struct stio_wq_t
{
stio_wq_t* next;
stio_wq_t* prev;
stio_iolen_t olen; /* original data length */
stio_uint8_t* ptr; /* pointer to data */
stio_iolen_t len; /* remaining data length */
void* ctx;
stio_dev_t* dev; /* back-pointer to the device */
stio_tmridx_t tmridx;
stio_devaddr_t dstaddr;
};
#define STIO_WQ_INIT(wq) ((wq)->next = (wq)->prev = (wq))
#define STIO_WQ_TAIL(wq) ((wq)->prev)
#define STIO_WQ_HEAD(wq) ((wq)->next)
#define STIO_WQ_ISEMPTY(wq) (STIO_WQ_HEAD(wq) == (wq))
#define STIO_WQ_ISNODE(wq,x) ((wq) != (x))
#define STIO_WQ_ISHEAD(wq,x) (STIO_WQ_HEAD(wq) == (x))
#define STIO_WQ_ISTAIL(wq,x) (STIO_WQ_TAIL(wq) == (x))
#define STIO_WQ_NEXT(x) ((x)->next)
#define STIO_WQ_PREV(x) ((x)->prev)
#define STIO_WQ_LINK(p,x,n) do { \
stio_wq_t* pp = (p), * nn = (n); \
(x)->prev = (p); \
(x)->next = (n); \
nn->prev = (x); \
pp->next = (x); \
} while (0)
#define STIO_WQ_UNLINK(x) do { \
stio_wq_t* pp = (x)->prev, * nn = (x)->next; \
nn->prev = pp; pp->next = nn; \
} while (0)
#define STIO_WQ_REPL(o,n) do { \
stio_wq_t* oo = (o), * nn = (n); \
nn->next = oo->next; \
nn->next->prev = nn; \
nn->prev = oo->prev; \
nn->prev->next = nn; \
} while (0)
/* insert an item at the back of the queue */
/*#define STIO_WQ_ENQ(wq,x) STIO_WQ_LINK(STIO_WQ_TAIL(wq), x, STIO_WQ_TAIL(wq)->next)*/
#define STIO_WQ_ENQ(wq,x) STIO_WQ_LINK(STIO_WQ_TAIL(wq), x, wq)
/* remove an item in the front from the queue */
#define STIO_WQ_DEQ(wq) STIO_WQ_UNLINK(STIO_WQ_HEAD(wq))
#define STIO_DEV_HEADERS \
stio_t* stio; \
stio_size_t dev_size; \
int dev_capa; \
stio_dev_mth_t* dev_mth; \
stio_dev_evcb_t* dev_evcb; \
stio_wq_t wq; \
stio_dev_t* dev_prev; \
stio_dev_t* dev_next
struct stio_dev_t
{
STIO_DEV_HEADERS;
};
enum stio_dev_capa_t
{
STIO_DEV_CAPA_VIRTUAL = (1 << 0),
STIO_DEV_CAPA_IN = (1 << 1),
STIO_DEV_CAPA_OUT = (1 << 2),
/* #STIO_DEV_CAPA_PRI is meaningful only if #STIO_DEV_CAPA_IN is set */
STIO_DEV_CAPA_PRI = (1 << 3),
STIO_DEV_CAPA_STREAM = (1 << 4),
STIO_DEV_CAPA_OUT_QUEUED = (1 << 5),
/* internal use only. never set this bit to the dev_capa field */
STIO_DEV_CAPA_IN_DISABLED = (1 << 9),
STIO_DEV_CAPA_IN_CLOSED = (1 << 10),
STIO_DEV_CAPA_OUT_CLOSED = (1 << 11),
STIO_DEV_CAPA_IN_WATCHED = (1 << 12),
STIO_DEV_CAPA_OUT_WATCHED = (1 << 13),
STIO_DEV_CAPA_PRI_WATCHED = (1 << 14), /**< can be set only if STIO_DEV_CAPA_IN_WATCHED is set */
STIO_DEV_CAPA_ACTIVE = (1 << 15),
STIO_DEV_CAPA_HALTED = (1 << 16),
STIO_DEV_CAPA_ZOMBIE = (1 << 17)
};
typedef enum stio_dev_capa_t stio_dev_capa_t;
enum stio_dev_watch_cmd_t
{
STIO_DEV_WATCH_START,
STIO_DEV_WATCH_UPDATE,
STIO_DEV_WATCH_RENEW, /* automatic update */
STIO_DEV_WATCH_STOP
};
typedef enum stio_dev_watch_cmd_t stio_dev_watch_cmd_t;
enum stio_dev_event_t
{
STIO_DEV_EVENT_IN = (1 << 0),
STIO_DEV_EVENT_OUT = (1 << 1),
STIO_DEV_EVENT_PRI = (1 << 2),
STIO_DEV_EVENT_HUP = (1 << 3),
STIO_DEV_EVENT_ERR = (1 << 4)
};
typedef enum stio_dev_event_t stio_dev_event_t;
/* ========================================================================= */
#ifdef __cplusplus
extern "C" {
#endif
STIO_EXPORT stio_t* stio_open (
stio_mmgr_t* mmgr,
stio_size_t xtnsize,
stio_size_t tmrcapa, /**< initial timer capacity */
stio_errnum_t* errnum
);
STIO_EXPORT void stio_close (
stio_t* stio
);
STIO_EXPORT int stio_init (
stio_t* stio,
stio_mmgr_t* mmgr,
stio_size_t tmrcapa
);
STIO_EXPORT void stio_fini (
stio_t* stio
);
STIO_EXPORT int stio_exec (
stio_t* stio
);
STIO_EXPORT int stio_loop (
stio_t* stio
);
STIO_EXPORT void stio_stop (
stio_t* stio,
stio_stopreq_t stopreq
);
STIO_EXPORT stio_dev_t* stio_makedev (
stio_t* stio,
stio_size_t dev_size,
stio_dev_mth_t* dev_mth,
stio_dev_evcb_t* dev_evcb,
void* make_ctx
);
STIO_EXPORT void stio_killdev (
stio_t* stio,
stio_dev_t* dev
);
STIO_EXPORT int stio_dev_ioctl (
stio_dev_t* dev,
int cmd,
void* arg
);
STIO_EXPORT int stio_dev_watch (
stio_dev_t* dev,
stio_dev_watch_cmd_t cmd,
/** 0 or bitwise-ORed of #STIO_DEV_EVENT_IN and #STIO_DEV_EVENT_OUT */
int events
);
STIO_EXPORT int stio_dev_read (
stio_dev_t* dev,
int enabled
);
/**
* The stio_dev_write() function posts a writing request.
* It attempts to write data immediately if there is no pending requests.
* If writing fails, it returns -1. If writing succeeds, it calls the
* on_write callback. If the callback fails, it returns -1. If the callback
* succeeds, it returns 1. If no immediate writing is possible, the request
* is enqueued to a pending request list. If enqueing gets successful,
* it returns 0. otherwise it returns -1.
*/
STIO_EXPORT int stio_dev_write (
stio_dev_t* dev,
const void* data,
stio_iolen_t len,
void* wrctx,
const stio_devaddr_t* dstaddr
);
STIO_EXPORT int stio_dev_timedwrite (
stio_dev_t* dev,
const void* data,
stio_iolen_t len,
const stio_ntime_t* tmout,
void* wrctx,
const stio_devaddr_t* dstaddr
);
STIO_EXPORT void stio_dev_halt (
stio_dev_t* dev
);
/* ========================================================================= */
#define stio_inittime(x,s,ns) (((x)->sec = (s)), ((x)->nsec = (ns)))
#define stio_cleartime(x) stio_inittime(x,0,0)
#define stio_cmptime(x,y) \
(((x)->sec == (y)->sec)? ((x)->nsec - (y)->nsec): \
((x)->sec - (y)->sec))
/* if time has been normalized properly, nsec must be equal to or
* greater than 0. */
#define stio_isnegtime(x) ((x)->sec < 0)
#define stio_ispostime(x) ((x)->sec > 0 || ((x)->sec == 0 && (x)->nsec > 0))
#define stio_iszerotime(x) ((x)->sec == 0 && (x)->nsec == 0)
/**
* The stio_gettime() function gets the current time.
*/
STIO_EXPORT void stio_gettime (
stio_ntime_t* nt
);
/**
* The stio_addtime() function adds x and y and stores the result in z
*/
STIO_EXPORT void stio_addtime (
const stio_ntime_t* x,
const stio_ntime_t* y,
stio_ntime_t* z
);
/**
* The stio_subtime() function subtract y from x and stores the result in z.
*/
STIO_EXPORT void stio_subtime (
const stio_ntime_t* x,
const stio_ntime_t* y,
stio_ntime_t* z
);
/**
* The stio_instmrjob() function schedules a new event.
*
* \return #STIO_TMRIDX_INVALID on failure, valid index on success.
*/
STIO_EXPORT stio_tmridx_t stio_instmrjob (
stio_t* stio,
const stio_tmrjob_t* job
);
STIO_EXPORT stio_tmridx_t stio_updtmrjob (
stio_t* stio,
stio_tmridx_t index,
const stio_tmrjob_t* job
);
STIO_EXPORT void stio_deltmrjob (
stio_t* stio,
stio_tmridx_t index
);
/**
* The stio_gettmrjob() function returns the
* pointer to the registered event at the given index.
*/
STIO_EXPORT stio_tmrjob_t* stio_gettmrjob (
stio_t* stio,
stio_tmridx_t index
);
STIO_EXPORT int stio_gettmrjobdeadline (
stio_t* stio,
stio_tmridx_t index,
stio_ntime_t* deadline
);
/* ========================================================================= */
#if defined(STIO_HAVE_UINT16_T)
STIO_EXPORT stio_uint16_t stio_ntoh16 (
stio_uint16_t x
);
STIO_EXPORT stio_uint16_t stio_hton16 (
stio_uint16_t x
);
#endif
#if defined(STIO_HAVE_UINT32_T)
STIO_EXPORT stio_uint32_t stio_ntoh32 (
stio_uint32_t x
);
STIO_EXPORT stio_uint32_t stio_hton32 (
stio_uint32_t x
);
#endif
#if defined(STIO_HAVE_UINT64_T)
STIO_EXPORT stio_uint64_t stio_ntoh64 (
stio_uint64_t x
);
STIO_EXPORT stio_uint64_t stio_hton64 (
stio_uint64_t x
);
#endif
#if defined(STIO_HAVE_UINT128_T)
STIO_EXPORT stio_uint128_t stio_ntoh128 (
stio_uint128_t x
);
STIO_EXPORT stio_uint128_t stio_hton128 (
stio_uint128_t x
);
#endif
/* ========================================================================= */
#ifdef __cplusplus
}
#endif
#endif

2364
mio/m4/libtool.m4 vendored

File diff suppressed because it is too large Load Diff

125
mio/m4/ltoptions.m4 vendored
View File

@ -1,14 +1,14 @@
# Helper functions for option handling. -*- Autoconf -*-
#
# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# 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 7 ltoptions.m4
# serial 8 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@ -29,7 +29,7 @@ m4_define([_LT_SET_OPTION],
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]),
[m4_warning([Unknown $1 option `$2'])])[]dnl
[m4_warning([Unknown $1 option '$2'])])[]dnl
])
@ -75,13 +75,15 @@ m4_if([$1],[LT_INIT],[
dnl
dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither
dnl `shared' nor `disable-shared' was passed, we enable building of shared
dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
[_LT_ENABLE_FAST_INSTALL])
_LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
[_LT_WITH_AIX_SONAME([aix])])
])
])# _LT_SET_OPTIONS
@ -112,7 +114,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN],
[_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `dlopen' option into LT_INIT's first parameter.])
put the 'dlopen' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
@ -148,7 +150,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
_LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `win32-dll' option into LT_INIT's first parameter.])
put the 'win32-dll' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
@ -157,9 +159,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
# _LT_ENABLE_SHARED([DEFAULT])
# ----------------------------
# implement the --enable-shared flag, and supports the `shared' and
# `disable-shared' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
# implement the --enable-shared flag, and supports the 'shared' and
# 'disable-shared' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared],
@ -172,14 +174,14 @@ AC_ARG_ENABLE([shared],
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS="$lt_save_ifs"
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
IFS="$lt_save_ifs"
IFS=$lt_save_ifs
;;
esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
@ -211,9 +213,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], [])
# _LT_ENABLE_STATIC([DEFAULT])
# ----------------------------
# implement the --enable-static flag, and support the `static' and
# `disable-static' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
# implement the --enable-static flag, and support the 'static' and
# 'disable-static' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static],
@ -226,14 +228,14 @@ AC_ARG_ENABLE([static],
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS="$lt_save_ifs"
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
IFS="$lt_save_ifs"
IFS=$lt_save_ifs
;;
esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
@ -265,9 +267,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], [])
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ----------------------------------
# implement the --enable-fast-install flag, and support the `fast-install'
# and `disable-fast-install' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
# implement the --enable-fast-install flag, and support the 'fast-install'
# and 'disable-fast-install' LT_INIT options.
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install],
@ -280,14 +282,14 @@ AC_ARG_ENABLE([fast-install],
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
IFS="$lt_save_ifs"
IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
IFS="$lt_save_ifs"
IFS=$lt_save_ifs
;;
esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
@ -304,14 +306,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `fast-install' option into LT_INIT's first parameter.])
the 'fast-install' option into LT_INIT's first parameter.])
])
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `disable-fast-install' option into LT_INIT's first parameter.])
the 'disable-fast-install' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
@ -319,11 +321,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_AIX_SONAME([DEFAULT])
# ----------------------------------
# implement the --with-aix-soname flag, and support the `aix-soname=aix'
# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
m4_define([_LT_WITH_AIX_SONAME],
[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
shared_archive_member_spec=
case $host,$enable_shared in
power*-*-aix[[5-9]]*,yes)
AC_MSG_CHECKING([which variant of shared library versioning to provide])
AC_ARG_WITH([aix-soname],
[AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
[shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
[case $withval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
;;
esac
lt_cv_with_aix_soname=$with_aix_soname],
[AC_CACHE_VAL([lt_cv_with_aix_soname],
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
with_aix_soname=$lt_cv_with_aix_soname])
AC_MSG_RESULT([$with_aix_soname])
if test aix != "$with_aix_soname"; then
# For the AIX way of multilib, we name the shared archive member
# based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
# and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
# Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
# the AIX toolchain works better with OBJECT_MODE set (default 32).
if test 64 = "${OBJECT_MODE-32}"; then
shared_archive_member_spec=shr_64
else
shared_archive_member_spec=shr
fi
fi
;;
*)
with_aix_soname=aix
;;
esac
_LT_DECL([], [shared_archive_member_spec], [0],
[Shared archive member basename, for filename based shared library versioning on AIX])dnl
])# _LT_WITH_AIX_SONAME
LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
# _LT_WITH_PIC([MODE])
# --------------------
# implement the --with-pic flag, and support the `pic-only' and `no-pic'
# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
# LT_INIT options.
# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
@ -334,19 +389,17 @@ m4_define([_LT_WITH_PIC],
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $withval; do
IFS="$lt_save_ifs"
IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS="$lt_save_ifs"
IFS=$lt_save_ifs
;;
esac],
[pic_mode=default])
test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
[pic_mode=m4_default([$1], [default])])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
@ -359,7 +412,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE],
[_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `pic-only' option into LT_INIT's first parameter.])
put the 'pic-only' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:

7
mio/m4/ltsugar.m4 vendored
View File

@ -1,6 +1,7 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
@ -33,7 +34,7 @@ m4_define([_lt_join],
# ------------
# Manipulate m4 lists.
# These macros are necessary as long as will still need to support
# Autoconf-2.59 which quotes differently.
# Autoconf-2.59, which quotes differently.
m4_define([lt_car], [[$1]])
m4_define([lt_cdr],
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
@ -44,7 +45,7 @@ m4_define([lt_unquote], $1)
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
# ------------------------------------------
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
# Note that neither SEPARATOR nor STRING are expanded; they are appended
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
# No SEPARATOR is output if MACRO-NAME was previously undefined (different

12
mio/m4/ltversion.m4 vendored
View File

@ -1,6 +1,6 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Copyright (C) 2004 Free Software Foundation, Inc.
# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
@ -9,15 +9,15 @@
# @configure_input@
# serial 3337 ltversion.m4
# serial 4179 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.4.2])
m4_define([LT_PACKAGE_REVISION], [1.3337])
m4_define([LT_PACKAGE_VERSION], [2.4.6])
m4_define([LT_PACKAGE_REVISION], [2.4.6])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.4.2'
macro_revision='1.3337'
[macro_version='2.4.6'
macro_revision='2.4.6'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])

View File

@ -1,6 +1,7 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
# Foundation, Inc.
# Written by Scott James Remnant, 2004.
#
# This file is free software; the Free Software Foundation gives
@ -11,7 +12,7 @@
# These exist entirely to fool aclocal when bootstrapping libtool.
#
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
# which have later been changed to m4_define as they aren't part of the
# exported API, or moved to Autoconf or Automake where they belong.
#