From baa90fc30b0bbc07c6a28aeaeecd43dffd68f146 Mon Sep 17 00:00:00 2001 From: Alain FLAISCHER Date: Wed, 24 May 2017 10:31:25 +0200 Subject: [PATCH 1/3] Add extern C to userspace lib header files --- sdk/userspace/include/fpga_mgmt.h | 8 ++++++++ sdk/userspace/include/fpga_pci.h | 8 ++++++++ sdk/userspace/include/utils/io.h | 8 ++++++++ sdk/userspace/include/utils/lcd.h | 8 ++++++++ sdk/userspace/include/utils/log.h | 8 ++++++++ 5 files changed, 40 insertions(+) diff --git a/sdk/userspace/include/fpga_mgmt.h b/sdk/userspace/include/fpga_mgmt.h index 57ad437c7..c2a66dd00 100644 --- a/sdk/userspace/include/fpga_mgmt.h +++ b/sdk/userspace/include/fpga_mgmt.h @@ -20,6 +20,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + /** * Initialize the fpga_mgmt library. * Calls fpga_pci_init. @@ -158,3 +162,7 @@ int fpga_mgmt_set_vDIP(int slot_id, uint16_t value); * @returns 0 on success, non-zero on error */ int fpga_mgmt_get_vDIP_status(int slot_id, uint16_t *value); + +#ifdef __cplusplus +} +#endif diff --git a/sdk/userspace/include/fpga_pci.h b/sdk/userspace/include/fpga_pci.h index b36b3260e..3541dff0a 100644 --- a/sdk/userspace/include/fpga_pci.h +++ b/sdk/userspace/include/fpga_pci.h @@ -19,6 +19,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /** * FPGA_PCI_BARS_MAX: * -compile time tunable via mkall_fpga_mgmt_tools.sh, with the below default. @@ -203,3 +207,7 @@ int fpga_pci_rescan_slot_app_pfs(int slot_id); */ int fpga_pci_get_address(pci_bar_handle_t handle, uint64_t offset, uint64_t dword_len, void **ptr); + +#ifdef __cplusplus +} +#endif diff --git a/sdk/userspace/include/utils/io.h b/sdk/userspace/include/utils/io.h index b1776f1cf..b029956b1 100644 --- a/sdk/userspace/include/utils/io.h +++ b/sdk/userspace/include/utils/io.h @@ -23,6 +23,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + /** * Set up epoll. * @@ -200,3 +204,7 @@ int string_to_uint(unsigned int *num, const char *str); * @returns How many files are open in a given process, -1 on error. */ int number_of_open_files(pid_t pid); + +#ifdef __cplusplus +} +#endif diff --git a/sdk/userspace/include/utils/lcd.h b/sdk/userspace/include/utils/lcd.h index 038928cfe..27ac03eed 100644 --- a/sdk/userspace/include/utils/lcd.h +++ b/sdk/userspace/include/utils/lcd.h @@ -31,6 +31,10 @@ /** PCI device format string */ #define PCI_DEV_FMT "%04x:%02x:%02x.%d" +#ifdef __cplusplus +extern "C" { +#endif + /** * Sleep for some milliseconds. * @@ -48,3 +52,7 @@ static inline int msleep(uint64_t ms) return clock_nanosleep(CLOCK_MONOTONIC, 0, &sleep_time, NULL); } + +#ifdef __cplusplus +} +#endif diff --git a/sdk/userspace/include/utils/log.h b/sdk/userspace/include/utils/log.h index 60cec19aa..09149785c 100644 --- a/sdk/userspace/include/utils/log.h +++ b/sdk/userspace/include/utils/log.h @@ -40,6 +40,10 @@ enum { LOGGER_FLAGS_SERIALIZE = (1u << 0), }; +#ifdef __cplusplus +extern "C" { +#endif + /** Logger. */ struct logger { /** Name (for debugging). */ @@ -174,3 +178,7 @@ static inline __printf(1, 2) void log_dummy(const char *fmt, ...) extern const struct logger logger_stdout; extern const struct logger logger_kmsg; extern const struct logger *logger_default; + +#ifdef __cplusplus +} +#endif From d317140d48767b868d02693987f2630a970f8eb5 Mon Sep 17 00:00:00 2001 From: Alain FLAISCHER Date: Wed, 24 May 2017 10:58:57 +0200 Subject: [PATCH 2/3] Add explicit long int conversion in msleep function --- sdk/userspace/include/utils/lcd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/userspace/include/utils/lcd.h b/sdk/userspace/include/utils/lcd.h index 27ac03eed..78bfd5214 100644 --- a/sdk/userspace/include/utils/lcd.h +++ b/sdk/userspace/include/utils/lcd.h @@ -46,8 +46,8 @@ extern "C" { static inline int msleep(uint64_t ms) { struct timespec sleep_time = { - .tv_sec = ms / MS_PER_SECOND, - .tv_nsec = (ms % MS_PER_SECOND) * NS_PER_MS + .tv_sec = (long int)(ms / MS_PER_SECOND), + .tv_nsec = (long int)((ms % MS_PER_SECOND) * NS_PER_MS) }; return clock_nanosleep(CLOCK_MONOTONIC, 0, &sleep_time, NULL); From e22ee4693dafe590a2d2047a8d63c6dc57bb80ed Mon Sep 17 00:00:00 2001 From: Alain FLAISCHER Date: Mon, 29 May 2017 14:16:29 +0200 Subject: [PATCH 3/3] Update sleep_time cast according to time.h definition --- sdk/userspace/include/utils/lcd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/userspace/include/utils/lcd.h b/sdk/userspace/include/utils/lcd.h index 78bfd5214..006c56248 100644 --- a/sdk/userspace/include/utils/lcd.h +++ b/sdk/userspace/include/utils/lcd.h @@ -46,8 +46,8 @@ extern "C" { static inline int msleep(uint64_t ms) { struct timespec sleep_time = { - .tv_sec = (long int)(ms / MS_PER_SECOND), - .tv_nsec = (long int)((ms % MS_PER_SECOND) * NS_PER_MS) + .tv_sec = (time_t)(ms / MS_PER_SECOND), + .tv_nsec = (long)((ms % MS_PER_SECOND) * NS_PER_MS) }; return clock_nanosleep(CLOCK_MONOTONIC, 0, &sleep_time, NULL);