diff --git a/lithos_c/inc/Lth_hashmap.h b/lithos_c/inc/Lth_hashmap.h index 9715e02..e33d5fc 100644 --- a/lithos_c/inc/Lth_hashmap.h +++ b/lithos_c/inc/Lth_hashmap.h @@ -12,7 +12,9 @@ // //----------------------------------------------------------------------------- -#ifndef lithos3__Lth_hashmap_h +#include "Lth_libinfo.h" + +#if !defined(lithos3__Lth_hashmap_h) && !LITHOS3_NO_HASHMAP #define lithos3__Lth_hashmap_h #include "Lth_stdlib.h" diff --git a/lithos_c/inc/Lth_libinfo.h b/lithos_c/inc/Lth_libinfo.h new file mode 100644 index 0000000..324a941 --- /dev/null +++ b/lithos_c/inc/Lth_libinfo.h @@ -0,0 +1,32 @@ +//----------------------------------------------------------------------------- +// +// Copyright © 2017 Project Golan +// +// See "LICENSE.lithos3" for more information. +// +//----------------------------------------------------------------------------- +// +// Library setup. +// +//----------------------------------------------------------------------------- + +#if LITHOS3_NO_STDLIB +# define LITHOS3_NO_HASHMAP 1 +# define LITHOS3_NO_TOKEN 1 +# define LITHOS3_NO_TOKENSTREAM 1 +# define LITHOS3_NO_MANIFEST 1 +#endif + +#if LITHOS3_NO_HASHMAP +# define LITHOS3_NO_MANIFEST 1 +#endif + +#if LITHOS3_NO_TOKEN +# define LITHOS3_NO_TOKENSTREAM 1 +#endif + +#if LITHOS3_NO_TOKENSTREAM +# define LITHOS3_NO_MANIFEST 1 +#endif + +// EOF diff --git a/lithos_c/inc/Lth_linklist.h b/lithos_c/inc/Lth_linklist.h deleted file mode 100644 index cb23d1e..0000000 --- a/lithos_c/inc/Lth_linklist.h +++ /dev/null @@ -1,106 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright © 2016-2017 Project Golan -// -// See "LICENSE.lithos3" for more information. -// -//----------------------------------------------------------------------------- -// -// Doubly linked list structure. -// -//----------------------------------------------------------------------------- - -#ifndef lithos3__Lth_linklist_h -#define lithos3__Lth_linklist_h - -#define Lth_ListForEach(tmpv, lst) \ - for(Lth_LinkList *list = (lst); list; list = list->next) \ - __with(tmpv = list->owner;) - -#define Lth_ListFor(tmpv, lst) \ - for(Lth_LinkList *list = (lst); list;) \ - __with(Lth_LinkList *next = list->next, **prev = list->prev; \ - tmpv = list->owner;) - -#define Lth_ListInsert(list, object, head) \ - (void) \ - ( \ - Lth_ListLink((list), (head)), \ - (list)->owner = object \ - ) - -#define Lth_ListInsertTail(list, object, head, tail) \ - (void) \ - ( \ - Lth_ListLinkTail((list), (head), (tail)), \ - (list)->owner = object \ - ) - -#define Lth_ListMove(list, head) \ - (void) \ - ( \ - Lth_ListRemove((list)), \ - Lth_ListLink((list), (head)) \ - ) - - -// Type Definitions ----------------------------------------------------------| - -// -// Lth_LinkList -// -typedef struct Lth_LinkList -{ - struct Lth_LinkList *next, **prev; - void *owner; -} Lth_LinkList; - - -// Static Functions ----------------------------------------------------------| - -// -// Lth_ListLink -// -static inline void Lth_ListLink(Lth_LinkList *list, Lth_LinkList **head) -{ - Lth_LinkList *next = *head; - - if((list->next = next)) - next->prev = &list->next; - - list->prev = head; - *head = list; -} - -// -// Lth_ListLinkTail -// -static inline void Lth_ListLinkTail(Lth_LinkList *list, Lth_LinkList **head, - Lth_LinkList **tail) -{ - Lth_LinkList *prev = *tail; - - if(*(list->prev = head)) - list->prev = &prev->next; - else - *head = list; - - prev->next = list; - *tail = list; -} - -// -// Lth_ListRemove -// -static inline void Lth_ListRemove(Lth_LinkList *list) -{ - Lth_LinkList *next = list->next, **prev = list->prev; - - if(prev && (*prev = next)) - next->prev = prev; - - list->next = NULL; - list->prev = NULL; -} - -#endif//lithos3__Lth_linklist_h diff --git a/lithos_c/inc/Lth_manifest.h b/lithos_c/inc/Lth_manifest.h index 7afee83..f115128 100644 --- a/lithos_c/inc/Lth_manifest.h +++ b/lithos_c/inc/Lth_manifest.h @@ -10,7 +10,9 @@ // //----------------------------------------------------------------------------- -#ifndef lithos3__Lth_manifest_h +#include "Lth_libinfo.h" + +#if !defined(lithos3__Lth_manifest_h) && !LITHOS3_NO_MANIFEST #define lithos3__Lth_manifest_h #include "Lth_types.h" diff --git a/lithos_c/inc/Lth_stdlib.h b/lithos_c/inc/Lth_stdlib.h index 0616776..9319132 100644 --- a/lithos_c/inc/Lth_stdlib.h +++ b/lithos_c/inc/Lth_stdlib.h @@ -10,7 +10,9 @@ // //----------------------------------------------------------------------------- -#ifndef lithos3__Lth_stdlib_h +#include "Lth_libinfo.h" + +#if !defined(lithos3__Lth_stdlib_h) && !LITHOS3_NO_STDLIB #define lithos3__Lth_stdlib_h #include "Lth_types.h" diff --git a/lithos_c/inc/Lth_token.h b/lithos_c/inc/Lth_token.h index e4e8960..f3ab96b 100644 --- a/lithos_c/inc/Lth_token.h +++ b/lithos_c/inc/Lth_token.h @@ -14,6 +14,8 @@ // //----------------------------------------------------------------------------- +#include "Lth_libinfo.h" + #if defined(Lth_X) Lth_X(ChrSeq) @@ -34,7 +36,7 @@ Lth_X(LnEnd ) // \n #undef Lth_X -#elif !defined(lithos3__Lth_token_h) +#elif !defined(lithos3__Lth_token_h) && !LITHOS3_NO_TOKEN #define lithos3__Lth_token_h #include diff --git a/lithos_c/inc/Lth_tokenstream.h b/lithos_c/inc/Lth_tokenstream.h index ee24770..2e41413 100644 --- a/lithos_c/inc/Lth_tokenstream.h +++ b/lithos_c/inc/Lth_tokenstream.h @@ -10,7 +10,9 @@ // //----------------------------------------------------------------------------- -#ifndef lithos3__Lth_tokenstream_h +#include "Lth_libinfo.h" + +#if !defined(lithos3__Lth_tokenstream_h) && !LITHOS3_NO_TOKENSTREAM #define lithos3__Lth_tokenstream_h #include "Lth_token.h" diff --git a/lithos_c/src/manifest.c b/lithos_c/src/manifest.c index e6bfae6..ca68a17 100644 --- a/lithos_c/src/manifest.c +++ b/lithos_c/src/manifest.c @@ -10,6 +10,9 @@ // //----------------------------------------------------------------------------- +#include "Lth_libinfo.h" + +#if !LITHOS3_NO_MANIFEST #include "Lth.h" #include @@ -448,4 +451,4 @@ Lth_Manifest Lth_ManifestNew_Strng(char const *key, char const *value) return GenManifestValue(Strng, strng, Lth_strdup(value)); } -// EOF +#endif//LITHOS3_NO_MANIFEST diff --git a/lithos_c/src/stdlib.c b/lithos_c/src/stdlib.c index 9836c8f..7c58fd7 100644 --- a/lithos_c/src/stdlib.c +++ b/lithos_c/src/stdlib.c @@ -10,6 +10,10 @@ // //----------------------------------------------------------------------------- +#include "Lth_libinfo.h" + +#if !LITHOS3_NO_STDLIB + #include "Lth.h" #include @@ -253,4 +257,4 @@ size_t Lth_Hash_wchar(wchar_t const *s) return ret; } -// EOF +#endif//LITHOS3_NO_STDLIB diff --git a/lithos_c/src/token.c b/lithos_c/src/token.c index a626d0f..fa761f7 100644 --- a/lithos_c/src/token.c +++ b/lithos_c/src/token.c @@ -12,6 +12,10 @@ // //----------------------------------------------------------------------------- +#include "Lth_libinfo.h" + +#if !LITHOS3_NO_TOKEN + #define _GNU_SOURCE #include "Lth.h" @@ -149,4 +153,4 @@ char const *Lth_TokenName(Lth_TokenType type) return names[type]; } -// EOF +#endif//LITHOS3_NO_TOKEN diff --git a/lithos_c/src/tokenstream.c b/lithos_c/src/tokenstream.c index 0883a81..5e860e9 100644 --- a/lithos_c/src/tokenstream.c +++ b/lithos_c/src/tokenstream.c @@ -12,6 +12,10 @@ // //----------------------------------------------------------------------------- +#include "Lth_libinfo.h" + +#if !LITHOS3_NO_TOKENSTREAM + #define _GNU_SOURCE #include "Lth.h" @@ -215,4 +219,4 @@ bool Lth_TokenStreamDrop(Lth_TokenStream *stream, Lth_TokenType tt) return false; } -// EOF +#endif//LITHOS3_NO_TOKENSTREAM