Skip to content

Commit 848587e

Browse files
author
kolban
committed
Thu Jan 19 21:51:14 CST 2017
1 parent a4db3b1 commit 848587e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+9268
-0
lines changed

c-utils/c_timeutils.c

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* c_timeutils.c
3+
*
4+
* Created on: Nov 26, 2016
5+
* Author: kolban
6+
*/
7+
#include <sys/time.h>
8+
#include <stdint.h>
9+
#include <stdio.h>
10+
11+
/**
12+
* Add a number of milliseconds to a timeval and replace the
13+
* existing timeval with the new value.
14+
*/
15+
void timeval_addMsecs(struct timeval *a, uint32_t msecs) {
16+
int uSecs = (msecs%1000) * 1000 + a->tv_usec;
17+
a->tv_usec = uSecs % 1000000;
18+
a->tv_sec += msecs/1000 + uSecs/1000000;
19+
} // addMsecs
20+
21+
/**
22+
* Convert a timeval into the number of msecs.
23+
*/
24+
uint32_t timeval_toMsecs(struct timeval *a) {
25+
return a->tv_sec * 1000 + a->tv_usec/1000;
26+
} // timeval_toMsecs
27+
28+
29+
/**
30+
* Subtract one timeval from another.
31+
*/
32+
struct timeval timeval_sub(struct timeval *a, struct timeval *b) {
33+
struct timeval result;
34+
result.tv_sec = a->tv_sec - b->tv_sec;
35+
result.tv_usec = a->tv_usec - b->tv_usec;
36+
if (a->tv_usec < b->tv_usec) {
37+
result.tv_sec -= 1;
38+
result.tv_usec += 1000000;
39+
}
40+
return result;
41+
} // timeval_sub
42+
43+
44+
/*
45+
* Add one timeval to another.
46+
*/
47+
struct timeval timeval_add(struct timeval *a, struct timeval *b) {
48+
struct timeval result;
49+
result.tv_sec = a->tv_sec + b->tv_sec;
50+
result.tv_usec = a->tv_usec + b->tv_usec;
51+
if (result.tv_usec >= 1000000) {
52+
result.tv_sec += 1;
53+
result.tv_usec -= 1000000;
54+
}
55+
return result;
56+
} // timeval_add
57+
58+
/**
59+
* Return the number of milliseconds until future time value.
60+
*/
61+
uint32_t timeval_durationFromNow(struct timeval *a) {
62+
struct timeval b;
63+
gettimeofday(&b, NULL);
64+
struct timeval delta = timeval_sub(a, &b);
65+
if (delta.tv_sec < 0) {
66+
return 0;
67+
}
68+
return timeval_toMsecs(&delta);
69+
// assuming that a is later than b, then the result is a-b
70+
} // timeval_durationFromNow
71+
72+
/**
73+
* Return the number of milliseconds the historic time value was before now.
74+
*/
75+
uint32_t timeval_durationBeforeNow(struct timeval *a) {
76+
struct timeval b;
77+
gettimeofday(&b, NULL);
78+
struct timeval delta = timeval_sub(&b, a);
79+
if (delta.tv_sec < 0) {
80+
return 0;
81+
}
82+
return timeval_toMsecs(&delta);
83+
} // timeval_durationBeforeNow

c-utils/c_timeutils.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* c_timeutils.h
3+
*
4+
* Created on: Nov 26, 2016
5+
* Author: kolban
6+
*/
7+
8+
#if !defined(_C_TIMEUTILS_H_)
9+
#define _C_TIMEUTILS_H_
10+
#include <sys/time.h>
11+
#include <stdint.h>
12+
13+
struct timeval timeval_add(struct timeval *a, struct timeval *b);
14+
void timeval_addMsecs(struct timeval *a, uint32_t msecs);
15+
uint32_t timeval_durationBeforeNow(struct timeval *a);
16+
uint32_t timeval_durationFromNow(struct timeval *a);
17+
struct timeval timeval_sub(struct timeval *a, struct timeval *b);
18+
uint32_t timeval_toMsecs(struct timeval *a);
19+
20+
#endif /* _C_TIMEUTILS_H_ */

networking/mqtt/paho_mqtt_embedded_c/.cproject

