Back to index

lightning-sunbird  0.9+nobinonly
Functions
nextstep.c File Reference
#include "primpl.h"
#import <mach/mach.h>
#import <mach/mach_error.h>
#import <mach-o/dyld.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <syscall.h>

Go to the source code of this file.

Functions

caddr_t mmap (caddr_t addr, size_t len, int prot, int flags, int fildes, off_t off)
int munmap (caddr_t addr, size_t len)
int mprotect (caddr_t addr, size_t len, int prot)
voidsbrk (int incr)
caddr_t my_mmap (caddr_t addr, size_t len, int prot, int flags, int fildes, off_t off)
int my_munmap (caddr_t addr, size_t len)
int my_mprotect (caddr_t addr, size_t len, int prot)
char * strdup (const char *s1)
 Duplicates a C string, returns NULL if failed, or passed NULL.
NSObjectFileImageReturnCode NSCreateObjectFileImageFromFile (const char *pathName, NSObjectFileImage *objectFileImage)
voidNSAddressOfSymbol (NSSymbol symbol)
NSModule NSLinkModule (NSObjectFileImage objectFileImage, const char *moduleName, enum bool bindNow)
NSSymbol NSLookupAndBindSymbol (const char *symbolName)
enum bool NSUnLinkModule (NSModule module, enum bool keepMemoryMapped)
void _MD_EarlyInit (void)
PRWord_MD_HomeGCRegisters (PRThread *t, int isCurrent, int *np)
void _MD_SET_PRIORITY (_MDThread *thread, PRUintn newPri)
PRStatus _MD_InitializeThread (PRThread *thread)
PRStatus _MD_WAIT (PRThread *thread, PRIntervalTime ticks)
PRStatus _MD_WAKEUP_WAITER (PRThread *thread)
void _MD_YIELD (void)
PRStatus _MD_CREATE_THREAD (PRThread *thread, void(*start)(void *), PRThreadPriority priority, PRThreadScope scope, PRThreadState state, PRUint32 stackSize)

Function Documentation

PRStatus _MD_CREATE_THREAD ( PRThread thread,
void(*)(void *)  start,
PRThreadPriority  priority,
PRThreadScope  scope,
PRThreadState  state,
PRUint32  stackSize 
)

Definition at line 272 of file nextstep.c.

{
    PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for NEXTSTEP.");
       return PR_FAILURE;
}

Definition at line 215 of file nextstep.c.

{
}
PRWord* _MD_HomeGCRegisters ( PRThread t,
int  isCurrent,
int np 
)

Definition at line 219 of file nextstep.c.

{
#ifndef _PR_PTHREADS
    if (isCurrent) {
       (void) sigsetjmp(CONTEXT(t), 1);
    }
    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
    return (PRWord *) CONTEXT(t);
#else
       *np = 0;
       return NULL;
#endif
}

Definition at line 242 of file nextstep.c.

{
       return PR_SUCCESS;
}
void _MD_SET_PRIORITY ( _MDThread thread,
PRUintn  newPri 
)

Definition at line 236 of file nextstep.c.

{
    return;
}
PRStatus _MD_WAIT ( PRThread thread,
PRIntervalTime  ticks 
)

Definition at line 248 of file nextstep.c.

{
    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
    _PR_MD_SWITCH_CONTEXT(thread);
    return PR_SUCCESS;
}

Here is the call graph for this function:

Definition at line 256 of file nextstep.c.

{
    if (thread) {
       PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
    }
    return PR_SUCCESS;
}

Definition at line 266 of file nextstep.c.

{
    PR_NOT_REACHED("_MD_YIELD should not be called for NEXTSTEP.");
}
caddr_t mmap ( caddr_t  addr,
size_t  len,
int  prot,
int  flags,
int  fildes,
off_t  off 
)

Definition at line 55 of file nextstep.c.

