2022-03-10 02:37:20 +01:00
|
|
|
// The Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) The Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2022 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_CL_CODE_H
|
|
|
|
|
|
|
|
/// cl_program wrapping
|
|
|
|
struct ircd::cl::code
|
|
|
|
{
|
2022-10-23 21:40:37 +02:00
|
|
|
static const size_t iov_max;
|
|
|
|
|
2022-03-10 02:37:20 +01:00
|
|
|
void *handle {nullptr};
|
|
|
|
|
2022-03-27 11:47:29 +02:00
|
|
|
explicit operator bool() const;
|
|
|
|
|
2022-03-10 02:37:20 +01:00
|
|
|
long status() const;
|
|
|
|
size_t devs() const;
|
|
|
|
size_t bins(const vector_view<size_t> &) const;
|
|
|
|
size_t bins_size() const;
|
|
|
|
|
|
|
|
vector_view<const mutable_buffer> bin(vector_view<mutable_buffer>) const;
|
|
|
|
string_view src(const mutable_buffer &) const;
|
|
|
|
|
|
|
|
void compile(const string_view &opts = {});
|
|
|
|
void link(const string_view &opts = {});
|
|
|
|
void build(const string_view &opts = {});
|
|
|
|
|
2022-10-23 21:40:37 +02:00
|
|
|
private:
|
|
|
|
void create(const vector_view<const const_buffer> &bins);
|
|
|
|
void create(const vector_view<const string_view> &srcs);
|
|
|
|
|
|
|
|
public:
|
2022-10-23 21:43:38 +02:00
|
|
|
IRCD_OVERLOAD(path);
|
2022-03-27 11:48:25 +02:00
|
|
|
explicit code(const const_buffer &bc);
|
2022-03-10 02:37:20 +01:00
|
|
|
explicit code(const vector_view<const const_buffer> &bins);
|
|
|
|
code(const vector_view<const string_view> &srcs);
|
|
|
|
code(const string_view &src);
|
2022-10-23 21:43:38 +02:00
|
|
|
code(path_t, const vector_view<const string_view> &paths);
|
|
|
|
code(path_t, const string_view &path);
|
2022-03-10 02:37:20 +01:00
|
|
|
code() = default;
|
|
|
|
code(code &&) noexcept;
|
2022-04-24 04:41:10 +02:00
|
|
|
code(const code &) = delete;
|
2022-03-10 02:37:20 +01:00
|
|
|
code &operator=(code &&) noexcept;
|
2022-04-24 04:41:10 +02:00
|
|
|
code &operator=(const code &) = delete;
|
2022-03-10 02:37:20 +01:00
|
|
|
~code() noexcept;
|
|
|
|
};
|
2022-03-21 23:18:08 +01:00
|
|
|
|
|
|
|
inline
|
|
|
|
ircd::cl::code::code(code &&o)
|
|
|
|
noexcept
|
|
|
|
:handle{std::move(o.handle)}
|
|
|
|
{
|
|
|
|
o.handle = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ircd::cl::code &
|
|
|
|
ircd::cl::code::operator=(code &&o)
|
|
|
|
noexcept
|
|
|
|
{
|
|
|
|
this->~code();
|
|
|
|
handle = std::move(o.handle);
|
|
|
|
o.handle = nullptr;
|
|
|
|
return *this;
|
|
|
|
}
|
2022-03-27 11:47:29 +02:00
|
|
|
|
|
|
|
inline ircd::cl::code::operator
|
2022-04-24 04:41:10 +02:00
|
|
|
bool()
|
|
|
|
const
|
2022-03-27 11:47:29 +02:00
|
|
|
{
|
|
|
|
return handle;
|
|
|
|
}
|