• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <sys/cdefs.h>
20 #include <unistd.h>
21 
22 /*
23  * Declare this library function as reimplementation.
24  * Prevent circular dependencies, but allow _real_ library to hijack
25  */
26 #if defined(_WIN32)
27 #define LIBLOG_WEAK static /* Accept that it is totally private */
28 #else
29 #define LIBLOG_WEAK extern "C" __attribute__((weak, visibility("default")))
30 #endif
31 
32 /* possible missing definitions in sys/cdefs.h */
33 
34 /* DECLS */
35 #ifndef __BEGIN_DECLS
36 #if defined(__cplusplus)
37 #define __BEGIN_DECLS extern "C" {
38 #define __END_DECLS }
39 #else
40 #define __BEGIN_DECLS
41 #define __END_DECLS
42 #endif
43 #endif
44 
45 /* possible missing definitions in unistd.h */
46 
47 #ifndef TEMP_FAILURE_RETRY
48 /* Used to retry syscalls that can return EINTR. */
49 #define TEMP_FAILURE_RETRY(exp)            \
50   ({                                       \
51     __typeof__(exp) _rc;                   \
52     do {                                   \
53       _rc = (exp);                         \
54     } while (_rc == -1 && errno == EINTR); \
55     _rc;                                   \
56   })
57 #endif
58