mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-23 11:24:34 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e3d6ebb1d | ||
|
|
66194a8645 | ||
|
|
0f18e4fcc0 | ||
|
|
96a497b03e | ||
|
|
2a6697d514 | ||
|
|
5c7a6f1163 | ||
|
|
618480140c | ||
|
|
55f92d25ba | ||
|
|
82d0b0dcb8 | ||
|
|
b0aec77056 |
No files matched your search
+22
@@ -0,0 +1,22 @@
|
||||
# Travis CI integration -- https://travis-ci.org/troglobit/libuev
|
||||
language: c
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
env:
|
||||
global:
|
||||
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
|
||||
# via the "travis encrypt" command using the project repo's public key
|
||||
- secure: "ikQcWMCLFoxq0+wMiqrNT5HRn0d4e3AxuF8VzNUNFrk6jUvHIufC/OKvr8VWPTjCaAQXZjWfdQAAARUXzJV10WZ7xpiv5qt4bt26Qih2AwMPMJeUOYrqXgQqhTPBp05iLYpo4ybICteXRI3zKKUA1wkdDC0jyu3rl+Fbveekbe0="
|
||||
|
||||
addons:
|
||||
coverity_scan:
|
||||
project:
|
||||
name: "troglobit/libuev"
|
||||
description: "libuEv | Simple asynchronous event loop for Linux."
|
||||
notification_email: troglobit@gmail.com
|
||||
build_command: "make"
|
||||
branch_pattern: master
|
||||
|
||||
script: make
|
||||
@@ -1,24 +1,20 @@
|
||||
Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
Copyright (c) 2013 Joachim Nilsson <troglobit()gmail!com>
|
||||
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:
|
||||
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 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.
|
||||
|
||||
For an explanation and background of the MIT license, see the Wikipedia
|
||||
article https://en.wikipedia.org/wiki/MIT_License
|
||||
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.
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*-Makefile-*- for libuEv
|
||||
#
|
||||
# Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
# Copyright (c) 2013 Joachim Nilsson <troglobit()gmail!com>
|
||||
# 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
|
||||
@@ -25,7 +25,7 @@
|
||||
.PHONY: all test clean
|
||||
|
||||
#VERSION = $(shell git tag -l | tail -1)
|
||||
VERSION ?= 1.0.2
|
||||
VERSION ?= 1.0.3
|
||||
NAME = libuev
|
||||
PKG = $(NAME)-$(VERSION)
|
||||
ARCHIVE = $(PKG).tar.xz
|
||||
@@ -33,15 +33,12 @@ ARCHIVE = $(PKG).tar.xz
|
||||
CC ?= $(CROSS)gcc
|
||||
AR ?= $(CROSS)ar
|
||||
STRIP ?= $(CROSS)strip
|
||||
CHECK ?= sparse
|
||||
CFLAGS += -fPIC -Os
|
||||
CPPFLAGS += -W -Wall -Werror
|
||||
ARFLAGS = crus
|
||||
CHECK_FLAGS = -Wcast-to-as -Wdefault-bitfield-sign -Wdo-while -Wparen-string \
|
||||
-Wptr-subtraction-blows -Wreturn-void -Wshadow -Wtypesign -Wbitwise \
|
||||
-std=gnu99 -D__x86_64__ -D__LP64__ -I/usr/include/x86_64-linux-gnu
|
||||
JUNK = *~ *.bak *.map .*.d DEADJOE *.gdb *.elf core core.*
|
||||
|
||||
ROOTDIR ?= $(shell pwd)
|
||||
LIBNAME = $(NAME)
|
||||
prefix ?= /usr/local
|
||||
libdir ?= $(prefix)/lib
|
||||
@@ -61,7 +58,7 @@ TARGET = $(STATICLIB) $(SOLIB)
|
||||
|
||||
# Pattern rules
|
||||
.c.o:
|
||||
@printf " CC $@\n"
|
||||
@printf " CC $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
|
||||
@$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||
|
||||
# Smart autodependecy generation via GCC -M.
|
||||
@@ -115,11 +112,12 @@ joystick: Makefile joystick.o $(STATICLIB)
|
||||
@printf " JOTST %s\n" $(STATICLIB)
|
||||
@$(CC) $(CPPFLAGS) -g -o joystick joystick.c $(STATICLIB) && ./joystick
|
||||
|
||||
check:
|
||||
@$(CHECK) $(CHECK_FLAGS) $(CPPFLAGS) $(SRCS) bench.c
|
||||
# Runs Clang scan-build on the whole tree
|
||||
check: clean
|
||||
@scan-build $(MAKE) all
|
||||
|
||||
clean:
|
||||
-@$(RM) $(TARGET) *.o test
|
||||
-@$(RM) $(TARGET) *.o test joystick bench
|
||||
|
||||
distclean: clean
|
||||
-@$(RM) $(DEPS) $(JUNK)
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
libuEv | Simple event loop for Linux
|
||||
====================================
|
||||
[](https://travis-ci.org/troglobit/libuev)
|
||||
[](https://scan.coverity.com/projects/3846)
|
||||
|
||||
|
||||
Table of Contents
|
||||
-----------------
|
||||
|
||||
* [Introduction](#introduction)
|
||||
* [API](#api)
|
||||
* [Example](#example)
|
||||
* [Build & Install](#build--install)
|
||||
* [Origin & References](#origin--references)
|
||||
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
> “Why an event loop, why not use threads?”
|
||||
|
||||
@@ -38,7 +54,14 @@ small size overhead impact of the library. The primary target of libuEv
|
||||
is a modern Linux system.
|
||||
|
||||
Experienced developers may appreciate that libuEv is built on top of
|
||||
modern Linux APIs: epoll, timerfd and signalfd.
|
||||
modern Linux APIs: epoll, timerfd and signalfd. Note, a certain amount
|
||||
of care is needed when dealing with APIs that employ signalfd. For
|
||||
details, see this article at [lwn.net](http://lwn.net/Articles/415684/).
|
||||
|
||||
> “Event driven software improves concurrency” -- Dave Zarzycki, Apple
|
||||
|
||||
See the [launchd video](http://www.youtube.com/watch?v=cD_s6Fjdri8) for
|
||||
more info.
|
||||
|
||||
|
||||
API
|
||||
@@ -80,7 +103,7 @@ To be able to set up callbacks to events the developer first need to
|
||||
create an *event context*, achieved by calling `uev_init()` with a
|
||||
pointer to a local `uev_ctx_t` variable.
|
||||
|
||||
Events are monitored by watchers in libuEV. A watcher is nothing more
|
||||
Events are monitored by watchers in libuEv. A watcher is nothing more
|
||||
than a mechnism that polls a file descriptor. Register a watcher with a
|
||||
callback to the event context by passing the `uev_ctx_t` variable, along
|
||||
with an `uev_t` variable to each event's `_init()` function.
|
||||
@@ -165,15 +188,15 @@ int main(void)
|
||||
To compile the program, save the code as `joystick.c` and call GCC with
|
||||
`gcc -o joystick joystick.c io.c timer.c signal.c main.c` from this
|
||||
directory, skips using a Makefile altogether. Alternatively, call the
|
||||
`Makefile` with `make joystick` from this directory.
|
||||
`Makefile` with <kbd>make joystick</kbd> from this directory.
|
||||
|
||||
For a more complete, and perhaps more relevant example, see the code for
|
||||
the TFTP/FTP server [uftpd](https://github.com/troglobit/uftpd). It
|
||||
uses libuEv as a GIT submodule.
|
||||
|
||||
Also, see the `bench.c` program (`make bench` from within the library)
|
||||
for [reference benchmarks](http://libev.schmorp.de/bench.html) against
|
||||
libevent and libev.
|
||||
Also, see the `bench.c` program (<kbd>make bench</kbd> from within the
|
||||
library) for [reference benchmarks](http://libev.schmorp.de/bench.html)
|
||||
against libevent and libev.
|
||||
|
||||
|
||||
Build & Install
|
||||
@@ -184,9 +207,9 @@ use GCC and GNU Make specific extensions here and there. This is not on
|
||||
purpose and patches to correct this are most welcome. Particularly
|
||||
patches to support *BSD and its kqueue interface.
|
||||
|
||||
* `make all`: The library
|
||||
* `make test`: Test and showcase
|
||||
* `make install`: Honors `$prefix` and `$DESTDIR` environment variables
|
||||
* <kbd>make all</kbd>: The library
|
||||
* <kbd>make test</kbd>: Test and showcase
|
||||
* <kbd>make install</kbd>: Honors `$prefix` and `$DESTDIR` environment variables
|
||||
|
||||
Size of libuEv:
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013 Joachim Nilsson <troglobit()gmail!com>
|
||||
* 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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* Simple example of how to use libuEv with Linux joystick API
|
||||
*
|
||||
* Copyright (c) 2014 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
|
||||
* a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013 Joachim Nilsson <troglobit()gmail!com>
|
||||
* 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013 Joachim Nilsson <troglobit()gmail!com>
|
||||
* 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Test libuEv event library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013 Joachim Nilsson <troglobit()gmail!com>
|
||||
* 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
|
||||
@@ -42,17 +42,17 @@ static uev_t *watchdog;
|
||||
|
||||
static void lifetime_cb(uev_ctx_t *ctx, uev_t UNUSED(*w), void *arg, int UNUSED(events))
|
||||
{
|
||||
fprintf(stderr, "\nLifetime exceeded %p\n", arg);
|
||||
fprintf(stderr, "\nLifetime exceeded, program completed successfully! (arg:%p)\n", arg);
|
||||
uev_exit(ctx);
|
||||
}
|
||||
|
||||
/* The pipe watchdog, if it triggers we haven't received data in time. */
|
||||
static void timeout_cb(uev_ctx_t *ctx, uev_t *w, void *arg, int UNUSED(events))
|
||||
static void timeout_cb(uev_ctx_t *ctx, uev_t *UNUSED(w), void *arg, int UNUSED(events))
|
||||
{
|
||||
watchdog = NULL;
|
||||
fprintf(stderr, "\nTimeout exceeded %p\n", arg);
|
||||
|
||||
uev_timer_stop(w);
|
||||
// uev_timer_stop(w); <-- No need to stop timers with period=0 :)
|
||||
uev_exit(ctx);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013 Joachim Nilsson <troglobit()gmail!com>
|
||||
* 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* libuEv - Micro event loop library
|
||||
*
|
||||
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
|
||||
* Copyright (c) 2013 Joachim Nilsson <troglobit()gmail!com>
|
||||
* 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
|
||||
|
||||
Reference in new issue
Block a user