33 lines
849 B
C
33 lines
849 B
C
// Copyright 2014 The ChromiumOS Authors
|
|
// 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.
|
|
|
|
#ifndef GESTURES_EINTR_WRAPPER_H_
|
|
#define GESTURES_EINTR_WRAPPER_H_
|
|
|
|
#include <errno.h>
|
|
|
|
#define HANDLE_EINTR(x) ({ \
|
|
typeof(x) eintr_wrapper_result; \
|
|
do { \
|
|
eintr_wrapper_result = (x); \
|
|
} while (eintr_wrapper_result == -1 && errno == EINTR); \
|
|
eintr_wrapper_result; \
|
|
})
|
|
|
|
#define IGNORE_EINTR(x) ({ \
|
|
typeof(x) eintr_wrapper_result; \
|
|
do { \
|
|
eintr_wrapper_result = (x); \
|
|
if (eintr_wrapper_result == -1 && errno == EINTR) { \
|
|
eintr_wrapper_result = 0; \
|
|
} \
|
|
} while (0); \
|
|
eintr_wrapper_result; \
|
|
})
|
|
|
|
#endif // GESTURES_EINTR_WRAPPER_H_
|