{
       return (caddr_t) syscall (SYS_mmap, addr, len, prot, flags, fildes, off);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int mprotect ( caddr_t  addr,
size_t  len,
int  prot 
)

Definition at line 68 of file nextstep.c.

{
       return syscall (SYS_mprotect, addr, len, prot);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int munmap ( caddr_t  addr,
size_t  len 
)

Definition at line 62 of file nextstep.c.

{
       return syscall (SYS_munmap, addr, len);
}

Here is the call graph for this function:

Here is the caller graph for this function:

caddr_t my_mmap ( caddr_t  addr,
size_t  len,
int  prot,
int  flags,
int  fildes,
off_t  off 
)

Definition at line 89 of file nextstep.c.

{
       kern_return_t ret_val;
       
       /*     First map ...
       */
       ret_val = map_fd ( fildes,                              /* fd                       */
                         (vm_offset_t) off,             /* offset                   */
                                     (vm_offset_t*)&addr,             /* address                  */
                                     TRUE,                                   /* find_space        */
                                     (vm_size_t) len);                /* size                            */

       if (ret_val != KERN_SUCCESS) {
       mach_error("Error calling map_fd() in mmap", ret_val );
              return (caddr_t)0;
       }
       
       /*     ... then protect (this is probably bad)
       */
       ret_val = vm_protect( task_self(),               /* target_task              */
                                           (vm_address_t)addr, /* address                  */
                                           (vm_size_t) len,           /* size                     */
                                           FALSE,                                   /* set_maximum              */
                                           (vm_prot_t) prot);         /* new_protection    */
       if (ret_val != KERN_SUCCESS) {
              mach_error("vm_protect in mmap()", ret_val );
              return (caddr_t)0;
       }
       
       return addr;
}
int my_mprotect ( caddr_t  addr,
size_t  len,
int  prot 
)

Definition at line 138 of file nextstep.c.

{
       vm_prot_t mach_prot;
       kern_return_t ret_val;
       
       switch (prot) {
              case PROT_READ:             mach_prot = VM_PROT_READ;          break;
              case PROT_WRITE:     mach_prot = VM_PROT_WRITE;         break;
              case PROT_EXEC:             mach_prot = VM_PROT_EXECUTE;       break;
              case PROT_NONE:             mach_prot = VM_PROT_NONE;          break;
       }
       
       ret_val = vm_protect(task_self(),                /* target_task              */
                                           (vm_address_t)addr, /* address                  */
                                           (vm_size_t) len,           /* size                     */
                                           FALSE,                                   /* set_maximum              */
                                           (vm_prot_t) prot);         /* new_protection    */

       if (ret_val != KERN_SUCCESS) {
              mach_error("vm_protect in mprotect()", ret_val);
              return -1;
       }
       
       return 0;
}
int my_munmap ( caddr_t  addr,
size_t  len 
)

Definition at line 122 of file nextstep.c.

{
       kern_return_t ret_val;

       ret_val = vm_deallocate(task_self(),
                                                 (vm_address_t) addr,
                                                 (vm_size_t) len);

       if (ret_val != KERN_SUCCESS) {
              mach_error("vm_deallocate in munmap()", ret_val);
              return -1;
       }
       
       return 0;
}
void* NSAddressOfSymbol ( NSSymbol  symbol)

Definition at line 186 of file nextstep.c.

{
       return NULL;
}

Here is the caller graph for this function:

NSObjectFileImageReturnCode NSCreateObjectFileImageFromFile ( const char *  pathName,
NSObjectFileImage *  objectFileImage 
)

Definition at line 179 of file nextstep.c.

{
       return NSObjectFileImageFailure;
}
NSModule NSLinkModule ( NSObjectFileImage  objectFileImage,
const char *  moduleName,
enum bool  bindNow 
)

Definition at line 192 of file nextstep.c.

{
       return NULL;
}
NSSymbol NSLookupAndBindSymbol ( const char *  symbolName)

Definition at line 200 of file nextstep.c.

{
       return NULL;
}

Here is the caller graph for this function:

enum bool NSUnLinkModule ( NSModule  module,
enum bool  keepMemoryMapped 
)

Definition at line 206 of file nextstep.c.

{
       return 0;
}

Here is the caller graph for this function:

void* sbrk ( int  incr)

Definition at line 82 of file nextstep.c.

{
       return (void *) syscall (SYS_sbrk, incr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* strdup ( const char *  s1)

Duplicates a C string, returns NULL if failed, or passed NULL.

Definition at line 164 of file nextstep.c.

{
       int len = strlen (s1);
       char *copy = (char*) malloc (len+1);
       
       if (copy == (char*)0)
              return (char*)0;

       strcpy (copy, s1);

       return copy;
}

Here is the call graph for this function: