moved some functions to sys.c
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fa90b72c85
commit
514b6dc96d
@ -56,6 +56,7 @@ pkginclude_HEADERS = \
|
|||||||
hcl-rbt.h \
|
hcl-rbt.h \
|
||||||
hcl-upac.h \
|
hcl-upac.h \
|
||||||
hcl-utl.h \
|
hcl-utl.h \
|
||||||
|
hcl-sys.h \
|
||||||
hcl-xma.h
|
hcl-xma.h
|
||||||
|
|
||||||
pkglib_LTLIBRARIES = libhcl.la
|
pkglib_LTLIBRARIES = libhcl.la
|
||||||
@ -108,13 +109,18 @@ if ENABLE_HCLX
|
|||||||
pkglib_LTLIBRARIES += libhclx.la
|
pkglib_LTLIBRARIES += libhclx.la
|
||||||
pkginclude_HEADERS += hcl-x.h hcl-tmr.h hcl-xutl.h hcl-json.h
|
pkginclude_HEADERS += hcl-x.h hcl-tmr.h hcl-xutl.h hcl-json.h
|
||||||
libhclx_la_SOURCES = \
|
libhclx_la_SOURCES = \
|
||||||
tmr.c hcl-tmr.h \
|
hcl-json.h \
|
||||||
xutl.c xutl-sa.h hcl-xutl.h \
|
hcl-sys.h \
|
||||||
json.c hcl-json.h \
|
hcl-tmr.h \
|
||||||
hcl-x.h \
|
hcl-x.h \
|
||||||
|
hcl-xtul.h \
|
||||||
|
json.c \
|
||||||
|
sys.c \
|
||||||
|
tmr.c \
|
||||||
x-client.c \
|
x-client.c \
|
||||||
x-proto.c \
|
x-proto.c \
|
||||||
x-server.c
|
x-server.c \
|
||||||
|
xutl.c xutl-sa.h
|
||||||
libhclx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) $(CPPFLAGS_PFMOD)
|
libhclx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) $(CPPFLAGS_PFMOD)
|
||||||
libhclx_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
libhclx_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||||
libhclx_la_LIBADD = libhcl.la $(LIBADD_LIB_COMMON)
|
libhclx_la_LIBADD = libhcl.la $(LIBADD_LIB_COMMON)
|
||||||
|
@ -170,13 +170,13 @@ libhcl_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
|||||||
$(libhcl_la_LDFLAGS) $(LDFLAGS) -o $@
|
$(libhcl_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
@ENABLE_HCLX_TRUE@libhclx_la_DEPENDENCIES = libhcl.la \
|
@ENABLE_HCLX_TRUE@libhclx_la_DEPENDENCIES = libhcl.la \
|
||||||
@ENABLE_HCLX_TRUE@ $(am__DEPENDENCIES_5)
|
@ENABLE_HCLX_TRUE@ $(am__DEPENDENCIES_5)
|
||||||
am__libhclx_la_SOURCES_DIST = tmr.c hcl-tmr.h xutl.c xutl-sa.h \
|
am__libhclx_la_SOURCES_DIST = hcl-json.h hcl-sys.h hcl-tmr.h hcl-x.h \
|
||||||
hcl-xutl.h json.c hcl-json.h hcl-x.h x-client.c x-proto.c \
|
hcl-xtul.h json.c sys.c tmr.c x-client.c x-proto.c x-server.c \
|
||||||
x-server.c
|
xutl.c xutl-sa.h
|
||||||
@ENABLE_HCLX_TRUE@am_libhclx_la_OBJECTS = libhclx_la-tmr.lo \
|
@ENABLE_HCLX_TRUE@am_libhclx_la_OBJECTS = libhclx_la-json.lo \
|
||||||
@ENABLE_HCLX_TRUE@ libhclx_la-xutl.lo libhclx_la-json.lo \
|
@ENABLE_HCLX_TRUE@ libhclx_la-sys.lo libhclx_la-tmr.lo \
|
||||||
@ENABLE_HCLX_TRUE@ libhclx_la-x-client.lo libhclx_la-x-proto.lo \
|
@ENABLE_HCLX_TRUE@ libhclx_la-x-client.lo libhclx_la-x-proto.lo \
|
||||||
@ENABLE_HCLX_TRUE@ libhclx_la-x-server.lo
|
@ENABLE_HCLX_TRUE@ libhclx_la-x-server.lo libhclx_la-xutl.lo
|
||||||
libhclx_la_OBJECTS = $(am_libhclx_la_OBJECTS)
|
libhclx_la_OBJECTS = $(am_libhclx_la_OBJECTS)
|
||||||
libhclx_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
libhclx_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||||
@ -212,7 +212,7 @@ am__depfiles_remade = ./$(DEPDIR)/libhcl_la-bigint.Plo \
|
|||||||
./$(DEPDIR)/libhcl_la-utf16.Plo ./$(DEPDIR)/libhcl_la-utf8.Plo \
|
./$(DEPDIR)/libhcl_la-utf16.Plo ./$(DEPDIR)/libhcl_la-utf8.Plo \
|
||||||
./$(DEPDIR)/libhcl_la-utl.Plo ./$(DEPDIR)/libhcl_la-xchg.Plo \
|
./$(DEPDIR)/libhcl_la-utl.Plo ./$(DEPDIR)/libhcl_la-xchg.Plo \
|
||||||
./$(DEPDIR)/libhcl_la-xma.Plo ./$(DEPDIR)/libhclx_la-json.Plo \
|
./$(DEPDIR)/libhcl_la-xma.Plo ./$(DEPDIR)/libhclx_la-json.Plo \
|
||||||
./$(DEPDIR)/libhclx_la-tmr.Plo \
|
./$(DEPDIR)/libhclx_la-sys.Plo ./$(DEPDIR)/libhclx_la-tmr.Plo \
|
||||||
./$(DEPDIR)/libhclx_la-x-client.Plo \
|
./$(DEPDIR)/libhclx_la-x-client.Plo \
|
||||||
./$(DEPDIR)/libhclx_la-x-proto.Plo \
|
./$(DEPDIR)/libhclx_la-x-proto.Plo \
|
||||||
./$(DEPDIR)/libhclx_la-x-server.Plo \
|
./$(DEPDIR)/libhclx_la-x-server.Plo \
|
||||||
@ -244,8 +244,8 @@ am__can_run_installinfo = \
|
|||||||
*) (install-info --version) >/dev/null 2>&1;; \
|
*) (install-info --version) >/dev/null 2>&1;; \
|
||||||
esac
|
esac
|
||||||
am__pkginclude_HEADERS_DIST = hcl.h hcl-chr.h hcl-cmn.h hcl-fmt.h \
|
am__pkginclude_HEADERS_DIST = hcl.h hcl-chr.h hcl-cmn.h hcl-fmt.h \
|
||||||
hcl-opt.h hcl-pac1.h hcl-rbt.h hcl-upac.h hcl-utl.h hcl-xma.h \
|
hcl-opt.h hcl-pac1.h hcl-rbt.h hcl-upac.h hcl-utl.h hcl-sys.h \
|
||||||
hcl-x.h hcl-tmr.h hcl-xutl.h hcl-json.h
|
hcl-xma.h hcl-x.h hcl-tmr.h hcl-xutl.h hcl-json.h
|
||||||
HEADERS = $(pkginclude_HEADERS)
|
HEADERS = $(pkginclude_HEADERS)
|
||||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
|
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
|
||||||
hcl-cfg.h.in
|
hcl-cfg.h.in
|
||||||
@ -435,7 +435,7 @@ LIBADD_LIB_COMMON = $(LIBM) $(am__append_1) $(am__append_2) \
|
|||||||
@WIN32_TRUE@ -DHCL_DEFAULT_PFMODPOSTFIX=\"-1.dll\" \
|
@WIN32_TRUE@ -DHCL_DEFAULT_PFMODPOSTFIX=\"-1.dll\" \
|
||||||
@WIN32_TRUE@ $(am__append_4) $(am__append_5)
|
@WIN32_TRUE@ $(am__append_4) $(am__append_5)
|
||||||
pkginclude_HEADERS = hcl.h hcl-chr.h hcl-cmn.h hcl-fmt.h hcl-opt.h \
|
pkginclude_HEADERS = hcl.h hcl-chr.h hcl-cmn.h hcl-fmt.h hcl-opt.h \
|
||||||
hcl-pac1.h hcl-rbt.h hcl-upac.h hcl-utl.h hcl-xma.h \
|
hcl-pac1.h hcl-rbt.h hcl-upac.h hcl-utl.h hcl-sys.h hcl-xma.h \
|
||||||
$(am__append_8)
|
$(am__append_8)
|
||||||
pkglib_LTLIBRARIES = libhcl.la $(am__append_7)
|
pkglib_LTLIBRARIES = libhcl.la $(am__append_7)
|
||||||
libhcl_la_SOURCES = \
|
libhcl_la_SOURCES = \
|
||||||
@ -477,13 +477,18 @@ libhcl_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
|
|||||||
libhcl_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
libhcl_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||||
libhcl_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_6)
|
libhcl_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_6)
|
||||||
@ENABLE_HCLX_TRUE@libhclx_la_SOURCES = \
|
@ENABLE_HCLX_TRUE@libhclx_la_SOURCES = \
|
||||||
@ENABLE_HCLX_TRUE@ tmr.c hcl-tmr.h \
|
@ENABLE_HCLX_TRUE@ hcl-json.h \
|
||||||
@ENABLE_HCLX_TRUE@ xutl.c xutl-sa.h hcl-xutl.h \
|
@ENABLE_HCLX_TRUE@ hcl-sys.h \
|
||||||
@ENABLE_HCLX_TRUE@ json.c hcl-json.h \
|
@ENABLE_HCLX_TRUE@ hcl-tmr.h \
|
||||||
@ENABLE_HCLX_TRUE@ hcl-x.h \
|
@ENABLE_HCLX_TRUE@ hcl-x.h \
|
||||||
|
@ENABLE_HCLX_TRUE@ hcl-xtul.h \
|
||||||
|
@ENABLE_HCLX_TRUE@ json.c \
|
||||||
|
@ENABLE_HCLX_TRUE@ sys.c \
|
||||||
|
@ENABLE_HCLX_TRUE@ tmr.c \
|
||||||
@ENABLE_HCLX_TRUE@ x-client.c \
|
@ENABLE_HCLX_TRUE@ x-client.c \
|
||||||
@ENABLE_HCLX_TRUE@ x-proto.c \
|
@ENABLE_HCLX_TRUE@ x-proto.c \
|
||||||
@ENABLE_HCLX_TRUE@ x-server.c
|
@ENABLE_HCLX_TRUE@ x-server.c \
|
||||||
|
@ENABLE_HCLX_TRUE@ xutl.c xutl-sa.h
|
||||||
|
|
||||||
@ENABLE_HCLX_TRUE@libhclx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) $(CPPFLAGS_PFMOD)
|
@ENABLE_HCLX_TRUE@libhclx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) $(CPPFLAGS_PFMOD)
|
||||||
@ENABLE_HCLX_TRUE@libhclx_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
@ENABLE_HCLX_TRUE@libhclx_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||||
@ -614,6 +619,7 @@ distclean-compile:
|
|||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-xchg.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-xchg.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-xma.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-xma.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-json.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-json.Plo@am__quote@ # am--include-marker
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-sys.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-tmr.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-tmr.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-x-client.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-x-client.Plo@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-x-proto.Plo@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhclx_la-x-proto.Plo@am__quote@ # am--include-marker
|
||||||
@ -846,20 +852,6 @@ libhcl_la-xma.lo: xma.c
|
|||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @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) $(libhcl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhcl_la-xma.lo `test -f 'xma.c' || echo '$(srcdir)/'`xma.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) $(libhcl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhcl_la-xma.lo `test -f 'xma.c' || echo '$(srcdir)/'`xma.c
|
||||||
|
|
||||||
libhclx_la-tmr.lo: tmr.c
|
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-tmr.lo -MD -MP -MF $(DEPDIR)/libhclx_la-tmr.Tpo -c -o libhclx_la-tmr.lo `test -f 'tmr.c' || echo '$(srcdir)/'`tmr.c
|
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhclx_la-tmr.Tpo $(DEPDIR)/libhclx_la-tmr.Plo
|
|
||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tmr.c' object='libhclx_la-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) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-tmr.lo `test -f 'tmr.c' || echo '$(srcdir)/'`tmr.c
|
|
||||||
|
|
||||||
libhclx_la-xutl.lo: xutl.c
|
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-xutl.lo -MD -MP -MF $(DEPDIR)/libhclx_la-xutl.Tpo -c -o libhclx_la-xutl.lo `test -f 'xutl.c' || echo '$(srcdir)/'`xutl.c
|
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhclx_la-xutl.Tpo $(DEPDIR)/libhclx_la-xutl.Plo
|
|
||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xutl.c' object='libhclx_la-xutl.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) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-xutl.lo `test -f 'xutl.c' || echo '$(srcdir)/'`xutl.c
|
|
||||||
|
|
||||||
libhclx_la-json.lo: json.c
|
libhclx_la-json.lo: json.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-json.lo -MD -MP -MF $(DEPDIR)/libhclx_la-json.Tpo -c -o libhclx_la-json.lo `test -f 'json.c' || echo '$(srcdir)/'`json.c
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-json.lo -MD -MP -MF $(DEPDIR)/libhclx_la-json.Tpo -c -o libhclx_la-json.lo `test -f 'json.c' || echo '$(srcdir)/'`json.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhclx_la-json.Tpo $(DEPDIR)/libhclx_la-json.Plo
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhclx_la-json.Tpo $(DEPDIR)/libhclx_la-json.Plo
|
||||||
@ -867,6 +859,20 @@ libhclx_la-json.lo: json.c
|
|||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @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) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-json.lo `test -f 'json.c' || echo '$(srcdir)/'`json.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) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-json.lo `test -f 'json.c' || echo '$(srcdir)/'`json.c
|
||||||
|
|
||||||
|
libhclx_la-sys.lo: sys.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-sys.lo -MD -MP -MF $(DEPDIR)/libhclx_la-sys.Tpo -c -o libhclx_la-sys.lo `test -f 'sys.c' || echo '$(srcdir)/'`sys.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhclx_la-sys.Tpo $(DEPDIR)/libhclx_la-sys.Plo
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sys.c' object='libhclx_la-sys.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) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-sys.lo `test -f 'sys.c' || echo '$(srcdir)/'`sys.c
|
||||||
|
|
||||||
|
libhclx_la-tmr.lo: tmr.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-tmr.lo -MD -MP -MF $(DEPDIR)/libhclx_la-tmr.Tpo -c -o libhclx_la-tmr.lo `test -f 'tmr.c' || echo '$(srcdir)/'`tmr.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhclx_la-tmr.Tpo $(DEPDIR)/libhclx_la-tmr.Plo
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tmr.c' object='libhclx_la-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) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-tmr.lo `test -f 'tmr.c' || echo '$(srcdir)/'`tmr.c
|
||||||
|
|
||||||
libhclx_la-x-client.lo: x-client.c
|
libhclx_la-x-client.lo: x-client.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-x-client.lo -MD -MP -MF $(DEPDIR)/libhclx_la-x-client.Tpo -c -o libhclx_la-x-client.lo `test -f 'x-client.c' || echo '$(srcdir)/'`x-client.c
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-x-client.lo -MD -MP -MF $(DEPDIR)/libhclx_la-x-client.Tpo -c -o libhclx_la-x-client.lo `test -f 'x-client.c' || echo '$(srcdir)/'`x-client.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhclx_la-x-client.Tpo $(DEPDIR)/libhclx_la-x-client.Plo
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhclx_la-x-client.Tpo $(DEPDIR)/libhclx_la-x-client.Plo
|
||||||
@ -888,6 +894,13 @@ libhclx_la-x-server.lo: x-server.c
|
|||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @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) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-x-server.lo `test -f 'x-server.c' || echo '$(srcdir)/'`x-server.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) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-x-server.lo `test -f 'x-server.c' || echo '$(srcdir)/'`x-server.c
|
||||||
|
|
||||||
|
libhclx_la-xutl.lo: xutl.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhclx_la-xutl.lo -MD -MP -MF $(DEPDIR)/libhclx_la-xutl.Tpo -c -o libhclx_la-xutl.lo `test -f 'xutl.c' || echo '$(srcdir)/'`xutl.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhclx_la-xutl.Tpo $(DEPDIR)/libhclx_la-xutl.Plo
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xutl.c' object='libhclx_la-xutl.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) $(libhclx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhclx_la-xutl.lo `test -f 'xutl.c' || echo '$(srcdir)/'`xutl.c
|
||||||
|
|
||||||
mostlyclean-libtool:
|
mostlyclean-libtool:
|
||||||
-rm -f *.lo
|
-rm -f *.lo
|
||||||
|
|
||||||
@ -1071,6 +1084,7 @@ distclean: distclean-am
|
|||||||
-rm -f ./$(DEPDIR)/libhcl_la-xchg.Plo
|
-rm -f ./$(DEPDIR)/libhcl_la-xchg.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhcl_la-xma.Plo
|
-rm -f ./$(DEPDIR)/libhcl_la-xma.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-json.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-json.Plo
|
||||||
|
-rm -f ./$(DEPDIR)/libhclx_la-sys.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-tmr.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-tmr.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-x-client.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-x-client.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-x-proto.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-x-proto.Plo
|
||||||
@ -1151,6 +1165,7 @@ maintainer-clean: maintainer-clean-am
|
|||||||
-rm -f ./$(DEPDIR)/libhcl_la-xchg.Plo
|
-rm -f ./$(DEPDIR)/libhcl_la-xchg.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhcl_la-xma.Plo
|
-rm -f ./$(DEPDIR)/libhcl_la-xma.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-json.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-json.Plo
|
||||||
|
-rm -f ./$(DEPDIR)/libhclx_la-sys.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-tmr.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-tmr.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-x-client.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-x-client.Plo
|
||||||
-rm -f ./$(DEPDIR)/libhclx_la-x-proto.Plo
|
-rm -f ./$(DEPDIR)/libhclx_la-x-proto.Plo
|
||||||
|
70
lib/hcl-sys.h
Normal file
70
lib/hcl-sys.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2016-2018 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 _HCL_SYS_T_
|
||||||
|
#define _HCL_SYS_T_
|
||||||
|
|
||||||
|
#include <hcl.h>
|
||||||
|
|
||||||
|
/* forward declaration to skip including <sys/uio.h> just for struct iovec */
|
||||||
|
typedef struct iovec hcl_iovec_t;
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_sys_send_iov (
|
||||||
|
int sck,
|
||||||
|
hcl_iovec_t* iov, /* note this is not read-only and can change */
|
||||||
|
int count
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_sys_open_pipes (
|
||||||
|
int pfd[2],
|
||||||
|
int nonblock
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_sys_close_pipes (
|
||||||
|
int pfd[2]
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_sys_set_nonblock (
|
||||||
|
int fd,
|
||||||
|
int v
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_sys_set_cloexec (
|
||||||
|
int fd,
|
||||||
|
int v
|
||||||
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_sys_is_errno_wb (
|
||||||
|
int no
|
||||||
|
);
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -505,6 +505,10 @@ HCL_EXPORT int hcl_sys_set_cloexec (
|
|||||||
int v
|
int v
|
||||||
);
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT int hcl_sys_is_errno_wb (
|
||||||
|
int no
|
||||||
|
);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
178
lib/sys.c
Normal file
178
lib/sys.c
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2016-2018 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <hcl-sys.h>
|
||||||
|
#
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
# include <windows.h>
|
||||||
|
# include <tchar.h>
|
||||||
|
#elif defined(__OS2__)
|
||||||
|
# define INCL_DOSMODULEMGR
|
||||||
|
# define INCL_DOSPROCESS
|
||||||
|
# define INCL_DOSERRORS
|
||||||
|
# include <os2.h>
|
||||||
|
#elif defined(__DOS__)
|
||||||
|
# include <dos.h>
|
||||||
|
# include <time.h>
|
||||||
|
# include <signal.h>
|
||||||
|
#elif defined(macintosh)
|
||||||
|
# include <Timer.h>
|
||||||
|
#else
|
||||||
|
|
||||||
|
# if defined(HAVE_TIME_H)
|
||||||
|
# include <time.h>
|
||||||
|
# endif
|
||||||
|
# if defined(HAVE_SYS_TIME_H)
|
||||||
|
# include <sys/time.h>
|
||||||
|
# endif
|
||||||
|
# if defined(HAVE_SIGNAL_H)
|
||||||
|
# include <signal.h>
|
||||||
|
# endif
|
||||||
|
# if defined(HAVE_SYS_MMAN_H)
|
||||||
|
# include <sys/mman.h>
|
||||||
|
# endif
|
||||||
|
# if defined(HAVE_SYS_UIO_H)
|
||||||
|
# include <sys/uio.h>
|
||||||
|
# endif
|
||||||
|
# if defined(HAVE_SYS_EPOLL_H)
|
||||||
|
# include <sys/epoll.h>
|
||||||
|
# define USE_EPOLL
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# include <unistd.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <sys/socket.h>
|
||||||
|
# include <netinet/in.h>
|
||||||
|
# include <poll.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int hcl_sys_send_iov (int sck, hcl_iovec_t* iov, int count)
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
ssize_t nwritten;
|
||||||
|
struct msghdr msg;
|
||||||
|
|
||||||
|
memset (&msg, 0, HCL_SIZEOF(msg));
|
||||||
|
msg.msg_iov = (struct iovec*)&iov[index];
|
||||||
|
msg.msg_iovlen = count - index;
|
||||||
|
nwritten = sendmsg(sck, &msg, 0);
|
||||||
|
if (nwritten <= -1) return -1;
|
||||||
|
|
||||||
|
while (index < count && (size_t)nwritten >= iov[index].iov_len)
|
||||||
|
nwritten -= iov[index++].iov_len;
|
||||||
|
|
||||||
|
if (index == count) break;
|
||||||
|
|
||||||
|
iov[index].iov_base = (void*)((hcl_uint8_t*)iov[index].iov_base + nwritten);
|
||||||
|
iov[index].iov_len -= nwritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hcl_sys_open_pipes (int pfd[2], int nonblock)
|
||||||
|
{
|
||||||
|
/* TODO: mimic open_pipes() in std.c */
|
||||||
|
|
||||||
|
if (pipe(pfd) <= -1) return -1;
|
||||||
|
|
||||||
|
hcl_sys_set_nonblock(pfd[0], nonblock);
|
||||||
|
hcl_sys_set_nonblock(pfd[1], nonblock);
|
||||||
|
hcl_sys_set_cloexec(pfd[0], 1);
|
||||||
|
hcl_sys_set_cloexec(pfd[1], 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hcl_sys_close_pipes (int pfd[2])
|
||||||
|
{
|
||||||
|
if (pfd[0] >= 0)
|
||||||
|
{
|
||||||
|
close (pfd[0]);
|
||||||
|
pfd[0] = -1;
|
||||||
|
}
|
||||||
|
if (pfd[1] >= 0)
|
||||||
|
{
|
||||||
|
close (pfd[1]);
|
||||||
|
pfd[1] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int hcl_sys_set_nonblock (int fd, int v)
|
||||||
|
{
|
||||||
|
#if defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK)
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
if ((flags = fcntl(fd, F_GETFL, 0)) <= -1) return -1;
|
||||||
|
|
||||||
|
if (v) flags |= O_NONBLOCK;
|
||||||
|
else flags &= ~O_NONBLOCK;
|
||||||
|
|
||||||
|
if (fcntl(fd, F_SETFL, flags) <= -1) return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
errno = ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int hcl_sys_set_cloexec (int fd, int v)
|
||||||
|
{
|
||||||
|
#if defined(F_GETFL) && defined(F_SETFL) && defined(FD_CLOEXEC)
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
if ((flags = fcntl(fd, F_GETFD, 0)) <= -1) return -1;
|
||||||
|
|
||||||
|
if (v) flags |= FD_CLOEXEC;
|
||||||
|
else flags &= ~FD_CLOEXEC;
|
||||||
|
|
||||||
|
if (fcntl(fd, F_SETFD, flags) <= -1) return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
errno = ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int hcl_sys_is_errno_wb (int no)
|
||||||
|
{
|
||||||
|
#if defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
|
||||||
|
return no == EWOULDBLOCK || no == EAGAIN;
|
||||||
|
#elif defined(EWOULDBLOCK)
|
||||||
|
return no == EWOULDBLOCK;
|
||||||
|
#elif defined(EAGAIN)
|
||||||
|
return no == EAGAIN;
|
||||||
|
#endif
|
||||||
|
}
|
@ -22,10 +22,11 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hcl-x.h"
|
#include <hcl-x.h>
|
||||||
#include "hcl-prv.h"
|
#include "hcl-prv.h"
|
||||||
#include "hcl-tmr.h"
|
#include <hcl-tmr.h>
|
||||||
#include "hcl-xutl.h"
|
#include <hcl-xutl.h>
|
||||||
|
#include <hcl-sys.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
141
lib/x-server.c
141
lib/x-server.c
@ -22,10 +22,11 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hcl-x.h"
|
#include <hcl-x.h>
|
||||||
#include "hcl-prv.h"
|
#include "hcl-prv.h"
|
||||||
#include "hcl-tmr.h"
|
#include <hcl-tmr.h>
|
||||||
#include "hcl-xutl.h"
|
#include <hcl-xutl.h>
|
||||||
|
#include <hcl-sys.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -68,6 +69,7 @@
|
|||||||
# endif
|
# endif
|
||||||
# if defined(HAVE_SYS_EPOLL_H)
|
# if defined(HAVE_SYS_EPOLL_H)
|
||||||
# include <sys/epoll.h>
|
# include <sys/epoll.h>
|
||||||
|
# define USE_EPOLL
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
@ -215,8 +217,10 @@ struct hcl_server_t
|
|||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
#if defined(USE_EPOLL)
|
||||||
int ep_fd;
|
int ep_fd;
|
||||||
struct epoll_event ev_buf[128];
|
struct epoll_event ev_buf[128];
|
||||||
|
#endif
|
||||||
hcl_server_listener_t* head;
|
hcl_server_listener_t* head;
|
||||||
hcl_oow_t count;
|
hcl_oow_t count;
|
||||||
} listener;
|
} listener;
|
||||||
@ -1700,9 +1704,11 @@ static void set_err_with_syserr (hcl_server_t* server, int syserr_type, int syse
|
|||||||
static void free_all_listeners (hcl_server_t* server)
|
static void free_all_listeners (hcl_server_t* server)
|
||||||
{
|
{
|
||||||
hcl_server_listener_t* lp;
|
hcl_server_listener_t* lp;
|
||||||
|
#if defined(USE_EPOLL)
|
||||||
struct epoll_event dummy_ev;
|
struct epoll_event dummy_ev;
|
||||||
|
|
||||||
epoll_ctl (server->listener.ep_fd, EPOLL_CTL_DEL, server->mux_pipe[0], &dummy_ev);
|
epoll_ctl (server->listener.ep_fd, EPOLL_CTL_DEL, server->mux_pipe[0], &dummy_ev);
|
||||||
|
#endif
|
||||||
|
|
||||||
while (server->listener.head)
|
while (server->listener.head)
|
||||||
{
|
{
|
||||||
@ -1710,20 +1716,25 @@ static void free_all_listeners (hcl_server_t* server)
|
|||||||
server->listener.head = lp->next_listener;
|
server->listener.head = lp->next_listener;
|
||||||
server->listener.count--;
|
server->listener.count--;
|
||||||
|
|
||||||
|
#if defined(USE_EPOLL)
|
||||||
epoll_ctl (server->listener.ep_fd, EPOLL_CTL_DEL, lp->sck, &dummy_ev);
|
epoll_ctl (server->listener.ep_fd, EPOLL_CTL_DEL, lp->sck, &dummy_ev);
|
||||||
|
#endif
|
||||||
close (lp->sck);
|
close (lp->sck);
|
||||||
hcl_server_freemem (server, lp);
|
hcl_server_freemem (server, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_EPOLL)
|
||||||
HCL_ASSERT (server->dummy_hcl, server->listener.ep_fd >= 0);
|
HCL_ASSERT (server->dummy_hcl, server->listener.ep_fd >= 0);
|
||||||
close (server->listener.ep_fd);
|
close (server->listener.ep_fd);
|
||||||
server->listener.ep_fd = -1;
|
server->listener.ep_fd = -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setup_listeners (hcl_server_t* server, const hcl_bch_t* addrs)
|
static int setup_listeners (hcl_server_t* server, const hcl_bch_t* addrs)
|
||||||
{
|
{
|
||||||
const hcl_bch_t* addr_ptr, * comma;
|
const hcl_bch_t* addr_ptr, * comma;
|
||||||
int ep_fd, fcv;
|
int ep_fd, fcv;
|
||||||
|
#if defined(USE_EPOLL)
|
||||||
struct epoll_event ev;
|
struct epoll_event ev;
|
||||||
|
|
||||||
ep_fd = epoll_create(1024);
|
ep_fd = epoll_create(1024);
|
||||||
@ -1734,10 +1745,7 @@ static int setup_listeners (hcl_server_t* server, const hcl_bch_t* addrs)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(O_CLOEXEC)
|
hcl_sys_set_cloexec(ep_fd, 1);
|
||||||
fcv = fcntl(ep_fd, F_GETFD, 0);
|
|
||||||
if (fcv >= 0) fcntl(ep_fd, F_SETFD, fcv | O_CLOEXEC);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
HCL_MEMSET (&ev, 0, HCL_SIZEOF(ev));
|
HCL_MEMSET (&ev, 0, HCL_SIZEOF(ev));
|
||||||
ev.events = EPOLLIN | EPOLLHUP | EPOLLERR;
|
ev.events = EPOLLIN | EPOLLHUP | EPOLLERR;
|
||||||
@ -1751,6 +1759,7 @@ static int setup_listeners (hcl_server_t* server, const hcl_bch_t* addrs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
server->listener.ep_fd = ep_fd;
|
server->listener.ep_fd = ep_fd;
|
||||||
|
#endif
|
||||||
addr_ptr = addrs;
|
addr_ptr = addrs;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -1801,6 +1810,8 @@ static int setup_listeners (hcl_server_t* server, const hcl_bch_t* addrs)
|
|||||||
goto next_segment;
|
goto next_segment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(USE_EPOLL)
|
||||||
HCL_MEMSET (&ev, 0, HCL_SIZEOF(ev));
|
HCL_MEMSET (&ev, 0, HCL_SIZEOF(ev));
|
||||||
ev.events = EPOLLIN | EPOLLHUP | EPOLLERR;
|
ev.events = EPOLLIN | EPOLLHUP | EPOLLERR;
|
||||||
ev.data.fd = srv_fd;
|
ev.data.fd = srv_fd;
|
||||||
@ -1811,6 +1822,7 @@ static int setup_listeners (hcl_server_t* server, const hcl_bch_t* addrs)
|
|||||||
close (srv_fd);
|
close (srv_fd);
|
||||||
goto next_segment;
|
goto next_segment;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
listener = (hcl_server_listener_t*)hcl_server_allocmem(server, HCL_SIZEOF(*listener));
|
listener = (hcl_server_listener_t*)hcl_server_allocmem(server, HCL_SIZEOF(*listener));
|
||||||
if (!listener)
|
if (!listener)
|
||||||
@ -1869,7 +1881,11 @@ int hcl_server_start (hcl_server_t* server, const hcl_bch_t* addrs)
|
|||||||
pthread_mutex_unlock (&server->tmr_mutex);
|
pthread_mutex_unlock (&server->tmr_mutex);
|
||||||
if (n <= -1) HCL_INIT_NTIME (&tmout, 10, 0);
|
if (n <= -1) HCL_INIT_NTIME (&tmout, 10, 0);
|
||||||
|
|
||||||
|
#if defined(USE_EPOLL)
|
||||||
n = epoll_wait(server->listener.ep_fd, server->listener.ev_buf, HCL_COUNTOF(server->listener.ev_buf), HCL_SECNSEC_TO_MSEC(tmout.sec, tmout.nsec));
|
n = epoll_wait(server->listener.ep_fd, server->listener.ev_buf, HCL_COUNTOF(server->listener.ev_buf), HCL_SECNSEC_TO_MSEC(tmout.sec, tmout.nsec));
|
||||||
|
#else
|
||||||
|
n = poll(); /* TODO: */
|
||||||
|
#endif
|
||||||
|
|
||||||
purge_all_workers (server, HCL_SERVER_WORKER_STATE_DEAD);
|
purge_all_workers (server, HCL_SERVER_WORKER_STATE_DEAD);
|
||||||
if (n <= -1)
|
if (n <= -1)
|
||||||
@ -1888,12 +1904,19 @@ int hcl_server_start (hcl_server_t* server, const hcl_bch_t* addrs)
|
|||||||
|
|
||||||
while (n > 0)
|
while (n > 0)
|
||||||
{
|
{
|
||||||
|
#if defined(USE_EPOLL)
|
||||||
struct epoll_event* evp;
|
struct epoll_event* evp;
|
||||||
|
#endif
|
||||||
|
|
||||||
--n;
|
--n;
|
||||||
|
|
||||||
|
#if defined(USE_EPOLL)
|
||||||
evp = &server->listener.ev_buf[n];
|
evp = &server->listener.ev_buf[n];
|
||||||
if (!evp->events /*& (POLLIN | POLLHUP | POLLERR) */) continue;
|
if (!evp->events /*& (POLLIN | POLLHUP | POLLERR) */) continue;
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* TODO: */
|
||||||
|
#endif
|
||||||
|
|
||||||
if (evp->data.fd == server->mux_pipe[0])
|
if (evp->data.fd == server->mux_pipe[0])
|
||||||
{
|
{
|
||||||
@ -1910,14 +1933,7 @@ int hcl_server_start (hcl_server_t* server, const hcl_bch_t* addrs)
|
|||||||
{
|
{
|
||||||
if (server->stopreq) break; /* normal termination requested */
|
if (server->stopreq) break; /* normal termination requested */
|
||||||
if (errno == EINTR) continue; /* interrupted but no termination requested */
|
if (errno == EINTR) continue; /* interrupted but no termination requested */
|
||||||
#if defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
|
if (hcl_sys_is_errnor_wb(errno)) continue;
|
||||||
if (errno == EWOULDBLOCK || errno == EAGAIN) continue;
|
|
||||||
#elif defined(EWOULDBLOCK)
|
|
||||||
if (errno == EWOULDBLOCK) continue;
|
|
||||||
#elif defined(EAGAIN)
|
|
||||||
if (errno == EAGAIN) continue;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
set_err_with_syserr (server, 0, errno, "unable to accept worker on server socket %d", evp->data.fd);
|
set_err_with_syserr (server, 0, errno, "unable to accept worker on server socket %d", evp->data.fd);
|
||||||
xret = -1;
|
xret = -1;
|
||||||
break;
|
break;
|
||||||
@ -2188,98 +2204,3 @@ void hcl_server_freemem (hcl_server_t* server, void* ptr)
|
|||||||
{
|
{
|
||||||
HCL_MMGR_FREE (server->_mmgr, ptr);
|
HCL_MMGR_FREE (server->_mmgr, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
|
||||||
|
|
||||||
int hcl_sys_send_iov (int sck, hcl_iovec_t* iov, int count)
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
ssize_t nwritten;
|
|
||||||
struct msghdr msg;
|
|
||||||
|
|
||||||
memset (&msg, 0, HCL_SIZEOF(msg));
|
|
||||||
msg.msg_iov = (struct iovec*)&iov[index];
|
|
||||||
msg.msg_iovlen = count - index;
|
|
||||||
nwritten = sendmsg(sck, &msg, 0);
|
|
||||||
if (nwritten <= -1) return -1;
|
|
||||||
|
|
||||||
while (index < count && (size_t)nwritten >= iov[index].iov_len)
|
|
||||||
nwritten -= iov[index++].iov_len;
|
|
||||||
|
|
||||||
if (index == count) break;
|
|
||||||
|
|
||||||
iov[index].iov_base = (void*)((hcl_uint8_t*)iov[index].iov_base + nwritten);
|
|
||||||
iov[index].iov_len -= nwritten;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int hcl_sys_open_pipes (int pfd[2], int nonblock)
|
|
||||||
{
|
|
||||||
/* TODO: mimic open_pipes() in std.c */
|
|
||||||
|
|
||||||
if (pipe(pfd) <= -1) return -1;
|
|
||||||
|
|
||||||
hcl_sys_set_nonblock(pfd[0], nonblock);
|
|
||||||
hcl_sys_set_nonblock(pfd[1], nonblock);
|
|
||||||
hcl_sys_set_cloexec(pfd[0], 1);
|
|
||||||
hcl_sys_set_cloexec(pfd[1], 1);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hcl_sys_close_pipes (int pfd[2])
|
|
||||||
{
|
|
||||||
if (pfd[0] >= 0)
|
|
||||||
{
|
|
||||||
close (pfd[0]);
|
|
||||||
pfd[0] = -1;
|
|
||||||
}
|
|
||||||
if (pfd[1] >= 0)
|
|
||||||
{
|
|
||||||
close (pfd[1]);
|
|
||||||
pfd[1] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int hcl_sys_set_nonblock (int fd, int v)
|
|
||||||
{
|
|
||||||
#if defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK)
|
|
||||||
int flags;
|
|
||||||
|
|
||||||
if ((flags = fcntl(fd, F_GETFL, 0)) <= -1) return -1;
|
|
||||||
|
|
||||||
if (v) flags |= O_NONBLOCK;
|
|
||||||
else flags &= ~O_NONBLOCK;
|
|
||||||
|
|
||||||
if (fcntl(fd, F_SETFL, flags) <= -1) return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
errno = ENOSYS;
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int hcl_sys_set_cloexec (int fd, int v)
|
|
||||||
{
|
|
||||||
#if defined(F_GETFL) && defined(F_SETFL) && defined(FD_CLOEXEC)
|
|
||||||
int flags;
|
|
||||||
|
|
||||||
if ((flags = fcntl(fd, F_GETFD, 0)) <= -1) return -1;
|
|
||||||
|
|
||||||
if (v) flags |= FD_CLOEXEC;
|
|
||||||
else flags &= ~FD_CLOEXEC;
|
|
||||||
|
|
||||||
if (fcntl(fd, F_SETFD, flags) <= -1) return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
errno = ENOSYS;
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user