1.3.0 release

master
Alexander Vdolainen 10 years ago
parent 313de17a73
commit 766efbd706

@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
AC_INIT(libsexpr, 1.3) AC_INIT(libsexpr, 1.3.0)
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])

2
debian/changelog vendored

@ -1,4 +1,4 @@
libsexpr (1.2-1) unstable; urgency=low libsexpr (1.3.0) stable; urgency=low
* Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP> * Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>

4
debian/control vendored

@ -1,7 +1,7 @@
Source: libsexpr Source: libsexpr
Priority: extra Priority: extra
Maintainer: Alexander Vdolainen <vdo@askele.com> Maintainer: Alexander Vdolainen <vdo@askele.com>
Build-Depends: debhelper (>= 8.0.0), autotools-dev Build-Depends: debhelper (>= 8.0.0), autotools-dev, libc-dev
Standards-Version: 3.9.3 Standards-Version: 3.9.3
Section: libs Section: libs
Homepage: http://askele.com/software Homepage: http://askele.com/software
@ -11,7 +11,7 @@ Homepage: http://askele.com/software
Package: libsexpr-dev Package: libsexpr-dev
Section: libdevel Section: libdevel
Architecture: any Architecture: any
Depends: libsexpr (= ${binary:Version}) Depends: libsexpr (= ${binary:Version}), libc-dev
Description: Development files for libsexpr Description: Development files for libsexpr
Development files for library working with S-expressions Development files for library working with S-expressions

@ -1 +1 @@
liblibsexpr 1.2 libsexpr (>> 1.2-0), libsexpr (<< 1.2-99) liblibsexpr 1.3.0 libsexpr (>> 1.3.0), libsexpr (<< 1.3.99)

@ -4,7 +4,6 @@ AM_CPPFLAGS = \
-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \ -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
-DPACKAGE_SRC_DIR=\""$(srcdir)"\" \ -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \ -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
-D_NO_MEMORY_MANAGEMENT_ \
$(LIBTDATA_CFLAGS) -I../include $(LIBTDATA_CFLAGS) -I../include
AM_CFLAGS =\ AM_CFLAGS =\

