Anonymous avatar Anonymous committed e4e0412

Removed trailing whitespace from the C code.

Comments (0)

Files changed (5)

 /*
  * queue.c
- * 
+ *
  * This module implements a queue
  *
  * */
 {
     pthread_rwlock_fcfs_queue_item_t * ret;
     void * void_ret;
-    
+
     /* If there are no messages present in the queue */
     if (queue->head == NULL)
     {
         return NULL;
     }
-    
+
     /* Retrieve the first element */
     ret = queue->head;
     /* Remove it from the list */
 
     void_ret = ret->data;
     free(ret);
-    
+
     return void_ret;
 }
 
 {
     pthread_rwlock_fcfs_queue_item_t * ret;
     void * void_ret;
-    
+
     /* If there are no messages present in the queue */
     if (queue->head == NULL)
     {
         return NULL;
     }
-    
+
     /* Retrieve the first element */
     ret = queue->head;
 
     void_ret = ret->data;
-    
+
     return void_ret;
 }
 
     msg_with_next->data = msg;
 
     if (queue->tail == NULL)
-    {                
+    {
         queue->head = queue->tail = msg_with_next;
         msg_with_next->next = NULL;
     }
 {
     pthread_rwlock_fcfs_queue_item_t * ret;
     void * void_ret;
-    
+
     /* If there are no messages present in the queue */
     if (queue->tail == NULL)
     {
         return NULL;
     }
-    
+
     /* Retrieve the first element */
     ret = queue->tail;
 
     void_ret = ret->data;
-    
+
     return void_ret;
 }
 

pthreads/rwlock.c

     void * context
     )
 {
-    /* If the rwlock is going to be destroyed - exit now. 
+    /* If the rwlock is going to be destroyed - exit now.
      * An exception is if we are gaining write access to clear up all
      * existing threads.
      * */
 
     /* Now - destroy the lock. */
     pthread_rwlock_fcfs_queue_destroy(rwlock->queue);
-    
+
     free(rwlock);
 
     return;

pthreads/rwlock_fcfs.h

 #include <pthread/rwlock_fcfs_queue.h>
 
 /* This is the struct that is pointed to by the elements of the queue of
- * the FCFS RWLock 
+ * the FCFS RWLock
  * */
 struct pthread_rwlock_fcfs_item_struct
 {
 #define PTHREAD_RWLOCK_FCFS_DEBUG_ARGS , char * id
 #define PTHREAD_RWLOCK_FCFS_DEBUG_CALL_ARGS , id
 #else
-#define PTHREAD_RWLOCK_FCFS_DEBUG_ARGS 
-#define PTHREAD_RWLOCK_FCFS_DEBUG_CALL_ARGS 
+#define PTHREAD_RWLOCK_FCFS_DEBUG_ARGS
+#define PTHREAD_RWLOCK_FCFS_DEBUG_CALL_ARGS
 #endif
 
-/* 
+/*
  * Allocate a new FCFS RWLock
  * */
 extern pthread_rwlock_fcfs_t * pthread_rwlock_fcfs_alloc(void);
  * */
 extern void pthread_rwlock_fcfs_release(pthread_rwlock_fcfs_t * rwlock PTHREAD_RWLOCK_FCFS_DEBUG_ARGS);
 
-/* 
+/*
  * Destroy the RWLock
  * */
 extern void pthread_rwlock_fcfs_destroy(pthread_rwlock_fcfs_t * rwlock);
 
 /*
- * Wait until a certain time (abstime) to get a read access. If it is 
- * not given, continue_callback is called and asks whether to continue 
- * or not. 
- * 
+ * Wait until a certain time (abstime) to get a read access. If it is
+ * not given, continue_callback is called and asks whether to continue
+ * or not.
+ *
  * If it wishes to continue, it is responsible for setting the new abstime.
  *
  * context is the context variable for continue_callback
- * 
+ *
  * */
 extern int pthread_rwlock_fcfs_timed_gain_read(
         pthread_rwlock_fcfs_t * rwlock,
         );
 
 /*
- * Wait until a certain time (abstime) to get a write access. If it is not 
- * given, continue_callback is called and asks whether to continue or not. 
- * 
+ * Wait until a certain time (abstime) to get a write access. If it is not
+ * given, continue_callback is called and asks whether to continue or not.
+ *
  * If it wishes to continue, it is responsible for setting the new abstime.
  *
  * context is the context variable for continue_callback
- * 
+ *
  * */
 extern int pthread_rwlock_fcfs_timed_gain_write(
         pthread_rwlock_fcfs_t * rwlock,
         PTHREAD_RWLOCK_FCFS_DEBUG_ARGS
         );
 
-/* 
+/*
  * Attempt to gain a read access. If it is not given immidiately it returns an
  * error code other than 0.
  *
 extern int pthread_rwlock_fcfs_try_gain_read(pthread_rwlock_fcfs_t * rwlock PTHREAD_RWLOCK_FCFS_DEBUG_ARGS);
 
 
-/* 
+/*
  * Attempt to gain a write access. If it is not given immidiately it returns an
  * error code other than 0.
  *
  * */
 extern int pthread_rwlock_fcfs_try_gain_write(pthread_rwlock_fcfs_t * rwlock PTHREAD_RWLOCK_FCFS_DEBUG_ARGS);
 
-    
+
 #endif /* #ifndef __PTHREAD_RWLOCK_FCFS_H */
 
 

pthreads/rwlock_fcfs_queue.h

 }
 #endif
 
-#endif /* #ifndef __PTHREAD_RWLOCK_FCFS_QUEUE_H */ 
+#endif /* #ifndef __PTHREAD_RWLOCK_FCFS_QUEUE_H */
 

pthreads/test_rwlock.c

 
 #include <pthread/rwlock_fcfs.h>
 
-static const pthread_mutex_t initial_mutex_constant = 
+static const pthread_mutex_t initial_mutex_constant =
     PTHREAD_MUTEX_INITIALIZER
     ;
 
             struct timespec timeout;
             struct timezone tz;
             int ret;
-            
+
             gettimeofday(&now, &tz);
             timeout.tv_nsec = (now.tv_usec + (rand()%1000000));
             if (timeout.tv_nsec > 1000000)
                 timeout.tv_sec += timeout.tv_nsec / 1000000;
                 timeout.tv_nsec %= 1000000;
             }
