VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/md/_freebsd.h@ 4884

最後變更 在這個檔案從4884是 4884,由 vboxsync 提交於 17 年 前

Updated to 3.21 from mozilla.org.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 7.9 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#ifndef nspr_freebsd_defs_h___
39#define nspr_freebsd_defs_h___
40
41#include "prthread.h"
42
43#if __FreeBSD__ >= 2
44#include <osreldate.h> /* for __FreeBSD_version */
45#endif
46#include <sys/syscall.h>
47
48#define PR_LINKER_ARCH "freebsd"
49#define _PR_SI_SYSNAME "FREEBSD"
50#if defined(__i386__)
51#define _PR_SI_ARCHITECTURE "x86"
52#elif defined(__alpha__)
53#define _PR_SI_ARCHITECTURE "alpha"
54#elif defined(__sparc__)
55#define _PR_SI_ARCHITECTURE "sparc"
56#elif defined(__ia64__)
57#define _PR_SI_ARCHITECTURE "ia64"
58#elif defined(__amd64__)
59#define _PR_SI_ARCHITECTURE "amd64"
60#else
61#error "Unknown CPU architecture"
62#endif
63#if defined(__ELF__)
64#define PR_DLL_SUFFIX ".so"
65#else
66#define PR_DLL_SUFFIX ".so.1.0"
67#endif
68
69#define _PR_VMBASE 0x30000000
70#define _PR_STACK_VMBASE 0x50000000
71#define _MD_DEFAULT_STACK_SIZE 65536L
72#define _MD_MMAP_FLAGS MAP_PRIVATE
73
74#undef HAVE_STACK_GROWING_UP
75#define HAVE_DLL
76#define USE_DLFCN
77#define _PR_HAVE_SOCKADDR_LEN
78#define _PR_STAT_HAS_ST_ATIMESPEC
79#define _PR_NO_LARGE_FILES
80
81#if defined(_PR_PTHREADS)
82#if __FreeBSD_version >= 400008
83/*
84 * libc_r before this version of FreeBSD doesn't have poll().
85 * Although libc has poll(), it is not thread-safe so we can't
86 * use it in the pthreads version.
87 */
88#define _PR_POLL_AVAILABLE
89#endif
90#else
91#if __FreeBSD_version >= 300000
92#define _PR_POLL_AVAILABLE
93#define _PR_USE_POLL
94#endif
95#endif
96
97#define _PR_HAVE_SYSV_SEMAPHORES
98#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
99
100#if __FreeBSD_version >= 400014
101#define _PR_INET6
102#define _PR_HAVE_INET_NTOP
103#define _PR_HAVE_GETHOSTBYNAME2
104#define _PR_HAVE_GETADDRINFO
105#define _PR_INET6_PROBE
106#define _PR_IPV6_V6ONLY_PROBE
107#endif
108
109#define USE_SETJMP
110
111#ifndef _PR_PTHREADS
112#include <setjmp.h>
113
114#define PR_CONTEXT_TYPE sigjmp_buf
115
116#define CONTEXT(_th) ((_th)->md.context)
117
118#define _MD_GET_SP(_th) (_th)->md.context[0]._sjb[2]
119#define PR_NUM_GCREGS _JBLEN
120
121/*
122** Initialize a thread context to run "_main()" when started
123*/
124#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
125{ \
126 *status = PR_TRUE; \
127 if (sigsetjmp(CONTEXT(_thread), 1)) { \
128 _main(); \
129 } \
130 _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \
131}
132
133#define _MD_SWITCH_CONTEXT(_thread) \
134 if (!sigsetjmp(CONTEXT(_thread), 1)) { \
135 (_thread)->md.errcode = errno; \
136 _PR_Schedule(); \
137 }
138
139/*
140** Restore a thread context, saved by _MD_SWITCH_CONTEXT
141*/
142#define _MD_RESTORE_CONTEXT(_thread) \
143{ \
144 errno = (_thread)->md.errcode; \
145 _MD_SET_CURRENT_THREAD(_thread); \
146 siglongjmp(CONTEXT(_thread), 1); \
147}
148
149/* Machine-dependent (MD) data structures */
150
151struct _MDThread {
152 PR_CONTEXT_TYPE context;
153 int id;
154 int errcode;
155};
156
157struct _MDThreadStack {
158 PRInt8 notused;
159};
160
161struct _MDLock {
162 PRInt8 notused;
163};
164
165struct _MDSemaphore {
166 PRInt8 notused;
167};
168
169struct _MDCVar {
170 PRInt8 notused;
171};
172
173struct _MDSegment {
174 PRInt8 notused;
175};
176
177/*
178 * md-specific cpu structure field
179 */
180#define _PR_MD_MAX_OSFD FD_SETSIZE
181
182struct _MDCPU_Unix {
183 PRCList ioQ;
184 PRUint32 ioq_timeout;
185 PRInt32 ioq_max_osfd;
186 PRInt32 ioq_osfd_cnt;
187#ifndef _PR_USE_POLL
188 fd_set fd_read_set, fd_write_set, fd_exception_set;
189 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
190 fd_exception_cnt[_PR_MD_MAX_OSFD];
191#else
192 struct pollfd *ioq_pollfds;
193 int ioq_pollfds_size;
194#endif /* _PR_USE_POLL */
195};
196
197#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
198#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
199#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
200#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
201#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
202#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
203#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
204#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
205#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
206#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
207#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
208#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
209#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
210
211#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
212
213struct _MDCPU {
214 struct _MDCPU_Unix md_unix;
215};
216
217#define _MD_INIT_LOCKS()
218#define _MD_NEW_LOCK(lock) PR_SUCCESS
219#define _MD_FREE_LOCK(lock)
220#define _MD_LOCK(lock)
221#define _MD_UNLOCK(lock)
222#define _MD_INIT_IO()
223#define _MD_IOQ_LOCK()
224#define _MD_IOQ_UNLOCK()
225
226extern PRStatus _MD_InitializeThread(PRThread *thread);
227
228#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
229#define _MD_INIT_THREAD _MD_InitializeThread
230#define _MD_EXIT_THREAD(thread)
231#define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread
232#define _MD_RESUME_THREAD(thread) _MD_resume_thread
233#define _MD_CLEAN_THREAD(_thread)
234
235extern PRStatus _MD_CREATE_THREAD(
236 PRThread *thread,
237 void (*start) (void *),
238 PRThreadPriority priority,
239 PRThreadScope scope,
240 PRThreadState state,
241 PRUint32 stackSize);
242extern void _MD_SET_PRIORITY(struct _MDThread *thread, PRUintn newPri);
243extern PRStatus _MD_WAIT(PRThread *, PRIntervalTime timeout);
244extern PRStatus _MD_WAKEUP_WAITER(PRThread *);
245extern void _MD_YIELD(void);
246
247#endif /* ! _PR_PTHREADS */
248
249extern void _MD_EarlyInit(void);
250extern PRIntervalTime _PR_UNIX_GetInterval(void);
251extern PRIntervalTime _PR_UNIX_TicksPerSecond(void);
252
253#define _MD_EARLY_INIT _MD_EarlyInit
254#define _MD_FINAL_INIT _PR_UnixInit
255#define _MD_GET_INTERVAL _PR_UNIX_GetInterval
256#define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
257
258/*
259 * We wrapped the select() call. _MD_SELECT refers to the built-in,
260 * unwrapped version.
261 */
262#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
263
264#if defined(_PR_POLL_AVAILABLE)
265#include <poll.h>
266#define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
267#endif
268
269/* freebsd has INADDR_LOOPBACK defined, but in /usr/include/rpc/types.h, and I didn't
270 want to be including that.. */
271#ifndef INADDR_LOOPBACK
272#define INADDR_LOOPBACK (u_long)0x7F000001
273#endif
274
275/* For writev() */
276#include <sys/uio.h>
277
278#endif /* nspr_freebsd_defs_h___ */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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