diff --git a/lib/c/2014/Makefile b/lib/c/2014/Makefile index b18a9e469ed7c24e8c845138c5adb2db856ae180..6c7d812d0150c556e17b149b0e03e423cad811b9 100644 --- a/lib/c/2014/Makefile +++ b/lib/c/2014/Makefile @@ -102,7 +102,7 @@ endif # compilation rules %.pic.o: %.c - $(CC) -fPIC $(CFLAGS) -c -o $@ $< + $(CC) $(FPIC) $(CFLAGS) -c -o $@ $< %.o: %.c %.h $(CC) $(CFLAGS) -c -o $@ $< @@ -110,7 +110,7 @@ endif # rules invoked by 'test' .PHONY: run-test-% run-test-%: $(TEST_DIR)/gen/% | $(TEST_DIR)/gen - $(VALGRIND) $< + LD_LIBRARY_PATH=.. $(VALGRIND) $< .PRECIOUS: $(TEST_DIR)/gen/% diff --git a/lib/c/2014/labcomm2014.c b/lib/c/2014/labcomm2014.c index f599e78e81b6076823d75c4bad84899540842bbf..97b983ae9abd60a03d505a38b485718761158b9a 100644 --- a/lib/c/2014/labcomm2014.c +++ b/lib/c/2014/labcomm2014.c @@ -43,26 +43,28 @@ void *labcomm_void_instance = &labcomm_void_instance; -/* Unwrapping reader/writer functions */ -#define UNWRAP_ac(rw, ac, ...) ac -#define UNWRAP(func, ...) \ - while (1) { \ - if (UNWRAP_ac(__VA_ARGS__)->action->func) { \ - return UNWRAP_ac(__VA_ARGS__)->action->func(__VA_ARGS__); } \ - if (UNWRAP_ac(__VA_ARGS__)->next == NULL) { return -ENOSYS; } \ - UNWRAP_ac( __VA_ARGS__) = UNWRAP_ac(__VA_ARGS__)->next; \ - } - int labcomm2014_reader_alloc(struct labcomm2014_reader *r, struct labcomm2014_reader_action_context *action_context) { - UNWRAP(alloc, r, action_context); + while (1) { + if (action_context->action->alloc) + return action_context->action->alloc(r, action_context); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } int labcomm2014_reader_free(struct labcomm2014_reader *r, struct labcomm2014_reader_action_context *action_context) { - UNWRAP(free, r, action_context); + while (1) { + if (action_context->action->free) + return action_context->action->free(r, action_context); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } int labcomm2014_reader_start(struct labcomm2014_reader *r, @@ -71,19 +73,37 @@ int labcomm2014_reader_start(struct labcomm2014_reader *r, const struct labcomm2014_signature *signature, void *value) { - UNWRAP(start, r, action_context, local_index, remote_index, signature, value); + while (1) { + if (action_context->action->start) + return action_context->action->start(r, action_context, local_index, remote_index, signature, value); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } int labcomm2014_reader_end(struct labcomm2014_reader *r, struct labcomm2014_reader_action_context *action_context) { - UNWRAP(end, r, action_context); + while (1) { + if (action_context->action->end) + return action_context->action->end(r, action_context); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } int labcomm2014_reader_fill(struct labcomm2014_reader *r, struct labcomm2014_reader_action_context *action_context) { - UNWRAP(fill, r, action_context); + while (1) { + if (action_context->action->fill) + return action_context->action->fill(r, action_context); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } int labcomm2014_reader_ioctl(struct labcomm2014_reader *r, @@ -92,20 +112,37 @@ int labcomm2014_reader_ioctl(struct labcomm2014_reader *r, const struct labcomm2014_signature *signature, uint32_t ioctl_action, va_list args) { - UNWRAP(ioctl, r, action_context, - local_index, remote_index, signature, ioctl_action, args); + while (1) { + if (action_context->action->ioctl) + return action_context->action->ioctl(r, action_context, local_index, remote_index, signature, ioctl_action, args); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } int labcomm2014_writer_alloc(struct labcomm2014_writer *w, struct labcomm2014_writer_action_context *action_context) { - UNWRAP(alloc, w, action_context); + while (1) { + if (action_context->action->alloc) + return action_context->action->alloc(w, action_context); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } int labcomm2014_writer_free(struct labcomm2014_writer *w, struct labcomm2014_writer_action_context *action_context) { - UNWRAP(free, w, action_context); + while (1) { + if (action_context->action->free) + return action_context->action->free(w, action_context); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } int labcomm2014_writer_start(struct labcomm2014_writer *w, @@ -113,19 +150,37 @@ int labcomm2014_writer_start(struct labcomm2014_writer *w, int index, const struct labcomm2014_signature *signature, void *value) { - UNWRAP(start, w, action_context, index, signature, value); + while (1) { + if (action_context->action->start) + return action_context->action->start(w, action_context, index, signature, value); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } int labcomm2014_writer_end(struct labcomm2014_writer *w, struct labcomm2014_writer_action_context *action_context) { - UNWRAP(end, w, action_context); + while (1) { + if (action_context->action->end) + return action_context->action->end(w, action_context); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } int labcomm2014_writer_flush(struct labcomm2014_writer *w, struct labcomm2014_writer_action_context *action_context) { - UNWRAP(flush, w, action_context); + while (1) { + if (action_context->action->flush) + return action_context->action->flush(w, action_context); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } int labcomm2014_writer_ioctl(struct labcomm2014_writer *w, @@ -134,15 +189,15 @@ int labcomm2014_writer_ioctl(struct labcomm2014_writer *w, const struct labcomm2014_signature *signature, uint32_t ioctl_action, va_list args) { - UNWRAP(ioctl, w, action_context, index, signature, ioctl_action, args); + while (1) { + if (action_context->action->ioctl) + return action_context->action->ioctl(w, action_context, index, signature, ioctl_action, args); + if (action_context->next == NULL) + return -ENOSYS; + action_context = action_context->next; + } } -#undef UNWRAP -#undef UNWRAP_ac - - - - static const char *labcomm2014_error_string[] = { #define LABCOMM2014_ERROR(name, description) description , #include "labcomm2014_error.h" @@ -227,7 +282,7 @@ void *labcomm2014_signature_array_ref(struct labcomm2014_memory *memory, *data = labcomm2014_memory_alloc(memory, 0, n * size); if (*data) { memset(*data, 0, n * size); - memcpy(*data + (old_first - *first) * size, + memcpy((char *) *data + (old_first - *first) * size, old_data, (old_last - old_first) * size); } @@ -236,7 +291,7 @@ void *labcomm2014_signature_array_ref(struct labcomm2014_memory *memory, } if (*data) { // dump(*data, size, *first, *last); - return *data + (index - *first) * size; + return (char *) *data + (index - *first) * size; } else { return NULL; } diff --git a/lib/c/2014/labcomm2014.h b/lib/c/2014/labcomm2014.h index ca490ccb6a0b375fd0cdcfac3b6c6215a24b5488..e0d19f6b5e369325b32cbfe11ba1f759aee3a8ec 100644 --- a/lib/c/2014/labcomm2014.h +++ b/lib/c/2014/labcomm2014.h @@ -30,8 +30,8 @@ #else #include <stdint.h> #include <unistd.h> - #include <limits.h> #endif +#include <limits.h> #include "labcomm2014_error.h" #include "labcomm2014_scheduler.h" diff --git a/lib/c/2014/labcomm2014.vcxproj b/lib/c/2014/labcomm2014.vcxproj new file mode 100644 index 0000000000000000000000000000000000000000..6922d42b74778623839917d0edc0ab3a59318747 --- /dev/null +++ b/lib/c/2014/labcomm2014.vcxproj @@ -0,0 +1,105 @@ +<?xml version="1.0" encoding="us-ascii"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(TWINCATSDK)MsBuild\TwinCAT Common\*.targets" /> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|TwinCAT RT (x64)"> + <Configuration>Debug</Configuration> + <Platform>TwinCAT RT (x64)</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|TwinCAT RT (x64)"> + <Configuration>Release</Configuration> + <Platform>TwinCAT RT (x64)</Platform> + </ProjectConfiguration> + </ItemGroup> + <ItemGroup> + <ClInclude Include="labcomm2014_compat_tc31.h" /> + <ClInclude Include="labcomm2014.h" /> + <ClInclude Include="labcomm2014_default_error_handler.h" /> + <ClInclude Include="labcomm2014_default_memory.h" /> + <ClInclude Include="labcomm2014_default_scheduler.h" /> + <ClInclude Include="labcomm2014_dynamic_buffer_writer.h" /> + <ClInclude Include="labcomm2014_error.h" /> + <ClInclude Include="labcomm2014_fd_reader.h" /> + <ClInclude Include="labcomm2014_fd_writer.h" /> + <ClInclude Include="labcomm2014_ioctl.h" /> + <ClInclude Include="labcomm2014_private.h" /> + <ClInclude Include="labcomm2014_renaming.h" /> + <ClInclude Include="labcomm2014_renaming_decoder.h" /> + <ClInclude Include="labcomm2014_renaming_encoder.h" /> + <ClInclude Include="labcomm2014_renaming_private.h" /> + <ClInclude Include="labcomm2014_scheduler.h" /> + <ClInclude Include="labcomm2014_scheduler_private.h" /> + <ClInclude Include="labcomm2014_type_signature.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="labcomm2014.c" /> + <ClCompile Include="labcomm2014_decoder.c" /> + <ClCompile Include="labcomm2014_default_error_handler.c" /> + <ClCompile Include="labcomm2014_default_memory.c" /> + <ClCompile Include="labcomm2014_default_scheduler.c" /> + <ClCompile Include="labcomm2014_dynamic_buffer_writer.c" /> + <ClCompile Include="labcomm2014_encoder.c" /> + <ClCompile Include="labcomm2014_error.c" /> + <ClCompile Include="labcomm2014_fd_reader.c" /> + <ClCompile Include="labcomm2014_fd_writer.c" /> + <ClCompile Include="labcomm2014_memory.c" /> + <ClCompile Include="labcomm2014_renaming.c" /> + <ClCompile Include="labcomm2014_renaming_decoder.c" /> + <ClCompile Include="labcomm2014_renaming_encoder.c" /> + <ClCompile Include="labcomm2014_renaming_registry.c" /> + <ClCompile Include="labcomm2014_scheduler.c" /> + <ClCompile Include="labcomm2014_time.c" /> + <ClCompile Include="labcomm2014_type_signature.c" /> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{1841FE1E-1E6C-449E-882D-7F26F60384E8}</ProjectGuid> + <RootNamespace>labcomm2014</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|TwinCAT RT (x64)'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|TwinCAT RT (x64)'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|TwinCAT RT (x64)'" Label="Configuration" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|TwinCAT RT (x64)'" Label="Configuration" /> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|TwinCAT RT (x64)'" Label="PropertySheets" /> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|TwinCAT RT (x64)'" Label="PropertySheets" /> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.21006.1</_ProjectFileVersion> + <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|TwinCAT RT (x64)'">AllRules.ruleset</CodeAnalysisRuleSet> + <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|TwinCAT RT (x64)'" /> + <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|TwinCAT RT (x64)'" /> + <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|TwinCAT RT (x64)'">AllRules.ruleset</CodeAnalysisRuleSet> + <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|TwinCAT RT (x64)'" /> + <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|TwinCAT RT (x64)'" /> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|TwinCAT RT (x64)'"> + <PreBuildEvent> + <Command> + </Command> + </PreBuildEvent> + <ClCompile> + <PreprocessorDefinitions>LABCOMM_COMPAT="labcomm2014_compat_tc31.h";LABCOMM_NO_STDIO;USE_CRT_OWN_IMPL;_X64_;_AMD64_;_WIN64;_DEBUG;STD_CALL;CONDITION_HANDLING;WIN32_LEAN_AND_MEAN;RDRDBG;SRVDBG;DBG;_IDWBUILD;IS_R0;WINNT;DEBUG;_WDM_INCLUDED_;_WIN32_WINNT=_WIN32_WINNT_WINXP;NTDDI_VERSION=NTDDI_WINXPSP2;TC_VER=301;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|TwinCAT RT (x64)'"> + <PreBuildEvent> + <Command> + </Command> + </PreBuildEvent> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + </ClCompile> + </ItemDefinitionGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> \ No newline at end of file diff --git a/lib/c/2014/labcomm2014_compat_tc31.h b/lib/c/2014/labcomm2014_compat_tc31.h new file mode 100644 index 0000000000000000000000000000000000000000..7e22acf6b9a36f01dcaa15eef2a0c1dc0a53619a --- /dev/null +++ b/lib/c/2014/labcomm2014_compat_tc31.h @@ -0,0 +1,14 @@ +#ifndef LABCOMM_COMPAT_TC31 +#define LABCOMM_COMPAT_TC31 + +#include <stddef.h> + +#define ECONNRESET 101 +#define ENOTSUP 102 +#define EALREADY 103 + +#define inline __inline + +typedef unsigned __int32 uint32_t; + +#endif diff --git a/lib/c/2014/labcomm2014_decoder.c b/lib/c/2014/labcomm2014_decoder.c index e270afc4a464d1f3b4752d639165ddd75192bdc6..860628bad0204124ec4aff29dcfa5e2f0aeeb9ec 100644 --- a/lib/c/2014/labcomm2014_decoder.c +++ b/lib/c/2014/labcomm2014_decoder.c @@ -26,7 +26,7 @@ #include "labcomm2014_ioctl.h" #include "labcomm2014_dynamic_buffer_writer.h" -#ifdef DEBUG +#if defined(DEBUG) && !defined(LABCOMM_NO_STDIO) #define DEBUG_FPRINTF(str, ...) fprintf(str, ##__VA_ARGS__) #else #define DEBUG_FPRINTF(str, ...) diff --git a/lib/c/2014/labcomm2014_default_scheduler.c b/lib/c/2014/labcomm2014_default_scheduler.c index f1fd3d6b4155c6d9e0bf29c6375c26c4bc7241a6..04b9144ecede453c5164eeb4436357ce9d6950f4 100644 --- a/lib/c/2014/labcomm2014_default_scheduler.c +++ b/lib/c/2014/labcomm2014_default_scheduler.c @@ -90,20 +90,20 @@ static int scheduler_enqueue(struct labcomm2014_scheduler *s, } static const struct labcomm2014_scheduler_action scheduler_action = { - .free = scheduler_free, - .writer_lock = scheduler_writer_lock, - .writer_unlock = scheduler_writer_unlock, - .data_lock = scheduler_data_lock, - .data_unlock = scheduler_data_unlock, - .now = scheduler_now, - .sleep = scheduler_sleep, - .wakeup = scheduler_wakeup, - .enqueue = scheduler_enqueue + scheduler_free, + scheduler_writer_lock, + scheduler_writer_unlock, + scheduler_data_lock, + scheduler_data_unlock, + scheduler_now, + scheduler_sleep, + scheduler_wakeup, + scheduler_enqueue }; static struct labcomm2014_scheduler scheduler = { - .action = &scheduler_action, - .context = NULL + &scheduler_action, + NULL }; struct labcomm2014_scheduler *labcomm2014_default_scheduler = &scheduler; diff --git a/lib/c/2014/labcomm2014_dynamic_buffer_writer.c b/lib/c/2014/labcomm2014_dynamic_buffer_writer.c index c2098625eaa72e50dba1344e410df085a5c4228e..8609ce17641457550fd3f3a054f3a79228039a6e 100644 --- a/lib/c/2014/labcomm2014_dynamic_buffer_writer.c +++ b/lib/c/2014/labcomm2014_dynamic_buffer_writer.c @@ -123,12 +123,12 @@ static int dyn_ioctl(struct labcomm2014_writer *w, } static const struct labcomm2014_writer_action action = { - .alloc = dyn_alloc, - .free = dyn_free, - .start = dyn_start, - .end = dyn_end, - .flush = dyn_flush, - .ioctl = dyn_ioctl + dyn_alloc, + dyn_free, + dyn_start, + dyn_end, + dyn_flush, + dyn_ioctl }; const struct labcomm2014_writer_action *labcomm2014_dynamic_buffer_writer_action = &action; diff --git a/lib/c/2014/labcomm2014_fd_reader.c b/lib/c/2014/labcomm2014_fd_reader.c index ad2d22285e2b9b31b25e727fa40e9b33da6502c7..23d5ba547d2e6fd98679e6b3b7d27ebb5281009d 100644 --- a/lib/c/2014/labcomm2014_fd_reader.c +++ b/lib/c/2014/labcomm2014_fd_reader.c @@ -20,7 +20,6 @@ */ #include <errno.h> -#include <unistd.h> #include <stdlib.h> #include <string.h> #include "labcomm2014_private.h" diff --git a/lib/c/2014/labcomm2014_fd_writer.c b/lib/c/2014/labcomm2014_fd_writer.c index 42c9dbcc14eb765dbae6547000994a2c7c3c8153..0e4d00937ea7c51fa659fb758d9d8fc086e561bd 100644 --- a/lib/c/2014/labcomm2014_fd_writer.c +++ b/lib/c/2014/labcomm2014_fd_writer.c @@ -20,7 +20,6 @@ */ #include <errno.h> -#include <unistd.h> #include <string.h> #include <stdlib.h> #include <stdarg.h> diff --git a/lib/c/2014/labcomm2014_renaming.c b/lib/c/2014/labcomm2014_renaming.c index 332c63843c7ec2cb8841ed1fe76fe97207332e5d..fbdb851fde3814447ae3936a5f9cdf5c17ef51e0 100644 --- a/lib/c/2014/labcomm2014_renaming.c +++ b/lib/c/2014/labcomm2014_renaming.c @@ -29,7 +29,7 @@ char *labcomm2014_renaming_prefix(struct labcomm2014_memory *m, char *result, *prefix = context; int length; - length = strlen(name) + strlen(prefix) + 1; + length = (int) (strlen(name) + strlen(prefix) + 1); result = labcomm2014_memory_alloc(m, 0, length); if (result != NULL) { strcpy(result, prefix); diff --git a/lib/c/2014/labcomm2014_scheduler.c b/lib/c/2014/labcomm2014_scheduler.c index 40288207149d93efc11c5084433b04d374b26a0c..465398b118b7e6601b02a5791ea3ff8eb49aca79 100644 --- a/lib/c/2014/labcomm2014_scheduler.c +++ b/lib/c/2014/labcomm2014_scheduler.c @@ -22,56 +22,62 @@ #include <errno.h> #include "labcomm2014_scheduler_private.h" -#define SCHEDULER_scheduler(scheduler, ...) scheduler -#define SCHEDULER(func, ...) \ - if (SCHEDULER_scheduler(__VA_ARGS__) && \ - SCHEDULER_scheduler(__VA_ARGS__)->action->func) { \ - return SCHEDULER_scheduler(__VA_ARGS__)->action->func(__VA_ARGS__); \ - } \ - return -ENOSYS; - int labcomm2014_scheduler_free(struct labcomm2014_scheduler *s) { - SCHEDULER(free, s); + if (s && s->action->free) + return s->action->free(s); + return -ENOSYS; } int labcomm2014_scheduler_writer_lock(struct labcomm2014_scheduler *s) { - SCHEDULER(writer_lock, s); + if (s && s->action->writer_lock) + return s->action->writer_lock(s); + return -ENOSYS; } int labcomm2014_scheduler_writer_unlock(struct labcomm2014_scheduler *s) { - SCHEDULER(writer_unlock, s); + if (s && s->action->writer_unlock) + return s->action->writer_unlock(s); + return -ENOSYS; } int labcomm2014_scheduler_data_lock(struct labcomm2014_scheduler *s) { - SCHEDULER(data_lock, s); + if (s && s->action->data_lock) + return s->action->data_lock(s); + return -ENOSYS; } int labcomm2014_scheduler_data_unlock(struct labcomm2014_scheduler *s) { - SCHEDULER(data_unlock, s); + if (s && s->action->data_unlock) + return s->action->data_unlock(s); + return -ENOSYS; } struct labcomm2014_time *labcomm2014_scheduler_now(struct labcomm2014_scheduler *s) { if (s && s->action->now) { - return s->action->now(s); - } - return NULL; + return s->action->now(s); + } + return 0; } int labcomm2014_scheduler_sleep(struct labcomm2014_scheduler *s, struct labcomm2014_time *wakeup) { - SCHEDULER(sleep, s, wakeup); + if (s && s->action->sleep) + return s->action->sleep(s, wakeup); + return -ENOSYS; } int labcomm2014_scheduler_wakeup(struct labcomm2014_scheduler *s) { - SCHEDULER(wakeup, s); + if (s && s->action->wakeup) + return s->action->wakeup(s); + return -ENOSYS; } int labcomm2014_scheduler_enqueue(struct labcomm2014_scheduler *s, @@ -79,7 +85,7 @@ int labcomm2014_scheduler_enqueue(struct labcomm2014_scheduler *s, void (*func)(void *context), void *context) { - SCHEDULER(enqueue, s, delay, func, context); + if (s && s->action->enqueue) + return s->action->enqueue(s, delay, func, context); + return -ENOSYS; } - - diff --git a/lib/c/2014/labcomm2014_time.c b/lib/c/2014/labcomm2014_time.c index eb5e1f5e43ab2cf4c6e03739078b57d022267874..8805f90d2c50c2d2c67246ad30cc171ae52baa74 100644 --- a/lib/c/2014/labcomm2014_time.c +++ b/lib/c/2014/labcomm2014_time.c @@ -22,21 +22,17 @@ #include <errno.h> #include "labcomm2014_scheduler_private.h" -#define TIME_time(time, ...) time -#define TIME(func, ...) \ - if (TIME_time(__VA_ARGS__) && \ - TIME_time(__VA_ARGS__)->action->func) { \ - return TIME_time(__VA_ARGS__)->action->func(__VA_ARGS__); \ - } \ - return -ENOSYS; - int labcomm2014_time_free(struct labcomm2014_time *s) { - TIME(free, s); + if (s && s->action->free) + return s->action->free(s); + return -ENOSYS; } int labcomm2014_time_add_usec(struct labcomm2014_time *s, uint32_t usec) { - TIME(add_usec, s, usec); + if (s && s->action->add_usec) + return s->action->add_usec(s, usec); + return -ENOSYS; } diff --git a/lib/c/2014/labcomm2014_type_signature.c b/lib/c/2014/labcomm2014_type_signature.c index dce1836199fd47e30bf53f8f4766dd81cf3c7b43..b01c79c0096c3a7ad28dbd00b7faa0dc6c211f5f 100644 --- a/lib/c/2014/labcomm2014_type_signature.c +++ b/lib/c/2014/labcomm2014_type_signature.c @@ -2,6 +2,8 @@ #include <string.h> // for memcmp #include <stdio.h> // for debug printf +#define CMP_BUFLEN 512 + /* Dump signature bytes on stdout */ @@ -75,11 +77,10 @@ static labcomm2014_bool sig_dump_checked(struct labcomm2014_signature_data *sign labcomm2014_bool labcomm2014_signature_cmp( struct labcomm2014_signature_data *s1, struct labcomm2014_signature_data *s2) { - int buflen=512; - char buf1[buflen]; - int len1=buflen; - char buf2[buflen]; - int len2=buflen; + char buf1[CMP_BUFLEN]; + int len1=CMP_BUFLEN; + char buf2[CMP_BUFLEN]; + int len2=CMP_BUFLEN; labcomm2014_bool res1 = labcomm2014_signature_dump(s1, buf1, &len1); labcomm2014_bool res2 = labcomm2014_signature_dump(s2, buf2, &len2); if(res1 || res2) { diff --git a/lib/c/os_compat.mk b/lib/c/os_compat.mk index 505c7a2f930b639e22f140698b62cb1ab12d9a8a..12986eab94fa16fe46f6e3d1b85a67b75a002cd8 100644 --- a/lib/c/os_compat.mk +++ b/lib/c/os_compat.mk @@ -2,6 +2,7 @@ UNAME_S=$(shell uname -s) VERSION=2014 LIBVERSION=2014 +FPIC=-fPIC ifeq ($(UNAME_S),Linux) CC=$(CROSS_COMPILE)gcc @@ -29,6 +30,7 @@ else ifneq ($(findstring CYGWIN,$(UNAME_S)),) CC=$(CROSS_COMPILE)gcc LD=$(CROSS_COMPILE)ld CFLAGS=-std=c99 -g -Wall -Werror -O3 -I. + FPIC= LDFLAGS=-L.. LDLIBS=-llabcomm$(LIBVERSION) -lrt ALL_DEPS:=$(filter-out %.so.1, $(ALL_DEPS)) # No -fPIC supported in windows?