cehsrc
8 years agoadd .gitignore master
Christian Thaeter [Thu, 14 Jul 2011 22:21:20 +0000 (00:21 +0200)]
add .gitignore

8 years agodeploy mem functions in bufq and pftree
Christian Thaeter [Thu, 14 Jul 2011 22:20:27 +0000 (00:20 +0200)]
deploy mem functions in bufq and pftree

8 years agoadd strndup to mem.c|h
Christian Thaeter [Thu, 14 Jul 2011 22:11:42 +0000 (00:11 +0200)]
add strndup to mem.c|h

8 years agomemory management helpers
Christian Thaeter [Thu, 14 Jul 2011 01:38:14 +0000 (03:38 +0200)]
memory management helpers

typedefs and wrappers for common memory management functions
taking one extra userdata argument to implement custom allocators

8 years agointroduce buffer queues
Christian Thaeter [Mon, 11 Jul 2011 21:56:26 +0000 (23:56 +0200)]
introduce buffer queues

Buffer queues are dynamic buffers where one can append arbitrary data
(example: read(), recv()) and as soon some block of data is complete
it can be detached from the head.

8 years agorename ON_CERROR and NO_CERROR
Christian Thaeter [Fri, 8 Jul 2011 13:18:30 +0000 (15:18 +0200)]
rename ON_CERROR and NO_CERROR

8 years agorename DIE to CERROR_DIE
Christian Thaeter [Wed, 6 Jul 2011 06:51:08 +0000 (08:51 +0200)]
rename DIE to CERROR_DIE

8 years agofully qualified NOBUG_ names for logging
Christian Thaeter [Wed, 6 Jul 2011 06:50:25 +0000 (08:50 +0200)]
fully qualified NOBUG_ names for logging

8 years agorename error to cerror
Christian Thaeter [Wed, 6 Jul 2011 05:38:21 +0000 (07:38 +0200)]
rename error to cerror

8 years agoreplace ON_ERROR_GOTO(target) with a more generic 'ON_ERROR'
Christian Thaeter [Wed, 6 Jul 2011 04:43:18 +0000 (06:43 +0200)]
replace ON_ERROR_GOTO(target) with a more generic 'ON_ERROR'

example:
failure();
ON_ERROR goto except;

8 years agoEven more error makeover
Christian Thaeter [Wed, 6 Jul 2011 04:31:56 +0000 (06:31 +0200)]
Even more error makeover

* conditional errors ERROR_SET_IF(...
* conditional errors with jump ERROR_GOTO_IF(...
* ON_ERROR_GOTO(target) to catch errors returned from function calls
* error_again() to reactivate the last cleared error
* macro magic to make the 'extra' parameter optional
* error_expect(NULL) returns true if no error is pending

Example:

NOBUG_DEFINE_FLAG(test);
ERROR_DEFINE_PARENT (FOO, "foo error", ERRNO);

void
failure ()
{
  ERROR_SET (test, FOO);
}

int main()
{
  NOBUG_INIT;

  if (error_expect(NULL))
    {
      ON_ERROR_GOTO (except);
      ECHO ("no error yet");

      failure();  // this sets the error
      ON_ERROR_GOTO (except);

      ECHO ("never seen");
      // another way to raise an error
      ERROR_GOTO_IF (1, except, test, FOO);
    }
  return 0;

 except:
  if (error_expect(ERROR_ERRNO))
    {
      ECHO ("catched errno");
    }
  return 1;
}

// $ ./a.out
// 0000000002: ECHO: foo.c:23: thread_1: main: no error yet
// 0000000003: ERR: foo.c:13: thread_1: failure: foo error
// 0000000004: ECHO: foo.c:37: thread_1: main: catched errno

8 years agoSupport for error hierarchies
Christian Thaeter [Wed, 6 Jul 2011 03:18:56 +0000 (05:18 +0200)]
Support for error hierarchies

This makes 'errors' structures instead simple strings which keep a parent
pointer. Such can be initialized with the new ERROR_DEFINE_PARENT macro.

error_expect() walks this parents and returns 1 when the current set error
is a descendant of the expected error.

8 years agocosmetics in error.h
Christian Thaeter [Tue, 5 Jul 2011 04:03:36 +0000 (06:03 +0200)]
cosmetics in error.h

8 years agomove error handling into its own dir
Christian Thaeter [Tue, 5 Jul 2011 03:25:30 +0000 (05:25 +0200)]
move error handling into its own dir

8 years agofixes in error.h|c
Christian Thaeter [Tue, 5 Jul 2011 03:24:34 +0000 (05:24 +0200)]
fixes in error.h|c

Prepare for non threading variant, typos etc

8 years agocleanup in the priqueue test-code
Christian Thaeter [Tue, 5 Jul 2011 03:23:27 +0000 (05:23 +0200)]
cleanup in the priqueue test-code

8 years agosmall refinements to psplay
Christian Thaeter [Tue, 5 Jul 2011 03:22:41 +0000 (05:22 +0200)]
small refinements to psplay

inline initializer, typos etc

8 years agoAdd a copy function to the priqueue
Christian Thaeter [Tue, 21 Jun 2011 21:35:50 +0000 (23:35 +0200)]
Add a copy function to the priqueue

by providing a custom copy function one can adjust otherwise non-copyable
elements. This should be used cautionary because dereferencing elements may
poison the cache and thus have some considerable performance impact
(profile this)

8 years agopriqueue implementation
Christian Thaeter [Sun, 12 Jun 2011 01:55:19 +0000 (03:55 +0200)]
priqueue implementation

this adds a minimalistic priority queue based on a binary heap

8 years agofirst (mariginally working) draft for prefix-trees
Christian Thaeter [Sat, 14 May 2011 06:49:20 +0000 (08:49 +0200)]
first (mariginally working) draft for prefix-trees

8 years agopsplay improvements
Christian Thaeter [Sat, 14 May 2011 02:58:40 +0000 (04:58 +0200)]
psplay improvements

* move write barrier function into vtable
* refine splay parameter
 * -1 turns splaying off
 * 0 will do a full splay (except for the unimplemented 'zig' case yet)
 * >0 does probabilistic splaying as before

8 years agorefactored psplay
Christian Thaeter [Sun, 8 May 2011 03:12:34 +0000 (05:12 +0200)]
refactored psplay

8 years agoCollection of a lot library worthy sources, many from lumiera
Christian Thaeter [Fri, 29 Apr 2011 19:52:22 +0000 (21:52 +0200)]
Collection of a lot library worthy sources, many from lumiera

removed the lumiera namespaces everywhere