mirror of
https://github.com/saymrwulf/uhd.git
synced 2026-05-16 21:10:10 +00:00
rfnoc: Add device_id allocator
This is a single atomic allocator in the global uhd::rfnoc namespace, so that devices can allocate themselves device IDs without having to confer with the rest of the RFNoC infrastructure.
This commit is contained in:
parent
67ea15ad4b
commit
b92a8e2f2b
3 changed files with 40 additions and 0 deletions
22
host/lib/include/uhdlib/rfnoc/device_id.hpp
Normal file
22
host/lib/include/uhdlib/rfnoc/device_id.hpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// Copyright 2019 Ettus Research, a National Instruments Brand
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
//
|
||||
|
||||
#ifndef INCLUDED_LIBUHD_DEVICE_ID_HPP
|
||||
#define INCLUDED_LIBUHD_DEVICE_ID_HPP
|
||||
|
||||
#include <uhdlib/rfnoc/rfnoc_common.hpp>
|
||||
|
||||
namespace uhd { namespace rfnoc {
|
||||
|
||||
//! Return a new, unique device ID.
|
||||
//
|
||||
// This function will never return the same device ID twice.
|
||||
device_id_t allocate_device_id();
|
||||
|
||||
}} /* namespace uhd::rfnoc */
|
||||
|
||||
#endif /* INCLUDED_LIBUHD_DEVICE_ID_HPP */
|
||||
|
||||
|
|
@ -24,6 +24,7 @@ LIBUHD_APPEND_SOURCES(
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/chdr_packet.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/client_zero.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ctrl_iface.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_id.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/epid_allocator.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/graph_impl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/graph.cpp
|
||||
|
|
|
|||
17
host/lib/rfnoc/device_id.cpp
Normal file
17
host/lib/rfnoc/device_id.cpp
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// Copyright 2019 Ettus Research, a National Instruments Brand
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
//
|
||||
|
||||
#include <uhdlib/rfnoc/device_id.hpp>
|
||||
#include <atomic>
|
||||
|
||||
using namespace uhd::rfnoc;
|
||||
|
||||
device_id_t uhd::rfnoc::allocate_device_id()
|
||||
{
|
||||
static std::atomic<device_id_t> counter{1};
|
||||
return counter++;
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue