diff options
author | Martin Burnicki <martin.burnicki@meinberg.de> | 2017-05-05 12:00:00 +0200 |
---|---|---|
committer | Martin Burnicki <martin.burnicki@meinberg.de> | 2017-05-05 12:00:00 +0200 |
commit | 077cacebb5b28795f51f2cb4ea6d1c20d33ab81a (patch) | |
tree | de8640d98df054678c561e3dd9004b18b6a9c06d | |
parent | 2e95ddd6c5bd57d495e4305d55efc0dc0f2ba658 (diff) | |
download | mbgtools-fbsd-077cacebb5b28795f51f2cb4ea6d1c20d33ab81a.tar.gz mbgtools-fbsd-077cacebb5b28795f51f2cb4ea6d1c20d33ab81a.zip |
Clean up buildmbgtools-fbsd-dev-2017-05-05
Fix some potential 'unused variable' errors.
Fix some warnings from clang.
Fix build for big endian targets.
-rwxr-xr-x | Makefile | 8 | ||||
-rwxr-xr-x | mbgclock/mbgclock_main.c | 16 | ||||
-rwxr-xr-x | mbglib/common/cfg_hlp.h | 98 | ||||
-rwxr-xr-x | mbglib/common/gpsdefs.h | 37 | ||||
-rwxr-xr-x | mbglib/common/lan_util.c | 17 | ||||
-rwxr-xr-x | mbglib/common/mbgdevio.c | 10 | ||||
-rwxr-xr-x | mbglib/common/pcpsdrvr.c | 14 |
7 files changed, 126 insertions, 74 deletions
@@ -1,13 +1,15 @@ ######################################################################### # -# $Id: Makefile 1.1.1.13 2016/08/10 13:46:22 martin TEST $ +# $Id: Makefile 1.1.1.14 2017/05/04 15:02:28 martin TEST $ # # Description: # Makefile for mbgtools which recurses into the subdirectories. # # ----------------------------------------------------------------------- # $Log: Makefile $ +# Revision 1.1.1.14 2017/05/04 15:02:28 martin +# Also test subdirs for BSDmakefile. # Revision 1.1.1.13 2016/08/10 13:46:22 martin # *** empty log message *** # Revision 1.1.1.12 2016/08/10 11:31:37 martin @@ -122,7 +124,7 @@ INFO=top 1st: .ifndef SUBDIRS -chk_subdir = $(shell test -f $(strip $(1))/Makefile && echo "$(1)" ) +chk_subdir = $(shell test -f $(strip $(1))/Makefile || test -f $(strip $(1))/BSDmakefile && echo "$(1)" ) .ifndef DONT_BUILD_LIBS SUBDIRS += $(SO_SUBDIRS) @@ -195,7 +197,7 @@ SUBDIRS += mbgclock .PHONY: all clean distclean install uninstall all clean distclean install uninstall: @for dir in $(SUBDIRS); do \ - if test -f $$dir/Makefile; then \ + if test -f $$dir/Makefile || test -f $$dir/BSDmakefile; then \ echo "Making $@ in $$dir"; \ /bin/sh -c "cd $$dir; $(MAKE) $@"; \ fi \ diff --git a/mbgclock/mbgclock_main.c b/mbgclock/mbgclock_main.c index b99da6c..cc09e42 100755 --- a/mbgclock/mbgclock_main.c +++ b/mbgclock/mbgclock_main.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgclock_main.c 1.1.1.14 2015/01/16 09:53:54 martin TEST $ + * $Id: mbgclock_main.c 1.1.1.15 2017/05/05 14:38:04 martin TEST $ * * Description: * Main file for for mbgclock driver to support Meinberg bus level @@ -14,6 +14,8 @@ * * ----------------------------------------------------------------------- * $Log: mbgclock_main.c $ + * Revision 1.1.1.15 2017/05/05 14:38:04 martin + * Fixed some potential 'unused variable' errors. * Revision 1.1.1.14 2015/01/16 09:53:54 martin * Use "struct thread" instead of obsolete "d_thread_t" type. * Reported by John Baldwin and George Neville-Neil (FreeBSD bug #196692). @@ -33,7 +35,7 @@ * Revision 1.1.1.5 2011/01/28 09:31:21 martin * Fixed debug/non-debug build. * Revision 1.1.1.4 2011/01/27 15:15:23 martin - * Loads and unloads properly. Calls pcps_start_device() which + * Loads and unloads properly. Calls pcps_start_device() which * properly reads some data from a card. * Revision 1.1.1.3 2011/01/26 16:37:18 martin * Ioctl support compiled in. @@ -48,6 +50,7 @@ #include <pcpsdrvr.h> #include <mbgddmsg.h> #include <mbgversion.h> +#include <mbgioctl.h> #include <sys/param.h> /* defines used in kernel.h */ #include <sys/module.h> @@ -74,10 +77,11 @@ #define MBG_DRVR_NAME "mbgclock" const char pcps_driver_name[] = MBG_DRVR_NAME; - -static MBG_DBG_DATA mbg_dbg_data; -static MBG_DBG_PORT mbg_dbg_port = 0x378 + 0; //##++ -static PCPS_IO_ADDR_MAPPED mbg_dbg_port_mapped; //##++ +#if USE_DEBUG_PORT + static MBG_DBG_DATA mbg_dbg_data; + static MBG_DBG_PORT mbg_dbg_port = 0x378 + 0; //##++ + static PCPS_IO_ADDR_MAPPED mbg_dbg_port_mapped; //##++ +#endif // defined( DEBUG ) static PCPS_DRVR_INFO drvr_info = { MBG_VERSION_CODE( MBG_MICRO_VERSION_CODE ), 0, MBG_DRVR_NAME " radio clock driver" }; diff --git a/mbglib/common/cfg_hlp.h b/mbglib/common/cfg_hlp.h index 1ea7397..870869c 100755 --- a/mbglib/common/cfg_hlp.h +++ b/mbglib/common/cfg_hlp.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: cfg_hlp.h 1.3.1.101 2017/04/25 15:41:20 martin TEST $ + * $Id: cfg_hlp.h 1.3.1.102 2017/05/04 15:05:10 martin TEST $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -19,6 +19,9 @@ * * ----------------------------------------------------------------------- * $Log: cfg_hlp.h $ + * Revision 1.3.1.102 2017/05/04 15:05:10 martin + * Exclude dfrac_sec_from_bin() from build for kernel targets + * which usually don't support floating point operations anyway. * Revision 1.3.1.101 2017/04/25 15:41:20 martin * Fixed build under FreeBSD. * Revision 1.3.1.100 2017/03/29 12:33:26 philipp @@ -967,9 +970,13 @@ MBG_TLV_UID mbg_tlv_create_id( void ) -// Depending on the target environment define a data type -// which can be used to convert binary fractions without -// range overflow. +/** + * @brief Data type used for intermediate results on 32 bit multiplications + * + * We need 64 bits for intermediate integer results to avoid a range overflow + * from 32 x 32 bit multiplications. On systems which don't support 64 bit types + * we use the "double" type as a workaround. + */ #if defined( MBG_TGT_MISSING_64_BIT_TYPES ) #define PCPS_HRT_FRAC_CONVERSION_TYPE double #else @@ -977,13 +984,14 @@ MBG_TLV_UID mbg_tlv_create_id( void ) #endif /** - * @brief Constant used to convert ::PCPS_TIME_STAMP::frac values + * @brief Constant used to convert e.g. ::PCPS_TIME_STAMP::frac values * * Max value of ::PCPS_TIME_STAMP::frac + 1, used for scaling */ #define PCPS_HRT_BIN_FRAC_SCALE ( (PCPS_HRT_FRAC_CONVERSION_TYPE) 4294967296.0 ) // == 0x100000000 + #ifndef PCPS_HRT_FRAC_SCALE /** * @brief Scale to be used to print ::PCPS_TIME_STAMP::frac values @@ -1008,6 +1016,20 @@ MBG_TLV_UID mbg_tlv_create_id( void ) #endif + +/** + * @brief Convert a 16 bit binary fraction to a scaled decimal + * + * @param[in] bin The binary fraction + * @param[in] scale The scale factor + * + * @return The calculated number + * + * @see ::dec_frac_to_bin_frac_16 + * @see ::dec_frac_to_bin_frac_32 + * @see ::bin_frac_32_to_dec_frac + * @see ::frac_sec_from_bin + */ static __mbg_inline uint32_t bin_frac_16_to_dec_frac( uint16_t bin, uint32_t scale ) { @@ -1017,6 +1039,19 @@ uint32_t bin_frac_16_to_dec_frac( uint16_t bin, uint32_t scale ) } // bin_frac_16_to_dec_frac + +/** + * @brief Convert a 32 bit binary fraction to a scaled decimal + * + * @param[in] bin The binary fraction + * @param[in] scale The scale factor + * + * @return The calculated number + * + * @see ::dec_frac_to_bin_frac_32 + * @see ::dec_frac_to_bin_frac_16 + * @see ::bin_frac_16_to_dec_frac + */ static __mbg_inline uint32_t bin_frac_32_to_dec_frac( uint32_t bin, uint32_t scale ) { @@ -1026,6 +1061,7 @@ uint32_t bin_frac_32_to_dec_frac( uint32_t bin, uint32_t scale ) } // bin_frac_32_to_dec_frac + #if !defined( MBG_TGT_MISSING_64_BIT_TYPES ) // On targets which don't provide 64 bit data types @@ -1053,37 +1089,36 @@ uint32_t dec_frac_to_bin_frac_32( uint32_t dec, uint32_t scale ) #endif -#define bin_frac_32_to_msec( _bin ) bin_frac_32_to_dec_frac( (_bin), 1000 ) -#define bin_frac_32_to_usec( _bin ) bin_frac_32_to_dec_frac( (_bin), 1000000 ) -#define bin_frac_32_to_nsec( _bin ) bin_frac_32_to_dec_frac( (_bin), 1000000000 ) -#define bin_frac_16_to_msec( _bin ) bin_frac_16_to_dec_frac( (_bin), 1000 ) -#define bin_frac_16_to_usec( _bin ) bin_frac_16_to_dec_frac( (_bin), 1000000 ) -#define bin_frac_16_to_nsec( _bin ) bin_frac_16_to_dec_frac( (_bin), 1000000000 ) +#define bin_frac_32_to_msec( _bin ) bin_frac_32_to_dec_frac( (_bin), 1000L ) +#define bin_frac_32_to_usec( _bin ) bin_frac_32_to_dec_frac( (_bin), 1000000L ) +#define bin_frac_32_to_nsec( _bin ) bin_frac_32_to_dec_frac( (_bin), 1000000000L ) +#define bin_frac_16_to_msec( _bin ) bin_frac_16_to_dec_frac( (_bin), 1000L ) +#define bin_frac_16_to_usec( _bin ) bin_frac_16_to_dec_frac( (_bin), 1000000L ) +#define bin_frac_16_to_nsec( _bin ) bin_frac_16_to_dec_frac( (_bin), 1000000000L ) -#define msec_to_bin_frac_32( _msec ) dec_frac_to_bin_frac_32( (_msec), 1000 ) -#define usec_to_bin_frac_32( _usec ) dec_frac_to_bin_frac_32( (_usec), 1000000 ) -#define nsec_to_bin_frac_32( _nsec ) dec_frac_to_bin_frac_32( (_nsec), 1000000000 ) -#define msec_to_bin_frac_16( _msec ) dec_frac_to_bin_frac_16( (_msec), 1000 ) -#define usec_to_bin_frac_16( _usec ) dec_frac_to_bin_frac_16( (_usec), 1000000 ) -#define nsec_to_bin_frac_16( _nsec ) dec_frac_to_bin_frac_16( (_nsec), 1000000000 ) + +#define msec_to_bin_frac_32( _msec ) dec_frac_to_bin_frac_32( (_msec), 1000L ) +#define usec_to_bin_frac_32( _usec ) dec_frac_to_bin_frac_32( (_usec), 1000000L ) +#define nsec_to_bin_frac_32( _nsec ) dec_frac_to_bin_frac_32( (_nsec), 1000000000L ) +#define msec_to_bin_frac_16( _msec ) dec_frac_to_bin_frac_16( (_msec), 1000L ) +#define usec_to_bin_frac_16( _usec ) dec_frac_to_bin_frac_16( (_usec), 1000000L ) +#define nsec_to_bin_frac_16( _nsec ) dec_frac_to_bin_frac_16( (_nsec), 1000000000L ) /** - * @brief Convert a fraction of a second from binary + * @brief Convert a binary fraction to a scaled decimal * - * Convert a fraction of a second from binary format (as returned - * as part of the ::PCPS_HR_TIME structure) to a decimal fraction, - * using a specified scale factor. + * Convert a binary fraction (e.g. of a second, as in ::PCPS_TIME_STAMP::frac) + * to a decimal fraction, using a specified scale factor. * * @param[in] b The binary fraction * @param[in] scale The scale factor * * @return The calculated number * - * @see ::PCPS_HRT_FRAC_SCALE - * @see ::PCPS_HRT_FRAC_SCALE_FMT + * @see ::bin_frac_32_to_dec_frac */ static __mbg_inline uint32_t frac_sec_from_bin( uint32_t b, uint32_t scale ) @@ -1094,18 +1129,23 @@ uint32_t frac_sec_from_bin( uint32_t b, uint32_t scale ) +#if !defined( MBG_TGT_KERNEL ) + /** - * @brief Convert a fraction of a second to double + * @brief Convert a binary fraction to "double" fractions * - * Convert a fraction of a second from binary format (as returned - * as part of the ::PCPS_HR_TIME structure) to a double with the - * units of seconds, e.g. 0xFFFFFFFF yields 0.9999999999.... + * Convert a binary fraction (e.g. of a second, as in ::PCPS_TIME_STAMP::frac) + * to a "double" with the units of seconds.<br> + * E.g. a 0xFFFFFFFF fraction yields 0.9999999999.... + * + * @note Excluded from build for kernel drivers which usually + * don't support floating point operations. * * @param[in] b The binary fraction * * @return The calculated fraction * - * @see ::PCPS_HRT_FRAC_SCALE + * @see ::PCPS_HRT_BIN_FRAC_SCALE */ static __mbg_inline double dfrac_sec_from_bin( uint32_t b ) @@ -1114,6 +1154,8 @@ double dfrac_sec_from_bin( uint32_t b ) } // dfrac_sec_from_bin +#endif // !defined( MBG_TGT_KERNEL ) + #if !defined( MBG_TGT_KERNEL ) diff --git a/mbglib/common/gpsdefs.h b/mbglib/common/gpsdefs.h index b5f9de7..e83cf8c 100755 --- a/mbglib/common/gpsdefs.h +++ b/mbglib/common/gpsdefs.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: gpsdefs.h 1.124.1.311 2017/04/25 11:36:24 martin TEST $ + * $Id: gpsdefs.h 1.124.1.312 2017/05/03 13:45:42 philipp TEST $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -13,6 +13,8 @@ * * ----------------------------------------------------------------------- * $Log: gpsdefs.h $ + * Revision 1.124.1.312 2017/05/03 13:45:42 philipp + * Refactored event types * Revision 1.124.1.311 2017/04/25 11:36:24 martin * Renamed GRC181PEX to GNS181PEX. * Revision 1.124.1.310 2017/04/11 10:30:14 philipp @@ -21365,51 +21367,40 @@ do \ enum MBG_EVENT_TYPES { - MBG_EVENT_TYPE_NTP_STOPPED, - MBG_EVENT_TYPE_NTP_NOT_SYNC, - MBG_EVENT_TYPE_NTP_SYNC, - MBG_EVENT_TYPE_LINK_DOWN, - MBG_EVENT_TYPE_LINK_UP, + MBG_EVENT_TYPE_NTP_STATE, MBG_EVENT_TYPE_HEARTBEAT, N_MBG_EVENT_TYPES }; #define MBG_EVENT_TYPE_STRS \ { \ - "NTP stopped", \ - "NTP not synchronized", \ - "NTP synchronized", \ - "Network link down", \ - "Network link up", \ + "NTP state", \ "Heartbeat" \ } enum MBG_EVENT_SEVERITIES { - MBG_EVENT_SEVERITY_CRITICAL, - MBG_EVENT_SEVERITY_ERROR, - MBG_EVENT_SEVERITY_WARNING, MBG_EVENT_SEVERITY_INFO, - MBG_EVENT_SEVERITY_SUCCESS, + MBG_EVENT_SEVERITY_WARNING, + MBG_EVENT_SEVERITY_ERROR, + MBG_EVENT_SEVERITY_CRITICAL, N_MBG_EVENT_SEVERITIES }; #define MBG_EVENT_SEVERITY_STRS \ { \ - "Critical", \ - "Error", \ - "Warning", \ "Info", \ - "Success" \ + "Warning", \ + "Error", \ + "Critical" \ } enum MBG_EVENT_SEVERITY_MSKS { - MBG_EVENT_SEVERITY_MSK_CRITICAL = (1UL << MBG_EVENT_SEVERITY_CRITICAL), - MBG_EVENT_SEVERITY_MSK_ERROR = (1UL << MBG_EVENT_SEVERITY_ERROR), - MBG_EVENT_SEVERITY_MSK_WARNING = (1UL << MBG_EVENT_SEVERITY_WARNING), MBG_EVENT_SEVERITY_MSK_INFO = (1UL << MBG_EVENT_SEVERITY_INFO), - MBG_EVENT_SEVERITY_MSK_SUCCESS = (1UL << MBG_EVENT_SEVERITY_SUCCESS) + MBG_EVENT_SEVERITY_MSK_WARNING = (1UL << MBG_EVENT_SEVERITY_WARNING), + MBG_EVENT_SEVERITY_MSK_ERROR = (1UL << MBG_EVENT_SEVERITY_ERROR), + MBG_EVENT_SEVERITY_MSK_CRITICAL = (1UL << MBG_EVENT_SEVERITY_CRITICAL) }; typedef struct diff --git a/mbglib/common/lan_util.c b/mbglib/common/lan_util.c index 19cbcfc..168aede 100755 --- a/mbglib/common/lan_util.c +++ b/mbglib/common/lan_util.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: lan_util.c 1.11.1.14 2017/04/10 13:05:16 martin TEST $ + * $Id: lan_util.c 1.11.1.15 2017/05/03 07:43:10 daniel TEST $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,8 @@ * * ----------------------------------------------------------------------- * $Log: lan_util.c $ + * Revision 1.11.1.15 2017/05/03 07:43:10 daniel + * Check port link in funtion get_port_ip4_settings() even if it returns an error * Revision 1.11.1.14 2017/04/10 13:05:16 martin * Fixed some compiler warnings. * Revision 1.11.1.13 2017/02/23 15:24:22Z martin @@ -1906,12 +1908,6 @@ int get_port_ip4_settings( const char *if_name, IP4_SETTINGS *p ) goto out; #endif - link_up = check_port_link( if_name ); - - if ( mbg_rc_is_success( rc ) ) - if ( link_up ) - p->flags |= IP4_MSK_LINK; - #if 0 //### TODO // We could also try to check VLAN and DHCP settings here, // but as of now, this is specific to an application. @@ -1931,6 +1927,13 @@ int get_port_ip4_settings( const char *if_name, IP4_SETTINGS *p ) #endif out: + + // Check linkup independent from success of getting IP4 parameters + link_up = check_port_link( if_name ); + + if ( link_up ) + p->flags |= IP4_MSK_LINK; + return rc; } // get_port_ip4_settings diff --git a/mbglib/common/mbgdevio.c b/mbglib/common/mbgdevio.c index 93be933..a379157 100755 --- a/mbglib/common/mbgdevio.c +++ b/mbglib/common/mbgdevio.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgdevio.c 1.38.1.45.1.11 2017/03/20 17:11:07 martin TEST $ + * $Id: mbgdevio.c 1.38.1.45.1.12 2017/05/05 10:39:28 martin TEST $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,8 @@ * * ----------------------------------------------------------------------- * $Log: mbgdevio.c $ + * Revision 1.38.1.45.1.12 2017/05/05 10:39:28 martin + * Fixed build for big endian targets. * Revision 1.38.1.45.1.11 2017/03/20 17:11:07 martin * Replaced dummy swab...() macro calls by real macros. * Revision 1.38.1.45.1.10 2017/02/22 14:29:17 martin @@ -7729,7 +7731,7 @@ _MBG_API_ATTR int _MBG_API mbg_get_gps_all_gpio_info( MBG_DEV_HANDLE dh, for ( i = 0; i < n_supp; i++ ) { MBG_GPIO_INFO_IDX *p = &gii[i]; - _mbg_swab_mbg_gpio_info_idx( p ); + _mbg_swab_mbg_gpio_info_idx( p, 1 ); } } #endif @@ -7767,7 +7769,7 @@ _MBG_API_ATTR int _MBG_API mbg_set_gps_gpio_settings_idx( MBG_DEV_HANDLE dh, _mbgdevio_vars(); #if defined( MBG_ARCH_BIG_ENDIAN ) MBG_GPIO_SETTINGS_IDX tmp = *p; - _mbg_swab_mbg_gpio_settings_idx( &tmp ); + _mbg_swab_mbg_gpio_settings_idx( &tmp, 1 ); p = &tmp; #endif _mbgdevio_write_gps_var_chk( dh, PC_GPS_GPIO_SETTINGS_IDX, @@ -7994,7 +7996,7 @@ _MBG_API_ATTR int _MBG_API mbg_set_gps_xmr_settings_idx( MBG_DEV_HANDLE dh, _mbgdevio_vars(); #if defined( MBG_ARCH_BIG_ENDIAN ) XMULTI_REF_SETTINGS_IDX tmp = *p; - _mbg_swab_xmr_settings_idx( &tmp ); + _mbg_swab_xmulti_ref_settings_idx( &tmp ); p = &tmp; #endif _mbgdevio_write_gps_var_chk( dh, PC_GPS_XMR_SETTINGS_IDX, diff --git a/mbglib/common/pcpsdrvr.c b/mbglib/common/pcpsdrvr.c index 9b7caa9..581bb07 100755 --- a/mbglib/common/pcpsdrvr.c +++ b/mbglib/common/pcpsdrvr.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: pcpsdrvr.c 1.51.1.37 2017/04/25 11:36:47 martin TEST $ + * $Id: pcpsdrvr.c 1.51.1.38 2017/05/05 14:38:35 martin TEST $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -63,6 +63,8 @@ * * ----------------------------------------------------------------------- * $Log: pcpsdrvr.c $ + * Revision 1.51.1.38 2017/05/05 14:38:35 martin + * Fixed some warnings from clang. * Revision 1.51.1.37 2017/04/25 11:36:47 martin * Renamed GRC181PEX to GNS181PEX. * Revision 1.51.1.36 2017/04/19 13:55:58 martin @@ -1187,7 +1189,12 @@ void unmap_sys_virtual_address( PCPS_DDEV *pddev ) #if ( DEBUG_ACCESS_TIMING || DEBUG_IO_TIMING ) -#define DEBUG_PRINT_ACCESS_TIMES ( 1 && defined( MBG_ARCH_X86 ) ) +#if ( 1 && defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_X86 ) ) + #define DEBUG_PRINT_ACCESS_TIMES 1 +#else + #define DEBUG_PRINT_ACCESS_TIMES 0 +#endif + #if DEBUG_PRINT_ACCESS_TIMES @@ -1202,7 +1209,8 @@ long _cyc_to_us( long long cyc ) } #endif -static inline + +static __mbg_inline long long _cyc_to_ps( long long cyc ) { cyc *= 1000000000; |