Files
compute-runtime/shared/source/device_binary_format/ar/ar.h
Patryk Wrobel c0342a0ab5 Optimize binaries' size by adjusting linkage of constants in headers
When header is included for the first time in translation unit,
then preprocessor simply copy-pastes its content. If we define a
constant in a header file and this constant has internal linkage
then each and every translation unit, which includes this header
will have its own copy of this constant.

C++17 introduces inline variables, which are meant to allow creation
of variables in header files, which do not cause multiple instances.

The inline variable has a single instance when:
- constexpr is used without static (constexpr implicitly implies inline)
- inline is used without static
- inline const is used without static (const does not imply internal linkage
when used with inline)

Signed-off-by: Patryk Wrobel <patryk.wrobel@intel.com>
2022-08-26 22:52:04 +02:00

38 lines
1.1 KiB
C++

/*
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/utilities/const_stringref.h"
namespace NEO {
namespace Ar {
constexpr ConstStringRef arMagic = "!<arch>\n";
constexpr ConstStringRef arFileEntryTrailingMagic = "\x60\x0A";
struct ArFileEntryHeader {
char identifier[16] = {'/', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '};
char fileModificationTimestamp[12] = {'0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '};
char ownerId[6] = {'0', ' ', ' ', ' ', ' ', ' '};
char groupId[6] = {'0', ' ', ' ', ' ', ' ', ' '};
char fileMode[8] = {'6', '4', '4', ' ', ' ', ' ', ' ', ' '};
char fileSizeInBytes[10] = {'0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '};
char trailingMagic[2] = {arFileEntryTrailingMagic[0], arFileEntryTrailingMagic[1]};
};
static_assert(60U == sizeof(ArFileEntryHeader), "");
namespace SpecialFileNames {
constexpr ConstStringRef longFileNamesFile = "//";
constexpr char longFileNamePrefix = '/';
constexpr char fileNameTerminator = '/';
} // namespace SpecialFileNames
} // namespace Ar
} // namespace NEO