Back to index

lightning-sunbird  0.9+nobinonly
openvms.c
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "primpl.h"
00039 
00040 void _MD_EarlyInit(void)
00041 {
00042 }
00043 
00044 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
00045 {
00046 #ifndef _PR_PTHREADS
00047     if (isCurrent) {
00048        (void) setjmp(CONTEXT(t));
00049     }
00050     *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
00051     return (PRWord *) CONTEXT(t);
00052 #else
00053        *np = 0;
00054        return NULL;
00055 #endif
00056 }
00057 
00058 #ifndef _PR_PTHREADS
00059 void
00060 _MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
00061 {
00062     return;
00063 }
00064 
00065 PRStatus
00066 _MD_InitializeThread(PRThread *thread)
00067 {
00068        return PR_SUCCESS;
00069 }
00070 
00071 PRStatus
00072 _MD_WAIT(PRThread *thread, PRIntervalTime ticks)
00073 {
00074     PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
00075     _PR_MD_SWITCH_CONTEXT(thread);
00076     return PR_SUCCESS;
00077 }
00078 
00079 PRStatus
00080 _MD_WAKEUP_WAITER(PRThread *thread)
00081 {
00082     if (thread) {
00083        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
00084     }
00085     return PR_SUCCESS;
00086 }
00087 
00088 /* These functions should not be called for OSF1 */
00089 void
00090 _MD_YIELD(void)
00091 {
00092     PR_NOT_REACHED("_MD_YIELD should not be called for OSF1.");
00093 }
00094 
00095 PRStatus
00096 _MD_CREATE_THREAD(
00097     PRThread *thread,
00098     void (*start) (void *),
00099     PRThreadPriority priority,
00100     PRThreadScope scope,
00101     PRThreadState state,
00102     PRUint32 stackSize)
00103 {
00104     PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for OSF1.");
00105        return PR_FAILURE;
00106 }
00107 #endif /* ! _PR_PTHREADS */
00108 
00109 #ifdef _PR_HAVE_ATOMIC_CAS
00110 
00111 #include <c_asm.h>
00112 
00113 #define _PR_OSF_ATOMIC_LOCK 1
00114 
00115 void 
00116 PR_StackPush(PRStack *stack, PRStackElem *stack_elem)
00117 {
00118 long locked;
00119 
00120        do {
00121               while ((long) stack->prstk_head.prstk_elem_next ==
00122                                                  _PR_OSF_ATOMIC_LOCK)
00123                      ;
00124               locked = __ATOMIC_EXCH_QUAD(&stack->prstk_head.prstk_elem_next,
00125                                                         _PR_OSF_ATOMIC_LOCK);       
00126 
00127        } while (locked == _PR_OSF_ATOMIC_LOCK);
00128        stack_elem->prstk_elem_next = (PRStackElem *) locked;
00129        /*
00130         * memory-barrier instruction
00131         */
00132        asm("mb");
00133        stack->prstk_head.prstk_elem_next = stack_elem;
00134 }
00135 
00136 PRStackElem * 
00137 PR_StackPop(PRStack *stack)
00138 {
00139 PRStackElem *element;
00140 long locked;
00141 
00142        do {
00143               while ((long)stack->prstk_head.prstk_elem_next == _PR_OSF_ATOMIC_LOCK)
00144                      ;
00145               locked = __ATOMIC_EXCH_QUAD(&stack->prstk_head.prstk_elem_next,
00146                                                         _PR_OSF_ATOMIC_LOCK);       
00147 
00148        } while (locked == _PR_OSF_ATOMIC_LOCK);
00149 
00150        element = (PRStackElem *) locked;
00151 
00152        if (element == NULL) {
00153               stack->prstk_head.prstk_elem_next = NULL;
00154        } else {
00155               stack->prstk_head.prstk_elem_next =
00156                      element->prstk_elem_next;
00157        }
00158        /*
00159         * memory-barrier instruction
00160         */
00161        asm("mb");
00162        return element;
00163 }
00164 #endif /* _PR_HAVE_ATOMIC_CAS */
00165 
00166 
00167 /*
00168 ** thread_suspend and thread_resume are used by the gc code
00169 ** in nsprpub/pr/src/pthreads/ptthread.c
00170 **
00171 ** These routines are never called for the current thread, and
00172 ** there is no check for that - so beware!
00173 */
00174 int thread_suspend(PRThread *thr_id) {
00175 
00176     extern int pthread_suspend_np (
00177                      pthread_t                       thread,
00178                      __pthreadLongUint_t             *regs,
00179                      void                            *spare);
00180 
00181     __pthreadLongUint_t regs[34];
00182     int res;
00183 
00184     /*
00185     ** A return res < 0 indicates that the thread was suspended
00186     ** but register information could not be obtained
00187     */
00188 
00189     res = pthread_suspend_np(thr_id->id,&regs[0],0);
00190     if (res==0)
00191        thr_id->sp = (void *) regs[30]; 
00192 
00193     thr_id->suspend |= PT_THREAD_SUSPENDED;
00194 
00195     /* Always succeeds */
00196     return 0;
00197 }
00198 
00199 int thread_resume(PRThread *thr_id) {
00200     extern int pthread_resume_np(pthread_t thread);
00201     int res;
00202 
00203     res = pthread_resume_np (thr_id->id);
00204        
00205     thr_id->suspend |= PT_THREAD_RESUMED;
00206 
00207     return 0;
00208 }
00209 
00210 /*
00211 ** Stubs for nspr_symvec.opt
00212 **
00213 ** PR_ResumeSet, PR_ResumeTest, and PR_SuspendAllSuspended
00214 ** (defined in ptthread.c) used to be exported by mistake
00215 ** (because they look like public functions).  They have been
00216 ** converted into static functions.
00217 **
00218 ** There is an existing third-party binary that uses NSPR: the
00219 ** Java plugin for Mozilla.  Because it is part of the Java
00220 ** SDK, we have no control over its releases.  So we need these
00221 ** stub functions to occupy the slots that used to be occupied
00222 ** by PR_ResumeSet, PR_ResumeTest, and PR_SuspendAllSuspended
00223 ** in the symbol vector so that LIBNSPR4 is backward compatible.
00224 **
00225 ** The Java plugin was also using PR_CreateThread which we didn't
00226 ** realise and hadn't "nailed down". So we now need to nail it down
00227 ** to its Mozilla 1.1 position and have to insert 51 additional stubs
00228 ** in order to achive this (stubs 4-54).
00229 **
00230 ** Over time some of these stubs will get reused by new symbols.
00231 **   - Stub54 is replaced by LL_MaxUint
00232 */
00233 
00234 void PR_VMS_Stub1(void) { }
00235 void PR_VMS_Stub2(void) { }
00236 void PR_VMS_Stub3(void) { }
00237 void PR_VMS_Stub4(void) { }
00238 void PR_VMS_Stub5(void) { }
00239 void PR_VMS_Stub6(void) { }
00240 void PR_VMS_Stub7(void) { }
00241 void PR_VMS_Stub8(void) { }
00242 void PR_VMS_Stub9(void) { }
00243 void PR_VMS_Stub10(void) { }
00244 void PR_VMS_Stub11(void) { }
00245 void PR_VMS_Stub12(void) { }
00246 void PR_VMS_Stub13(void) { }
00247 void PR_VMS_Stub14(void) { }
00248 void PR_VMS_Stub15(void) { }
00249 void PR_VMS_Stub16(void) { }
00250 void PR_VMS_Stub17(void) { }
00251 void PR_VMS_Stub18(void) { }
00252 void PR_VMS_Stub19(void) { }
00253 void PR_VMS_Stub20(void) { }
00254 void PR_VMS_Stub21(void) { }
00255 void PR_VMS_Stub22(void) { }
00256 void PR_VMS_Stub23(void) { }
00257 void PR_VMS_Stub24(void) { }
00258 void PR_VMS_Stub25(void) { }
00259 void PR_VMS_Stub26(void) { }
00260 void PR_VMS_Stub27(void) { }
00261 void PR_VMS_Stub28(void) { }
00262 void PR_VMS_Stub29(void) { }
00263 void PR_VMS_Stub30(void) { }
00264 void PR_VMS_Stub31(void) { }
00265 void PR_VMS_Stub32(void) { }
00266 void PR_VMS_Stub33(void) { }
00267 void PR_VMS_Stub34(void) { }
00268 void PR_VMS_Stub35(void) { }
00269 void PR_VMS_Stub36(void) { }
00270 void PR_VMS_Stub37(void) { }
00271 void PR_VMS_Stub38(void) { }
00272 void PR_VMS_Stub39(void) { }
00273 void PR_VMS_Stub40(void) { }
00274 void PR_VMS_Stub41(void) { }
00275 void PR_VMS_Stub42(void) { }
00276 void PR_VMS_Stub43(void) { }
00277 void PR_VMS_Stub44(void) { }
00278 void PR_VMS_Stub45(void) { }
00279 void PR_VMS_Stub46(void) { }
00280 void PR_VMS_Stub47(void) { }
00281 void PR_VMS_Stub48(void) { }
00282 void PR_VMS_Stub49(void) { }
00283 void PR_VMS_Stub50(void) { }
00284 void PR_VMS_Stub51(void) { }
00285 void PR_VMS_Stub52(void) { }
00286 void PR_VMS_Stub53(void) { }