Skip to content

Commit

Permalink
Support 32/64 bits build
Browse files Browse the repository at this point in the history
- Add SUPPORT_32BIT_IOCTL to CCFLAGS to support 32 bit ioctl system call
- This patch provides support of 32/64 bits build, whether using clang or gcc.
It enforces the type of returned parameters by changing macro to static
inline functions.
  • Loading branch information
zchokri committed Nov 24, 2016
1 parent cc8854f commit 4805efc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
8 changes: 5 additions & 3 deletions daemons/gptp/common/ieee1588.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,11 @@ class Timestamp {
#define INVALID_TIMESTAMP (Timestamp( 0xC0000000, 0, 0 )) /*!< Defines an invalid timestamp using a Timestamp instance and a fixed value*/
#define PDELAY_PENDING_TIMESTAMP (Timestamp( 0xC0000001, 0, 0 )) /*!< PDelay is pending timestamp */

#define TIMESTAMP_TO_NS(ts) (((static_cast<long long int>((ts).seconds_ms) \
<< sizeof((ts).seconds_ls)*8) + \
(ts).seconds_ls)*1000000000LL + (ts).nanoseconds) /*!< Converts timestamp value into nanoseconds value*/
static inline uint64_t TIMESTAMP_TO_NS(Timestamp &ts)
{
return (((static_cast<long long int>((ts).seconds_ms) << sizeof((ts).seconds_ls)*8) +
(ts).seconds_ls)*1000000000LL + (ts).nanoseconds) ; /*!< Converts timestamp value into nanoseconds value*/
}

/**
* @brief Swaps out byte-a-byte a 64 bit value
Expand Down
5 changes: 5 additions & 0 deletions daemons/gptp/common/ptptypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@

/**@file*/

#if defined(__clang__) && defined(__x86_64__)
// Clang/llvm has incompatible long double (fp128) for x86_64.
typedef double FrequencyRatio; /*!< Frequency Ratio */
#else
typedef long double FrequencyRatio; /*!< Frequency Ratio */
#endif

#define ETHER_ADDR_OCTETS 6 /*!< Number of octets in a link layer address*/
#define IP_ADDR_OCTETS 4 /*!< Number of octets in a ip address*/
Expand Down
3 changes: 2 additions & 1 deletion daemons/gptp/linux/shm_test/shm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ int main(int argc, char *argv[])
fprintf(stdout, "ml freq offset %Lf\n", ptpData->ml_freqoffset);
fprintf(stdout, "ls phoffset %ld\n", ptpData->ls_phoffset);
fprintf(stdout, "ls freq offset %Lf\n", ptpData->ls_freqoffset);
fprintf(stdout, "local time %lu\n", ptpData->local_time);
fprintf(stdout, "local time %llu\n", ptpData->local_time);
fprintf(stdout, "sync count %u\n", ptpData->sync_count);
fprintf(stdout, "pdelay count %u\n", ptpData->pdelay_count);
fprintf(stdout, "asCapable %s\n", ptpData->asCapable ? "True" : "False");
fprintf(stdout, "Port State %d\n", (int)ptpData->port_state);
fprintf(stdout, "process_id %d\n", (int)ptpData->process_id);

return 0;
}
Expand Down
5 changes: 5 additions & 0 deletions kmod/igb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ endif
# PTP is required for AVB support
CFLAGS_EXTRA += -DIGB_PTP

# Add 32 bit ioctl support
ifeq ($(32BIT_IOCTL_SUPPORT),y)
CFLAGS_EXTRA += -DSUPPORT_32BIT_IOCTL
endif

# Use IGB_PTP compile flag to enable IEEE-1588 PTP (documented in README)
ifeq ($(filter %IGB_PTP,$(CFLAGS_EXTRA)),-DIGB_PTP)
CFILES += igb_ptp.c
Expand Down
5 changes: 4 additions & 1 deletion lib/igb/igb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,10 @@ struct timespec timespec_addns(struct timespec *a, unsigned long addns)
return *a;
}

#define TS2NS(ts) (((ts).tv_sec*1000000000)+(ts).tv_nsec)
static inline u_int32_t TS2NS(struct timespec ts)
{
return (((ts).tv_sec*1000000000)+(ts).tv_nsec);
}

int igb_gettime(device_t *dev, clockid_t clk_id, u_int64_t *curtime,
struct timespec *system_time)
Expand Down

0 comments on commit 4805efc

Please sign in to comment.