mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-11-04 05:30:32 -05:00 
			
		
		
		
	add gettimeofday() compatibility function for windows
plugins that need that: - remotesink - remotesource
This commit is contained in:
		
							parent
							
								
									d49e28e266
								
							
						
					
					
						commit
						f61d1c3908
					
				@ -145,6 +145,10 @@ set(INSTALL_PLUGINS_DIR "${INSTALL_LIB_DIR}/plugins")
 | 
				
			|||||||
set(INSTALL_PLUGINSSRV_DIR "${INSTALL_LIB_DIR}/pluginssrv")
 | 
					set(INSTALL_PLUGINSSRV_DIR "${INSTALL_LIB_DIR}/pluginssrv")
 | 
				
			||||||
set(EXTERNAL_BUILD_LIBRARIES "${CMAKE_BINARY_DIR}/external")
 | 
					set(EXTERNAL_BUILD_LIBRARIES "${CMAKE_BINARY_DIR}/external")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# custom libraries
 | 
				
			||||||
 | 
					set(CUSTOM_APPLE_INCLUDE "${CMAKE_SOURCE_DIR}/custom/apple" CACHE INTERNAL "")
 | 
				
			||||||
 | 
					set(CUSTOM_WINDOWS_INCLUDE "${CMAKE_SOURCE_DIR}/custom/windows" CACHE INTERNAL "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
 | 
					if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
 | 
				
			||||||
  set(LINUX TRUE)
 | 
					  set(LINUX TRUE)
 | 
				
			||||||
  # populate distribution name
 | 
					  # populate distribution name
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										44
									
								
								custom/windows/windows_time.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								custom/windows/windows_time.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					#if (defined _WIN32_) || (defined _MSC_VER)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * missing gettimeofday implementation
 | 
				
			||||||
 | 
					 * for windows; based on postgresql
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef CUSTOM_WINDOWS_TIME_H_
 | 
				
			||||||
 | 
					#define CUSTOM_WINDOWS_TIME_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define _WINSOCKAPI_    // stops windows.h including winsock.h; timeval redefine
 | 
				
			||||||
 | 
					#include <Windows.h>
 | 
				
			||||||
 | 
					#include <stdint.h> // portable: uint64_t   MSVC: __int64 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// MSVC defines this in winsock2.h!?
 | 
				
			||||||
 | 
					typedef struct timeval {
 | 
				
			||||||
 | 
					    long tv_sec;
 | 
				
			||||||
 | 
					    long tv_usec;
 | 
				
			||||||
 | 
					} timeval;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int gettimeofday(struct timeval * tp, struct timezone * tzp)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
 | 
				
			||||||
 | 
					    // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
 | 
				
			||||||
 | 
					    // until 00:00:00 January 1, 1970 
 | 
				
			||||||
 | 
					    static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SYSTEMTIME  system_time;
 | 
				
			||||||
 | 
					    FILETIME    file_time;
 | 
				
			||||||
 | 
					    uint64_t    time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GetSystemTime( &system_time );
 | 
				
			||||||
 | 
					    SystemTimeToFileTime( &system_time, &file_time );
 | 
				
			||||||
 | 
					    time =  ((uint64_t)file_time.dwLowDateTime )      ;
 | 
				
			||||||
 | 
					    time += ((uint64_t)file_time.dwHighDateTime) << 32;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    tp->tv_sec  = (long) ((time - EPOCH) / 10000000L);
 | 
				
			||||||
 | 
					    tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // CUSTOM_WINDOWS_TIME_H_
 | 
				
			||||||
 | 
					#endif // _WIN32_
 | 
				
			||||||
@ -7,7 +7,6 @@ set(fcdhid_SOURCES
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(fcdhid_HEADERS
 | 
					set(fcdhid_HEADERS
 | 
				
			||||||
    	../custom/apple/apple_compat.h
 | 
					 | 
				
			||||||
	fcdhid.h
 | 
						fcdhid.h
 | 
				
			||||||
	hid-libusb.h
 | 
						hid-libusb.h
 | 
				
			||||||
	hidapi.h
 | 
						hidapi.h
 | 
				
			||||||
@ -16,6 +15,7 @@ set(fcdhid_HEADERS
 | 
				
			|||||||
include_directories(
 | 
					include_directories(
 | 
				
			||||||
        ${LIBUSB_INCLUDE_DIR}
 | 
					        ${LIBUSB_INCLUDE_DIR}
 | 
				
			||||||
        ${ICONV_INCLUDE_DIR}
 | 
					        ${ICONV_INCLUDE_DIR}
 | 
				
			||||||
 | 
					        ${CUSTOM_APPLE_INCLUDE}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_library(fcdhid SHARED
 | 
					add_library(fcdhid SHARED
 | 
				
			||||||
 | 
				
			|||||||
@ -69,9 +69,7 @@ extern "C" {
 | 
				
			|||||||
 * MacOS does not implement POSIX Thread Barriers
 | 
					 * MacOS does not implement POSIX Thread Barriers
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#ifdef __APPLE__
 | 
					#ifdef __APPLE__
 | 
				
			||||||
 | 
					#include "apple_compat.h"
 | 
				
			||||||
#include "../custom/apple/apple_compat.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Uncomment to enable the retrieval of Usage and Usage Page in
 | 
					/* Uncomment to enable the retrieval of Usage and Usage Page in
 | 
				
			||||||
 | 
				
			|||||||
@ -27,6 +27,7 @@ include_directories(
 | 
				
			|||||||
    ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
 | 
					    ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
 | 
				
			||||||
    ${Boost_INCLUDE_DIRS}
 | 
					    ${Boost_INCLUDE_DIRS}
 | 
				
			||||||
    ${CM256CC_INCLUDE_DIR}
 | 
					    ${CM256CC_INCLUDE_DIR}
 | 
				
			||||||
 | 
					    ${CUSTOM_WINDOWS_INCLUDE}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(NOT SERVER_MODE)
 | 
					if(NOT SERVER_MODE)
 | 
				
			||||||
 | 
				
			|||||||
@ -23,8 +23,13 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "remotesink.h"
 | 
					#include "remotesink.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if (defined _WIN32_) || (defined _MSC_VER)
 | 
				
			||||||
 | 
					#include "windows_time.h"
 | 
				
			||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
#include <sys/time.h>
 | 
					#include <sys/time.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#include <boost/crc.hpp>
 | 
					#include <boost/crc.hpp>
 | 
				
			||||||
#include <boost/cstdint.hpp>
 | 
					#include <boost/cstdint.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -27,6 +27,7 @@ include_directories(
 | 
				
			|||||||
    ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
 | 
					    ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
 | 
				
			||||||
    ${Boost_INCLUDE_DIRS}
 | 
					    ${Boost_INCLUDE_DIRS}
 | 
				
			||||||
    ${CM256CC_INCLUDE_DIR}
 | 
					    ${CM256CC_INCLUDE_DIR}
 | 
				
			||||||
 | 
					    ${CUSTOM_WINDOWS_INCLUDE}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(NOT SERVER_MODE)
 | 
					if(NOT SERVER_MODE)
 | 
				
			||||||
 | 
				
			|||||||
@ -17,8 +17,13 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "remotesource.h"
 | 
					#include "remotesource.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if (defined _WIN32_) || (defined _MSC_VER)
 | 
				
			||||||
 | 
					#include "windows_time.h"
 | 
				
			||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
#include <sys/time.h>
 | 
					#include <sys/time.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#include <boost/crc.hpp>
 | 
					#include <boost/crc.hpp>
 | 
				
			||||||
#include <boost/cstdint.hpp>
 | 
					#include <boost/cstdint.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -61,7 +61,7 @@
 | 
				
			|||||||
#endif // RTP_HAVE_VSUINT64SUFFIX
 | 
					#endif // RTP_HAVE_VSUINT64SUFFIX
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __APPLE__
 | 
					#ifdef __APPLE__
 | 
				
			||||||
#include   "../custom/apple/apple_compat.h"
 | 
					#include "../custom/apple/apple_compat.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace qrtplib
 | 
					namespace qrtplib
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user