comparison nspr/pr/src/misc/prenv.c @ 0:1e5118fa0cb1

This is NSS with a Cmake Buildsyste To compile a static NSS library for Windows we've used the Chromium-NSS fork and added a Cmake buildsystem to compile it statically for Windows. See README.chromium for chromium changes and README.trustbridge for our modifications.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 28 Jul 2014 10:47:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e5118fa0cb1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #include <string.h>
7 #include "primpl.h"
8
9 /* Lock used to lock the environment */
10 #if defined(_PR_NO_PREEMPT)
11 #define _PR_NEW_LOCK_ENV()
12 #define _PR_DELETE_LOCK_ENV()
13 #define _PR_LOCK_ENV()
14 #define _PR_UNLOCK_ENV()
15 #elif defined(_PR_LOCAL_THREADS_ONLY)
16 extern _PRCPU * _pr_primordialCPU;
17 static PRIntn _is;
18 #define _PR_NEW_LOCK_ENV()
19 #define _PR_DELETE_LOCK_ENV()
20 #define _PR_LOCK_ENV() if (_pr_primordialCPU) _PR_INTSOFF(_is);
21 #define _PR_UNLOCK_ENV() if (_pr_primordialCPU) _PR_INTSON(_is);
22 #else
23 static PRLock *_pr_envLock = NULL;
24 #define _PR_NEW_LOCK_ENV() {_pr_envLock = PR_NewLock();}
25 #define _PR_DELETE_LOCK_ENV() \
26 { if (_pr_envLock) { PR_DestroyLock(_pr_envLock); _pr_envLock = NULL; } }
27 #define _PR_LOCK_ENV() { if (_pr_envLock) PR_Lock(_pr_envLock); }
28 #define _PR_UNLOCK_ENV() { if (_pr_envLock) PR_Unlock(_pr_envLock); }
29 #endif
30
31 /************************************************************************/
32
33 void _PR_InitEnv(void)
34 {
35 _PR_NEW_LOCK_ENV();
36 }
37
38 void _PR_CleanupEnv(void)
39 {
40 _PR_DELETE_LOCK_ENV();
41 }
42
43 PR_IMPLEMENT(char*) PR_GetEnv(const char *var)
44 {
45 char *ev;
46
47 if (!_pr_initialized) _PR_ImplicitInitialization();
48
49 _PR_LOCK_ENV();
50 ev = _PR_MD_GET_ENV(var);
51 _PR_UNLOCK_ENV();
52 return ev;
53 }
54
55 PR_IMPLEMENT(PRStatus) PR_SetEnv(const char *string)
56 {
57 PRIntn result;
58
59 if (!_pr_initialized) _PR_ImplicitInitialization();
60
61 if ( !strchr(string, '=')) return(PR_FAILURE);
62
63 _PR_LOCK_ENV();
64 result = _PR_MD_PUT_ENV(string);
65 _PR_UNLOCK_ENV();
66 return (result)? PR_FAILURE : PR_SUCCESS;
67 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)