VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/prlong.h

最後變更 在這個檔案是 106112,由 vboxsync 提交於 4 月 前

libs/xpcom: Fix building code using the XPCOM SDK bindings outside of VirtualBox, ticketref:22714 bugref:10773

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 8.1 KB
 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38/*
39** File: prlong.h
40** Description: Portable access to 64 bit numerics
41**
42** Long-long (64-bit signed integer type) support. Some C compilers
43** don't support 64 bit integers yet, so we use these macros to
44** support both machines that do and don't.
45**/
46#ifndef prlong_h___
47#define prlong_h___
48
49#include "prtypes.h"
50
51#ifdef VBOX
52# include <iprt/types.h>
53#else
54# include <stdint.h>
55#endif
56
57#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
58#define LL_MaxInt VBoxNsllLL_MaxInt
59#define LL_MaxUint VBoxNsllLL_MaxUint
60#define LL_MinInt VBoxNsllLL_MinInt
61#define LL_Zero VBoxNsllLL_Zero
62#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
63
64PR_BEGIN_EXTERN_C
65
66#ifdef VBOX
67/***********************************************************************
68** DEFINES: LL_MaxInt
69** LL_MinInt
70** LL_Zero
71** LL_MaxUint
72** DESCRIPTION:
73** Various interesting constants and static variable
74** initializer
75***********************************************************************/
76DECL_FORCE_INLINE(PRInt64) LL_MaxInt(void)
77{
78 return INT64_MAX;
79}
80
81DECL_FORCE_INLINE(PRInt64) LL_MinInt(void)
82{
83 return INT64_MIN;
84}
85
86DECL_FORCE_INLINE(PRInt64) LL_Zero(void)
87{
88 return 0;
89}
90
91DECL_FORCE_INLINE(PRUint64) LL_MaxUint(void)
92{
93 return UINT64_MAX;
94}
95
96#define LL_MAXINT LL_MaxInt()
97#define LL_MININT LL_MinInt()
98#define LL_ZERO LL_Zero()
99#define LL_MAXUINT LL_MaxUint()
100#endif
101
102#if PR_BYTES_PER_LONG == 8
103#define LL_INIT(hi, lo) ((hi ## L << 32) + lo ## L)
104#elif (defined(WIN32) || defined(WIN16)) && !defined(__GNUC__)
105#define LL_INIT(hi, lo) ((hi ## i64 << 32) + lo ## i64)
106#else
107#define LL_INIT(hi, lo) ((hi ## LL << 32) + lo ## LL)
108#endif
109
110/***********************************************************************
111** MACROS: LL_*
112** DESCRIPTION:
113** The following macros define portable access to the 64 bit
114** math facilities.
115**
116***********************************************************************/
117
118/***********************************************************************
119** MACROS: LL_<relational operators>
120**
121** LL_IS_ZERO Test for zero
122** LL_EQ Test for equality
123** LL_NE Test for inequality
124** LL_GE_ZERO Test for zero or positive
125** LL_CMP Compare two values
126***********************************************************************/
127#define LL_IS_ZERO(a) ((a) == 0)
128#define LL_EQ(a, b) ((a) == (b))
129#define LL_NE(a, b) ((a) != (b))
130#define LL_GE_ZERO(a) ((a) >= 0)
131#define LL_CMP(a, op, b) ((PRInt64)(a) op (PRInt64)(b))
132#define LL_UCMP(a, op, b) ((PRUint64)(a) op (PRUint64)(b))
133
134/***********************************************************************
135** MACROS: LL_<logical operators>
136**
137** LL_AND Logical and
138** LL_OR Logical or
139** LL_XOR Logical exclusion
140** LL_OR2 A disgusting deviation
141** LL_NOT Negation (one's complement)
142***********************************************************************/
143#define LL_AND(r, a, b) ((r) = (a) & (b))
144#define LL_OR(r, a, b) ((r) = (a) | (b))
145#define LL_XOR(r, a, b) ((r) = (a) ^ (b))
146#define LL_OR2(r, a) ((r) = (r) | (a))
147#define LL_NOT(r, a) ((r) = ~(a))
148
149/***********************************************************************
150** MACROS: LL_<mathematical operators>
151**
152** LL_NEG Negation (two's complement)
153** LL_ADD Summation (two's complement)
154** LL_SUB Difference (two's complement)
155***********************************************************************/
156#define LL_NEG(r, a) ((r) = -(a))
157#define LL_ADD(r, a, b) ((r) = (a) + (b))
158#define LL_SUB(r, a, b) ((r) = (a) - (b))
159
160/***********************************************************************
161** MACROS: LL_<mathematical operators>
162**
163** LL_MUL Product (two's complement)
164** LL_DIV Quotient (two's complement)
165** LL_MOD Modulus (two's complement)
166***********************************************************************/
167#define LL_MUL(r, a, b) ((r) = (a) * (b))
168#define LL_DIV(r, a, b) ((r) = (a) / (b))
169#define LL_MOD(r, a, b) ((r) = (a) % (b))
170
171/***********************************************************************
172** MACROS: LL_<shifting operators>
173**
174** LL_SHL Shift left [0..64] bits
175** LL_SHR Shift right [0..64] bits with sign extension
176** LL_USHR Unsigned shift right [0..64] bits
177** LL_ISHL Signed shift left [0..64] bits
178***********************************************************************/
179#define LL_SHL(r, a, b) ((r) = (PRInt64)(a) << (b))
180#define LL_SHR(r, a, b) ((r) = (PRInt64)(a) >> (b))
181#define LL_USHR(r, a, b) ((r) = (PRUint64)(a) >> (b))
182#define LL_ISHL(r, a, b) ((r) = (PRInt64)(a) << (b))
183
184/***********************************************************************
185** MACROS: LL_<conversion operators>
186**
187** LL_L2I Convert to signed 32 bit
188** LL_L2UI Convert to unsigned 32 bit
189** LL_L2F Convert to floating point
190** LL_L2D Convert to floating point
191** LL_I2L Convert signed to 64 bit
192** LL_UI2L Convert unsigned to 64 bit
193** LL_F2L Convert float to 64 bit
194** LL_D2L Convert float to 64 bit
195***********************************************************************/
196#define LL_L2I(i, l) ((i) = (PRInt32)(l))
197#define LL_L2UI(ui, l) ((ui) = (PRUint32)(l))
198#define LL_L2F(f, l) ((f) = (PRFloat64)(l))
199#define LL_L2D(d, l) ((d) = (PRFloat64)(l))
200
201#define LL_I2L(l, i) ((l) = (PRInt64)(i))
202#define LL_UI2L(l, ui) ((l) = (PRInt64)(ui))
203#define LL_F2L(l, f) ((l) = (PRInt64)(f))
204#define LL_D2L(l, d) ((l) = (PRInt64)(d))
205
206/***********************************************************************
207** MACROS: LL_UDIVMOD
208** DESCRIPTION:
209** Produce both a quotient and a remainder given an unsigned
210** INPUTS: PRUint64 a: The dividend of the operation
211** PRUint64 b: The quotient of the operation
212** OUTPUTS: PRUint64 *qp: pointer to quotient
213** PRUint64 *rp: pointer to remainder
214***********************************************************************/
215#define LL_UDIVMOD(qp, rp, a, b) \
216 (*(qp) = ((PRUint64)(a) / (b)), \
217 *(rp) = ((PRUint64)(a) % (b)))
218
219PR_END_EXTERN_C
220
221#endif /* prlong_h___ */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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