michael@0: // Copyright (c) 2009 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: // This provides a wrapper around system calls which may be interrupted by a michael@0: // signal and return EINTR. See man 7 signal. michael@0: // michael@0: // On Windows, this wrapper macro does nothing. michael@0: michael@0: #ifndef BASE_EINTR_WRAPPER_H_ michael@0: #define BASE_EINTR_WRAPPER_H_ michael@0: michael@0: #include "build/build_config.h" michael@0: michael@0: #if defined(OS_POSIX) michael@0: michael@0: #include michael@0: michael@0: #define HANDLE_EINTR(x) ({ \ michael@0: typeof(x) __eintr_result__; \ michael@0: do { \ michael@0: __eintr_result__ = x; \ michael@0: } while (__eintr_result__ == -1 && errno == EINTR); \ michael@0: __eintr_result__;\ michael@0: }) michael@0: michael@0: #else michael@0: michael@0: #define HANDLE_EINTR(x) x michael@0: michael@0: #endif // OS_POSIX michael@0: michael@0: #endif // !BASE_EINTR_WRAPPER_H_