From: Dave Thaler Date: Fri, 27 May 2016 01:06:41 +0000 (-0700) Subject: VS 2013 changes for csdk X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=81955e9c075c87e751a24e9187c0fd6dcde4e864;p=contrib%2Fiotivity.git VS 2013 changes for csdk Change-Id: Ib4c437c96c80327eb80e259d4f937696afbe1002 Signed-off-by: Dave Thaler Reviewed-on: https://gerrit.iotivity.org/gerrit/8361 Reviewed-by: David Antler Tested-by: jenkins-iotivity --- diff --git a/resource/c_common/platform_features.h b/resource/c_common/platform_features.h index e2289d4..762d26e 100644 --- a/resource/c_common/platform_features.h +++ b/resource/c_common/platform_features.h @@ -50,7 +50,7 @@ # if defined(__cplusplus) # define INLINE_API inline # else -# ifdef _WIN32 +# ifdef _MSC_VER # define INLINE_API static __inline # else # define INLINE_API static inline diff --git a/resource/c_common/windows/include/vs12_snprintf.h b/resource/c_common/windows/include/vs12_snprintf.h index 6595b95..37f1d3f 100644 --- a/resource/c_common/windows/include/vs12_snprintf.h +++ b/resource/c_common/windows/include/vs12_snprintf.h @@ -24,6 +24,8 @@ extern "C" { #endif +#include + int vs12_snprintf(char *buffer, size_t count, const char *format, ...); #if defined(_MSC_VER) && (_MSC_VER < 1900) diff --git a/resource/c_common/windows/include/win_sleep.h b/resource/c_common/windows/include/win_sleep.h index c9b8fd7..8cd1479 100644 --- a/resource/c_common/windows/include/win_sleep.h +++ b/resource/c_common/windows/include/win_sleep.h @@ -26,6 +26,14 @@ extern "C" { #endif +#if defined(_MSC_VER) && (_MSC_VER < 1900) +struct timespec +{ + time_t tv_sec; // Seconds - >= 0 + long tv_nsec; // Nanoseconds - [0, 999999999] +}; +#endif + int nanosleep(const struct timespec *req, struct timespec *rem); int usleep(unsigned int usec); diff --git a/resource/csdk/connectivity/common/src/camutex_pthreads.c b/resource/csdk/connectivity/common/src/camutex_pthreads.c index 564a354..aa77eb0 100644 --- a/resource/csdk/connectivity/common/src/camutex_pthreads.c +++ b/resource/csdk/connectivity/common/src/camutex_pthreads.c @@ -58,6 +58,7 @@ #include #include #include +#include "platform_features.h" #include "camutex.h" #include "logger.h" diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/address.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/address.h index 37e8235..c26784c 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/address.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/address.h @@ -99,7 +99,7 @@ typedef struct coap_address_t }addr; }coap_address_t; -static inline int +INLINE_API int _coap_address_equals_impl(const coap_address_t *a, const coap_address_t *b) { @@ -124,7 +124,7 @@ _coap_address_equals_impl(const coap_address_t *a, return 0; } -static inline int +INLINE_API int _coap_is_mcast_impl(const coap_address_t *a) { if (!a) @@ -151,7 +151,7 @@ typedef struct coap_address_t uint8_t addr[DEV_ADDR_SIZE_MAX]; /**< device address. */ } coap_address_t; -static inline int +INLINE_API int _coap_address_equals_impl(const coap_address_t *a, const coap_address_t *b) { @@ -171,7 +171,7 @@ _coap_address_equals_impl(const coap_address_t *a, return 1; } -static inline int +INLINE_API int _coap_is_mcast_impl(const coap_address_t *a) { if (!a) @@ -190,7 +190,7 @@ _coap_is_mcast_impl(const coap_address_t *a) * * @param addr The coap_address_t object to initialize. */ -static inline void coap_address_init(coap_address_t *addr) +INLINE_API void coap_address_init(coap_address_t *addr) { assert(addr); memset(addr, 0, sizeof(coap_address_t)); @@ -205,7 +205,7 @@ static inline void coap_address_init(coap_address_t *addr) * @c 1 if addresses are equal, @c 0 otherwise. The parameters @p a * and @p b must not be @c NULL; */ -static inline int coap_address_equals(const coap_address_t *a, const coap_address_t *b) +INLINE_API int coap_address_equals(const coap_address_t *a, const coap_address_t *b) { assert(a); assert(b); @@ -216,7 +216,7 @@ static inline int coap_address_equals(const coap_address_t *a, const coap_addres * Checks if given address @p a denotes a multicast address. This * function returns @c 1 if @p a is multicast, @c 0 otherwise. */ -static inline int coap_is_mcast(const coap_address_t *a) +INLINE_API int coap_is_mcast(const coap_address_t *a) { return a && _coap_is_mcast_impl(a); } diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/async.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/async.h index 879cb38..0319827 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/async.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/async.h @@ -136,7 +136,7 @@ coap_async_state_t *coap_find_async(coap_context_t *context, coap_tid_t id); * * @param s The state object to update. */ -static inline void coap_touch_async(coap_async_state_t *s) +INLINE_API void coap_touch_async(coap_async_state_t *s) { coap_ticks(&s->created); } diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/bits.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/bits.h index 9add64f..3ac7fe1 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/bits.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/bits.h @@ -31,7 +31,7 @@ * * @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise. */ -inline static int bits_setb(uint8_t *vec, size_t size, uint8_t bit) +INLINE_API int bits_setb(uint8_t *vec, size_t size, uint8_t bit) { if (size <= (size_t)(bit >> 3)) return -1; @@ -51,7 +51,7 @@ inline static int bits_setb(uint8_t *vec, size_t size, uint8_t bit) * * @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise. */ -inline static int bits_clrb(uint8_t *vec, size_t size, uint8_t bit) +INLINE_API int bits_clrb(uint8_t *vec, size_t size, uint8_t bit) { if (size <= (size_t)(bit >> 3)) return -1; @@ -70,7 +70,7 @@ inline static int bits_clrb(uint8_t *vec, size_t size, uint8_t bit) * * @return @c 1 if the bit is set, @c 0 otherwise. */ -inline static int bits_getb(const uint8_t *vec, size_t size, uint8_t bit) +INLINE_API int bits_getb(const uint8_t *vec, size_t size, uint8_t bit) { if (size <= (size_t)(bit >> 3)) return -1; diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/block.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/block.h index 2d5ef07..bd660ef 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/block.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/block.h @@ -71,13 +71,13 @@ unsigned int coap_opt_block_num(const coap_opt_t *block_opt); * Checks if more than @p num blocks are required to deliver @p data_len * bytes of data for a block size of 1 << (@p szx + 4). */ -static inline int coap_more_blocks(size_t data_len, unsigned int num, unsigned short szx) +INLINE_API int coap_more_blocks(size_t data_len, unsigned int num, unsigned short szx) { return ((num + 1) << (szx + 4)) < data_len; } /** Sets the More-bit in @p block_opt */ -static inline void coap_opt_block_set_m(coap_opt_t *block_opt, int m) +INLINE_API void coap_opt_block_set_m(coap_opt_t *block_opt, int m) { if (m) *(COAP_OPT_VALUE(block_opt) + (COAP_OPT_LENGTH(block_opt) - 1)) |= 0x08; diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/coap_time.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/coap_time.h index b2c70e4..64d1b26 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/coap_time.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/coap_time.h @@ -47,12 +47,12 @@ extern "C" typedef uint32_t coap_tick_t; - static inline void coap_ticks_impl(coap_tick_t *t) + INLINE_API void coap_ticks_impl(coap_tick_t *t) { *t = sys_now(); } - static inline void coap_clock_init_impl(void) + INLINE_API void coap_clock_init_impl(void) { } @@ -78,7 +78,7 @@ extern "C" /** Set at startup to initialize the internal clock (time in seconds). */ extern clock_time_t clock_offset; - static inline void + INLINE_API void contiki_clock_init_impl(void) { clock_init(); @@ -87,7 +87,7 @@ extern "C" #define coap_clock_init contiki_clock_init_impl - static inline void + INLINE_API void contiki_ticks_impl(coap_tick_t *t) { *t = clock_time(); @@ -137,7 +137,7 @@ extern time_t clock_offset; #endif /* WITH_ARDUINO */ #ifndef coap_clock_init - static inline void coap_clock_init_impl(void) + INLINE_API void coap_clock_init_impl(void) { #ifdef HAVE_TIME_H clock_offset = time(NULL); @@ -162,7 +162,7 @@ extern time_t clock_offset; #endif /* coap_clock_init */ #ifndef coap_ticks - static inline void coap_ticks_impl(coap_tick_t *t) + INLINE_API void coap_ticks_impl(coap_tick_t *t) { #ifdef HAVE_SYS_TIME_H struct timeval tv; @@ -195,7 +195,7 @@ extern time_t clock_offset; * Returns @c 1 if and only if @p a is less than @p b where less is * defined on a signed data type. */ - static inline + INLINE_API int coap_time_lt(coap_tick_t a, coap_tick_t b) { return ((coap_tick_diff_t)(a - b)) < 0; @@ -205,7 +205,7 @@ extern time_t clock_offset; * Returns @c 1 if and only if @p a is less than or equal @p b where * less is defined on a signed data type. */ - static inline + INLINE_API int coap_time_le(coap_tick_t a, coap_tick_t b) { return a == b || coap_time_lt(a, b); diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/config.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/config.h index 1f3bc9b..622e795 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/config.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/config.h @@ -132,6 +132,18 @@ # endif #endif +#ifndef INLINE_API +# if defined(__cplusplus) +# define INLINE_API inline +# else +# ifdef _MSC_VER +# define INLINE_API static __inline +# else +# define INLINE_API static inline +# endif +# endif +#endif + /* Define to rpl_malloc if the replacement function should be used. */ /* #undef malloc */ diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/debug.c b/resource/csdk/connectivity/lib/libcoap-4.1.1/debug.c index 0169ae8..589e1c3 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/debug.c +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/debug.c @@ -53,7 +53,7 @@ static char *loglevels[] = #ifdef HAVE_TIME_H -static inline size_t print_timestamp(char *s, size_t len, coap_tick_t t) +INLINE_API size_t print_timestamp(char *s, size_t len, coap_tick_t t) { struct tm *tmp; time_t now = clock_offset + (t / COAP_TICKS_PER_SECOND); @@ -63,7 +63,7 @@ static inline size_t print_timestamp(char *s, size_t len, coap_tick_t t) #else /* alternative implementation: just print the timestamp */ -static inline size_t +INLINE_API size_t print_timestamp(char *s, size_t len, coap_tick_t t) { #ifdef HAVE_SNPRINTF @@ -89,7 +89,7 @@ print_timestamp(char *s, size_t len, coap_tick_t t) * * @return The length of @p s. */ -static inline size_t +INLINE_API size_t strnlen(const char *s, size_t maxlen) { size_t n = 0; diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/net.c b/resource/csdk/connectivity/lib/libcoap-4.1.1/net.c index 8e6f3b6..48e0455 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/net.c +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/net.c @@ -60,13 +60,13 @@ time_t clock_offset=0; -static inline coap_queue_t * +INLINE_API coap_queue_t * coap_malloc_node() { return (coap_queue_t *)coap_malloc(sizeof(coap_queue_t)); } -static inline void +INLINE_API void coap_free_node(coap_queue_t *node) { coap_free(node); @@ -79,13 +79,13 @@ coap_free_node(coap_queue_t *node) static void coap_retransmittimer_execute(void *arg); static void coap_retransmittimer_restart(coap_context_t *ctx); -static inline coap_queue_t * +INLINE_API coap_queue_t * coap_malloc_node() { return (coap_queue_t *)memp_malloc(MEMP_COAP_NODE); } -static inline void +INLINE_API void coap_free_node(coap_queue_t *node) { memp_free(MEMP_COAP_NODE, node); @@ -115,13 +115,13 @@ MEMB(node_storage, coap_queue_t, COAP_PDU_MAXCNT); PROCESS(coap_retransmit_process, "message retransmit process"); -static inline coap_queue_t * +INLINE_API coap_queue_t * coap_malloc_node() { return (coap_queue_t *)memb_alloc(&node_storage); } -static inline void +INLINE_API void coap_free_node(coap_queue_t *node) { memb_free(&node_storage, node); @@ -888,7 +888,7 @@ coap_tid_t coap_retransmit(coap_context_t *context, coap_queue_t *node) * This function returns @c 1 on success, or @c 0 if the option @p opt * would exceed @p maxpos. */ -static inline int check_opt_size(coap_opt_t *opt, unsigned char *maxpos) +INLINE_API int check_opt_size(coap_opt_t *opt, unsigned char *maxpos) { if (opt && opt < maxpos) { @@ -1076,7 +1076,7 @@ int coap_remove_from_queue(coap_queue_t **queue, coap_tid_t id, coap_queue_t **n } -static inline int token_match(const unsigned char *a, size_t alen, const unsigned char *b, +INLINE_API int token_match(const unsigned char *a, size_t alen, const unsigned char *b, size_t blen) { return alen == blen && (alen == 0 || memcmp(a, b, alen) == 0); @@ -1238,7 +1238,7 @@ coap_new_error_response(coap_pdu_t *request, unsigned char code, coap_opt_filter * Quick hack to determine the size of the resource description for * .well-known/core. */ -static inline size_t get_wkc_len(coap_context_t *context, coap_opt_t *query_filter) +INLINE_API size_t get_wkc_len(coap_context_t *context, coap_opt_t *query_filter) { unsigned char buf[1]; size_t len = 0; @@ -1513,7 +1513,7 @@ void handle_request(coap_context_t *context, coap_queue_t *node, const char* res } } -static inline void handle_response(coap_context_t *context, coap_queue_t *sent, coap_queue_t *rcvd) +INLINE_API void handle_response(coap_context_t *context, coap_queue_t *sent, coap_queue_t *rcvd) { /* Call application-specific reponse handler when available. If @@ -1531,7 +1531,7 @@ static inline void handle_response(coap_context_t *context, coap_queue_t *sent, } } -static inline int +INLINE_API int #ifdef __GNUC__ handle_locally(coap_context_t *context __attribute__ ((unused)), coap_queue_t *node __attribute__ ((unused))) diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/net.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/net.h index d2868b5..bd86b19 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/net.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/net.h @@ -155,7 +155,7 @@ extern "C" * @param context The context to register the handler for. * @param handler The response handler to register. */ - static inline void coap_register_response_handler(coap_context_t *context, + INLINE_API void coap_register_response_handler(coap_context_t *context, coap_response_handler_t handler) { context->response_handler = handler; @@ -168,7 +168,7 @@ extern "C" * @param ctx The context to use. * @param type The option type to register. */ - inline static void coap_register_option(coap_context_t *ctx, unsigned char type) + INLINE_API void coap_register_option(coap_context_t *ctx, unsigned char type) { coap_option_setb(ctx->known_options, type); } @@ -197,7 +197,7 @@ extern "C" * @param context the current coap_context_t object * @return incremented message id in network byte order */ -static inline unsigned short coap_new_message_id(coap_context_t *context) +INLINE_API unsigned short coap_new_message_id(coap_context_t *context) { ++(context->message_id); #if defined(WITH_ARDUINO) @@ -317,7 +317,7 @@ static inline unsigned short coap_new_message_id(coap_context_t *context) * @return The transaction id if RST was sent or @c COAP_INVALID_TID * on error. */ - static inline coap_tid_t coap_send_rst(coap_context_t *context, const coap_address_t *dst, + INLINE_API coap_tid_t coap_send_rst(coap_context_t *context, const coap_address_t *dst, coap_pdu_t *request) { return coap_send_message_type(context, dst, request, COAP_MESSAGE_RST); @@ -372,7 +372,7 @@ static inline unsigned short coap_new_message_id(coap_context_t *context) * * @return @c 1 if node was found, removed and destroyed, @c 0 otherwise. */ - inline static int coap_remove_transaction(coap_queue_t **queue, coap_tid_t id) + INLINE_API int coap_remove_transaction(coap_queue_t **queue, coap_tid_t id) { coap_queue_t *node; if (!coap_remove_from_queue(queue, id, &node)) diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/option.c b/resource/csdk/connectivity/lib/libcoap-4.1.1/option.c index ea60aab..60bb865 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/option.c +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/option.c @@ -208,7 +208,7 @@ coap_option_iterator_init(coap_pdu_t *pdu, coap_opt_iterator_t *oi, return oi; } -static inline int opt_finished(coap_opt_iterator_t *oi) +INLINE_API int opt_finished(coap_opt_iterator_t *oi) { assert(oi); diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/option.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/option.h index 9c33ac8..8441d5a 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/option.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/option.h @@ -112,7 +112,7 @@ typedef unsigned char coap_opt_filter_t[(COAP_MAX_OPT >> 3) + 1]; * * @param f The filter to clear. */ -static inline void coap_option_filter_clear(coap_opt_filter_t f) +INLINE_API void coap_option_filter_clear(coap_opt_filter_t f) { memset(f, 0, sizeof(coap_opt_filter_t)); } @@ -127,7 +127,7 @@ static inline void coap_option_filter_clear(coap_opt_filter_t f) * * @return @c 1 if bit was set, @c -1 otherwise. */ -inline static int coap_option_setb(coap_opt_filter_t filter, unsigned short type) +INLINE_API int coap_option_setb(coap_opt_filter_t filter, unsigned short type) { return bits_setb((uint8_t *) filter, sizeof(coap_opt_filter_t), type); } @@ -142,7 +142,7 @@ inline static int coap_option_setb(coap_opt_filter_t filter, unsigned short type * * @return @c 1 if bit was set, @c -1 otherwise. */ -inline static int coap_option_clrb(coap_opt_filter_t filter, unsigned short type) +INLINE_API int coap_option_clrb(coap_opt_filter_t filter, unsigned short type) { return bits_clrb((uint8_t *) filter, sizeof(coap_opt_filter_t), type); } @@ -157,7 +157,7 @@ inline static int coap_option_clrb(coap_opt_filter_t filter, unsigned short type * * @return @c 1 if bit was set, @c 0 if not, @c -1 on error. */ -inline static int coap_option_getb(const coap_opt_filter_t filter, unsigned short type) +INLINE_API int coap_option_getb(const coap_opt_filter_t filter, unsigned short type) { return bits_getb((uint8_t *) filter, sizeof(coap_opt_filter_t), type); } diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/prng.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/prng.h index 25e7720..8e2b85b 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/prng.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/prng.h @@ -29,7 +29,7 @@ * implementation for prng(). You might want to change prng() to use * a better PRNG on your specific platform. */ -static inline int coap_prng_impl(unsigned char *buf, size_t len) +INLINE_API int coap_prng_impl(unsigned char *buf, size_t len) { while (len--) *buf++ = rand() & 0xFF; @@ -43,7 +43,7 @@ static inline int coap_prng_impl(unsigned char *buf, size_t len) * implementation for prng(). You might want to change prng() to use * a better PRNG on your specific platform. */ -static inline int +INLINE_API int contiki_prng_impl(unsigned char *buf, size_t len) { unsigned short v = random_rand(); diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/resource.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/resource.h index 9382615..2349be1 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/resource.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/resource.h @@ -220,7 +220,7 @@ coap_print_status_t coap_print_link(const coap_resource_t *resource, unsigned ch * @param method The CoAP request method to handle. * @param handler The handler to register with @p resource. */ -static inline void coap_register_handler(coap_resource_t *resource, unsigned char method, +INLINE_API void coap_register_handler(coap_resource_t *resource, unsigned char method, coap_method_handler_t handler) { assert(resource); diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/t_list.h b/resource/csdk/connectivity/lib/libcoap-4.1.1/t_list.h index 5f25f96..60fb972 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/t_list.h +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/t_list.h @@ -91,30 +91,30 @@ struct list (struct_ptr)->LIST_CONCAT(name,_list) = NULL; \ } -static inline void * +INLINE_API void * list_head(list_t the_list) { return *the_list; } -static inline void list_remove(list_t the_list, void *item) +INLINE_API void list_remove(list_t the_list, void *item) { if (list_head(the_list)) LL_DELETE(*(struct list **)the_list, (struct list *)item); } -static inline void list_add(list_t the_list, void *item) +INLINE_API void list_add(list_t the_list, void *item) { list_remove(the_list, item); LL_APPEND(*(struct list **)the_list, (struct list *)item); } -static inline void list_push(list_t the_list, void *item) +INLINE_API void list_push(list_t the_list, void *item) { LL_PREPEND(*(struct list **)the_list, (struct list *)item); } -static inline void * +INLINE_API void * list_pop(list_t the_list) { struct list *l; @@ -125,7 +125,7 @@ list_pop(list_t the_list) return l; } -static inline void list_insert(list_t the_list, void *previtem, void *newitem) +INLINE_API void list_insert(list_t the_list, void *previtem, void *newitem) { if (previtem == NULL) { @@ -138,7 +138,7 @@ static inline void list_insert(list_t the_list, void *previtem, void *newitem) } } -static inline void * +INLINE_API void * list_item_next(void *item) { return item == NULL ? NULL : ((struct list *) item)->next; diff --git a/resource/csdk/connectivity/lib/libcoap-4.1.1/uri.c b/resource/csdk/connectivity/lib/libcoap-4.1.1/uri.c index 42dab60..d496e72 100644 --- a/resource/csdk/connectivity/lib/libcoap-4.1.1/uri.c +++ b/resource/csdk/connectivity/lib/libcoap-4.1.1/uri.c @@ -32,7 +32,7 @@ * @return A pointer to the first occurence of @p c, or @c NULL * if not found. */ -static inline unsigned char * +INLINE_API unsigned char * strnchr(unsigned char *s, size_t len, unsigned char c) { while (len && *s++ != c) @@ -493,7 +493,7 @@ coap_clone_uri(const coap_uri_t *uri) /* The function signature of coap_hash() is different from * segment_handler_t hence we use this wrapper as safe typecast. */ -static inline void hash_segment(unsigned char *s, size_t len, void *data) +INLINE_API void hash_segment(unsigned char *s, size_t len, void *data) { coap_hash(s, len, (unsigned char *) data); } diff --git a/resource/csdk/security/src/directpairing.c b/resource/csdk/security/src/directpairing.c index 68eb118..b22ca5b 100644 --- a/resource/csdk/security/src/directpairing.c +++ b/resource/csdk/security/src/directpairing.c @@ -956,9 +956,6 @@ OCStackResult DPDeviceDiscovery(unsigned short waittime) } OCStackResult ret; - struct timespec startTime = {.tv_sec=0, .tv_nsec=0}; - struct timespec currTime = {.tv_sec=0, .tv_nsec=0}; - struct timespec timeout; const char DP_DISCOVERY_QUERY[] = "/oic/sec/pconf"; @@ -979,13 +976,17 @@ OCStackResult DPDeviceDiscovery(unsigned short waittime) } // wait.. - timeout.tv_sec = 0; - timeout.tv_nsec = 100000000L; int clock_res = -1; +#if defined(_MSC_VER) + time_t startTime; + clock_res = (time(&startTime) == -1); +#else + struct timespec startTime = {.tv_sec=0, .tv_nsec=0}; #if defined(__ANDROID__) || _POSIX_TIMERS > 0 clock_res = clock_gettime(CLOCK_MONOTONIC, &startTime); #endif +#endif if (0 != clock_res) { OIC_LOG(ERROR, TAG, "clock error"); @@ -998,31 +999,38 @@ OCStackResult DPDeviceDiscovery(unsigned short waittime) while (1) { +#if defined(_MSC_VER) + time_t currTime; + clock_res = (time(&currTime) == -1); +#else + struct timespec currTime = {.tv_sec=0, .tv_nsec=0}; #if defined(__ANDROID__) || _POSIX_TIMERS > 0 clock_res = clock_gettime(CLOCK_MONOTONIC, &currTime); #endif +#endif if (0 != clock_res) { OIC_LOG(ERROR, TAG, "clock error"); ret = OC_STACK_ERROR; break; } +#if defined(_MSC_VER) + long elapsed = currTime - startTime; +#else long elapsed = (currTime.tv_sec - startTime.tv_sec); +#endif if (elapsed > waittime) { break; } else { -#if defined(_WIN32) - Sleep(100); -#else + struct timespec timeout = {.tv_sec=0, .tv_nsec=100000000L}; nanosleep(&timeout, NULL); -#endif // defined (_WIN32) } } - //Waiting for each response. + // Waiting for each response. ret = OCCancel(handle, OC_LOW_QOS, NULL, 0); if (OC_STACK_OK != ret) { diff --git a/resource/examples/winuiclientgui.cpp b/resource/examples/winuiclientgui.cpp index c8273a8..596bb4e 100644 --- a/resource/examples/winuiclientgui.cpp +++ b/resource/examples/winuiclientgui.cpp @@ -171,15 +171,17 @@ WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) } break; case WM_CREATE: - hIcon1 = LoadIcon (NULL, IDI_WARNING); - SendMessage(icon_button,BM_SETIMAGE,IMAGE_ICON,(LPARAM)hIcon1); - GetClientRect(hwnd, &rect); - g_BkgndBrush = GetSysColorBrush(COLOR_MENU); - - app = new WinUIClient::WinUIClientApp({client_open, fread, fwrite, fclose, unlink }); - app->Initialize(); - app->Run(); - + { + hIcon1 = LoadIcon (NULL, IDI_WARNING); + SendMessage(icon_button,BM_SETIMAGE,IMAGE_ICON,(LPARAM)hIcon1); + GetClientRect(hwnd, &rect); + g_BkgndBrush = GetSysColorBrush(COLOR_MENU); + + OCPersistentStorage ps = {client_open, fread, fwrite, fclose, unlink }; + app = new WinUIClient::WinUIClientApp(ps); + app->Initialize(); + app->Run(); + } break; case WM_DESTROY: diff --git a/resource/src/OCResource.cpp b/resource/src/OCResource.cpp index 49a9703..b381b9f 100644 --- a/resource/src/OCResource.cpp +++ b/resource/src/OCResource.cpp @@ -75,15 +75,15 @@ OCResource::OCResource(std::weak_ptr clientWrapper, const std::vector& interfaces) : m_clientWrapper(clientWrapper), m_uri(uri), m_resourceId(serverId, m_uri), - m_devAddr{ OC_DEFAULT_ADAPTER, OC_DEFAULT_FLAGS, 0, {0}, 0 -#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP) - , {0} -#endif - }, m_isObservable(observable), m_isCollection(false), m_resourceTypes(resourceTypes), m_interfaces(interfaces), m_observeHandle(nullptr) { + m_devAddr = OCDevAddr{OC_DEFAULT_ADAPTER, OC_DEFAULT_FLAGS, 0, {0}, 0, +#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP) + {0} +#endif + }; m_isCollection = std::find(m_interfaces.begin(), m_interfaces.end(), LINK_INTERFACE) != m_interfaces.end(); @@ -464,7 +464,7 @@ OCStackResult OCResource::cancelObserve(QualityOfService QoS) OCStackResult result = checked_guard(m_clientWrapper.lock(), &IClientWrapper::CancelObserveResource, - m_observeHandle, "", m_uri, m_headerOptions, QoS); + m_observeHandle, (const char*)"", m_uri, m_headerOptions, QoS); if(result == OC_STACK_OK) {