-            
+
             timeout.tv_nsec *= 1000;
             ret = pthread_rwlock_fcfs_timed_gain_read(
                 mylock,
             if (ret == 0)
             {
                 pthread_rwlock_fcfs_release(mylock PTHREAD_RWLOCK_FCFS_DEBUG_CALL_ARGS);
-            } 
+            }
 
             usleep(rand()%1000000);
             fflush(stdout);
             int ret;
             ret = pthread_rwlock_fcfs_try_gain_read(mylock PTHREAD_RWLOCK_FCFS_DEBUG_CALL_ARGS);
 
-            usleep(rand()%1000000);            
+            usleep(rand()%1000000);
 
             if (ret == 0)
             {
 
     pthread_mutex_lock(&num_active_mutex);
     num_active_threads--;
-    pthread_mutex_unlock(&num_active_mutex);  
+    pthread_mutex_unlock(&num_active_mutex);
 
     return NULL;
 }
             struct timespec timeout;
             struct timezone tz;
             int ret;
-            
+
             gettimeofday(&now, &tz);
             timeout.tv_nsec = (now.tv_usec + (rand()%1000000));
             if (timeout.tv_nsec > 1000000)
                 timeout.tv_sec += timeout.tv_nsec / 1000000;
                 timeout.tv_nsec %= 1000000;
             }
-            
+
             timeout.tv_nsec *= 1000;
             ret = pthread_rwlock_fcfs_timed_gain_write(
                 mylock,
             if (ret == 0)
             {
                 pthread_rwlock_fcfs_release(mylock PTHREAD_RWLOCK_FCFS_DEBUG_CALL_ARGS);
-            } 
+            }
 
             usleep(rand()%1000000);
             fflush(stdout);
             int ret;
             ret = pthread_rwlock_fcfs_try_gain_write(mylock PTHREAD_RWLOCK_FCFS_DEBUG_CALL_ARGS);
 
-            usleep(rand()%1000000);            
+            usleep(rand()%1000000);
 
             if (ret == 0)
             {
 
     pthread_mutex_lock(&num_active_mutex);
     num_active_threads--;
-    pthread_mutex_unlock(&num_active_mutex);  
+    pthread_mutex_unlock(&num_active_mutex);
 
     return NULL;
 }
             reader_thread,
             context
             );
-        
+
         if (check != 0)
         {
             fprintf(stderr, "Could not create Reader #%i!\n", a);
             writer_thread,
             context
             );
-        
+
         if (check != 0)
         {
             fprintf(stderr, "Could not create Writer #%i!\n", a);
         int local_num_active = 1;
         sleep(timeout);
         stop = 1;
-        
+
         while (local_num_active)
         {
             usleep(500);
     {
         pthread_join(writers[a], NULL);
     }
-    
+
 
     free(readers);
     free(writers);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.