@ -40,11 +40,16 @@ LA-CC-04-094
#include <sexpr/sexp.h> #include <sexpr/sexp.h>
#include <sexpr/faststack.h> #include <sexpr/faststack.h>
/* we need a locks in this case and we don't have ability to change API */
#ifndef _NO_MEMORY_MANAGEMENT_
#include <pthread.h>
#endif
/* /*
* constants related to atom buffer sizes and growth. * constants related to atom buffer sizes and growth.
*/ */
static size_t sexp_val_start_size = 256; static size_t sexp_val_start_size = 256;
static size_t sexp_val_grow_size = 64; static size_t sexp_val_grow_size = 128;
/* /*
* Function for tuning growth parameters. * Function for tuning growth parameters.
@ -79,6 +84,7 @@ parse_data_t;
*/ */
#ifndef _NO_MEMORY_MANAGEMENT_ #ifndef _NO_MEMORY_MANAGEMENT_
faststack_t *pd_cache; faststack_t *pd_cache;
pthread_mutex_t pd_cache_lock;
#endif #endif
/** /**
@ -91,6 +97,7 @@ faststack_t *pd_cache;
*/ */
#ifndef _NO_MEMORY_MANAGEMENT_ #ifndef _NO_MEMORY_MANAGEMENT_
faststack_t *sexp_t_cache; faststack_t *sexp_t_cache;
pthread_mutex_t sexp_cache_lock;
#endif #endif
/** /**
@ -115,23 +122,28 @@ sexp_t_allocate(void) {
if (sexp_t_cache == NULL) { if (sexp_t_cache == NULL) {
sexp_t_cache = make_stack(); sexp_t_cache = make_stack();
pthread_mutex_init(&sexp_cache_lock, NULL);
if (sexp_t_cache == NULL) { if (sexp_t_cache == NULL) {
sexp_errno = SEXP_ERR_MEMORY; sexp_errno = SEXP_ERR_MEMORY;
return NULL; return NULL;
} }
pthread_mutex_lock(&sexp_cache_lock);
#ifdef __cplusplus #ifdef __cplusplus
sx = (sexp_t *)sexp_malloc(sizeof(sexp_t)); sx = (sexp_t *)sexp_malloc(sizeof(sexp_t));
#else #else
sx = sexp_malloc(sizeof(sexp_t)); sx = sexp_malloc(sizeof(sexp_t));
#endif #endif
if (sx == NULL) { if (sx == NULL) {
pthread_mutex_unlock(&sexp_cache_lock);
sexp_errno = SEXP_ERR_MEMORY; sexp_errno = SEXP_ERR_MEMORY;
return NULL; return NULL;
} }
sx->next = sx->list = NULL; sx->next = sx->list = NULL;
pthread_mutex_unlock(&sexp_cache_lock);
} else { } else {
pthread_mutex_lock(&sexp_cache_lock);
if (empty_stack(sexp_t_cache)) { if (empty_stack(sexp_t_cache)) {
#ifdef __cplusplus #ifdef __cplusplus
sx = (sexp_t *)sexp_malloc(sizeof(sexp_t)); sx = (sexp_t *)sexp_malloc(sizeof(sexp_t));
@ -139,6 +151,7 @@ sexp_t_allocate(void) {
sx = sexp_malloc(sizeof(sexp_t)); sx = sexp_malloc(sizeof(sexp_t));
#endif #endif
if (sx == NULL) { if (sx == NULL) {
pthread_mutex_unlock(&sexp_cache_lock);
sexp_errno = SEXP_ERR_MEMORY; sexp_errno = SEXP_ERR_MEMORY;
return NULL; return NULL;
} }
@ -148,6 +161,7 @@ sexp_t_allocate(void) {
l = pop(sexp_t_cache); l = pop(sexp_t_cache);
sx = (sexp_t *)l->data; sx = (sexp_t *)l->data;
} }
pthread_mutex_unlock(&sexp_cache_lock);
} }
return sx; return sx;
@ -173,6 +187,7 @@ sexp_t_deallocate(sexp_t *s) {
if (sexp_t_cache == NULL) { if (sexp_t_cache == NULL) {
sexp_t_cache = make_stack(); sexp_t_cache = make_stack();
pthread_mutex_init(&sexp_cache_lock, NULL);
if (sexp_t_cache == NULL) { if (sexp_t_cache == NULL) {
/**** HOW DO WE GET THE USER TO KNOW SOMETHING HAPPENED? ****/ /**** HOW DO WE GET THE USER TO KNOW SOMETHING HAPPENED? ****/
@ -185,6 +200,7 @@ sexp_t_deallocate(sexp_t *s) {
return; return;
} }
} }
pthread_mutex_lock(&sexp_cache_lock);
s->list = s->next = NULL; s->list = s->next = NULL;
@ -193,8 +209,10 @@ sexp_t_deallocate(sexp_t *s) {
} }
s->val = NULL; s->val = NULL;
memset(s, 0, sizeof(sexp_t));
sexp_t_cache = push(sexp_t_cache, s); sexp_t_cache = push(sexp_t_cache, s);
pthread_mutex_unlock(&sexp_cache_lock);
} }
#endif #endif
@ -210,6 +228,7 @@ void sexp_cleanup(void) {
stack_lvl_t *l; stack_lvl_t *l;
if (pd_cache != NULL) { if (pd_cache != NULL) {
pthread_mutex_lock(&pd_cache_lock);
l = pd_cache->top; l = pd_cache->top;
while (l != NULL) { while (l != NULL) {
sexp_free(l->data,sizeof(parse_data_t)); sexp_free(l->data,sizeof(parse_data_t));
@ -217,15 +236,20 @@ void sexp_cleanup(void) {
} }
destroy_stack(pd_cache); destroy_stack(pd_cache);
pd_cache = NULL; pd_cache = NULL;
pthread_mutex_unlock(&pd_cache_lock);
pthread_mutex_destroy(&pd_cache_lock);
} }
if (sexp_t_cache != NULL) { if (sexp_t_cache != NULL) {
pthread_mutex_lock(&sexp_cache_lock);
l = sexp_t_cache->top; l = sexp_t_cache->top;
while (l != NULL) { while (l != NULL) {
sexp_free(l->data,sizeof(sexp_t)); sexp_free(l->data,sizeof(sexp_t));
l = l->below; l = l->below;
} }
destroy_stack(sexp_t_cache); destroy_stack(sexp_t_cache);
pthread_mutex_lock(&sexp_cache_lock);
pthread_mutex_destroy(&sexp_cache_lock);
sexp_t_cache = NULL; sexp_t_cache = NULL;
} }
} }
@ -248,13 +272,14 @@ pd_allocate(void) {
stack_lvl_t *l; stack_lvl_t *l;
if (pd_cache == NULL) { if (pd_cache == NULL) {
pthread_mutex_init(&pd_cache_lock, NULL);
pd_cache = make_stack(); pd_cache = make_stack();
if (pd_cache == NULL) { if (pd_cache == NULL) {
sexp_errno = SEXP_ERR_MEMORY; sexp_errno = SEXP_ERR_MEMORY;
return NULL; return NULL;
} }
pthread_mutex_lock(&pd_cache_lock);
#ifdef __cplusplus #ifdef __cplusplus
p = (parse_data_t *)sexp_malloc(sizeof(parse_data_t)); p = (parse_data_t *)sexp_malloc(sizeof(parse_data_t));
#else #else
@ -265,8 +290,9 @@ pd_allocate(void) {
sexp_errno = SEXP_ERR_MEMORY; sexp_errno = SEXP_ERR_MEMORY;
return NULL; return NULL;
} }
pthread_mutex_unlock(&pd_cache_lock);
} else { } else {
pthread_mutex_lock(&pd_cache_lock);
if (empty_stack(pd_cache)) { if (empty_stack(pd_cache)) {
#ifdef __cplusplus #ifdef __cplusplus
p = (parse_data_t *)sexp_malloc(sizeof(parse_data_t)); p = (parse_data_t *)sexp_malloc(sizeof(parse_data_t));
@ -276,12 +302,14 @@ pd_allocate(void) {
if (p == NULL) { if (p == NULL) {
sexp_errno = SEXP_ERR_MEMORY; sexp_errno = SEXP_ERR_MEMORY;
pthread_mutex_unlock(&pd_cache_lock);
return NULL; return NULL;
} }
} else { } else {
l = pop(pd_cache); l = pop(pd_cache);
p = (parse_data_t *)l->data; p = (parse_data_t *)l->data;
} }
pthread_mutex_unlock(&pd_cache_lock);
} }
return p; return p;
@ -301,14 +329,19 @@ void
pd_deallocate(parse_data_t *p) { pd_deallocate(parse_data_t *p) {
if (pd_cache == NULL) { if (pd_cache == NULL) {
pd_cache = make_stack(); pd_cache = make_stack();
pthread_mutex_init(&pd_cache_lock, NULL);
if (pd_cache == NULL) { if (pd_cache == NULL) {
sexp_free(p, sizeof(parse_data_t)); sexp_free(p, sizeof(parse_data_t));
sexp_errno = SEXP_ERR_MEMORY; sexp_errno = SEXP_ERR_MEMORY;
return; return;
} }
} }
pthread_mutex_lock(&pd_cache_lock);
memset(p, 0, sizeof(parse_data_t));
pd_cache = push(pd_cache, p); pd_cache = push(pd_cache, p);
pthread_mutex_unlock(&pd_cache_lock);
} }
#endif /* _NO_MEMORY_MANAGEMENT_ */ #endif /* _NO_MEMORY_MANAGEMENT_ */
@ -509,9 +542,9 @@ init_continuation(char *str)
/* allocate atom buffer */ /* allocate atom buffer */
#ifdef __cplusplus #ifdef __cplusplus
cc->val = (char *)sexp_malloc(sizeof(char)*sexp_val_start_size); cc->val = (char *)sexp_calloc(1, sizeof(char)*sexp_val_start_size);
#else #else
cc->val = sexp_malloc(sizeof(char)*sexp_val_start_size); cc->val = sexp_calloc(1, sizeof(char)*sexp_val_start_size);
#endif #endif
if (cc->val == NULL) { if (cc->val == NULL) {
@ -599,6 +632,12 @@ iparse_sexp (char *s, size_t len, pcont_t *cc) {
* cparse_sexp */ * cparse_sexp */
pcont_t *eparse_sexp (char *str, size_t len, pcont_t *lc); pcont_t *eparse_sexp (char *str, size_t len, pcont_t *lc);
#ifdef REGISTEROPTIMIZAITON
#define REGISTER register
#else
#define REGISTER
#endif
/** /**
* Continuation based parser - the guts of the package. * Continuation based parser - the guts of the package.
*/ */
@ -607,17 +646,17 @@ cparse_sexp (char *str, size_t len, pcont_t *lc)
{ {
char *t = NULL; char *t = NULL;
char *s = NULL; char *s = NULL;
register size_t binexpected = 0; REGISTER size_t binexpected = 0;
register size_t binread = 0; REGISTER size_t binread = 0;
register parsermode_t mode = PARSER_NORMAL; REGISTER parsermode_t mode = PARSER_NORMAL;
register size_t val_allocated = 0; REGISTER size_t val_allocated = 0;
register unsigned int squoted = 0; REGISTER unsigned int squoted = 0;
register size_t val_used = 0; REGISTER size_t val_used = 0;
register unsigned int state = 1; REGISTER unsigned int state = 1;
register unsigned int depth = 0; REGISTER unsigned int depth = 0;
register unsigned int qdepth = 0; REGISTER unsigned int qdepth = 0;
register unsigned int elts = 0; REGISTER unsigned int elts = 0;
register unsigned int esc = 0; REGISTER unsigned int esc = 0;
pcont_t *cc = NULL; pcont_t *cc = NULL;
char *val = NULL; char *val = NULL;
char *vcur = NULL; char *vcur = NULL;

Loading…
Cancel
Save