diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-14 20:54:35 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-14 20:54:35 +0000 |
commit | 2025d00c3fa5270a0ea10c9ec7a18cfa69007beb (patch) | |
tree | 34930235824be79a141351d1b40fa4faeef0e2a6 /base/posix | |
parent | a462eb604b7976fc6e264cca846a9c92e34254c5 (diff) | |
download | chromium_src-2025d00c3fa5270a0ea10c9ec7a18cfa69007beb.zip chromium_src-2025d00c3fa5270a0ea10c9ec7a18cfa69007beb.tar.gz chromium_src-2025d00c3fa5270a0ea10c9ec7a18cfa69007beb.tar.bz2 |
Move eintr_wrapper.h from base to base/posix
Review URL: https://codereview.chromium.org/11366229
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/posix')
-rw-r--r-- | base/posix/eintr_wrapper.h | 33 | ||||
-rw-r--r-- | base/posix/file_descriptor_shuffle.cc | 2 | ||||
-rw-r--r-- | base/posix/unix_domain_socket.cc | 2 |
3 files changed, 35 insertions, 2 deletions
diff --git a/base/posix/eintr_wrapper.h b/base/posix/eintr_wrapper.h new file mode 100644 index 0000000..1f3b59a --- /dev/null +++ b/base/posix/eintr_wrapper.h @@ -0,0 +1,33 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This provides a wrapper around system calls which may be interrupted by a +// signal and return EINTR. See man 7 signal. +// +// On Windows, this wrapper macro does nothing. + +#ifndef BASE_POSIX_EINTR_WRAPPER_H_ +#define BASE_POSIX_EINTR_WRAPPER_H_ + +#include "build/build_config.h" + +#if defined(OS_POSIX) + +#include <errno.h> + +#define HANDLE_EINTR(x) ({ \ + typeof(x) __eintr_result__; \ + do { \ + __eintr_result__ = (x); \ + } while (__eintr_result__ == -1 && errno == EINTR); \ + __eintr_result__;\ +}) + +#else + +#define HANDLE_EINTR(x) (x) + +#endif // OS_POSIX + +#endif // BASE_POSIX_EINTR_WRAPPER_H_ diff --git a/base/posix/file_descriptor_shuffle.cc b/base/posix/file_descriptor_shuffle.cc index 0dde958..b5b7339 100644 --- a/base/posix/file_descriptor_shuffle.cc +++ b/base/posix/file_descriptor_shuffle.cc @@ -8,7 +8,7 @@ #include <stddef.h> #include <ostream> -#include "base/eintr_wrapper.h" +#include "base/posix/eintr_wrapper.h" #include "base/logging.h" namespace base { diff --git a/base/posix/unix_domain_socket.cc b/base/posix/unix_domain_socket.cc index bd11292..730657d 100644 --- a/base/posix/unix_domain_socket.cc +++ b/base/posix/unix_domain_socket.cc @@ -9,9 +9,9 @@ #include <sys/uio.h> #include <sys/socket.h> -#include "base/eintr_wrapper.h" #include "base/logging.h" #include "base/pickle.h" +#include "base/posix/eintr_wrapper.h" #include "base/stl_util.h" const size_t UnixDomainSocket::kMaxFileDescriptors = 16; |