10 Commits
Author SHA1 Message Date
Joachim Nilsson 0e3d6ebb1d Minor improvement in how build is echoed to screen.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-24 23:51:24 +01:00
Joachim Nilsson 66194a8645 Update Introduction with cautionary warning about signalfd.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-24 14:27:32 +01:00
Joachim Nilsson 0f18e4fcc0 Minor update.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-22 01:22:56 +01:00
Joachim Nilsson 96a497b03e Simplify test.c example, no need to stop timer before exit.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-11 14:05:41 +01:00
Joachim Nilsson 2a6697d514 Add ToC and some kbd markup
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-11 14:04:48 +01:00
Joachim Nilsson 5c7a6f1163 Bump version for v1.0.3 release.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-07 02:14:17 +01:00
Joachim Nilsson 618480140c Update copyright years and reflow LICENSE file.
Update copyright years of all sources.

Reflow/reformat paragraphs in MIT license to match Finit,
i.e., no content changes only whitespace/linebreak changes.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-07 02:11:09 +01:00
Joachim Nilsson 55f92d25ba Change from Sparse to Clang's scan-build for make check target
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-07 02:03:20 +01:00
Joachim Nilsson 82d0b0dcb8 Add Coverity Scan integration.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-07 01:42:38 +01:00
Joachim Nilsson b0aec77056 Add Travis CI integration.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-01-07 01:36:45 +01:00
11 changed files with 96 additions and 57 deletions

No files matched your search

