Zero  0.1.0
w_pthread.h
Go to the documentation of this file.
1 /* -*- mode:C++; c-basic-offset:4 -*-
2  Shore-MT -- Multi-threaded port of the SHORE storage manager
3 
4  Copyright (c) 2007-2009
5  Data Intensive Applications and Systems Labaratory (DIAS)
6  Ecole Polytechnique Federale de Lausanne
7 
8  All Rights Reserved.
9 
10  Permission to use, copy, modify and distribute this software and
11  its documentation is hereby granted, provided that both the
12  copyright notice and this permission notice appear in all copies of
13  the software, derivative works or modified versions, and any
14  portions thereof, and that both notices appear in supporting
15  documentation.
16 
17  This code is distributed in the hope that it will be useful, but
18  WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS
20  DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
21  RESULTING FROM THE USE OF THIS SOFTWARE.
22 */
23 
24 // -*- mode:c++; c-basic-offset:4 -*-
25 /*<std-header orig-src='shore' incl-file-exclusion='STHREAD_H'>
26 
27  $Id: w_pthread.h,v 1.1 2010/12/09 15:20:17 nhall Exp $
28 
29 SHORE -- Scalable Heterogeneous Object REpository
30 
31 Copyright (c) 1994-99 Computer Sciences Department, University of
32  Wisconsin -- Madison
33 All Rights Reserved.
34 
35 Permission to use, copy, modify and distribute this software and its
36 documentation is hereby granted, provided that both the copyright
37 notice and this permission notice appear in all copies of the
38 software, derivative works or modified versions, and any portions
39 thereof, and that both notices appear in supporting documentation.
40 
41 THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY
42 OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS
43 "AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND
44 FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 
46 This software was developed with support by the Advanced Research
47 Project Agency, ARPA order number 018 (formerly 8230), monitored by
48 the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518.
49 Further funding for this work was provided by DARPA through
50 Rome Research Laboratory Contract No. F30602-97-2-0247.
51 
52 */
53 
54 /* -- do not edit anything above this line -- </std-header>*/
55 
56 #ifndef __W_PTHREAD_H
57 #define __W_PTHREAD_H
58 
59 #include <pthread.h>
60 #include <cstring>
61 #include <sstream>
62 
63 #define DO_PTHREAD_BARRIER(x) \
64 { int res = x; \
65  if(res && res != PTHREAD_BARRIER_SERIAL_THREAD) { \
66  std::stringstream S; \
67  S << "Unexpected result from " << #x << " " << res << " "; \
68  char buf[100]; \
69  (void) strerror_r(res, &buf[0], sizeof(buf)); \
70  S << buf << ends; \
71  W_FATAL_MSG(fcINTERNAL, << S.str()); \
72  } \
73 }
74 #define DO_PTHREAD(x) \
75 { int res = x; \
76  if(res) { \
77  std::stringstream S; \
78  S << "Unexpected result from " << #x << " " << res << " "; \
79  char buf[100]; \
80  void * xxrs; \
81  xxrs = (void *) strerror_r(res, &buf[0], sizeof(buf)); \
82  (void) xxrs; \
83  S << buf << ends; \
84  W_FATAL_MSG(fcINTERNAL, << S.str()); \
85  } \
86 }
87 #define DO_PTHREAD_TIMED(x) \
88 { int res = x; \
89  if(res && res != ETIMEDOUT) { \
90  W_FATAL_MSG(fcINTERNAL, \
91  <<"Unexpected result from " << #x << " " << res); \
92  } \
93 }
94 
95 #endif // __W_PTHREAD_H /*</std-footer>*/