/root/doris/be/src/common/macros.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | namespace doris { |
21 | | |
22 | | // Retry on EINTR for functions like read() that return -1 on error. |
23 | | #define RETRY_ON_EINTR(err, expr) \ |
24 | 73.8k | do { \ |
25 | 73.8k | static_assert(std::is_signed_v<decltype(err)>, #err " must be a signed integer"); \ |
26 | 73.8k | (err) = (expr); \ |
27 | 73.8k | } while ((err) == -1 && errno == EINTR) |
28 | | |
29 | | // Macro that allows definition of a variable appended with the current line |
30 | | // number in the source file. Typically for use by other macros to allow the |
31 | | // user to declare multiple variables with the same "base" name inside the same |
32 | | // lexical block. |
33 | 868k | #define VARNAME_LINENUM(varname) VARNAME_LINENUM_INTERNAL(varname##_L, __LINE__) |
34 | 868k | #define VARNAME_LINENUM_INTERNAL(v, line) VARNAME_LINENUM_INTERNAL2(v, line) |
35 | 868k | #define VARNAME_LINENUM_INTERNAL2(v, line) v##line |
36 | | |
37 | | } // namespace doris |