blob: a707bee751b8553b0d488585d22ba4663baa3d96 [file] [log] [blame]
Dejan Mircevskib6fe02f2016-01-07 13:44:22 -05001// Copyright (c) 2015-2016 The Khronos Group Inc.
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01002//
David Neto9fc86582016-09-01 15:33:59 -04003// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01006//
David Neto9fc86582016-09-01 15:33:59 -04007// http://www.apache.org/licenses/LICENSE-2.0
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01008//
David Neto9fc86582016-09-01 15:33:59 -04009// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010014
dan sinclair58a68762018-08-03 08:05:33 -040015#ifndef SOURCE_BINARY_H_
16#define SOURCE_BINARY_H_
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010017
David Neto5a703352016-02-17 14:44:00 -050018#include "spirv-tools/libspirv.h"
Umar Arshadfd965c92016-08-06 13:25:02 -040019#include "spirv_definition.h"
David Neto0ca6b592015-10-30 16:06:15 -040020
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010021// Functions
22
Lei Zhangaf9906e2015-11-16 10:48:43 -050023// Grabs the header from the SPIR-V module given in the binary parameter. The
24// endian parameter specifies the endianness of the binary module. On success,
25// returns SPV_SUCCESS and writes the parsed header into *header.
Andrew Woloszyn55ecc2e2015-11-11 11:05:07 -050026spv_result_t spvBinaryHeaderGet(const spv_const_binary binary,
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010027 const spv_endianness_t endian,
Lei Zhangaf9906e2015-11-16 10:48:43 -050028 spv_header_t* header);
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010029
David Neto37422e92016-12-19 13:26:42 -050030// Returns the number of non-null characters in str before the first null
31// character, or strsz if there is no null character. Examines at most the
32// first strsz characters in str. Returns 0 if str is nullptr. This is a
33// replacement for C11's strnlen_s which might not exist in all environments.
34size_t spv_strnlen_s(const char* str, size_t strsz);
35
dan sinclair58a68762018-08-03 08:05:33 -040036#endif // SOURCE_BINARY_H_