From b92a8e2f2b548eef7cb5d58edc92d26befcf67d7 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 19 Jun 2019 11:55:32 -0700 Subject: 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. --- host/lib/rfnoc/device_id.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 host/lib/rfnoc/device_id.cpp (limited to 'host/lib/rfnoc/device_id.cpp') diff --git a/host/lib/rfnoc/device_id.cpp b/host/lib/rfnoc/device_id.cpp new file mode 100644 index 000000000..6bd287dce --- /dev/null +++ b/host/lib/rfnoc/device_id.cpp @@ -0,0 +1,17 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include +#include + +using namespace uhd::rfnoc; + +device_id_t uhd::rfnoc::allocate_device_id() +{ + static std::atomic counter{1}; + return counter++; +} + -- cgit v1.2.3