1 /* 2 * Copyright (c) 2016-2017 Intel, Inc. All rights reserved. 3 * $COPYRIGHT$ 4 * 5 * Additional copyrights may follow 6 * 7 * $HEADER$ 8 */ 9 10 /** @file 11 * 12 * Buffer strnlen function for portability to archaic platforms. 13 */ 14 15 #ifndef PMIX_STRNLEN_H 16 #define PMIX_STRNLEN_H 17 18 #include <src/include/pmix_config.h> 19 20 #if defined(HAVE_STRNLEN) 21 #define PMIX_STRNLEN(c, a, b) \ 22 (c) = strnlen(a, b) 23 #else 24 #define PMIX_STRNLEN(c, a, b) \ 25 do { \ 26 size_t _x; \ 27 (c) = 0; \ 28 for (_x=0; _x < (b); _x++) { \ 29 if ('\0' == (a)[_x]) { \ 30 break; \ 31 } \ 32 ++(c); \ 33 } \ 34 } while(0) 35 #endif 36 37 #endif /* PMIX_STRNLEN_H */