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) 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.
+9 -11
View File
@@ -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)
+32 -9
View File
@@ -1,5 +1,21 @@
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?”
@@ -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:
+2 -2
View File
@@ -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
View File
@@ -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
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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
+5 -5
View File
@@ -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);
}
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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