Scrambler  1
fpthread_lib.c
Go to the documentation of this file.
00001 //#########################################################################
00002 //              
00003 //    Copyright (C) 2003-2012 Department of Physics and Astronomy,
00004 //                            University of Rochester,
00005 //                            Rochester, NY
00006 //
00007 //    fpthread_lib.c is part of AstroBEAR.
00008 //
00009 //    AstroBEAR is free software: you can redistribute it and/or modify   
00010 //    it under the terms of the GNU General Public License as published by 
00011 //    the Free Software Foundation, either version 3 of the License, or    
00012 //    (at your option) any later version.
00013 //
00014 //    AstroBEAR is distributed in the hope that it will be useful, 
00015 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 //    GNU General Public License for more details.
00018 //
00019 //    You should have received a copy of the GNU General Public License
00020 //    along with AstroBEAR.  If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 //#########################################################################
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include <errno.h>
00029 #include <pthread.h>
00030 #include <sched.h>
00031 
00032 
00036   
00037 
00038 void fpthread_create_(pthread_t *thread, pthread_attr_t *attr, void (*start_routine)(void*),void *data,int *ierr)
00039 {
00040   
00041   *ierr = pthread_create(thread,attr, (void*)start_routine,data);  
00042    return;
00043 }
00044 
00045 void fpthread_create_noattr_(pthread_t *thread, void (*start_routine)(void*),void *data,int *ierr)
00046 {
00047   *ierr = pthread_create(thread,NULL,(void*)start_routine,data);  
00048    return;
00049 }
00050 
00051 void fpthread_join_(pthread_t *thread, void **status, int *ierr)
00052 {
00053   *ierr = pthread_join(*thread,(void**) status);
00054   return;
00055 }
00056 
00057 void fpthread_cancel_(pthread_t *thread,int*ierr)
00058 {
00059    *ierr = pthread_cancel(*thread); 
00060    return;
00061 }
00062 
00063 void fpthread_detach_(pthread_t *thread, int *ierr)
00064 {
00065   *ierr = pthread_detach(*thread);
00066 }
00067 
00068 void fpthread_exit_(void *data)
00069 {
00070   pthread_exit((void *)data);
00071 }
00072 
00073 void fpthread_setschedprio_(pthread_t *thread, int *prio, int *ierr)
00074 {
00075   *ierr= pthread_setschedprio(*thread, *prio);
00076 }       
00077 
00078 void fpthread_getschedparam_(pthread_t *thread, int *policy, int *priority, int *ierr)
00079 {
00080   struct sched_param param;
00081   *ierr=pthread_getschedparam(*thread, policy, &param);
00082  *priority=param.sched_priority;
00083 }
00084 
00085 
00086 void fpthread_setschedparam_(pthread_t *thread, int *policy, int* priority, int *ierr)
00087 {
00088   struct sched_param param;
00089   param.sched_priority=*priority;
00090   *ierr=pthread_setschedparam(*thread, *policy, &param);
00091 }
00095 void fpthread_equal_(pthread_t *p1, pthread_t *p2,int *iequal,int *ierr)
00096 {
00097    *iequal=pthread_equal(*p1,*p2); 
00098    *ierr = 0;
00099 }
00100 
00101 void fpthread_self_(pthread_t *pout,int *ierr)
00102 {
00103   *pout = pthread_self();
00104   *ierr = 0;
00105 }
00106 
00107 void get_errno_(int *e)
00108 {
00109         *e = errno;
00110 }
00111 
00112 
00116 void fpthread_mutex_init_(pthread_mutex_t *mutex, pthread_mutexattr_t *attr, int *ierr)
00117 { 
00118    *ierr = pthread_mutex_init(mutex,attr);
00119    return;
00120 }
00121 
00122 void fpthread_mutex_lock_(pthread_mutex_t*mutex,int *ierr)
00123 {
00124    *ierr = pthread_mutex_lock(mutex);
00125 }
00126 
00127 void fpthread_mutex_trylock_(pthread_mutex_t*mutex,int *ierr)
00128 {
00129    *ierr = pthread_mutex_trylock(mutex);
00130 }
00131 
00132 void fpthread_mutex_unlock_(pthread_mutex_t*mutex,int *ierr)
00133 {
00134    *ierr = pthread_mutex_unlock(mutex);
00135 }
00136 
00137 void fpthread_mutex_destroy_(pthread_mutex_t*mutex,int *ierr)
00138 {
00139    *ierr = pthread_mutex_destroy(mutex);
00140 }
00141 
00146 
00147 void fpthread_cond_init_(pthread_cond_t *cond, pthread_condattr_t *attr, int *ierr)
00148 { 
00149    *ierr = pthread_cond_init(cond,attr);
00150 }
00151 
00152 void fpthread_cond_signal_(pthread_cond_t *cond,int *ierr)
00153 { 
00154    *ierr = pthread_cond_signal(cond);
00155 }
00156 
00157 void fpthread_cond_broadcast_(pthread_cond_t *cond,int *ierr)
00158 { 
00159    *ierr = pthread_cond_broadcast(cond);
00160 }
00161 
00162 void fpthread_cond_wait_(pthread_cond_t *cond,pthread_mutex_t*mutex,int *ierr)
00163 { 
00164    *ierr = pthread_cond_wait(cond,mutex);
00165 }
00166 
00167 void fpthread_cond_destroy_(pthread_cond_t *cond,int *ierr)
00168 { 
00169    *ierr = pthread_cond_destroy(cond);
00170 }
00171 
00172 
00176 
00177 void fpthread_attr_destroy_(pthread_attr_t *attr, int *ierr)
00178 {
00179   *ierr = pthread_attr_destroy(attr);
00180 }
00181 
00182 void fpthread_attr_init_(pthread_attr_t *attr, int *ierr)
00183 {
00184   *ierr = pthread_attr_init(attr);
00185 }
00186 
00187 void fpthread_attr_getdetachstate_(pthread_attr_t *attr, int *detachstate, int *ierr)
00188 {
00189    *ierr = pthread_attr_getdetachstate(attr, detachstate);
00190 }
00191 
00192 void fpthread_attr_setdetachstate_(pthread_attr_t *attr, int *detachstate, int *ierr)
00193 {
00194   //  printf("%d  %d \n",PTHREAD_SCOPE_SYSTEM, PTHREAD_SCOPE_PROCESS);
00195   *ierr = pthread_attr_setdetachstate(attr, *detachstate);
00196 }
00197 
00198 void fpthread_attr_getstacksize_(pthread_attr_t *attr, size_t *stacksize, int *ierr)
00199 {
00200    *ierr = pthread_attr_getstacksize(attr, stacksize);
00201 }
00202 
00203 void fpthread_attr_setstacksize_(pthread_attr_t *attr, size_t *stacksize, int *ierr)
00204 {
00205   *ierr = pthread_attr_setstacksize(attr, *stacksize);
00206 }
00207 
00208 void fpthread_attr_getstack_(pthread_attr_t *attr, size_t *stackaddr, size_t *stacksize, int *ierr)
00209 {
00210   void * cstackaddr;
00211   *ierr = pthread_attr_getstack(attr, &cstackaddr, stacksize);
00212   *stackaddr = (int *)cstackaddr;
00213 }
00214 
00215 void fpthread_attr_getscope_(pthread_attr_t *attr, int *scope, int *ierr)
00216 {
00217    *ierr = pthread_attr_getscope(attr, scope);
00218 }
00219 
00220 void fpthread_attr_setscope_(pthread_attr_t *attr, int *scope, int *ierr)
00221 {
00222   *ierr = pthread_attr_setscope(attr, *scope);
00223 }
00224 
00225 void fpthread_attr_getschedpolicy_(pthread_attr_t *attr, int *schedpolicy, int *ierr)
00226 {
00227    *ierr = pthread_attr_getschedpolicy(attr, schedpolicy);
00228 }
00229 
00230 void fpthread_attr_setschedpolicy_(pthread_attr_t *attr, int *schedpolicy, int *ierr)
00231 {
00232   *ierr = pthread_attr_setschedpolicy(attr, *schedpolicy);
00233 }
00234 
00235 void fpthread_attr_getschedparam_(pthread_attr_t *attr, struct sched_param *schedparam, int *ierr)
00236 {
00237    *ierr = pthread_attr_getschedparam(attr, schedparam);
00238 }
00239 
00240 void fpthread_attr_setschedparam_(pthread_attr_t *attr, struct sched_param *schedparam, int *ierr)
00241 {
00242   *ierr = pthread_attr_setschedparam(attr, schedparam);
00243 }
00244 
00245 
00246 
00247 //make functions void and tack on return value at end
00248 //duplicate call passing in components just with their names
00249 //Any non-pointer input arguments need to be made to pointers in both the declaration and the pthread call
 All Classes Files Functions Variables