VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.7/include/internal/numbers.h@ 108351

最後變更 在這個檔案從108351是 104078,由 vboxsync 提交於 12 月 前

openssl-3.1.5: Applied and adjusted our OpenSSL changes to 3.1.4. bugref:10638

檔案大小: 2.6 KB
 
1/*
2 * Copyright 2015-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_NUMBERS_H
11# define OSSL_INTERNAL_NUMBERS_H
12# ifndef RT_WITHOUT_PRAGMA_ONCE /* VBOX */
13# pragma once
14# endif /* VBOX */
15
16# include <limits.h>
17
18# if (-1 & 3) == 0x03 /* Two's complement */
19
20# define __MAXUINT__(T) ((T) -1)
21# define __MAXINT__(T) ((T) ((((T) 1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T)))
22# define __MININT__(T) (-__MAXINT__(T) - 1)
23
24# elif (-1 & 3) == 0x02 /* One's complement */
25
26# define __MAXUINT__(T) (((T) -1) + 1)
27# define __MAXINT__(T) ((T) ((((T) 1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T)))
28# define __MININT__(T) (-__MAXINT__(T))
29
30# elif (-1 & 3) == 0x01 /* Sign/magnitude */
31
32# define __MAXINT__(T) ((T) (((((T) 1) << ((sizeof(T) * CHAR_BIT) - 2)) - 1) | (((T) 1) << ((sizeof(T) * CHAR_BIT) - 2))))
33# define __MAXUINT__(T) ((T) (__MAXINT__(T) | (((T) 1) << ((sizeof(T) * CHAR_BIT) - 1))))
34# define __MININT__(T) (-__MAXINT__(T))
35
36# else
37
38# error "do not know the integer encoding on this architecture"
39
40# endif
41
42# ifndef INT8_MAX
43# define INT8_MIN __MININT__(int8_t)
44# define INT8_MAX __MAXINT__(int8_t)
45# define UINT8_MAX __MAXUINT__(uint8_t)
46# endif
47
48# ifndef INT16_MAX
49# define INT16_MIN __MININT__(int16_t)
50# define INT16_MAX __MAXINT__(int16_t)
51# define UINT16_MAX __MAXUINT__(uint16_t)
52# endif
53
54# ifndef INT32_MAX
55# define INT32_MIN __MININT__(int32_t)
56# define INT32_MAX __MAXINT__(int32_t)
57# define UINT32_MAX __MAXUINT__(uint32_t)
58# endif
59
60# ifndef INT64_MAX
61# define INT64_MIN __MININT__(int64_t)
62# define INT64_MAX __MAXINT__(int64_t)
63# define UINT64_MAX __MAXUINT__(uint64_t)
64# endif
65
66# ifndef INT128_MAX
67# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__ == 16
68typedef __int128_t int128_t;
69typedef __uint128_t uint128_t;
70# define INT128_MIN __MININT__(int128_t)
71# define INT128_MAX __MAXINT__(int128_t)
72# define UINT128_MAX __MAXUINT__(uint128_t)
73# endif
74# endif
75
76# ifndef SIZE_MAX
77# define SIZE_MAX __MAXUINT__(size_t)
78# endif
79
80# ifndef OSSL_INTMAX_MAX
81# define OSSL_INTMAX_MIN __MININT__(ossl_intmax_t)
82# define OSSL_INTMAX_MAX __MAXINT__(ossl_intmax_t)
83# define OSSL_UINTMAX_MAX __MAXUINT__(ossl_uintmax_t)
84# endif
85
86#endif
87
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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