| // Licensed to the Apache Software Foundation (ASF) under one |
| // or more contributor license agreements. See the NOTICE file |
| // distributed with this work for additional information |
| // regarding copyright ownership. The ASF licenses this file |
| // to you under the Apache License, Version 2.0 (the |
| // "License"); you may not use this file except in compliance |
| // with the License. You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, |
| // software distributed under the License is distributed on an |
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| // KIND, either express or implied. See the License for the |
| // specific language governing permissions and limitations |
| // under the License. |
| |
| #pragma once |
| |
| namespace doris { |
| |
| // Retry on EINTR for functions like read() that return -1 on error. |
| #define RETRY_ON_EINTR(err, expr) \ |
| do { \ |
| static_assert(std::is_signed_v<decltype(err)>, #err " must be a signed integer"); \ |
| (err) = (expr); \ |
| } while ((err) == -1 && errno == EINTR) |
| |
| // Macro that allows definition of a variable appended with the current line |
| // number in the source file. Typically for use by other macros to allow the |
| // user to declare multiple variables with the same "base" name inside the same |
| // lexical block. |
| #define VARNAME_LINENUM(varname) VARNAME_LINENUM_INTERNAL(varname##_L, __LINE__) |
| #define VARNAME_LINENUM_INTERNAL(v, line) VARNAME_LINENUM_INTERNAL2(v, line) |
| #define VARNAME_LINENUM_INTERNAL2(v, line) v##line |
| |
| } // namespace doris |