Lines changed: 184 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>embedded-C</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
10+
<triggers>clean,full,incremental,</triggers>
11+
<arguments>
12+
</arguments>
13+
</buildCommand>
14+
<buildCommand>
15+
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
16+
<triggers>full,incremental,</triggers>
17+
<arguments>
18+
</arguments>
19+
</buildCommand>
20+
</buildSpec>
21+
<natures>
22+
<nature>org.eclipse.cdt.core.cnature</nature>
23+
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
24+
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
25+
</natures>
26+
</projectDescription>
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation=16
3+
org.eclipse.cdt.core.formatter.alignment_for_assignment=16
4+
org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration=80
5+
org.eclipse.cdt.core.formatter.alignment_for_binary_expression=16
6+
org.eclipse.cdt.core.formatter.alignment_for_compact_if=16
7+
org.eclipse.cdt.core.formatter.alignment_for_conditional_expression=34
8+
org.eclipse.cdt.core.formatter.alignment_for_conditional_expression_chain=18
9+
org.eclipse.cdt.core.formatter.alignment_for_constructor_initializer_list=0
10+
org.eclipse.cdt.core.formatter.alignment_for_declarator_list=16
11+
org.eclipse.cdt.core.formatter.alignment_for_enumerator_list=48
12+
org.eclipse.cdt.core.formatter.alignment_for_expression_list=0
13+
org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer=16
14+
org.eclipse.cdt.core.formatter.alignment_for_member_access=0
15+
org.eclipse.cdt.core.formatter.alignment_for_overloaded_left_shift_chain=16
16+
org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration=16
17+
org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
18+
org.eclipse.cdt.core.formatter.brace_position_for_array_initializer=next_line
19+
org.eclipse.cdt.core.formatter.brace_position_for_block=next_line
20+
org.eclipse.cdt.core.formatter.brace_position_for_block_in_case=next_line
21+
org.eclipse.cdt.core.formatter.brace_position_for_method_declaration=next_line
22+
org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration=next_line
23+
org.eclipse.cdt.core.formatter.brace_position_for_switch=next_line
24+
org.eclipse.cdt.core.formatter.brace_position_for_type_declaration=next_line
25+
org.eclipse.cdt.core.formatter.comment.min_distance_between_code_and_line_comment=1
26+
org.eclipse.cdt.core.formatter.comment.never_indent_line_comments_on_first_column=true
27+
org.eclipse.cdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true
28+
org.eclipse.cdt.core.formatter.compact_else_if=true
29+
org.eclipse.cdt.core.formatter.continuation_indentation=2
30+
org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer=2
31+
org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line=false
32+
org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=false
33+
org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces=0
34+
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier=true
35+
org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header=false
36+
org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases=true
37+
org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header=false
38+
org.eclipse.cdt.core.formatter.indent_empty_lines=false
39+
org.eclipse.cdt.core.formatter.indent_statements_compare_to_block=true
40+
org.eclipse.cdt.core.formatter.indent_statements_compare_to_body=true
41+
org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases=true
42+
org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch=false
43+
org.eclipse.cdt.core.formatter.indentation.size=4
44+
org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
45+
org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration=do not insert
46+
org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
47+
org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
48+
org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
49+
org.eclipse.cdt.core.formatter.insert_new_line_before_colon_in_constructor_initializer_list=do not insert
50+
org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
51+
org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert
52+
org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
53+
org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block=insert
54+
org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator=insert
55+
org.eclipse.cdt.core.formatter.insert_space_after_binary_operator=insert
56+
org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments=insert
57+
org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters=insert
58+
org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block=insert
59+
org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
60+
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause=insert
61+
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case=insert
62+
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional=insert
63+
org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
64+
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
65+
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types=insert
66+
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list=insert
67+
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
68+
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list=insert
69+
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
70+
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
71+
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
72+
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments=insert
73+
org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters=insert
74+
org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments=do not insert
75+
org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters=do not insert
76+
org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
77+
org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket=do not insert
78+
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
79+
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
80+
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification=do not insert
81+
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
82+
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
83+
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
84+
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
85+
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
86+
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
87+
org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
88+
org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator=do not insert
89+
org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator=do not insert
90+
org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional=insert
91+
org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for=insert
92+
org.eclipse.cdt.core.formatter.insert_space_after_unary_operator=do not insert
93+
org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator=insert
94+
org.eclipse.cdt.core.formatter.insert_space_before_binary_operator=insert
95+
org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments=do not insert
96+
org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters=do not insert
97+
org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
98+
org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket=do not insert
99+
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
100+
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
101+
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification=do not insert
102+
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
103+
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
104+
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
105+
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
106+
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
107+
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
108+
org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
109+
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause=do not insert
110+
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case=do not insert
111+
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional=insert
112+
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default=do not insert
113+
org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
114+
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
115+
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types=do not insert
116+
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list=do not insert
117+
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
118+
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list=do not insert
119+
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
120+
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
121+
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
122+
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments=do not insert
123+
org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters=do not insert
124+
org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments=do not insert
125+
org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters=do not insert
126+
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
127+
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block=insert
128+
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
129+
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration=insert
130+
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
131+
org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
132+
org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket=do not insert
133+
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
134+
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification=insert
135+
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for=insert
136+
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if=insert
137+
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
138+
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
139+
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
140+
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
141+
org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while=insert
142+
org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator=do not insert
143+
org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator=do not insert
144+
org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional=insert
145+
org.eclipse.cdt.core.formatter.insert_space_before_semicolon=do not insert
146+
org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
147+
org.eclipse.cdt.core.formatter.insert_space_before_unary_operator=do not insert
148+
org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
149+
org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets=do not insert
150+
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification=do not insert
151+
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
152+
org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
153+
org.eclipse.cdt.core.formatter.join_wrapped_lines=true
154+
org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line=false
155+
org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line=false
156+
org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line=false
157+
org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line=false
158+
org.eclipse.cdt.core.formatter.lineSplit=80
159+
org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve=1
160+
org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line=true
161+
org.eclipse.cdt.core.formatter.tabulation.char=tab
162+
org.eclipse.cdt.core.formatter.tabulation.size=4
163+
org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations=false
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
eclipse.preferences.version=1
2+
formatter_profile=org.eclipse.cdt.ui.default.allman_profile
3+
formatter_settings_version=1

0 commit comments

Comments
 (0)