|
| 1 | +/* |
| 2 | + * This program is free software; you can redistribute it and/or modify |
| 3 | + * it under the terms of the GNU General Public License as published by |
| 4 | + * the Free Software Foundation; either version 2 of the License, or |
| 5 | + * (at your option) any later version. |
| 6 | + * |
| 7 | + * This program is distributed in the hope that it will be useful, |
| 8 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | + * GNU Library General Public License for more details. |
| 11 | + * |
| 12 | + * You should have received a copy of the GNU General Public License |
| 13 | + * along with this program; if not, write to the Free Software |
| 14 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 15 | + * |
| 16 | + * Strerror_r.cpp |
| 17 | + * Definition of strerror_r that is XSI-compliant. |
| 18 | + * Copyright (C) 2018 Shenghao Yang |
| 19 | + */ |
| 20 | + |
| 21 | +#if HAVE_CONFIG_H |
| 22 | +#include <config.h> |
| 23 | +#endif // HAVE_CONFIG_H |
| 24 | + |
| 25 | +// Required for string.h to declare the standards-compliant version of |
| 26 | +// strerror_r(), when compiling under glibc. Must come before the inclusion |
| 27 | +// of string.h. |
| 28 | +// These are conditional to avoid errors when not compiling with glibc, or |
| 29 | +// when compiling with a compiler that does not define _POSIX_C_SOURCE. |
| 30 | +#ifdef _GNU_SOURCE |
| 31 | +#undef _GNU_SOURCE |
| 32 | +#endif |
| 33 | + |
| 34 | +#ifdef _POSIX_C_SOURCE |
| 35 | +#undef _POSIX_C_SOURCE |
| 36 | +#endif |
| 37 | +#define _POSIX_C_SOURCE 200112L |
| 38 | + |
| 39 | +#include <string.h> |
| 40 | + |
| 41 | +#include "olad/Strerror_r.h" |
| 42 | + |
| 43 | +namespace ola { |
| 44 | + |
| 45 | +int Strerror_r(int errnum, char* buf, size_t buflen) { |
| 46 | + return strerror_r(errnum, buf, buflen); |
| 47 | +} |
| 48 | + |
| 49 | +} // namespace ola |
0 commit comments