usermode/library/pmalloc/src/arch-specific.h

00001 
00002 //
00003 // The Hoard Multiprocessor Memory Allocator
00004 // www.hoard.org
00005 //
00006 // Author: Emery Berger, http://www.cs.utexas.edu/users/emery
00007 //
00008 // Copyright (c) 1998-2001, The University of Texas at Austin.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Library General Public License as
00012 // published by the Free Software Foundation, http://www.fsf.org.
00013 //
00014 // This library is distributed in the hope that it will be useful, but
00015 // WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Library General Public License for more details.
00018 //
00020 
00021 #ifndef _ARCH_SPECIFIC_H_
00022 #define _ARCH_SPECIFIC_H_
00023 
00024 #include "config.h"
00025 
00026 #include <pthread.h>
00027 #include <unistd.h>
00028 
00029 
00030 #if USER_LOCKS && (defined(i386) || defined(sparc) || defined(__sgi))
00031 typedef unsigned long   hoardLockType;
00032 #else
00033 typedef pthread_mutex_t hoardLockType;
00034 #endif
00035 
00036 typedef pthread_t               hoardThreadType;
00037 
00038 
00039 extern "C" {
00040 
00042 
00043   void  hoardCreateThread (hoardThreadType& t,
00044                            void *(*function) (void *),
00045                            void * arg);
00046   void  hoardJoinThread (hoardThreadType& t);
00047   void  hoardSetConcurrency (int n);
00048 
00049   // Return a thread identifier appropriate for hashing:
00050   // if the system doesn't produce consecutive thread id's,
00051   // some hackery may be necessary.
00052   int   hoardGetThreadID (void);
00053 
00055 
00056 #if !USER_LOCKS
00057 
00058   // Define the lock operations inline to save a little overhead.
00059 
00060   inline void hoardLockInit (hoardLockType& lock) {
00061     pthread_mutex_init (&lock, NULL);
00062   }
00063 
00064   inline void hoardLock (hoardLockType& lock) {
00065     pthread_mutex_lock (&lock);
00066   }
00067 
00068   inline void hoardUnlock (hoardLockType& lock) {
00069     pthread_mutex_unlock (&lock);
00070   }
00071 
00072 #endif
00073 
00074   inline void  hoardLockDestroy (hoardLockType&) {
00075   }
00076 
00078 
00079   int   hoardGetPageSize (void);
00080   void *        hoardGetMemory (long size);
00081   void  hoardFreeMemory (void * ptr);
00082 
00084 
00085   void  hoardYield (void);
00086   int   hoardGetNumProcessors (void);
00087   unsigned long hoardInterlockedExchange (unsigned long * oldval,
00088                                           unsigned long newval);
00089 }
00090 
00091 #endif // _ARCH_SPECIFIC_H_
00092 

Generated on Sat Apr 23 11:43:35 2011 for Mnemosyne by  doxygen 1.4.7