+22
View File
@@ -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
+17 -21
View File
@@ -1,24 +1,20 @@
Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk> Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
Copyright (c) 2013 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.
For an explanation and background of the MIT license, see the Wikipedia
article https://en.wikipedia.org/wiki/MIT_License
+9 -11
View File
@@ -1,7 +1,7 @@
# -*-Makefile-*- for libuEv # -*-Makefile-*- for libuEv
# #
# Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk> # Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
# Copyright (c) 2013 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 of this software and associated documentation files (the # a copy of this software and associated documentation files (the
@@ -25,7 +25,7 @@
.PHONY: all test clean .PHONY: all test clean
#VERSION = $(shell git tag -l | tail -1) #VERSION = $(shell git tag -l | tail -1)
VERSION ?= 1.0.2 VERSION ?= 1.0.3
NAME = libuev NAME = libuev
PKG = $(NAME)-$(VERSION) PKG = $(NAME)-$(VERSION)
ARCHIVE = $(PKG).tar.xz ARCHIVE = $(PKG).tar.xz
@@ -33,15 +33,12 @@ ARCHIVE = $(PKG).tar.xz
CC ?= $(CROSS)gcc CC ?= $(CROSS)gcc
AR ?= $(CROSS)ar AR ?= $(CROSS)ar
STRIP ?= $(CROSS)strip STRIP ?= $(CROSS)strip
CHECK ?= sparse
CFLAGS += -fPIC -Os CFLAGS += -fPIC -Os
CPPFLAGS += -W -Wall -Werror CPPFLAGS += -W -Wall -Werror
ARFLAGS = crus 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.* JUNK = *~ *.bak *.map .*.d DEADJOE *.gdb *.elf core core.*
ROOTDIR ?= $(shell pwd)
LIBNAME = $(NAME) LIBNAME = $(NAME)
prefix ?= /usr/local prefix ?= /usr/local
libdir ?= $(prefix)/lib libdir ?= $(prefix)/lib
@@ -61,7 +58,7 @@ TARGET = $(STATICLIB) $(SOLIB)
# Pattern rules # Pattern rules
.c.o: .c.o:
@printf " CC $@\n" @printf " CC $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
@$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< @$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
# Smart autodependecy generation via GCC -M. # Smart autodependecy generation via GCC -M.
@@ -115,11 +112,12 @@ joystick: Makefile joystick.o $(STATICLIB)
@printf " JOTST %s\n" $(STATICLIB) @printf " JOTST %s\n" $(STATICLIB)
@$(CC) $(CPPFLAGS) -g -o joystick joystick.c $(STATICLIB) && ./joystick @$(CC) $(CPPFLAGS) -g -o joystick joystick.c $(STATICLIB) && ./joystick
check: # Runs Clang scan-build on the whole tree
@$(CHECK) $(CHECK_FLAGS) $(CPPFLAGS) $(SRCS) bench.c check: clean
@scan-build $(MAKE) all
clean: clean:
-@$(RM) $(TARGET) *.o test -@$(RM) $(TARGET) *.o test joystick bench
distclean: clean distclean: clean
-@$(RM) $(DEPS) $(JUNK) -@$(RM) $(DEPS) $(JUNK)
+32 -9
View File
@@ -1,5 +1,21 @@
libuEv | Simple event loop for Linux libuEv | Simple event loop for Linux
==================================== ====================================
[![Build Status](https://travis-ci.org/troglobit/libuev.png?branch=master)](https://travis-ci.org/troglobit/libuev)
[![Coverity Scan Status](https://scan.coverity.com/projects/3846/badge.svg)](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?” > “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. is a modern Linux system.
Experienced developers may appreciate that libuEv is built on top of 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 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 create an *event context*, achieved by calling `uev_init()` with a
pointer to a local `uev_ctx_t` variable. 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 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 callback to the event context by passing the `uev_ctx_t` variable, along
with an `uev_t` variable to each event's `_init()` function. 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 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 `gcc -o joystick joystick.c io.c timer.c signal.c main.c` from this
directory, skips using a Makefile altogether. Alternatively, call the 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 For a more complete, and perhaps more relevant example, see the code for
the TFTP/FTP server [uftpd](https://github.com/troglobit/uftpd). It the TFTP/FTP server [uftpd](https://github.com/troglobit/uftpd). It
uses libuEv as a GIT submodule. uses libuEv as a GIT submodule.
Also, see the `bench.c` program (`make bench` from within the library) Also, see the `bench.c` program (<kbd>make bench</kbd> from within the
for [reference benchmarks](http://libev.schmorp.de/bench.html) against library) for [reference benchmarks](http://libev.schmorp.de/bench.html)
libevent and libev. against libevent and libev.
Build & Install 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 purpose and patches to correct this are most welcome. Particularly
patches to support *BSD and its kqueue interface. patches to support *BSD and its kqueue interface.
* `make all`: The library * <kbd>make all</kbd>: The library
* `make test`: Test and showcase * <kbd>make test</kbd>: Test and showcase
* `make install`: Honors `$prefix` and `$DESTDIR` environment variables * <kbd>make install</kbd>: Honors `$prefix` and `$DESTDIR` environment variables
Size of libuEv: Size of libuEv:
+2 -2
View File
@@ -1,7 +1,7 @@
/* libuEv - Micro event loop library /* libuEv - Micro event loop library
* *
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk> * Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
* Copyright (c) 2013 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 of this software and associated documentation files (the * a copy of this software and associated documentation files (the
+1 -1
View File
@@ -1,6 +1,6 @@
/* Simple example of how to use libuEv with Linux joystick API /* 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 * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
+2 -2
View File
@@ -1,7 +1,7 @@
/* libuEv - Micro event loop library /* libuEv - Micro event loop library
* *
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk> * Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
* Copyright (c) 2013 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 of this software and associated documentation files (the * a copy of this software and associated documentation files (the
+2 -2
View File
@@ -1,7 +1,7 @@
/* libuEv - Micro event loop library /* libuEv - Micro event loop library
* *
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk> * Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
* Copyright (c) 2013 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 of this software and associated documentation files (the * a copy of this software and associated documentation files (the
+5 -5
View File
@@ -1,7 +1,7 @@
/* Test libuEv event library /* Test libuEv event library
* *
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk> * Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
* Copyright (c) 2013 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 of this software and associated documentation files (the * 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)) 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); uev_exit(ctx);
} }
/* The pipe watchdog, if it triggers we haven't received data in time. */ /* 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; watchdog = NULL;
fprintf(stderr, "\nTimeout exceeded %p\n", arg); 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); uev_exit(ctx);
} }
+2 -2
View File
@@ -1,7 +1,7 @@
/* libuEv - Micro event loop library /* libuEv - Micro event loop library
* *
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk> * Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
* Copyright (c) 2013 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 of this software and associated documentation files (the * a copy of this software and associated documentation files (the
+2 -2
View File
@@ -1,7 +1,7 @@
/* libuEv - Micro event loop library /* libuEv - Micro event loop library
* *
* Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk> * Copyright (c) 2012 Flemming Madsen <flemming!madsen()madsensoft!dk>
* Copyright (c) 2013 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 of this software and associated documentation files (the * a copy of this software and associated documentation files (the