1 /*
2  * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3  *           (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
4  *
5  * This file is part of lsp-plugins
6  * Created on: 12 авг. 2018 г.
7  *
8  * lsp-plugins is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * any later version.
12  *
13  * lsp-plugins is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef DSP_ARCH_NATIVE_CONTEXT_H_
23 #define DSP_ARCH_NATIVE_CONTEXT_H_
24 
25 #ifndef __DSP_NATIVE_IMPL
26     #error "This header should not be included directly"
27 #endif /* __DSP_NATIVE_IMPL */
28 
29 namespace native
30 {
start(dsp::context_t * ctx)31     void start(dsp::context_t *ctx)
32     {
33         ctx->top        = 0;
34     }
35 
finish(dsp::context_t * ctx)36     void finish(dsp::context_t *ctx)
37     {
38         if (ctx->top != 0)
39             lsp_warn("DSP context is not empty");
40     }
41 
info()42     dsp::info_t *info()
43     {
44         size_t size     =
45                 sizeof(dsp::info_t) +
46                 strlen(ARCH_STRING) + 1 +
47                 strlen("native cpu") + 1 +
48                 strlen("unknown") + 1;
49 
50         dsp::info_t *res = reinterpret_cast<dsp::info_t *>(malloc(size));
51         if (res == NULL)
52             return res;
53 
54         char *text  = reinterpret_cast<char *>(&res[1]);
55         res->arch       = text;
56         text            = stpcpy(text, ARCH_STRING) + 1;
57         res->cpu        = text;
58         text            = stpcpy(text, "native cpu") + 1;
59         res->model      = text;
60         text            = stpcpy(text, "unknown");
61         res->features   = text; // Empty string
62 
63         return res;
64     }
65 }
66 
67 #endif /* DSP_ARCH_NATIVE_CONTEXT_H_ */
68