Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lexborisov/Modest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlexborisov <lex.borisov@gmail.com>2017-03-11 12:23:24 +0300
committerlexborisov <lex.borisov@gmail.com>2017-03-11 12:23:24 +0300
commitf0ecc407e2769db2b0e5fcfe8ffc5be52d0c7761 (patch)
treee4df7863a5d5cbaf63c54ba3eff73191f257aa53
parent3e646672c10415524f8fd50f6e393c3fa72bd4ce (diff)
Remove all fprintf and printf
-rw-r--r--Makefile.cfg8
-rw-r--r--source/mycore/myosi.h35
-rw-r--r--source/mycss/an_plus_b.c4
-rw-r--r--source/mycss/mycss.h13
-rw-r--r--source/mycss/namespace/serialization.c2
-rw-r--r--source/mycss/selectors/serialization.c2
-rw-r--r--source/mycss/values/serialization.c20
-rw-r--r--source/myfont/myfont.c11
-rw-r--r--source/myfont/myfont.h1
-rwxr-xr-xsource/myhtml/api.h34
-rwxr-xr-xsource/myhtml/tag.c21
-rw-r--r--source/myhtml/tag.h2
-rw-r--r--source/myhtml/token.c99
-rw-r--r--source/myhtml/token.h4
-rw-r--r--source/myhtml/tree.c112
-rw-r--r--source/myhtml/tree.h4
-rw-r--r--source/myport/posix/mycore/io.c30
-rw-r--r--source/myport/posix/mycore/perf.c288
-rw-r--r--source/myport/windows_nt/mycore/io.c30
-rw-r--r--source/myport/windows_nt/mycore/memory.c3
-rw-r--r--source/myport/windows_nt/mycore/perf.c288
21 files changed, 32 insertions, 979 deletions
diff --git a/Makefile.cfg b/Makefile.cfg
index 8615855..6e60afa 100644
--- a/Makefile.cfg
+++ b/Makefile.cfg
@@ -24,12 +24,16 @@ OS ?= $(shell uname -s)
# Windows_NT
#*******************
ifeq ($(OS),Windows_NT)
- CFLAGS += -fPIC
+ LIB_NAME_SUFFIX := .dll
+ LIB_NAME_SUFFIX_STATIC := .dll.a
+
+ MODEST_CFLAGS += -Wno-unused-variable -Wno-unused-function --std=c99
+ LDFLAGS += -Wl,--out-implib,$(call MODEST_LIBRARY_STATIC_WITH_VERSION)
# Need set
MODEST_BUILD_OS := $(OS)
# this name eq source/myport/<namedir>
- MODEST_PORT_NAME := windows
+ MODEST_PORT_NAME := windows_nt
endif
# end of Windows_NT
diff --git a/source/mycore/myosi.h b/source/mycore/myosi.h
index b96433f..99005a3 100644
--- a/source/mycore/myosi.h
+++ b/source/mycore/myosi.h
@@ -60,19 +60,8 @@
#endif
/* Debug */
-#ifdef MyCORE_DEBUG_MODE
- #define MyCORE_DEBUG(format, ...) \
- mycore_fprintf(stderr, "DEBUG: "format"\n", ##__VA_ARGS__)
-#else
- #define MyCORE_DEBUG(format, ...)
-#endif
-
-#ifdef MyCORE_DEBUG_MODE
- #define MyCORE_DEBUG_ERROR(format, ...) \
- mycore_fprintf(stderr, "DEBUG ERROR: "format"\n", ##__VA_ARGS__)
-#else
- #define MyCORE_DEBUG_ERROR(format, ...)
-#endif
+#define MyCORE_DEBUG(format, ...)
+#define MyCORE_DEBUG_ERROR(format, ...)
#define MyCORE_FAILED(_status_) ((_status_) != MyCORE_STATUS_OK)
@@ -161,26 +150,16 @@ void * mycore_realloc(void* dst, size_t size);
void * mycore_calloc(size_t num, size_t size);
void * mycore_free(void* dst);
-/* io */
-int mycore_printf(const char* format, ...);
-int mycore_fprintf(FILE* out, const char* format, ...);
-int mycore_snprintf(char* buffer, size_t buffer_size, const char* format, ...);
-
/**
* Platform-specific hdef performance clock queries.
* Implemented in perf.c
*/
-/** Get clock resolution */
-uint64_t mycore_hperf_res(mystatus_t *status);
-
-/** Get current value in clock ticks */
-uint64_t mycore_hperf_clock(mystatus_t *status);
-
-/** Print an hperf measure */
-mystatus_t mycore_hperf_print(const char *name, uint64_t x, uint64_t y, FILE *fh);
-mystatus_t mycore_hperf_print_by_val(const char *name, uint64_t x, FILE *fh);
-
+///** Get clock resolution */
+//uint64_t mycore_hperf_res(mystatus_t *status);
+//
+///** Get current value in clock ticks */
+//uint64_t mycore_hperf_clock(mystatus_t *status);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/mycss/an_plus_b.c b/source/mycss/an_plus_b.c
index bd57d5d..5409b29 100644
--- a/source/mycss/an_plus_b.c
+++ b/source/mycss/an_plus_b.c
@@ -96,7 +96,7 @@ void mycss_an_plus_b_serialization(mycss_an_plus_b_entry_t* anb_entry, mycss_cal
char data[512];
if(anb_entry->a != 0) {
- int len = mycore_snprintf(data, 512, "%ld", anb_entry->a);
+ int len = snprintf(data, 512, "%ld", anb_entry->a);
if(len > 0)
callback(data, (size_t)len, context);
@@ -108,7 +108,7 @@ void mycss_an_plus_b_serialization(mycss_an_plus_b_entry_t* anb_entry, mycss_cal
if(anb_entry->b >= 0)
callback("+", 1, context);
- int len = mycore_snprintf(data, 512, "%ld", anb_entry->b);
+ int len = snprintf(data, 512, "%ld", anb_entry->b);
if(len > 0)
callback(data, (size_t)len, context);
diff --git a/source/mycss/mycss.h b/source/mycss/mycss.h
index 4d66e51..f969083 100644
--- a/source/mycss/mycss.h
+++ b/source/mycss/mycss.h
@@ -26,19 +26,8 @@
extern "C" {
#endif
-#ifdef MyCSS_DEBUG
- #define MyCSS_DEBUG_MESSAGE(format, ...) \
- mycore_fprintf(stderr, "DEBUG: "format"\n", ##__VA_ARGS__)
-#else
- #define MyCSS_DEBUG_MESSAGE(format, ...)
-#endif
-
-#ifdef DEBUG_MODE
-#define MyCORE_DEBUG_ERROR(format, ...) \
-mycore_fprintf(stderr, "DEBUG ERROR: "format"\n", ##__VA_ARGS__)
-#else
+#define MyCSS_DEBUG_MESSAGE(format, ...)
#define MyCORE_DEBUG_ERROR(format, ...)
-#endif
#include "mycss/myosi.h"
#include "mycss/entry.h"
diff --git a/source/mycss/namespace/serialization.c b/source/mycss/namespace/serialization.c
index 6b76ff4..54e6b4a 100644
--- a/source/mycss/namespace/serialization.c
+++ b/source/mycss/namespace/serialization.c
@@ -49,7 +49,7 @@ void mycss_namespace_serialization_entry(mycss_namespace_t* ns, mycss_namespace_
callback(ns_entry->name->data, ns_entry->name->length, context);
}
else if(ns_entry->ns_id == MyHTML_NAMESPACE_ANY)
- return; //mycore_fprintf(fh, "*");
+ return;
else if(ns_entry->ns_id == MyHTML_NAMESPACE_UNDEF) {
/* some print */
}
diff --git a/source/mycss/selectors/serialization.c b/source/mycss/selectors/serialization.c
index 080c5e2..676542c 100644
--- a/source/mycss/selectors/serialization.c
+++ b/source/mycss/selectors/serialization.c
@@ -28,7 +28,7 @@ void mycss_selectors_serialization_chain(mycss_selectors_t* selectors, mycss_sel
if(selector->combinator == MyCSS_SELECTORS_COMBINATOR_DESCENDANT)
callback(" ", 1, context);
else if(selector->combinator == MyCSS_SELECTORS_COMBINATOR_UNDEF) {
- /* mycore_fprintf(fh, "") */
+ /* "" */
}
else {
callback(" ", 1, context);
diff --git a/source/mycss/values/serialization.c b/source/mycss/values/serialization.c
index 7fcd14d..60ad72d 100644
--- a/source/mycss/values/serialization.c
+++ b/source/mycss/values/serialization.c
@@ -42,11 +42,11 @@ void mycss_values_serialization_number(mycss_values_number_t* value, mycss_callb
char buff[512];
if(value->is_float) {
- int len = mycore_snprintf(buff, 512, "%0.4f", value->f);
+ int len = snprintf(buff, 512, "%0.4f", value->f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
- int len = mycore_snprintf(buff, 512, "%d", value->i);
+ int len = snprintf(buff, 512, "%d", value->i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
}
@@ -59,11 +59,11 @@ void mycss_values_serialization_length(mycss_values_length_t* value, mycss_callb
char buff[512];
if(value->is_float) {
- int len = mycore_snprintf(buff, 512, "%0.4f", value->f);
+ int len = snprintf(buff, 512, "%0.4f", value->f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
- int len = mycore_snprintf(buff, 512, "%d", value->i);
+ int len = snprintf(buff, 512, "%d", value->i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
@@ -81,11 +81,11 @@ void mycss_values_serialization_angle(mycss_values_angle_t* value, mycss_callbac
char buff[512];
if(value->is_float) {
- int len = mycore_snprintf(buff, 512, "%0.4f", value->f);
+ int len = snprintf(buff, 512, "%0.4f", value->f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
- int len = mycore_snprintf(buff, 512, "%d", value->i);
+ int len = snprintf(buff, 512, "%d", value->i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
@@ -103,11 +103,11 @@ void mycss_values_serialization_resolution(mycss_values_resolution_t* value, myc
char buff[512];
if(value->is_float) {
- int len = mycore_snprintf(buff, 512, "%0.4f", value->f);
+ int len = snprintf(buff, 512, "%0.4f", value->f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
- int len = mycore_snprintf(buff, 512, "%d", value->i);
+ int len = snprintf(buff, 512, "%d", value->i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
@@ -125,11 +125,11 @@ void mycss_values_serialization_percentage(mycss_values_percentage_t* value, myc
char buff[512];
if(value->is_float) {
- int len = mycore_snprintf(buff, 512, "%0.4f%%", value->f);
+ int len = snprintf(buff, 512, "%0.4f%%", value->f);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
else {
- int len = mycore_snprintf(buff, 512, "%d%%", value->i);
+ int len = snprintf(buff, 512, "%d%%", value->i);
mycss_values_serialization_to_callback(buff, len, callback, context);
}
}
diff --git a/source/myfont/myfont.c b/source/myfont/myfont.c
index a6b4be6..583cb55 100644
--- a/source/myfont/myfont.c
+++ b/source/myfont/myfont.c
@@ -298,17 +298,6 @@ mystatus_t myfont_check_required_tables(myfont_font_t *mf)
return MyFONT_STATUS_OK;
}
-void myfont_font_print_exists_table(myfont_font_t *mf, FILE *file)
-{
- size_t i;
- for(i = 0; i < MyFONT_TKEY_LAST_KEY; i++)
- {
- if(mf->cache.tables_offset[i]) {
- mycore_fprintf(file, "%s = %u\n", myfont_table_name[i], mf->cache.tables_offset[i]);
- }
- }
-}
-
// metrics
float myfont_metrics_baseline(myfont_font_t *mf, float font_size)
{
diff --git a/source/myfont/myfont.h b/source/myfont/myfont.h
index 67a02c1..f85a945 100644
--- a/source/myfont/myfont.h
+++ b/source/myfont/myfont.h
@@ -102,7 +102,6 @@ void myfont_free(myfont_font_t *mf, void* data);
mystatus_t myfont_load(myfont_font_t *mf, const char *filepath);
-void myfont_font_print_exists_table(myfont_font_t *mf, FILE *file);
mystatus_t myfont_check_required_tables(myfont_font_t *mf);
float myfont_metrics_baseline(myfont_font_t *mf, float font_size);
diff --git a/source/myhtml/api.h b/source/myhtml/api.h
index c07b6f3..f43f9a7 100755
--- a/source/myhtml/api.h
+++ b/source/myhtml/api.h
@@ -831,40 +831,6 @@ size_t
myhtml_tree_get_mchar_node_id(myhtml_tree_t* tree);
/**
- * Print tree of a node. Print including current node
- *
- * @param[in] myhtml_tree_t*
- * @param[in] myhtml_tree_node_t*
- * @param[in] file handle, for example use stdout
- * @param[in] tab (\t) increment for pretty print, set 0
- */
-void
-myhtml_tree_print_by_node(myhtml_tree_t* tree, myhtml_tree_node_t* node,
- FILE* out, size_t inc);
-
-/**
- * Print tree of a node. Print excluding current node
- *
- * @param[in] myhtml_tree_t*
- * @param[in] myhtml_tree_node_t*
- * @param[in] file handle, for example use stdout
- * @param[in] tab (\t) increment for pretty print, set 0
- */
-void
-myhtml_tree_print_node_children(myhtml_tree_t* tree, myhtml_tree_node_t* node,
- FILE* out, size_t inc);
-
-/**
- * Print a node
- *
- * @param[in] myhtml_tree_t*
- * @param[in] myhtml_tree_node_t*
- * @param[in] file handle, for example use stdout
- */
-void
-myhtml_tree_print_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out);
-
-/**
* Get first Incoming Buffer
*
* @param[in] myhtml_tree_t*
diff --git a/source/myhtml/tag.c b/source/myhtml/tag.c
index 55de2f3..2ea07f2 100755
--- a/source/myhtml/tag.c
+++ b/source/myhtml/tag.c
@@ -142,24 +142,3 @@ const myhtml_tag_context_t * myhtml_tag_get_by_name(myhtml_tag_t* tags, const ch
return (myhtml_tag_context_t*)tags->tree->nodes[idx].value;
}
-
-void myhtml_tag_print(myhtml_tag_t* tags, FILE* fh)
-{
- size_t i;
- for(i = MyHTML_TAG_FIRST_ENTRY; i < MyHTML_TAG_LAST_ENTRY; i++)
- {
- const myhtml_tag_context_t *ctx = myhtml_tag_get_by_id(tags, i);
-
- mycore_fprintf(fh, "<%s id=\"" MyCORE_FMT_Z "\">\n", ctx->name, i);
- }
-
- for(i = (MyHTML_TAG_LAST_ENTRY + 1); i < tags->tags_count; i++)
- {
- const myhtml_tag_context_t *ctx = myhtml_tag_get_by_id(tags, i);
-
- mycore_fprintf(fh, "<%s id=\"" MyCORE_FMT_Z "\">\n", ctx->name, i);
- }
-}
-
-
-
diff --git a/source/myhtml/tag.h b/source/myhtml/tag.h
index cb85ce8..27004af 100644
--- a/source/myhtml/tag.h
+++ b/source/myhtml/tag.h
@@ -105,8 +105,6 @@ const myhtml_tag_context_t * myhtml_tag_get_by_name(myhtml_tag_t* tags, const ch
const myhtml_tag_context_t * myhtml_tag_static_get_by_id(size_t idx);
const myhtml_tag_context_t * myhtml_tag_static_search(const char* name, size_t length);
-void myhtml_tag_print(myhtml_tag_t* tags, FILE* fh);
-
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/source/myhtml/token.c b/source/myhtml/token.c
index 561ecac..e9713e7 100644
--- a/source/myhtml/token.c
+++ b/source/myhtml/token.c
@@ -867,102 +867,3 @@ void myhtml_token_set_replacement_character_for_null_token(myhtml_tree_t* tree,
node->str = new_str;
}
-void myhtml_token_print_param_by_idx(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out)
-{
- if(node->type & MyHTML_TOKEN_TYPE_CLOSE) {
- mycore_fprintf(out, "</");
- }
- else {
- mycore_fprintf(out, "<");
- }
-
- mycore_fprintf(out, "tag_id=" MyCORE_FMT_Z "; body_begin=" MyCORE_FMT_Z "; body_length=" MyCORE_FMT_Z "; attr_first=0x%p; attr_last=0x%p",
- node->tag_id, node->raw_begin, node->raw_length,
- node->attr_first, node->attr_last);
-
- if(node->type & MyHTML_TOKEN_TYPE_CLOSE_SELF) {
- mycore_fprintf(out, " />\n");
- }
- else {
- mycore_fprintf(out, ">\n");
- }
-}
-
-void myhtml_token_print_by_idx(myhtml_tree_t* tree, myhtml_token_node_t* node, FILE* out)
-{
- const myhtml_tag_context_t *ctx = myhtml_tag_get_by_id(tree->tags, node->tag_id);
-
- if(node->tag_id == MyHTML_TAG__TEXT ||
- node->tag_id == MyHTML_TAG__COMMENT)
- {
- if(node->str.length) {
- mycore_fprintf(out, "%.*s: %.*s\n", (int)ctx->name_length, ctx->name,
- (int)node->str.length, node->str.data);
- }
- else {
- mycore_fprintf(out, "%.*s is empty\n", (int)ctx->name_length, ctx->name);
- }
- }
- else
- {
- if(node->type & MyHTML_TOKEN_TYPE_CLOSE) {
- mycore_fprintf(out, "</");
- }
- else {
- mycore_fprintf(out, "<");
- }
-
- mycore_fprintf(out, "%.*s tagid=\"" MyCORE_FMT_Z "\"", (int)ctx->name_length, ctx->name, node->tag_id);
-
- myhtml_token_print_attr(tree, node, out);
-
- if(node->type & MyHTML_TOKEN_TYPE_CLOSE_SELF) {
- mycore_fprintf(out, " />\n");
- }
- else {
- mycore_fprintf(out, ">\n");
- }
- }
-}
-
-void myhtml_token_print_attr(myhtml_tree_t* tree, myhtml_token_node_t* node, FILE* out)
-{
- myhtml_token_attr_t* attr = node->attr_first;
-
- while(attr)
- {
- mycore_fprintf(out, " %s", attr->key.data);
-
- if(attr->ns != MyHTML_NAMESPACE_HTML)
- {
- switch (attr->ns) {
- case MyHTML_NAMESPACE_SVG:
- mycore_fprintf(out, ":svg");
- break;
- case MyHTML_NAMESPACE_MATHML:
- mycore_fprintf(out, ":math");
- break;
- case MyHTML_NAMESPACE_XLINK:
- mycore_fprintf(out, ":xlink");
- break;
- case MyHTML_NAMESPACE_XML:
- mycore_fprintf(out, ":xml");
- break;
- case MyHTML_NAMESPACE_XMLNS:
- mycore_fprintf(out, ":xmlns");
- break;
- default:
- mycore_fprintf(out, ":UNDEF");
- break;
- }
- }
-
- if(attr->value.length) {
- mycore_fprintf(out, "=\"%s\"", attr->value.data);
- }
-
- attr = attr->next;
- }
-}
-
-
diff --git a/source/myhtml/token.h b/source/myhtml/token.h
index 5d7b629..a7aeaf7 100644
--- a/source/myhtml/token.h
+++ b/source/myhtml/token.h
@@ -154,10 +154,6 @@ bool myhtml_token_attr_compare(myhtml_token_node_t* target, myhtml_token_node_t*
myhtml_token_node_t * myhtml_token_merged_two_token_string(myhtml_tree_t* tree, myhtml_token_node_t* token_to, myhtml_token_node_t* token_from, bool cp_reverse);
void myhtml_token_set_replacement_character_for_null_token(myhtml_tree_t* tree, myhtml_token_node_t* node);
-void myhtml_token_print_param_by_idx(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out);
-void myhtml_token_print_by_idx(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out);
-void myhtml_token_print_attr(myhtml_tree_t* myhtml_tree, myhtml_token_node_t* node, FILE* out);
-
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/source/myhtml/tree.c b/source/myhtml/tree.c
index 79eef24..0e60653 100644
--- a/source/myhtml/tree.c
+++ b/source/myhtml/tree.c
@@ -1681,7 +1681,7 @@ bool myhtml_tree_adoption_agency_algorithm(myhtml_tree_t* tree, myhtml_token_nod
// step 8
//if(afe_last != list[i])
- // mycore_fprintf(stderr, "oh");
+ // fprintf(stderr, "oh");
// step 9
myhtml_tree_node_t* current_node = myhtml_tree_current_node(tree);
@@ -1763,7 +1763,7 @@ bool myhtml_tree_adoption_agency_algorithm(myhtml_tree_t* tree, myhtml_token_nod
if(node_index > 0)
node_index--;
else {
- mycore_fprintf(stderr, "ERROR: adoption agency algorithm; decrement node_index, node_index is null");
+ MyCORE_DEBUG_ERROR("Adoption agency algorithm; decrement node_index, node_index is null");
return false;
}
@@ -2150,114 +2150,6 @@ size_t myhtml_tree_template_insertion_length(myhtml_tree_t* tree)
return tree->template_insertion->length;
}
-void myhtml_tree_print_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out)
-{
- if(node == NULL)
- return;
-
- const myhtml_tag_context_t *ctx = myhtml_tag_get_by_id(tree->tags, node->tag_id);
-
- if(node->tag_id == MyHTML_TAG__TEXT ||
- node->tag_id == MyHTML_TAG__COMMENT)
- {
- if(node->token)
- mycore_fprintf(out, "<%.*s>: %.*s\n", (int)ctx->name_length, ctx->name,
- (int)node->token->str.length, node->token->str.data);
- else
- mycore_fprintf(out, "<%.*s>\n", (int)ctx->name_length, ctx->name);
- }
- else if(node->tag_id == MyHTML_TAG__DOCTYPE)
- {
- mycore_fprintf(out, "<!DOCTYPE");
-
- if(tree->doctype.attr_name) {
- mycore_fprintf(out, " %s", tree->doctype.attr_name);
- }
-
- if(tree->doctype.attr_public) {
- mycore_fprintf(out, " %s", tree->doctype.attr_public);
- }
-
- if(tree->doctype.attr_system) {
- mycore_fprintf(out, " %s", tree->doctype.attr_system);
- }
-
- mycore_fprintf(out, ">\n");
- }
- else
- {
- if(node->token && node->token->type & MyHTML_TOKEN_TYPE_CLOSE) {
- mycore_fprintf(out, "</%.*s", (int)ctx->name_length, ctx->name);
- }
- else {
- mycore_fprintf(out, "<%.*s", (int)ctx->name_length, ctx->name);
- }
-
- if(node->ns != MyHTML_NAMESPACE_HTML) {
- switch (node->ns) {
- case MyHTML_NAMESPACE_SVG:
- mycore_fprintf(out, ":svg");
- break;
- case MyHTML_NAMESPACE_MATHML:
- mycore_fprintf(out, ":math");
- break;
- case MyHTML_NAMESPACE_XLINK:
- mycore_fprintf(out, ":xlink");
- break;
- case MyHTML_NAMESPACE_XML:
- mycore_fprintf(out, ":xml");
- break;
- case MyHTML_NAMESPACE_XMLNS:
- mycore_fprintf(out, ":xmlns");
- break;
- default:
- break;
- }
- }
-
- if(node->token)
- myhtml_token_print_attr(tree, node->token, out);
-
- mycore_fprintf(out, ">\n");
- }
-}
-
-void _myhtml_tree_print_node_children(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc)
-{
- if(node == NULL)
- return;
-
- size_t i;
-
- while(node)
- {
- for(i = 0; i < inc; i++)
- mycore_fprintf(out, "\t");
-
- myhtml_tree_print_node(tree, node, out);
- _myhtml_tree_print_node_children(tree, node->child, out, (inc + 1));
-
- node = node->next;
- }
-}
-
-void myhtml_tree_print_node_children(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc)
-{
- if(node == NULL)
- return;
-
- _myhtml_tree_print_node_children(tree, node->child, out, inc);
-}
-
-void myhtml_tree_print_by_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc)
-{
- if(node == NULL)
- return;
-
- myhtml_tree_print_node(tree, node, out);
- myhtml_tree_print_node_children(tree, node, out, (inc + 1));
-}
-
// token list
myhtml_tree_token_list_t * myhtml_tree_token_list_init(void)
{
diff --git a/source/myhtml/tree.h b/source/myhtml/tree.h
index e98ad44..1697b79 100644
--- a/source/myhtml/tree.h
+++ b/source/myhtml/tree.h
@@ -361,10 +361,6 @@ void myhtml_tree_node_clean(myhtml_tree_node_t* tree_node);
void myhtml_tree_node_free(myhtml_tree_node_t* node);
myhtml_tree_node_t * myhtml_tree_node_clone(myhtml_tree_node_t* node);
-void myhtml_tree_print_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out);
-void myhtml_tree_print_node_children(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc);
-void myhtml_tree_print_by_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, FILE* out, size_t inc);
-
void myhtml_tree_node_add_child(myhtml_tree_node_t* root, myhtml_tree_node_t* node);
void myhtml_tree_node_insert_before(myhtml_tree_node_t* root, myhtml_tree_node_t* node);
void myhtml_tree_node_insert_after(myhtml_tree_node_t* root, myhtml_tree_node_t* node);
diff --git a/source/myport/posix/mycore/io.c b/source/myport/posix/mycore/io.c
index 2a6a4e0..9dac45c 100644
--- a/source/myport/posix/mycore/io.c
+++ b/source/myport/posix/mycore/io.c
@@ -21,36 +21,6 @@
#include "mycore/myosi.h"
#include <stdarg.h>
-int mycore_printf(const char* format, ...)
-{
- va_list argptr;
- va_start(argptr, format);
- int res = vprintf(format, argptr);
- va_end(argptr);
-
- return res;
-}
-
-int mycore_fprintf(FILE* out, const char* format, ...)
-{
- va_list argptr;
- va_start(argptr, format);
- int res = vfprintf(out, format, argptr);
- va_end(argptr);
-
- return res;
-}
-
-int mycore_snprintf(char* buffer, size_t buffer_size, const char* format, ...)
-{
- va_list argptr;
- va_start(argptr, format);
- int res = vsnprintf(buffer, buffer_size, format, argptr);
- va_end(argptr);
-
- return res;
-}
-
/* FILE */
FILE * mycore_fopen(const char *restrict filename, const char *restrict mode)
{
diff --git a/source/myport/posix/mycore/perf.c b/source/myport/posix/mycore/perf.c
deleted file mode 100644
index fcb8142..0000000
--- a/source/myport/posix/mycore/perf.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- Copyright (C) 2015-2017 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Authors: insoreiges@gmail.com (Evgeny Yakovlev), lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-/**
- * Platform-specific hdef performance clock value.
- */
-
-#include "mycore/myosi.h"
-#include <time.h>
-
-#if !defined(IS_OS_WINDOWS)
-#include <unistd.h>
-#endif
-
-#if !defined(MyCORE_WITH_PERF)
-
-uint64_t mycore_hperf_res(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF;
-
- return 0;
-}
-
-uint64_t mycore_hperf_clock(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF;
-
- return 0;
-}
-
-#else
-
-#if defined(__APPLE__)
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#elif defined(IS_OS_WINDOWS)
-#endif
-
-#if defined(MyCORE_FORCE_RDTSC) /* Force using rdtsc, useful for comparison */
-
-/**
- * Get CPU rdtsc frequency.
- *
- * TODO: I think using rdtsc for measuring user-space counters is not correct:
- * - rdtsc does not have a constant rate. instead ot is scaled to physical core's internal clock which changes due to power saving modes on modern CPUs
- * - rdtsc is software-emulated in virtual machines which will introduce an inconsistency in reported ticks
- * - user space process can be preempted between consecutive rdtsc measures but the physical clock will still tick while it is executing a different thread.
- * also think what would happen if preempted process will be re-scheduled on a different physical core which has a different tsc value.
- * - computing rdtsc frequency produces unreliable results (due to all of the above)
- *
- * Consider using platform-specific monotonic hperf timers (ftrace/dtrace) or even clock().
- */
-uint64_t mycore_hperf_res(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_OK;
-
-#if defined(__APPLE__) && defined(CTL_HW) && defined(HW_CPU_FREQ)
- unsigned long long freq = 0;
-
- /* OSX kernel: sysctl(CTL_HW | HW_CPU_FREQ) */
- size_t len = sizeof(freq);
- int mib[2] = {CTL_HW, HW_CPU_FREQ};
-
- int error = sysctl(mib, 2, &freq, &len, NULL, 0);
- if (error) {
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- return freq;
-
-#elif defined(__linux__)
- unsigned long long freq = 0;
-
- /* Use procfs on linux */
- FILE* fp = NULL;
- fp = fopen("/proc/cpuinfo", "r");
- if (fp == NULL) {
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- /* Find 'CPU MHz :' */
- char buf[1024] = {0};
- double fval = 0.0;
- while (fgets(buf, sizeof(buf), fp) != NULL) {
- if (sscanf(buf, "cpu MHz : %lf\n", &fval) == 1) {
- freq = (unsigned long long)(fval * 1000000ull);
- break;
- }
- }
-
- fclose(fp);
- return freq;
-
-#else
-# warning Cant figure out cpu frequency on this platfrom
-
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
-#endif /* defined __APPLE__ || __linux__ ... */
-}
-
-uint64_t mycore_hperf_clock(mystatus_t *status)
-{
- uint64_t x;
-
- __asm__ volatile (
- "cpuid\n\t" /* cpuid serializes any out-of-order prefetches before executing rdtsc (clobbers ebx, ecx, edx) */
- "rdtsc\n\t"
- "shl $32, %%rdx\n\t"
- "or %%rdx, %%rax"
- : "=a" (x)
- :
- : "rdx", "ebx", "ecx");
-
- return x;
-}
-
-#elif defined(_POSIX_TIMERS) && defined(_POSIX_CPUTIME) \
- && defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 199309L) /* Do we have clock_gettime? */
-
-#define NSEC_PER_SECOND 1000000000ull
-#define TIMESPEC_TO_USEC(tspec) (((uint64_t)(tspec).tv_sec * NSEC_PER_SECOND) + (tspec).tv_nsec)
-
-uint64_t mycore_hperf_res(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_OK;
-
- struct timespec tspec;
- int error = clock_getres(CLOCK_PROCESS_CPUTIME_ID, &tspec);
- if (error) {
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- unsigned long long ticks_per_sec = (unsigned long long)((double)NSEC_PER_SECOND / TIMESPEC_TO_USEC(tspec));
- return ticks_per_sec;
-}
-
-uint64_t mycore_hperf_clock(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_OK;
-
- struct timespec tspec;
- int error = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tspec);
- if (error) {
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- return TIMESPEC_TO_USEC(tspec);
-}
-
-#elif defined(__APPLE__) && defined(__MACH__)
-
-/*
- * TODO: on OSX we can use clock_get_time: http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x
- * Or this: http://web.archive.org/web/20100517095152/http://www.wand.net.nz/~smr26/wordpress/2009/01/19/monotonic-time-in-mac-os-x/comment-page-1/
- */
-
-// TODO: this is incorrect plug for mac os x
-// look at links before this comment
-
-#include <mach/mach_time.h>
-
-uint64_t mycore_hperf_res(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_OK;
-
- unsigned long long freq = 0;
-
- size_t len = sizeof(freq);
- int mib[2] = {CTL_HW, HW_CPU_FREQ};
-
- int error = sysctl(mib, 2, &freq, &len, NULL, 0);
- if (error) {
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- return freq;
-}
-
-uint64_t mycore_hperf_clock(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_OK;
-
- return mach_absolute_time();
-}
-
-#else
-
-# warning No hperf implementation for this platform
-
-uint64_t mycore_hperf_res(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
-}
-
-uint64_t mycore_hperf_clock(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
-}
-
-#endif /* defined(MyCORE_FORCE_RDTSC) ... */
-#endif /* MyCORE_WITH_PERF */
-
-#define _MyCORE_CHECK_STATUS_AND_PRINT_ERROR \
- if(status == MyCORE_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF) { \
- mycore_fprintf(fh, "MyCORE: Library compiled without perf source. Please, build library with -DMyCORE_WITH_PERF flag\n"); \
- } \
- else if(status) { \
- mycore_fprintf(fh, "MyCORE: Something wrong! Perhaps, your platform does not support the measurement of performance\n"); \
- } \
- else
-
-mystatus_t mycore_hperf_print(const char *name, uint64_t x, uint64_t y, FILE *fh) {
- mystatus_t status;
-
- unsigned long long freq = mycore_hperf_res(&status);
-
- if(freq) {
- _MyCORE_CHECK_STATUS_AND_PRINT_ERROR {
- mycore_fprintf(fh, "%s: %0.5f\n", name, (((float)(y - x) / (float)freq)));
- }
- }
-
- return status;
-}
-
-mystatus_t mycore_hperf_print_by_val(const char *name, uint64_t x, FILE *fh) {
- mystatus_t status;
-
- unsigned long long freq = mycore_hperf_res(&status);
-
- if(freq) {
- _MyCORE_CHECK_STATUS_AND_PRINT_ERROR {
- mycore_fprintf(fh, "%s: %0.5f\n", name, ((float)x / (float)freq));
- }
- }
-
- return status;
-}
-
-
diff --git a/source/myport/windows_nt/mycore/io.c b/source/myport/windows_nt/mycore/io.c
index 2a6a4e0..9dac45c 100644
--- a/source/myport/windows_nt/mycore/io.c
+++ b/source/myport/windows_nt/mycore/io.c
@@ -21,36 +21,6 @@
#include "mycore/myosi.h"
#include <stdarg.h>
-int mycore_printf(const char* format, ...)
-{
- va_list argptr;
- va_start(argptr, format);
- int res = vprintf(format, argptr);
- va_end(argptr);
-
- return res;
-}
-
-int mycore_fprintf(FILE* out, const char* format, ...)
-{
- va_list argptr;
- va_start(argptr, format);
- int res = vfprintf(out, format, argptr);
- va_end(argptr);
-
- return res;
-}
-
-int mycore_snprintf(char* buffer, size_t buffer_size, const char* format, ...)
-{
- va_list argptr;
- va_start(argptr, format);
- int res = vsnprintf(buffer, buffer_size, format, argptr);
- va_end(argptr);
-
- return res;
-}
-
/* FILE */
FILE * mycore_fopen(const char *restrict filename, const char *restrict mode)
{
diff --git a/source/myport/windows_nt/mycore/memory.c b/source/myport/windows_nt/mycore/memory.c
index ecdcf8c..4cfd1e0 100644
--- a/source/myport/windows_nt/mycore/memory.c
+++ b/source/myport/windows_nt/mycore/memory.c
@@ -35,7 +35,8 @@ void * mycore_calloc(size_t num, size_t size)
return calloc(num, size);
}
-void mycore_free(void* dst)
+void * mycore_free(void* dst)
{
free(dst);
+ return NULL;
}
diff --git a/source/myport/windows_nt/mycore/perf.c b/source/myport/windows_nt/mycore/perf.c
deleted file mode 100644
index 38c397b..0000000
--- a/source/myport/windows_nt/mycore/perf.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- Copyright (C) 2015-2017 Alexander Borisov
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Authors: insoreiges@gmail.com (Evgeny Yakovlev), lex.borisov@gmail.com (Alexander Borisov)
-*/
-
-/**
- * Platform-specific hdef performance clock value.
- */
-
-#include "mycore/myosi.h"
-#include <time.h>
-
-#if !defined(IS_OS_WINDOWS)
-#include <unistd.h>
-#endif
-
-#if !defined(MyCORE_WITH_PERF)
-
-uint64_t mycore_hperf_res(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF;
-
- return 0;
-}
-
-uint64_t mycore_hperf_clock(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF;
-
- return 0;
-}
-
-#else
-
-#if defined(__APPLE__)
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#elif defined(IS_OS_WINDOWS)
-#endif
-
-#if defined(MyCORE_FORCE_RDTSC) /* Force using rdtsc, useful for comparison */
-
-/**
- * Get CPU rdtsc frequency.
- *
- * TODO: I think using rdtsc for measuring user-space counters is not correct:
- * - rdtsc does not have a constant rate. instead ot is scaled to physical core's internal clock which changes due to power saving modes on modern CPUs
- * - rdtsc is software-emulated in virtual machines which will introduce an inconsistency in reported ticks
- * - user space process can be preempted between consecutive rdtsc measures but the physical clock will still tick while it is executing a different thread.
- * also think what would happen if preempted process will be re-scheduled on a different physical core which has a different tsc value.
- * - computing rdtsc frequency produces unreliable results (due to all of the above)
- *
- * Consider using platform-specific monotonic hperf timers (ftrace/dtrace) or even clock().
- */
-uint64_t mycore_hperf_res(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_OK;
-
-#if defined(__APPLE__) && defined(CTL_HW) && defined(HW_CPU_FREQ)
- unsigned long long freq = 0;
-
- /* OSX kernel: sysctl(CTL_HW | HW_CPU_FREQ) */
- size_t len = sizeof(freq);
- int mib[2] = {CTL_HW, HW_CPU_FREQ};
-
- int error = sysctl(mib, 2, &freq, &len, NULL, 0);
- if (error) {
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- return freq;
-
-#elif defined(__linux__)
- unsigned long long freq = 0;
-
- /* Use procfs on linux */
- FILE* fp = NULL;
- fp = fopen("/proc/cpuinfo", "r");
- if (fp == NULL) {
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- /* Find 'CPU MHz :' */
- char buf[1024] = {0};
- double fval = 0.0;
- while (fgets(buf, sizeof(buf), fp) != NULL) {
- if (sscanf(buf, "cpu MHz : %lf\n", &fval) == 1) {
- freq = (unsigned long long)(fval * 1000000ull);
- break;
- }
- }
-
- fclose(fp);
- return freq;
-
-#else
-# warning Cant figure out cpu frequency on this platfrom
-
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
-#endif /* defined __APPLE__ || __linux__ ... */
-}
-
-uint64_t mycore_hperf_clock(mystatus_t *status)
-{
- uint64_t x;
-
- __asm__ volatile (
- "cpuid\n\t" /* cpuid serializes any out-of-order prefetches before executing rdtsc (clobbers ebx, ecx, edx) */
- "rdtsc\n\t"
- "shl $32, %%rdx\n\t"
- "or %%rdx, %%rax"
- : "=a" (x)
- :
- : "rdx", "ebx", "ecx");
-
- return x;
-}
-
-#elif defined(_POSIX_TIMERS) && defined(_POSIX_CPUTIME) \
- && defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 199309L) /* Do we have clock_gettime? */
-
-#define NSEC_PER_SECOND 1000000000ull
-#define TIMESPEC_TO_USEC(tspec) (((uint64_t)(tspec).tv_sec * NSEC_PER_SECOND) + (tspec).tv_nsec)
-
-uint64_t mycore_hperf_res(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_OK;
-
- struct timespec tspec;
- int error = clock_getres(CLOCK_PROCESS_CPUTIME_ID, &tspec);
- if (error) {
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- unsigned long long ticks_per_sec = (unsigned long long)((double)NSEC_PER_SECOND / TIMESPEC_TO_USEC(tspec));
- return ticks_per_sec;
-}
-
-uint64_t mycore_hperf_clock(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_OK;
-
- struct timespec tspec;
- int error = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tspec);
- if (error) {
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- return TIMESPEC_TO_USEC(tspec);
-}
-
-#elif defined(__APPLE__) && defined(__MACH__)
-
-/*
- * TODO: on OSX we can use clock_get_time: http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x
- * Or this: http://web.archive.org/web/20100517095152/http://www.wand.net.nz/~smr26/wordpress/2009/01/19/monotonic-time-in-mac-os-x/comment-page-1/
- */
-
-// TODO: this is incorrect plug for mac os x
-// look at links before this comment
-
-#include <mach/mach_time.h>
-
-uint64_t mycore_hperf_res(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_OK;
-
- unsigned long long freq = 0;
-
- size_t len = sizeof(freq);
- int mib[2] = {CTL_HW, HW_CPU_FREQ};
-
- int error = sysctl(mib, 2, &freq, &len, NULL, 0);
- if (error) {
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
- }
-
- return freq;
-}
-
-uint64_t mycore_hperf_clock(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_OK;
-
- return mach_absolute_time();
-}
-
-#else
-
-# warning No hperf implementation for this platform
-
-uint64_t mycore_hperf_res(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
-}
-
-uint64_t mycore_hperf_clock(mystatus_t *status)
-{
- if(status)
- *status = MyCORE_STATUS_PERF_ERROR_FIND_CPU_CLOCK;
-
- return 0;
-}
-
-#endif /* defined(MyCORE_FORCE_RDTSC) ... */
-#endif /* MyCORE_WITH_PERF */
-
-#define _MyCORE_CHECK_STATUS_AND_PRINT_ERROR \
- if(status == MyCORE_STATUS_PERF_ERROR_COMPILED_WITHOUT_PERF) { \
- fprintf(fh, "MyCORE: Library compiled without perf source. Please, build library with -DMyCORE_WITH_PERF flag\n"); \
- } \
- else if(status) { \
- fprintf(fh, "MyCORE: Something wrong! Perhaps, your platform does not support the measurement of performance\n"); \
- } \
- else
-
-mystatus_t mycore_hperf_print(const char *name, uint64_t x, uint64_t y, FILE *fh) {
- mystatus_t status;
-
- unsigned long long freq = mycore_hperf_res(&status);
-
- if(freq) {
- _MyCORE_CHECK_STATUS_AND_PRINT_ERROR {
- fprintf(fh, "%s: %0.5f\n", name, (((float)(y - x) / (float)freq)));
- }
- }
-
- return status;
-}
-
-mystatus_t mycore_hperf_print_by_val(const char *name, uint64_t x, FILE *fh) {
- mystatus_t status;
-
- unsigned long long freq = mycore_hperf_res(&status);
-
- if(freq) {
- _MyCORE_CHECK_STATUS_AND_PRINT_ERROR {
- fprintf(fh, "%s: %0.5f\n", name, ((float)x / (float)freq));
- }
- }
-
- return status;
-}
-
-