From 0a308f035c0c6da6b7c1b8bae7b44d84586863e6 Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Sun, 26 Jul 2009 19:47:05 +0000 Subject: [PATCH] more header cleaning; updated INSTALL --- INSTALL | 6 +-- src/stasis/bufferManager.c | 5 --- src/stasis/bufferManager/legacy/pageCache.c | 21 ++++----- src/stasis/common.c | 50 ++++++++++----------- src/stasis/io/pfile.c | 16 ++----- src/stasis/logger/groupForce.c | 3 -- src/stasis/logger/logEntry.c | 9 ++-- src/stasis/logger/logger2.c | 6 --- src/stasis/operations.c | 25 +++++------ src/stasis/operations/arrayList.c | 2 - src/stasis/operations/regions.c | 2 +- src/stasis/page/slotted.c | 1 - src/stasis/recovery2.c | 10 ++--- src/stasis/stats.c | 1 - src/stasis/transactional2.c | 3 -- stasis/common.h | 6 --- test/dfa/ping_pong_dfa.c | 3 -- test/stasis/check_multiplexer.c | 7 +-- 18 files changed, 60 insertions(+), 116 deletions(-) diff --git a/INSTALL b/INSTALL index 3526ad5..b295be5 100644 --- a/INSTALL +++ b/INSTALL @@ -1,10 +1,10 @@ Prerequisites (ubuntu/debian): - autoconf build-essential cmake + build-essential cmake Recommended build procedure: - ./bootstrap ; mkdir build ; cd build ; cmake .. + mkdir build ; cd build ; cmake .. make -j 4 cd test ; make test @@ -19,7 +19,7 @@ Optional dependencies: Obsolete build procedure ========================= -(Uses automake and libtool) +(Uses autoconf, automake and libtool) ./reconf ; ./configure --quiet make -j 4 diff --git a/src/stasis/bufferManager.c b/src/stasis/bufferManager.c index b7eb1d2..4645dca 100644 --- a/src/stasis/bufferManager.c +++ b/src/stasis/bufferManager.c @@ -44,13 +44,8 @@ terms specified in this license. * * implementation of the page buffer * *************************************************/ - -#include - #ifdef PROFILE_LATCHES_WRITE_ONLY - - #define _GNU_SOURCE #include // Need _GNU_SOURCE for asprintf #include diff --git a/src/stasis/bufferManager/legacy/pageCache.c b/src/stasis/bufferManager/legacy/pageCache.c index 47f474d..ef2e528 100644 --- a/src/stasis/bufferManager/legacy/pageCache.c +++ b/src/stasis/bufferManager/legacy/pageCache.c @@ -5,13 +5,10 @@ allows bufferManager's implementation to focus on providing atomic writes, and locking. */ -#include #include #include - #include - #include #include @@ -57,7 +54,7 @@ static void headInsert(Page *ret) { } static void middleInsert(Page *ret) { - + assert(cache_state == FULL); /* assert( bufferSize == MAX_BUFFER_SIZE ); */ @@ -82,7 +79,7 @@ static void qRemove(Page *ret) { assert(cache_state == FULL); assert(ret->next != ret && ret->prev != ret); - + if( ret->prev ) ret->prev->next = ret->next; else /* is head */ @@ -90,7 +87,7 @@ static void qRemove(Page *ret) { if( ret->next ) { ret->next->prev = ret->prev; /* TODO: these if can be better organizeed for speed */ - if( ret == repMiddle ) + if( ret == repMiddle ) /* select new middle */ repMiddle = ret->next; } @@ -112,12 +109,12 @@ void cacheInsertPage (Page * ret) { if(bufferSize == MAX_BUFFER_SIZE/* - 1*/) { /* Set up page kick mechanism. */ int i; Page *iter; - + cache_state = FULL; - + headInsert(ret); assert(ret->next != ret && ret->prev != ret); - + /* split up queue: * "in all cases studied ... fixing the primary region to 30% ... * resulted in the best performance" @@ -127,7 +124,7 @@ void cacheInsertPage (Page * ret) { repMiddle->queue = 1; repMiddle = repMiddle->next; } - + for( iter = repMiddle; iter; iter = iter->next ) { iter->queue = 2; } @@ -154,12 +151,12 @@ void cacheHitOnPage(Page * ret) { qRemove(ret); headInsert(ret); assert(ret->next != ret && ret->prev != ret); - + if( ret->queue == 2 ) { /* keep first queue same size */ repMiddle = repMiddle->prev; repMiddle->queue = 2; - + ret->queue = 1; } } diff --git a/src/stasis/common.c b/src/stasis/common.c index a7014c6..9026edd 100644 --- a/src/stasis/common.c +++ b/src/stasis/common.c @@ -1,12 +1,10 @@ #define _GNU_SOURCE -#include #include #include #include -#include #include #undef pthread_mutex_t @@ -20,15 +18,15 @@ /* -int __lladd_pthread_mutex_init(lladd_pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr, +int __lladd_pthread_mutex_init(lladd_pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr, const char * file, int line, const char * name) { - + mutex->file = file; mutex->line = line; mutex->name = name; init_tuple(&(mutex->tup)); - + mutex->lockpoints = pblHtCreate(); return pthread_mutex_init(&(mutex->mutex), mutexattr); @@ -47,14 +45,14 @@ int __lladd_pthread_mutex_lock(lladd_pthread_mutex_t *mutex, char * file, int li while(EBUSY == (ret = pthread_mutex_trylock(&(mutex->mutex)))) { blockCount ++; pthread_yield(); - + if(blockCount >= 30000 && ! (blockCount % 30000)) { printf("Spinning at %s:%d, %ld times. Held by: %s\n", file, line, blockCount, mutex->last_acquired_at); fflush(NULL); } } - + profile_tuple * tup = pblHtLookup(mutex->lockpoints, location, location_length+1); @@ -62,9 +60,9 @@ int __lladd_pthread_mutex_lock(lladd_pthread_mutex_t *mutex, char * file, int li if(!tup) { tup = malloc(sizeof(profile_tuple)); - + init_tuple(tup); - + pblHtInsert(mutex->lockpoints, location, location_length+1, tup); } @@ -89,18 +87,18 @@ int __lladd_pthread_mutex_unlock(lladd_pthread_mutex_t *mutex) { } int __lladd_pthread_mutex_destroy(lladd_pthread_mutex_t *mutex) { - // Dump profiling info to stdout + // Dump profiling info to stdout profile_tuple * tup; - printf("Free mutex %s Init: %s %d\n ", mutex->name, mutex->file, mutex->line); + printf("Free mutex %s Init: %s %d\n ", mutex->name, mutex->file, mutex->line); print_profile_tuple(&(mutex->tup)); printf("\n Lock points: [mean, stddev, max] \n"); - // Now, iterate over all of the lockpoints: + // Now, iterate over all of the lockpoints: for(tup = pblHtFirst(mutex->lockpoints); tup; tup = pblHtNext(mutex->lockpoints)) { - printf("\t%s ", (char*)pblHtCurrentKey(mutex->lockpoints)); + printf("\t%s ", (char*)pblHtCurrentKey(mutex->lockpoints)); print_profile_tuple(tup); printf("\n"); free(tup); @@ -113,12 +111,12 @@ int __lladd_pthread_mutex_destroy(lladd_pthread_mutex_t *mutex) { } -// @todo The profiled version of pthread_cond_wait isn't really implemented, so it throws off the mutex statistics. -int __lladd_pthread_cond_wait(pthread_cond_t *cond, lladd_pthread_mutex_t *mutex, +// @todo The profiled version of pthread_cond_wait isn't really implemented, so it throws off the mutex statistics. +int __lladd_pthread_cond_wait(pthread_cond_t *cond, lladd_pthread_mutex_t *mutex, char * file, int line, char * cond_name, char * mutex_name) { int ret; char * location; - int location_length; + int location_length; profile_tuple * tup = pblHtLookup(mutex->lockpoints, mutex->last_acquired_at, strlen(mutex->last_acquired_at)+1); @@ -137,9 +135,9 @@ int __lladd_pthread_cond_wait(pthread_cond_t *cond, lladd_pthread_mutex_t *mutex if(!tup) { tup = malloc(sizeof(profile_tuple)); - + init_tuple(tup); - + pblHtInsert(mutex->lockpoints, location, location_length+1, tup); } @@ -176,7 +174,7 @@ __profile_rwl *__profile_rw_initlock (char * file, int line) { init_tuple(&(ret->tup)); ret->lockpoints = pblHtCreate(); - + ret->lock = initlock(); ret->holder = 0; ret->readCount = 0; @@ -286,7 +284,7 @@ void __profile_readunlock (__profile_rwl *lock) { pthread_t self = pthread_self(); assert(lock->holder == self); lock->readCount--; - if(!lock->readCount) { + if(!lock->readCount) { lock->holder = 0; free(lock->last_acquired_at); // last_acquired_at gets leaked by readunlock. writeunlock(lock->lock); @@ -310,7 +308,7 @@ void __profile_writeunlock (__profile_rwl *lock) { void __profile_unlock (__profile_rwl * lock) { #ifdef PROFILE_LATCHES_WRITE_ONLY - if(!lock->readCount) { + if(!lock->readCount) { #else if(lock->lock->writers) { #endif @@ -339,18 +337,18 @@ void __profile_deletelock (__profile_rwl *lock) { printf("Free rwl init: %s %d\t ", lock->file, lock->line); print_profile_tuple(&(lock->tup)); printf("\n"); - printf("Lock points: [mean, stddev, max] \n"); - + printf("Lock points: [mean, stddev, max] \n"); + for(tup = pblHtFirst(lock->lockpoints); tup; tup = pblHtNext(lock->lockpoints)) { - printf("\t%s ", (char*)pblHtCurrentKey(lock->lockpoints)); + printf("\t%s ", (char*)pblHtCurrentKey(lock->lockpoints)); print_profile_tuple(tup); printf("\n"); free(tup); - } + } #else for(tup = pblHtFirst(lock->lockpoints); tup; tup = pblHtNext(lock->lockpoints)) { free(tup); - } + } #endif pblHtDelete(lock->lockpoints); diff --git a/src/stasis/io/pfile.c b/src/stasis/io/pfile.c index 5e83fcc..42d902f 100644 --- a/src/stasis/io/pfile.c +++ b/src/stasis/io/pfile.c @@ -1,18 +1,10 @@ #include -#define _XOPEN_SOURCE 500 -#include -#include -#include -#include -#include -#include -#include - - -#include #include -#include + +#include +#include +#include /** @file diff --git a/src/stasis/logger/groupForce.c b/src/stasis/logger/groupForce.c index ed61352..1d4f41d 100644 --- a/src/stasis/logger/groupForce.c +++ b/src/stasis/logger/groupForce.c @@ -4,9 +4,6 @@ * Created on: May 12, 2009 * Author: sears */ - -#include -#include #include #include diff --git a/src/stasis/logger/logEntry.c b/src/stasis/logger/logEntry.c index f90122b..5c16ee4 100644 --- a/src/stasis/logger/logEntry.c +++ b/src/stasis/logger/logEntry.c @@ -39,16 +39,13 @@ authors grant the U.S. Government and others acting in its behalf permission to use and distribute the software in accordance with the terms specified in this license. ---*/ - -#include -#include - -#include - #include // For stasis_record_type_to_size() #include // needed for LoggerSizeOfInternalLogEntry() #include #include + +#include + LogEntry * allocCommonLogEntry(lsn_t prevLSN, int xid, unsigned int type) { LogEntry * ret = calloc(1,sizeof(struct __raw_log_entry)); ret->LSN = -1; diff --git a/src/stasis/logger/logger2.c b/src/stasis/logger/logger2.c index 9274c1e..0e0b2c2 100644 --- a/src/stasis/logger/logger2.c +++ b/src/stasis/logger/logger2.c @@ -45,13 +45,7 @@ terms specified in this license. Abstract log implementation. Provides access to methods that directly read and write log entries, force the log to disk, etc. - - @todo Switch logger2 to use function pointers */ - -#include -#include - #include #include diff --git a/src/stasis/operations.c b/src/stasis/operations.c index d87acdc..eae5949 100644 --- a/src/stasis/operations.c +++ b/src/stasis/operations.c @@ -3,7 +3,7 @@ This software is copyrighted by the Regents of the University of California, and other parties. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files. - + The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies @@ -13,20 +13,20 @@ authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply. - + IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - + GOVERNMENT USE: If you are acquiring this software on behalf of the U.S. government, the Government shall have only "Restricted Rights" in the software and related documentation as defined in the Federal @@ -39,15 +39,12 @@ authors grant the U.S. Government and others acting in its behalf permission to use and distribute the software in accordance with the terms specified in this license. ---*/ -#include -#include - -#include - #include #include #include +#include + static stasis_operation_impl stasis_operation_table[MAX_OPERATIONS]; void stasis_operation_impl_register(stasis_operation_impl o) { @@ -86,18 +83,18 @@ void stasis_operation_table_init() { // placeholder stasis_operation_impl_register(stasis_op_impl_dealloc()); stasis_operation_impl_register(stasis_op_impl_realloc()); - + stasis_operation_impl_register(stasis_op_impl_page_set_range()); stasis_operation_impl_register(stasis_op_impl_page_set_range_inverse()); - + stasis_operation_impl_register(stasis_op_impl_noop()); - + stasis_operation_impl_register(stasis_op_impl_array_list_header_init()); stasis_operation_impl_register(stasis_op_impl_page_initialize()); - + stasis_operation_impl_register(stasis_op_impl_set_range()); stasis_operation_impl_register(stasis_op_impl_set_range_inverse()); - + stasis_operation_impl_register(stasis_op_impl_linked_list_insert()); stasis_operation_impl_register(stasis_op_impl_linked_list_remove()); diff --git a/src/stasis/operations/arrayList.c b/src/stasis/operations/arrayList.c index 5f0e626..4955ed8 100644 --- a/src/stasis/operations/arrayList.c +++ b/src/stasis/operations/arrayList.c @@ -1,5 +1,3 @@ -#include - #include #include diff --git a/src/stasis/operations/regions.c b/src/stasis/operations/regions.c index 54e420c..11a90b2 100644 --- a/src/stasis/operations/regions.c +++ b/src/stasis/operations/regions.c @@ -1,7 +1,7 @@ -#include "config.h" #include #include #include + #include typedef struct regionAllocLogArg{ diff --git a/src/stasis/page/slotted.c b/src/stasis/page/slotted.c index 74c3514..2971626 100644 --- a/src/stasis/page/slotted.c +++ b/src/stasis/page/slotted.c @@ -1,4 +1,3 @@ -#include "config.h" #include #include //#include diff --git a/src/stasis/recovery2.c b/src/stasis/recovery2.c index 93b48ea..d49273f 100644 --- a/src/stasis/recovery2.c +++ b/src/stasis/recovery2.c @@ -5,13 +5,6 @@ Implements three phase recovery */ - -#include -#include - -#include -#include - #include #include @@ -26,6 +19,9 @@ #include #include // Needed for pageReadLSN. +#include +#include + static pblHashTable_t * transactionLSN; static LinkedList * rollbackLSNs = NULL; /** @todo There is no real reason to have this mutex (which prevents diff --git a/src/stasis/stats.c b/src/stasis/stats.c index bf43471..5bcdfd6 100644 --- a/src/stasis/stats.c +++ b/src/stasis/stats.c @@ -1,4 +1,3 @@ -#include #include #include diff --git a/src/stasis/transactional2.c b/src/stasis/transactional2.c index d0ca1ee..70d2f02 100644 --- a/src/stasis/transactional2.c +++ b/src/stasis/transactional2.c @@ -1,6 +1,3 @@ -#include - -#include #include #include #include diff --git a/stasis/common.h b/stasis/common.h index 9ce70e3..fe416af 100644 --- a/stasis/common.h +++ b/stasis/common.h @@ -122,10 +122,6 @@ typedef int16_t pagetype_t; /*#define PROFILE_LATCHES*/ /*#define NO_LATCHES */ -#if _POSIX_C_SOURCE >= 199309L || _XOPEN_SOURCE >= 500 -#define HAVE_FDATASYNC -#endif - #ifdef DEBUGGING /** @todo Files that use DEBUG have to pull in stdio.h, which is a pain! */ #define DEBUG(...) \ @@ -162,8 +158,6 @@ typedef struct { */ typedef struct Page_s Page; - - #include "compensations.h" #endif /* __stasis_common_h */ diff --git a/test/dfa/ping_pong_dfa.c b/test/dfa/ping_pong_dfa.c index 23b1936..a664138 100644 --- a/test/dfa/ping_pong_dfa.c +++ b/test/dfa/ping_pong_dfa.c @@ -39,9 +39,6 @@ authors grant the U.S. Government and others acting in its behalf permission to use and distribute the software in accordance with the terms specified in this license. ---*/ - -#include - #include "../check_includes.h" #include #include diff --git a/test/stasis/check_multiplexer.c b/test/stasis/check_multiplexer.c index 8b1d188..cc3f437 100644 --- a/test/stasis/check_multiplexer.c +++ b/test/stasis/check_multiplexer.c @@ -46,14 +46,11 @@ terms specified in this license. #include #include -#include -#include -#include -#include - #include #include +#include + #define LOG_NAME "check_iterator.log" #define NUM_BYTES_IN_FIFO 1000