nsprpub/pr/src/md/unix/freebsd.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/src/md/unix/freebsd.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,87 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "primpl.h"
    1.10 +
    1.11 +#include <signal.h>
    1.12 +
    1.13 +void _MD_EarlyInit(void)
    1.14 +{
    1.15 +    /*
    1.16 +     * Ignore FPE because coercion of a NaN to an int causes SIGFPE
    1.17 +     * to be raised.
    1.18 +     */
    1.19 +    struct sigaction act;
    1.20 +
    1.21 +    act.sa_handler = SIG_IGN;
    1.22 +    sigemptyset(&act.sa_mask);
    1.23 +    act.sa_flags = SA_RESTART;
    1.24 +    sigaction(SIGFPE, &act, 0);
    1.25 +}
    1.26 +
    1.27 +PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
    1.28 +{
    1.29 +#ifndef _PR_PTHREADS
    1.30 +    if (isCurrent) {
    1.31 +	(void) sigsetjmp(CONTEXT(t), 1);
    1.32 +    }
    1.33 +    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
    1.34 +    return (PRWord *) CONTEXT(t);
    1.35 +#else
    1.36 +	*np = 0;
    1.37 +	return NULL;
    1.38 +#endif
    1.39 +}
    1.40 +
    1.41 +#ifndef _PR_PTHREADS
    1.42 +void
    1.43 +_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
    1.44 +{
    1.45 +    return;
    1.46 +}
    1.47 +
    1.48 +PRStatus
    1.49 +_MD_InitializeThread(PRThread *thread)
    1.50 +{
    1.51 +	return PR_SUCCESS;
    1.52 +}
    1.53 +
    1.54 +PRStatus
    1.55 +_MD_WAIT(PRThread *thread, PRIntervalTime ticks)
    1.56 +{
    1.57 +    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
    1.58 +    _PR_MD_SWITCH_CONTEXT(thread);
    1.59 +    return PR_SUCCESS;
    1.60 +}
    1.61 +
    1.62 +PRStatus
    1.63 +_MD_WAKEUP_WAITER(PRThread *thread)
    1.64 +{
    1.65 +    if (thread) {
    1.66 +	PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
    1.67 +    }
    1.68 +    return PR_SUCCESS;
    1.69 +}
    1.70 +
    1.71 +/* These functions should not be called for FreeBSD */
    1.72 +void
    1.73 +_MD_YIELD(void)
    1.74 +{
    1.75 +    PR_NOT_REACHED("_MD_YIELD should not be called for FreeBSD.");
    1.76 +}
    1.77 +
    1.78 +PRStatus
    1.79 +_MD_CREATE_THREAD(
    1.80 +    PRThread *thread,
    1.81 +    void (*start) (void *),
    1.82 +    PRThreadPriority priority,
    1.83 +    PRThreadScope scope,
    1.84 +    PRThreadState state,
    1.85 +    PRUint32 stackSize)
    1.86 +{
    1.87 +    PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for FreeBSD.");
    1.88 +	return PR_FAILURE;
    1.89 +}
    1.90 +#endif /* ! _PR_PTHREADS */

mercurial