Skip to content

Commit

Permalink
windows: add a few missing depencies
Browse files Browse the repository at this point in the history
  • Loading branch information
rghilduta committed Nov 30, 2023
1 parent 82eabb2 commit 94f2159
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 2 deletions.
44 changes: 44 additions & 0 deletions host/common/include/windows/gettimeofday.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* This file is part of the bladeRF project:
* http://www.github.com/nuand/bladeRF
*
* Copyright (c) 2023 Nuand LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef WIN_GETTIMEOFDAY_H_
#define WIN_GETTIMEOFDAY_H_

#include <pthread.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef WIN32
#error "This file is intended for use with WIN32 systems only."
#endif

int gettimeofday(struct timeval *tp, struct timezone *tzp);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif
49 changes: 49 additions & 0 deletions host/common/src/windows/gettimeofday.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This file is part of the bladeRF project:
* http://www.github.com/nuand/bladeRF
*
* Copyright (c) 2023 Nuand LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef WIN32
#error "This file is intended for use with WIN32 systems only."
#endif

#include <windows.h>
#include <stdint.h>
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
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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ set(SRC
main.c
${BLADERF_HOST_COMMON_SOURCE_DIR}/conversions.c
)
if(MSVC)
set(SRC ${SRC}
${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/getopt_long.c
)
endif()

include_directories(${INCLUDES})
add_executable(libbladeRF_test_quick_retune ${SRC})
Expand Down
5 changes: 5 additions & 0 deletions host/libraries/libbladeRF_test/test_rx_meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ set(SRC
${BLADERF_HOST_COMMON_SOURCE_DIR}/log.c
${BLADERF_HOST_COMMON_SOURCE_DIR}/conversions.c
)
if(MSVC)
set(SRC ${SRC}
${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/getopt_long.c
)
endif(MSVC)
add_executable(${PROJECT_NAME} ${SRC})

target_link_libraries(
Expand Down
11 changes: 11 additions & 0 deletions host/libraries/libbladeRF_test/test_timestamps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ set(SRC
../common/src/test_common.c
${BLADERF_HOST_COMMON_SOURCE_DIR}/conversions.c
)
if(MSVC)
set(SRC ${SRC}
${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/gettimeofday.c
)
endif(MSVC)
add_executable(libbladeRF_test_tx_pulse ${SRC})
target_link_libraries(libbladeRF_test_tx_pulse ${LIBS})

Expand All @@ -70,6 +75,12 @@ set(SRC
../common/src/test_common.c
${BLADERF_HOST_COMMON_SOURCE_DIR}/conversions.c
)
if(MSVC)
set(SRC ${SRC}
${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/getopt_long.c
${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/gettimeofday.c
)
endif(MSVC)
add_executable(libbladeRF_test_txrx_hwloop ${SRC})
target_link_libraries(libbladeRF_test_txrx_hwloop ${LIBS})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@
#include <limits.h>
#include <inttypes.h>
#include <libbladeRF.h>
#include <sys/time.h>
#include "test_timestamps.h"
#include "minmax.h"

#ifdef _WIN32
#include "gettimeofday.h"
#else
#include <sys/time.h>
#endif

/* This test requires external verification via a spectrum analyzer.
* It simply transmits ON/OFF bursts, and is more intended to ensure the API
* functions aren't bombing out than it is to exercise signal integrity/timing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@
#include <limits.h>
#include <inttypes.h>
#include <libbladeRF.h>
#include <sys/time.h>
#include <getopt.h>
#include <pthread.h>
#include "conversions.h"
#include "test_timestamps.h"
#include "test_txrx_hwloop.h"
#include "minmax.h"

#ifdef _WIN32
#include "gettimeofday.h"
#else
#include <sys/time.h>
#endif

/* This test requires external verification via a spectrum analyzer.
* It simply transmits ON/OFF bursts, and is more intended to ensure the API
* functions aren't bombing out than it is to exercise signal integrity/timing.
Expand Down
4 changes: 4 additions & 0 deletions host/utilities/bladeRF-cli/src/cmd/generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include <stdlib.h>
#include <string.h>

#ifdef _WIN32
#define _USE_MATH_DEFINES
#include <math.h>
#endif
#include "conversions.h"
#include "host_config.h"
#include "minmax.h"
Expand Down

0 comments on commit 94f2159

Please sign in to comment.