diff options
author | Alan Modra <amodra@gmail.com> | 2021-03-19 17:39:24 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-03-21 23:00:32 +1030 |
commit | e93388417c1ecc6d69b155045cabb994cb8687fd (patch) | |
tree | 24fa2ed727efd5a1775e4c8b76b8d92a5ae0ea10 /bfd/bfd-in.h | |
parent | 38e41a88457d2fcab42596c5d0183e410868c813 (diff) | |
download | gdb-e93388417c1ecc6d69b155045cabb994cb8687fd.zip gdb-e93388417c1ecc6d69b155045cabb994cb8687fd.tar.gz gdb-e93388417c1ecc6d69b155045cabb994cb8687fd.tar.bz2 |
Provide an inline startswith function in bfd.h
bfd/
* bfd-in.h (startswith): New inline.
(CONST_STRNEQ): Use startswith.
* bfd-in2.h: Regenerate.
gdbsupport/
* common-utils.h (startswith): Delete version now supplied by bfd.h.
libctf/
* ctf-impl.h: Include string.h.
Diffstat (limited to 'bfd/bfd-in.h')
-rw-r--r-- | bfd/bfd-in.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index c9a7673..453ac48 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -65,7 +65,6 @@ extern "C" { definition of strncmp is provided here. Note - these macros do NOT work if STR2 is not a constant string. */ -#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0) /* strcpy() can have a similar problem, but since we know we are copying a constant string, we can use memcpy which will be faster since there is no need to check for a NUL byte inside STR. We @@ -564,3 +563,12 @@ struct ecoff_debug_swap; struct ecoff_extr; struct bfd_link_info; struct bfd_link_hash_entry; + +/* Return TRUE if the start of STR matches PREFIX, FALSE otherwise. */ + +static inline bfd_boolean +startswith (const char *str, const char *prefix) +{ + return strncmp (str, prefix, strlen (prefix)) == 0; +} +#define CONST_STRNEQ(STR1,STR2) startswith (STR1, STR2) |