File: libddi.cpp.mako

package info (click to toggle)
level-zero 1.26.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,468 kB
  • sloc: cpp: 130,327; ansic: 16,197; python: 9,824; makefile: 4
file content (76 lines) | stat: -rw-r--r-- 2,202 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<%!
import re
from templates import helper as th
%><%
    n=namespace
    N=n.upper()

    x=tags['$x']
    X=x.upper()
%>/*
 *
 * Copyright (C) 2019-2025 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 * @file ${name}.cpp
 *
 */
#include "${x}_lib.h"
#ifndef L0_STATIC_LOADER_BUILD
#include "${n}_ddi.h"
#endif

namespace ${x}_lib
{
    ///////////////////////////////////////////////////////////////////////////////

#ifdef L0_STATIC_LOADER_BUILD
    __zedlllocal ${x}_result_t context_t::${n}DdiTableInit(ze_api_version_t version)
    {
        ${x}_result_t result = ${X}_RESULT_SUCCESS;

    %for tbl in th.get_pfntables(specs, meta, n, tags):
        if( ${X}_RESULT_SUCCESS == result )
        {
    %if tbl['optional'] == True:
            // Optional
            auto getTable = reinterpret_cast<${tbl['pfn']}>(
                GET_FUNCTION_PTR(loader, "${tbl['export']['name']}") );
            getTableWithCheck(getTable, version, &initial${n}DdiTable.${tbl['name']} );
    %else:
            auto getTable = reinterpret_cast<${tbl['pfn']}>(
                GET_FUNCTION_PTR(loader, "${tbl['export']['name']}") );
            result = getTableWithCheck(getTable, version, &initial${n}DdiTable.${tbl['name']} );
    %endif
            %for obj in tbl['functions']:
            initial${n}DdiTable.${tbl['name']}.${th.make_pfn_name(n, tags, obj)} = reinterpret_cast<${th.make_pfn_type(n, tags, obj)}>(
                GET_FUNCTION_PTR(loader, "${th.make_func_name(n, tags, obj)}") );
            %endfor
        }

    %endfor
        return result;
    }
#else
    __zedlllocal ${x}_result_t context_t::${n}DdiTableInit(ze_api_version_t version)
    {
        ${x}_result_t result = ${X}_RESULT_SUCCESS;

    %for tbl in th.get_pfntables(specs, meta, n, tags):
        if( ${X}_RESULT_SUCCESS == result )
        {
            %if tbl['optional'] == True:
            // Optional
            ${tbl['export']['name']}( version, &initial${n}DdiTable.${tbl['name']} );
            %else:
            result = ${tbl['export']['name']}( version, &initial${n}DdiTable.${tbl['name']} );
            %endif
        }

    %endfor
        return result;
    }
#endif

} // namespace ${x}_lib