mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-23 11:24:34 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78995951ae | ||
|
|
3adc7a03c0 | ||
|
|
2abeb39fe8 | ||
|
|
1480976724 | ||
|
|
6ffa76c2f8 | ||
|
|
8a4e8c4af6 | ||
|
|
950015715d | ||
|
|
fb6ac1ecac | ||
|
|
0909decabc | ||
|
|
3452fbd381 | ||
|
|
f64561b708 | ||
|
|
b94023faed | ||
|
|
6637804b80 | ||
|
|
361b013da5 | ||
|
|
052b08e0b5 | ||
|
|
ca803bb12f |
No files matched your search
+4
-2
@@ -1,7 +1,9 @@
|
|||||||
# Travis CI integration -- https://travis-ci.org/troglobit/libuev
|
# Travis CI integration -- https://travis-ci.org/troglobit/libuev
|
||||||
|
# Defaults to GNU GCC and autotools: ./configure && make && make test
|
||||||
language: c
|
language: c
|
||||||
compiler:
|
|
||||||
- gcc
|
# We don't need to install packages, use dockerized build, quicker
|
||||||
|
sudo: false
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
|||||||
+37
-1
@@ -3,6 +3,41 @@ Change Log
|
|||||||
|
|
||||||
All notable changes to the project are documented in this file.
|
All notable changes to the project are documented in this file.
|
||||||
|
|
||||||
|
[v1.2.2] - 2015-08-30
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Minor bugfix release.
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
- The `ifdef STATIC` in the Makefile has been removed. Now both the
|
||||||
|
.a and .so libraries are built. The user may then select what to
|
||||||
|
install. This is a change for convenience when using libuEv from
|
||||||
|
a GNU Configure & Build based project.
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Fix odd data ordering issue on Debian Jessie in new `uev_private_t`
|
||||||
|
- Fix issue #6: Segfault when stopping timer before calling `uev_exit()`
|
||||||
|
|
||||||
|
|
||||||
|
[v1.2.1] - 2015-07-02
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
- Private data members in `uev.h` have now been moved to a new file
|
||||||
|
called `private.h`. This will hopefully make it easier to understand
|
||||||
|
what a user of libuEv is allowed to play around with. Thanks to @vonj
|
||||||
|
for the discussions around this!
|
||||||
|
- All builds of libuEv now default to use -fPIC, this bloats the code
|
||||||
|
slightly, but ensures that linking works for all use cases, withouth
|
||||||
|
introducing unnecessary complexity.
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Fix install/uninstall Makefile recipes so they work for both static
|
||||||
|
and dynamic builds. Also, make sure to install all required headers.
|
||||||
|
- Jakob Eriksson noticed that `O_CLOEXEC` does not exist in the Debian 6
|
||||||
|
EGLIBC, but `EPOLL_CLOEXEC` does, and is also what `epoll_create1()`
|
||||||
|
should use. Thank you @vonj!
|
||||||
|
|
||||||
|
|
||||||
[v1.2.0] - 2015-06-09
|
[v1.2.0] - 2015-06-09
|
||||||
---------------------
|
---------------------
|
||||||
@@ -121,7 +156,8 @@ v0.0.1 - 2012-03-17
|
|||||||
[Initial announcement] of [libuevent] by [Flemming Madsen] to the Lua
|
[Initial announcement] of [libuevent] by [Flemming Madsen] to the Lua
|
||||||
users mailing list.
|
users mailing list.
|
||||||
|
|
||||||
[UNRELEASED]: https://github.com/troglobit/libuev/compare/v1.2.0...HEAD
|
[UNRELEASED]: https://github.com/troglobit/libuev/compare/v1.2.1...HEAD
|
||||||
|
[v1.2.1]: https://github.com/troglobit/libuev/compare/v1.2.0...v1.2.1
|
||||||
[v1.2.0]: https://github.com/troglobit/libuev/compare/v1.1.0...v1.2.0
|
[v1.2.0]: https://github.com/troglobit/libuev/compare/v1.1.0...v1.2.0
|
||||||
[v1.1.0]: https://github.com/troglobit/libuev/compare/v1.0.5...v1.1.0
|
[v1.1.0]: https://github.com/troglobit/libuev/compare/v1.0.5...v1.1.0
|
||||||
[v1.0.5]: https://github.com/troglobit/libuev/compare/v1.0.4...v1.0.5
|
[v1.0.5]: https://github.com/troglobit/libuev/compare/v1.0.4...v1.0.5
|
||||||
|
|||||||
@@ -1,31 +1,33 @@
|
|||||||
# libuEv main build file
|
# libuEv -- Simple event loop for Linux
|
||||||
#
|
#
|
||||||
# Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
# Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||||
# Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
# Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# a copy of this software and associated documentation files (the
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
# "Software"), to deal in the Software without restriction, including
|
# in the Software without restriction, including without limitation the rights
|
||||||
# without limitation the rights to use, copy, modify, merge, publish,
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
# permit persons to whom the Software is furnished to do so, subject to
|
# furnished to do so, subject to the following conditions:
|
||||||
# the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be
|
# The above copyright notice and this permission notice shall be included in
|
||||||
# included in all copies or substantial portions of the Software.
|
# all copies or substantial portions of the Software.
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
#
|
#
|
||||||
.PHONY: all test clean joystick test examples bench
|
.PHONY: all test clean joystick test examples bench
|
||||||
|
|
||||||
|
# Figure out root of library, unless used as submodule
|
||||||
|
ROOTDIR ?= $(shell pwd)
|
||||||
|
|
||||||
#VERSION = $(shell git tag -l | tail -1)
|
#VERSION = $(shell git tag -l | tail -1)
|
||||||
VERSION ?= 1.2.0
|
VERSION ?= 1.2.2
|
||||||
NAME = libuev
|
NAME = libuev
|
||||||
PKG = $(NAME)-$(VERSION)
|
PKG = $(NAME)-$(VERSION)
|
||||||
ARCHIVE = $(PKG).tar.xz
|
ARCHIVE = $(PKG).tar.xz
|
||||||
@@ -33,38 +35,35 @@ ARCHIVE = $(PKG).tar.xz
|
|||||||
CC ?= $(CROSS)gcc
|
CC ?= $(CROSS)gcc
|
||||||
AR ?= $(CROSS)ar
|
AR ?= $(CROSS)ar
|
||||||
STRIP ?= $(CROSS)strip
|
STRIP ?= $(CROSS)strip
|
||||||
|
MAKE := @$(MAKE)
|
||||||
|
INSTALL := install --backup=off
|
||||||
|
STRIPINST := $(INSTALL) -s --strip-program=$(CROSS)strip -m 0755
|
||||||
|
|
||||||
ifneq ($(STATIC), 1)
|
|
||||||
CFLAGS += -fPIC
|
CFLAGS += -fPIC
|
||||||
endif
|
|
||||||
CFLAGS += -Os
|
CFLAGS += -Os
|
||||||
CPPFLAGS += -W -Wall -Werror
|
CPPFLAGS += -W -Wall -Werror
|
||||||
ARFLAGS = crus
|
ARFLAGS = crus
|
||||||
JUNK = *~ *.bak *.map .*.d DEADJOE *.gdb *.elf core core.* *.html
|
MAKEFLAGS = --no-print-directory --silent
|
||||||
|
|
||||||
MAKEFLAGS = --no-print-directory
|
DISTFILES = README CHANGELOG TODO LICENSE
|
||||||
|
HEADERS = uev.h private.h queue.h
|
||||||
|
OBJS := uev.o io.o timer.o signal.o
|
||||||
|
SRCS := $(OBJS:.o=.c)
|
||||||
|
DEPS := $(SRCS:.c=.d)
|
||||||
|
JUNK = *~ *.bak *.map .*.d *.so* *.a DEADJOE *.gdb *.elf core core.* *.html
|
||||||
|
|
||||||
ROOTDIR ?= $(shell pwd)
|
VER = 1
|
||||||
LIBNAME = $(NAME)
|
LIBNAME = $(NAME)
|
||||||
|
SOLIB = $(LIBNAME).so.$(VER)
|
||||||
|
SYMLIB = $(LIBNAME).so
|
||||||
|
STATICLIB = $(LIBNAME).a
|
||||||
|
TARGET = $(STATICLIB) $(SOLIB)
|
||||||
|
|
||||||
|
# Default install paths
|
||||||
prefix ?= /usr/local
|
prefix ?= /usr/local
|
||||||
libdir ?= $(prefix)/lib
|
libdir ?= $(prefix)/lib
|
||||||
datadir ?= $(prefix)/share/doc/$(LIBNAME)
|
datadir ?= $(prefix)/share/doc/$(LIBNAME)
|
||||||
incdir ?= $(prefix)/include
|
incdir ?= $(prefix)/include
|
||||||
DISTFILES = README CHANGELOG TODO LICENSE
|
|
||||||
HEADER = uev.h
|
|
||||||
|
|
||||||
OBJS := uev.o io.o timer.o signal.o
|
|
||||||
SRCS := $(OBJS:.o=.c)
|
|
||||||
DEPS := $(SRCS:.c=.d)
|
|
||||||
VER = 1
|
|
||||||
SOLIB = $(LIBNAME).so.$(VER)
|
|
||||||
SYMLIB = $(LIBNAME).so
|
|
||||||
STATICLIB = $(LIBNAME).a
|
|
||||||
ifeq ($(STATIC), 1)
|
|
||||||
TARGET = $(STATICLIB)
|
|
||||||
else
|
|
||||||
TARGET = $(STATICLIB) $(SOLIB)
|
|
||||||
endif
|
|
||||||
|
|
||||||
export STATICLIB JUNK ROOTDIR CFLAGS CPPFLAGS
|
export STATICLIB JUNK ROOTDIR CFLAGS CPPFLAGS
|
||||||
|
|
||||||
@@ -75,6 +74,8 @@ include rules.mk
|
|||||||
# Build rules
|
# Build rules
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
|
$(OBJS): Makefile
|
||||||
|
|
||||||
$(SOLIB): Makefile $(OBJS)
|
$(SOLIB): Makefile $(OBJS)
|
||||||
@printf " LINK $@\n"
|
@printf " LINK $@\n"
|
||||||
@$(CC) $(LDFLAGS) -shared -Wl,-soname=$@ -o $@ $(OBJS)
|
@$(CC) $(LDFLAGS) -shared -Wl,-soname=$@ -o $@ $(OBJS)
|
||||||
@@ -83,23 +84,35 @@ $(STATICLIB): Makefile $(OBJS)
|
|||||||
@printf " ARCHIVE $@\n"
|
@printf " ARCHIVE $@\n"
|
||||||
@$(AR) $(ARFLAGS) $@ $(OBJS)
|
@$(AR) $(ARFLAGS) $@ $(OBJS)
|
||||||
|
|
||||||
install: strip
|
install-exec: all
|
||||||
|
@printf " INSTALL $(DESTDIR)$(libdir)/$(SOLIB)\n"
|
||||||
@install -d $(DESTDIR)$(libdir)
|
@install -d $(DESTDIR)$(libdir)
|
||||||
@printf " INSTALL $(DESTDIR)$(libdir)/$(TARGET)\n"
|
|
||||||
@install $(SOLIB) $(DESTDIR)$(libdir)/$(SOLIB)
|
@install $(SOLIB) $(DESTDIR)$(libdir)/$(SOLIB)
|
||||||
@install $(STATICLIB) $(DESTDIR)$(libdir)/$(STATICLIB)
|
|
||||||
@ln -sf $(SOLIB) $(DESTDIR)$(libdir)/$(SYMLIB)
|
@ln -sf $(SOLIB) $(DESTDIR)$(libdir)/$(SYMLIB)
|
||||||
@install -d $(DESTDIR)$(incdir)
|
|
||||||
@install -m 0644 $(HEADER) $(DESTDIR)$(incdir)/$(HEADER)
|
install-dev:
|
||||||
@install -d $(DESTDIR)$(datadir)
|
@install -d $(DESTDIR)$(incdir)/$(LIBNAME)
|
||||||
@for file in $(DISTFILES); do \
|
@for file in $(HEADERS); do \
|
||||||
install -m 0644 $$file $(DESTDIR)$(datadir)/$$file; \
|
printf " INSTALL $(DESTDIR)$(incdir)/$(LIBNAME)/$$file\n"; \
|
||||||
|
install -m 0644 $$file $(DESTDIR)$(incdir)/$(LIBNAME)/$$file; \
|
||||||
done
|
done
|
||||||
|
@printf " INSTALL $(DESTDIR)$(libdir)/$(STATICLIB)\n"
|
||||||
|
@install -d $(DESTDIR)$(libdir)
|
||||||
|
@install $(STATICLIB) $(DESTDIR)$(libdir)/$(STATICLIB)
|
||||||
|
@install -d $(DESTDIR)$(datadir)
|
||||||
|
@for file in $(DISTFILES); do \
|
||||||
|
printf " INSTALL $(DESTDIR)$(datadir)/$$file\n"; \
|
||||||
|
install -m 0644 $$file $(DESTDIR)$(datadir)/$$file; \
|
||||||
|
done
|
||||||
|
|
||||||
|
install: install-exec install-dev
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
-@$(RM) -r $(DESTDIR)$(datadir)
|
-@$(RM) -r $(DESTDIR)$(datadir)
|
||||||
-@$(RM) -r $(DESTDIR)$(incdir)
|
-@$(RM) -r $(DESTDIR)$(incdir)/$(LIBNAME)
|
||||||
-@$(RM) $(DESTDIR)$(prefix)/lib/$(LIBNAME)*
|
-@$(RM) $(DESTDIR)$(libdir)/$(SOLIB)
|
||||||
|
-@$(RM) $(DESTDIR)$(libdir)/$(SYMLIB)
|
||||||
|
-@$(RM) $(DESTDIR)$(libdir)/$(STATICLIB)
|
||||||
|
|
||||||
strip: $(TARGET)
|
strip: $(TARGET)
|
||||||
@printf " STRIP %s\n" $(TARGET)
|
@printf " STRIP %s\n" $(TARGET)
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ used for inspiration is the very small [Picoev][9] by [Oku Kazuho].
|
|||||||
[Flemming Madsen]: http://www.madsensoft.dk
|
[Flemming Madsen]: http://www.madsensoft.dk
|
||||||
[Dave Zarzycki, Apple]: http://www.youtube.com/watch?v=cD_s6Fjdri8
|
[Dave Zarzycki, Apple]: http://www.youtube.com/watch?v=cD_s6Fjdri8
|
||||||
|
|
||||||
[libuEv] is developed and maintained by [Joachim Nilsson]
|
[libuEv] is developed and maintained by [Joachim Nilsson].
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
-- Local Variables:
|
-- Local Variables:
|
||||||
|
|||||||
+15
-16
@@ -2,24 +2,23 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2014-2015 Joachim Nilsson <troglobit()gmail!com>
|
* Copyright (c) 2014-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* a copy of this software and associated documentation files (the
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* in the Software without restriction, including without limitation the rights
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* furnished to do so, subject to the following conditions:
|
||||||
* the following conditions:
|
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* included in all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
|||||||
+15
-16
@@ -2,24 +2,23 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2015 Joachim Nilsson <troglobit@gmail.com>
|
* Copyright (c) 2015 Joachim Nilsson <troglobit@gmail.com>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* a copy of this software and associated documentation files (the
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* in the Software without restriction, including without limitation the rights
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* furnished to do so, subject to the following conditions:
|
||||||
* the following conditions:
|
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* included in all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|||||||
+15
-16
@@ -3,24 +3,23 @@
|
|||||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||||
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* a copy of this software and associated documentation files (the
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* in the Software without restriction, including without limitation the rights
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* furnished to do so, subject to the following conditions:
|
||||||
* the following conditions:
|
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* included in all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|||||||
@@ -3,24 +3,23 @@
|
|||||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||||
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* a copy of this software and associated documentation files (the
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* in the Software without restriction, including without limitation the rights
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* furnished to do so, subject to the following conditions:
|
||||||
* the following conditions:
|
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* included in all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/* libuEv - Private methods and data types, do not use directly!
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||||
|
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LIBUEV_PRIVATE_H_
|
||||||
|
#define LIBUEV_PRIVATE_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/epoll.h>
|
||||||
|
#include "queue.h" /* OpenBSD queue.h > old GLIBC version */
|
||||||
|
|
||||||
|
/* I/O, timer, or signal watcher */
|
||||||
|
typedef enum {
|
||||||
|
UEV_IO_TYPE = 1,
|
||||||
|
UEV_TIMER_TYPE,
|
||||||
|
UEV_SIGNAL_TYPE,
|
||||||
|
} uev_type_t;
|
||||||
|
|
||||||
|
/* Event mask, used internally only. */
|
||||||
|
#define UEV_EVENT_MASK (UEV_READ | UEV_WRITE)
|
||||||
|
|
||||||
|
/* Main libuEv context type */
|
||||||
|
typedef struct {
|
||||||
|
int running;
|
||||||
|
int fd; /* For epoll() */
|
||||||
|
uint32_t errors;
|
||||||
|
LIST_HEAD(,uev) watchers;
|
||||||
|
} uev_ctx_t;
|
||||||
|
|
||||||
|
/* Forward declare due to dependencys, don't try this at home kids. */
|
||||||
|
struct uev;
|
||||||
|
|
||||||
|
/* This is used to hide all private data members in uev_t */
|
||||||
|
#define uev_private_t \
|
||||||
|
LIST_ENTRY(uev) link; /* For queue.h linked list */ \
|
||||||
|
\
|
||||||
|
int active; \
|
||||||
|
int events; \
|
||||||
|
\
|
||||||
|
/* Watcher callback with optional argument */ \
|
||||||
|
void (*cb)(struct uev *, void *, int); \
|
||||||
|
void *arg; \
|
||||||
|
\
|
||||||
|
/* Timer watchers, time in milliseconds */ \
|
||||||
|
int timeout; \
|
||||||
|
int period; \
|
||||||
|
\
|
||||||
|
/* Signal watchers */ \
|
||||||
|
int signo; \
|
||||||
|
\
|
||||||
|
/* Watcher type */ \
|
||||||
|
uev_type_t
|
||||||
|
|
||||||
|
/* Internal API for dealing with generic watchers */
|
||||||
|
int uev_watcher_init (uev_ctx_t *ctx, struct uev *w, uev_type_t type,
|
||||||
|
void (*cb)(struct uev *, void *, int), void *arg,
|
||||||
|
int fd, int events);
|
||||||
|
int uev_watcher_start(struct uev *w);
|
||||||
|
int uev_watcher_stop (struct uev *w);
|
||||||
|
|
||||||
|
#endif /* LIBUEV_PRIVATE_H_ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Local Variables:
|
||||||
|
* version-control: t
|
||||||
|
* indent-tabs-mode: t
|
||||||
|
* c-file-style: "linux"
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
@@ -3,24 +3,23 @@
|
|||||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||||
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* a copy of this software and associated documentation files (the
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* in the Software without restriction, including without limitation the rights
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* furnished to do so, subject to the following conditions:
|
||||||
* the following conditions:
|
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* included in all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|||||||
@@ -3,24 +3,23 @@
|
|||||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||||
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* a copy of this software and associated documentation files (the
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* in the Software without restriction, including without limitation the rights
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* furnished to do so, subject to the following conditions:
|
||||||
* the following conditions:
|
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* included in all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -155,12 +154,12 @@ int uev_timer_start(uev_t *w)
|
|||||||
*/
|
*/
|
||||||
int uev_timer_stop(uev_t *w)
|
int uev_timer_stop(uev_t *w)
|
||||||
{
|
{
|
||||||
if (uev_watcher_stop(w))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* Stop kernel timer */
|
/* Stop kernel timer */
|
||||||
uev_timer_set(w, 0, 0);
|
uev_timer_set(w, 0, 0);
|
||||||
|
|
||||||
|
if (uev_watcher_stop(w))
|
||||||
|
return -1;
|
||||||
|
|
||||||
/* Close timerfd, will have to be reopened again on reset */
|
/* Close timerfd, will have to be reopened again on reset */
|
||||||
close(w->fd);
|
close(w->fd);
|
||||||
w->fd = -1;
|
w->fd = -1;
|
||||||
|
|||||||
@@ -3,24 +3,23 @@
|
|||||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||||
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* a copy of this software and associated documentation files (the
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* in the Software without restriction, including without limitation the rights
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* furnished to do so, subject to the following conditions:
|
||||||
* the following conditions:
|
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* included in all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -37,7 +36,7 @@
|
|||||||
|
|
||||||
static int _init(uev_ctx_t *ctx, int close_old)
|
static int _init(uev_ctx_t *ctx, int close_old)
|
||||||
{
|
{
|
||||||
int fd = epoll_create1(O_CLOEXEC);
|
int fd = epoll_create1(EPOLL_CLOEXEC);
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -3,33 +3,29 @@
|
|||||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||||
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
* Copyright (c) 2013-2015 Joachim Nilsson <troglobit()gmail!com>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* a copy of this software and associated documentation files (the
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* in the Software without restriction, including without limitation the rights
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* furnished to do so, subject to the following conditions:
|
||||||
* the following conditions:
|
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* included in all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBUEV_UEV_H_
|
#ifndef LIBUEV_UEV_H_
|
||||||
#define LIBUEV_UEV_H_
|
#define LIBUEV_UEV_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "private.h"
|
||||||
#include <sys/epoll.h>
|
|
||||||
|
|
||||||
#include "queue.h" /* OpenBSD queue.h > old GLIBC version */
|
|
||||||
|
|
||||||
/* Max. number of simulateneous events */
|
/* Max. number of simulateneous events */
|
||||||
#define UEV_MAX_EVENTS 10
|
#define UEV_MAX_EVENTS 10
|
||||||
@@ -38,61 +34,24 @@
|
|||||||
#define UEV_NONE 0
|
#define UEV_NONE 0
|
||||||
#define UEV_READ EPOLLIN
|
#define UEV_READ EPOLLIN
|
||||||
#define UEV_WRITE EPOLLOUT
|
#define UEV_WRITE EPOLLOUT
|
||||||
#define UEV_EVENT_MASK (UEV_READ | UEV_WRITE)
|
|
||||||
|
|
||||||
/* Run flags */
|
/* Run flags */
|
||||||
#define UEV_ONCE 1
|
#define UEV_ONCE 1
|
||||||
#define UEV_NONBLOCK 2
|
#define UEV_NONBLOCK 2
|
||||||
|
|
||||||
/* I/O, timer, or signal watcher */
|
/* Event watcher */
|
||||||
typedef enum {
|
|
||||||
UEV_IO_TYPE = 1,
|
|
||||||
UEV_TIMER_TYPE,
|
|
||||||
UEV_SIGNAL_TYPE,
|
|
||||||
} uev_type_t;
|
|
||||||
|
|
||||||
/* Forward declare due to dependencys, don't try this at home kids. */
|
|
||||||
struct uev;
|
|
||||||
|
|
||||||
/* Main libuEv context type */
|
|
||||||
typedef struct {
|
|
||||||
int running;
|
|
||||||
int fd; /* For epoll() */
|
|
||||||
uint32_t errors;
|
|
||||||
LIST_HEAD(,uev) watchers;
|
|
||||||
} uev_ctx_t;
|
|
||||||
|
|
||||||
/* I/O event watcher */
|
|
||||||
typedef struct uev {
|
typedef struct uev {
|
||||||
LIST_ENTRY(uev) link; /* For queue.h linked list */
|
/* Private data for libuEv internal engine */
|
||||||
|
uev_private_t type;
|
||||||
|
|
||||||
/* Common to all watchers */
|
/* Public data for users to reference */
|
||||||
uev_ctx_t *ctx;
|
|
||||||
uev_type_t type;
|
|
||||||
int active;
|
|
||||||
int fd;
|
int fd;
|
||||||
int events;
|
uev_ctx_t *ctx;
|
||||||
|
|
||||||
/* Watcher callback with optional argument */
|
|
||||||
void (*cb)(struct uev *, void *, int);
|
|
||||||
void *arg;
|
|
||||||
|
|
||||||
/* Timer watchers, time in milliseconds */
|
|
||||||
int timeout;
|
|
||||||
int period;
|
|
||||||
|
|
||||||
/* Signal watchers */
|
|
||||||
int signo;
|
|
||||||
} uev_t;
|
} uev_t;
|
||||||
|
|
||||||
/* Generic callback for watchers */
|
/* Generic callback for watchers */
|
||||||
typedef void (uev_cb_t)(uev_t *w, void *arg, int events);
|
typedef void (uev_cb_t)(uev_t *w, void *arg, int events);
|
||||||
|
|
||||||
/* Private methods, do not use directly! */
|
|
||||||
int uev_watcher_init (uev_ctx_t *ctx, uev_t *w, uev_type_t type, uev_cb_t *cb, void *arg, int fd, int events);
|
|
||||||
int uev_watcher_start (uev_t *w);
|
|
||||||
int uev_watcher_stop (uev_t *w);
|
|
||||||
|
|
||||||
/* Public interface */
|
/* Public interface */
|
||||||
int uev_init (uev_ctx_t *ctx);
|
int uev_init (uev_ctx_t *ctx);
|
||||||
int uev_exit (uev_ctx_t *ctx);
|
int uev_exit (uev_ctx_t *ctx);
|
||||||
|
|||||||
Reference in new issue
Block a user