VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.7/include/internal/endian.h@ 100620

Last change on this file since 100620 was 97984, checked in by vboxsync, 2 years ago

libs/openssl-3.0.7: Shut up pragma once warnings for internal headers. Added sed script for doing that. bugref:10317

File size: 2.0 KB
Line 
1/*
2 * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#ifndef OSSL_INTERNAL_ENDIAN_H
11# define OSSL_INTERNAL_ENDIAN_H
12# ifndef RT_WITHOUT_PRAGMA_ONCE /* VBOX */
13# pragma once
14# endif /* VBOX */
15
16/*
17 * IS_LITTLE_ENDIAN and IS_BIG_ENDIAN can be used to detect the endiannes
18 * at compile time. To use it, DECLARE_IS_ENDIAN must be used to declare
19 * a variable.
20 *
21 * L_ENDIAN and B_ENDIAN can be used at preprocessor time. They can be set
22 * in the configarion using the lib_cppflags variable. If neither is
23 * set, it will fall back to code works with either endianness.
24 */
25
26# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
27# define DECLARE_IS_ENDIAN const int ossl_is_little_endian = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
28# define IS_LITTLE_ENDIAN (ossl_is_little_endian)
29# define IS_BIG_ENDIAN (!ossl_is_little_endian)
30# if defined(L_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
31# error "L_ENDIAN defined on a big endian machine"
32# endif
33# if defined(B_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
34# error "B_ENDIAN defined on a little endian machine"
35# endif
36# if !defined(L_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
37# define L_ENDIAN
38# endif
39# if !defined(B_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
40# define B_ENDIAN
41# endif
42# else
43# define DECLARE_IS_ENDIAN \
44 const union { \
45 long one; \
46 char little; \
47 } ossl_is_endian = { 1 }
48
49# define IS_LITTLE_ENDIAN (ossl_is_endian.little != 0)
50# define IS_BIG_ENDIAN (ossl_is_endian.little == 0)
51# endif
52
53#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette