00001 /* -*- mode:C++; c-basic-offset:4 -*- 00002 Shore-MT -- Multi-threaded port of the SHORE storage manager 00003 00004 Copyright (c) 2007-2009 00005 Data Intensive Applications and Systems Labaratory (DIAS) 00006 Ecole Polytechnique Federale de Lausanne 00007 00008 All Rights Reserved. 00009 00010 Permission to use, copy, modify and distribute this software and 00011 its documentation is hereby granted, provided that both the 00012 copyright notice and this permission notice appear in all copies of 00013 the software, derivative works or modified versions, and any 00014 portions thereof, and that both notices appear in supporting 00015 documentation. 00016 00017 This code is distributed in the hope that it will be useful, but 00018 WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS 00020 DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER 00021 RESULTING FROM THE USE OF THIS SOFTWARE. 00022 */ 00023 00024 // -*- mode:c++; c-basic-offset:4 -*- 00025 /*<std-header orig-src='shore' incl-file-exclusion='STHREAD_H'> 00026 00027 $Id: w_pthread.h,v 1.1 2010/12/09 15:20:17 nhall Exp $ 00028 00029 SHORE -- Scalable Heterogeneous Object REpository 00030 00031 Copyright (c) 1994-99 Computer Sciences Department, University of 00032 Wisconsin -- Madison 00033 All Rights Reserved. 00034 00035 Permission to use, copy, modify and distribute this software and its 00036 documentation is hereby granted, provided that both the copyright 00037 notice and this permission notice appear in all copies of the 00038 software, derivative works or modified versions, and any portions 00039 thereof, and that both notices appear in supporting documentation. 00040 00041 THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY 00042 OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS 00043 "AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND 00044 FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 00045 00046 This software was developed with support by the Advanced Research 00047 Project Agency, ARPA order number 018 (formerly 8230), monitored by 00048 the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518. 00049 Further funding for this work was provided by DARPA through 00050 Rome Research Laboratory Contract No. F30602-97-2-0247. 00051 00052 */ 00053 00054 /* -- do not edit anything above this line -- </std-header>*/ 00055 00056 #ifndef W_PTHREAD_H 00057 #define W_PTHREAD_H 00058 00059 #include <pthread.h> 00060 #include <w_strstream.h> 00061 #include <string.h> 00062 00063 #define DO_PTHREAD_BARRIER(x) \ 00064 { int res = x; \ 00065 if(res && res != PTHREAD_BARRIER_SERIAL_THREAD) { \ 00066 w_ostrstream S; \ 00067 S << "Unexpected result from " << #x << " " << res << " "; \ 00068 char buf[100]; \ 00069 (void) strerror_r(res, &buf[0], sizeof(buf)); \ 00070 S << buf << ends; \ 00071 W_FATAL_MSG(fcINTERNAL, << S.c_str()); \ 00072 } \ 00073 } 00074 #define DO_PTHREAD(x) \ 00075 { int res = x; \ 00076 if(res) { \ 00077 w_ostrstream S; \ 00078 S << "Unexpected result from " << #x << " " << res << " "; \ 00079 char buf[100]; \ 00080 (void) strerror_r(res, &buf[0], sizeof(buf)); \ 00081 S << buf << ends; \ 00082 W_FATAL_MSG(fcINTERNAL, << S.c_str()); \ 00083 } \ 00084 } 00085 #define DO_PTHREAD_TIMED(x) \ 00086 { int res = x; \ 00087 if(res && res != ETIMEDOUT) { \ 00088 W_FATAL_MSG(fcINTERNAL, \ 00089 <<"Unexpected result from " << #x << " " << res); \ 00090 } \ 00091 } 00092 00093 #endif /*</std-footer>*/