VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.3/include/internal/endian.h@ 96542

最後變更 在這個檔案從96542是 94320,由 vboxsync 提交於 3 年 前

libs/openssl-3.0.1: Export to OSE and fix copyright headers in Makefiles, bugref:10128

檔案大小: 1.8 KB
 
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# pragma once
13
14/*
15 * IS_LITTLE_ENDIAN and IS_BIG_ENDIAN can be used to detect the endiannes
16 * at compile time. To use it, DECLARE_IS_ENDIAN must be used to declare
17 * a variable.
18 *
19 * L_ENDIAN and B_ENDIAN can be used at preprocessor time. They can be set
20 * in the configarion using the lib_cppflags variable. If neither is
21 * set, it will fall back to code works with either endianness.
22 */
23
24# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
25# define DECLARE_IS_ENDIAN const int ossl_is_little_endian = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
26# define IS_LITTLE_ENDIAN (ossl_is_little_endian)
27# define IS_BIG_ENDIAN (!ossl_is_little_endian)
28# if defined(L_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
29# error "L_ENDIAN defined on a big endian machine"
30# endif
31# if defined(B_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
32# error "B_ENDIAN defined on a little endian machine"
33# endif
34# if !defined(L_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
35# define L_ENDIAN
36# endif
37# if !defined(B_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
38# define B_ENDIAN
39# endif
40# else
41# define DECLARE_IS_ENDIAN \
42 const union { \
43 long one; \
44 char little; \
45 } ossl_is_endian = { 1 }
46
47# define IS_LITTLE_ENDIAN (ossl_is_endian.little != 0)
48# define IS_BIG_ENDIAN (ossl_is_endian.little == 0)
49# endif
50
51#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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