This moves the whole hashtable implementation into the SHL library. Now we can link it only to the applications that really use it. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
66 lines
2.3 KiB
C
66 lines
2.3 KiB
C
/*
|
|
* kmscon - Miscellaneous Helpers
|
|
*
|
|
* Copyright (c) 2011-2012 David Herrmann <dh.herrmann@googlemail.com>
|
|
* Copyright (c) 2011 University of Tuebingen
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
/*
|
|
* Miscellaneous Helpers
|
|
* This provides several helper objects like memory-rings or similar.
|
|
*/
|
|
|
|
#ifndef KMSCON_MISC_H
|
|
#define KMSCON_MISC_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include "static_hook.h"
|
|
|
|
/* ring buffer for arbitrary byte-streams */
|
|
|
|
struct kmscon_ring;
|
|
|
|
int kmscon_ring_new(struct kmscon_ring **out);
|
|
void kmscon_ring_free(struct kmscon_ring *ring);
|
|
bool kmscon_ring_is_empty(struct kmscon_ring *ring);
|
|
|
|
int kmscon_ring_write(struct kmscon_ring *ring, const char *val, size_t len);
|
|
const char *kmscon_ring_peek(struct kmscon_ring *ring, size_t *len);
|
|
void kmscon_ring_drop(struct kmscon_ring *ring, size_t len);
|
|
|
|
/* time measurement */
|
|
|
|
struct kmscon_timer;
|
|
|
|
int kmscon_timer_new(struct kmscon_timer **out);
|
|
void kmscon_timer_free(struct kmscon_timer *timer);
|
|
|
|
void kmscon_timer_reset(struct kmscon_timer *timer);
|
|
void kmscon_timer_start(struct kmscon_timer *timer);
|
|
uint64_t kmscon_timer_stop(struct kmscon_timer *timer);
|
|
uint64_t kmscon_timer_elapsed(struct kmscon_timer *timer);
|
|
|
|
#endif /* KMSCON_MISC_H */
|