VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/config/libc_r.h@ 55761

最後變更 在這個檔案從55761是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 5.3 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/* libc_r.h -- macros, defines, etc. to make using reentrant libc calls */
39/* a bit easier. This was initially done for AIX pthreads, */
40/* but should be usable for anyone... */
41
42/* Most of these use locally defined space instead of static library space. */
43/* Because of this, we use the _INIT_R to declare/allocate space (stack), */
44/* and the plain routines to actually do it..._WARNING_: avoid allocating */
45/* memory wherever possible. Memory allocation is fairly expensive, at */
46/* least on AIX...use arrays instead (which allocate from the stack.) */
47/* I know the names are a bit strange, but I wanted to be fairly certain */
48/* that we didn't have any namespace corruption...in general, the inits are */
49/* R_<name>_INIT_R(), and the actual calls are R_<name>_R(). */
50
51#ifndef _LIBC_R_H
52#define _LIBC_R_H
53
54/************/
55/* strtok */
56/************/
57#define R_STRTOK_INIT_R() \
58 char *r_strtok_r=NULL
59
60#define R_STRTOK_R(return,source,delim) \
61 return=strtok_r(source,delim,&r_strtok_r)
62
63#define R_STRTOK_NORET_R(source,delim) \
64 strtok_r(source,delim,&r_strtok_r)
65
66/**************/
67/* strerror */
68/**************/
69#define R_MAX_STRERROR_LEN_R 8192 /* Straight from limits.h */
70
71#define R_STRERROR_INIT_R() \
72 char r_strerror_r[R_MAX_STRERROR_LEN_R]
73
74#define R_STRERROR_R(val) \
75 strerror_r(val,r_strerror_r,R_MAX_STRERROR_LEN_R)
76
77/*****************/
78/* time things */
79/*****************/
80#define R_ASCTIME_INIT_R() \
81 char r_asctime_r[26]
82
83#define R_ASCTIME_R(val) \
84 asctime_r(val,r_asctime_r)
85
86#define R_CTIME_INIT_R() \
87 char r_ctime_r[26]
88
89#define R_CTIME_R(val) \
90 ctime_r(val,r_ctime_r)
91
92#define R_GMTIME_INIT_R() \
93 struct tm r_gmtime_r
94
95#define R_GMTIME_R(time) \
96 gmtime_r(time,&r_gmtime_r)
97
98#define R_LOCALTIME_INIT_R() \
99 struct tm r_localtime_r
100
101#define R_LOCALTIME_R(val) \
102 localtime_r(val,&r_localtime_r)
103
104/***********/
105/* crypt */
106/***********/
107#include <crypt.h>
108#define R_CRYPT_INIT_R() \
109 CRYPTD r_cryptd_r; \
110 bzero(&r_cryptd_r,sizeof(CRYPTD))
111
112#define R_CRYPT_R(pass,salt) \
113 crypt_r(pass,salt,&r_cryptd_r)
114
115/**************/
116/* pw stuff */
117/**************/
118#define R_MAX_PW_LEN_R 1024
119/* The following must be after the last declaration, but */
120/* before the first bit of code... */
121#define R_GETPWNAM_INIT_R(pw_ptr) \
122 struct passwd r_getpwnam_pw_r; \
123 char r_getpwnam_line_r[R_MAX_PW_LEN_R]; \
124 pw_ptr = &r_getpwnam_pw_r
125
126#define R_GETPWNAM_R(name) \
127 getpwnam_r(name,&r_getpwnam_pw_r,r_getpwnam_line_r,R_MAX_PW_LEN_R)
128
129/*******************/
130/* gethost stuff */
131/*******************/
132#define R_GETHOSTBYADDR_INIT_R() \
133 struct hostent r_gethostbyaddr_r; \
134 struct hostent_data r_gethostbyaddr_data_r
135
136#define R_GETHOSTBYADDR_R(addr,len,type,xptr_ent) \
137 bzero(&r_gethostbyaddr_r,sizeof(struct hostent)); \
138 bzero(&r_gethostbyaddr_data_r,sizeof(struct hostent_data)); \
139 xptr_ent = &r_gethostbyaddr_r; \
140 if (gethostbyaddr_r(addr,len,type, \
141 &r_gethostbyaddr_r,&r_gethostbyaddr_data_r) == -1) { \
142 xptr_ent = NULL; \
143 }
144
145#define R_GETHOSTBYNAME_INIT_R() \
146 struct hostent r_gethostbyname_r; \
147 struct hostent_data r_gethostbyname_data_r
148
149#define R_GETHOSTBYNAME_R(name,xptr_ent) \
150 bzero(&r_gethostbyname_r,sizeof(struct hostent)); \
151 bzero(&r_gethostbyname_data_r,sizeof(struct hostent_data)); \
152 xptr_ent = &r_gethostbyname_r; \
153 if (gethostbyname_r(name, \
154 &r_gethostbyname_r,&r_gethostbyname_data_r) == -1) { \
155 xptr_ent = NULL; \
156 }
157
158#endif /* _LIBC_R_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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