Skip to content

Commit 2d0c60e

Browse files
authored
Merge pull request #340 from aflaischer/master
Add extern C and explicit cast in msleep function
2 parents 12ab515 + e22ee46 commit 2d0c60e

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

sdk/userspace/include/fpga_mgmt.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#include <hal/fpga_common.h>
2121
#include <fpga_pci.h>
2222

23+
#ifdef __cplusplus
24+
extern "C" {
25+
#endif
26+
2327
/**
2428
* Initialize the fpga_mgmt library.
2529
* Calls fpga_pci_init.
@@ -158,3 +162,7 @@ int fpga_mgmt_set_vDIP(int slot_id, uint16_t value);
158162
* @returns 0 on success, non-zero on error
159163
*/
160164
int fpga_mgmt_get_vDIP_status(int slot_id, uint16_t *value);
165+
166+
#ifdef __cplusplus
167+
}
168+
#endif

sdk/userspace/include/fpga_pci.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
#include <hal/fpga_common.h>
2121

22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif
25+
2226
/**
2327
* FPGA_PCI_BARS_MAX:
2428
* -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);
203207
*/
204208
int fpga_pci_get_address(pci_bar_handle_t handle, uint64_t offset,
205209
uint64_t dword_len, void **ptr);
210+
211+
#ifdef __cplusplus
212+
}
213+
#endif

sdk/userspace/include/utils/io.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#include <stdbool.h>
2424
#include <sys/types.h>
2525

26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
2630
/**
2731
* Set up epoll.
2832
*
@@ -200,3 +204,7 @@ int string_to_uint(unsigned int *num, const char *str);
200204
* @returns How many files are open in a given process, -1 on error.
201205
*/
202206
int number_of_open_files(pid_t pid);
207+
208+
#ifdef __cplusplus
209+
}
210+
#endif

sdk/userspace/include/utils/lcd.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
/** PCI device format string */
3232
#define PCI_DEV_FMT "%04x:%02x:%02x.%d"
3333

34+
#ifdef __cplusplus
35+
extern "C" {
36+
#endif
37+
3438
/**
3539
* Sleep for some milliseconds.
3640
*
@@ -42,9 +46,13 @@
4246
static inline int msleep(uint64_t ms)
4347
{
4448
struct timespec sleep_time = {
45-
.tv_sec = ms / MS_PER_SECOND,
46-
.tv_nsec = (ms % MS_PER_SECOND) * NS_PER_MS
49+
.tv_sec = (time_t)(ms / MS_PER_SECOND),
50+
.tv_nsec = (long)((ms % MS_PER_SECOND) * NS_PER_MS)
4751
};
4852

4953
return clock_nanosleep(CLOCK_MONOTONIC, 0, &sleep_time, NULL);
5054
}
55+
56+
#ifdef __cplusplus
57+
}
58+
#endif

sdk/userspace/include/utils/log.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ enum {
4040
LOGGER_FLAGS_SERIALIZE = (1u << 0),
4141
};
4242

43+
#ifdef __cplusplus
44+
extern "C" {
45+
#endif
46+
4347
/** Logger. */
4448
struct logger {
4549
/** Name (for debugging). */
@@ -174,3 +178,7 @@ static inline __printf(1, 2) void log_dummy(const char *fmt, ...)
174178
extern const struct logger logger_stdout;
175179
extern const struct logger logger_kmsg;
176180
extern const struct logger *logger_default;
181+
182+
#ifdef __cplusplus
183+
}
184+
#endif

0 commit comments

Comments
 (0)