diff options
| author | rillig <rillig@NetBSD.org> | 2021-04-14 17:39:11 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2021-04-14 17:39:11 +0000 |
| commit | 2234229eb289f42ca1a13607e2bfe0ebaba701dc (patch) | |
| tree | 2e666ff5f8018741a9422aa2d7bcf3cbca86b6f0 /usr.bin/make | |
| parent | 208606ff025ec1da06e47de5dcb8cb78a4eac31b (diff) | |
make: let the compiler decide whether to inline string functions
On x86_64, this reduces the binary size by 2 kB.
Diffstat (limited to 'usr.bin/make')
| -rw-r--r-- | usr.bin/make/make.h | 3 | ||||
| -rw-r--r-- | usr.bin/make/str.h | 36 |
2 files changed, 20 insertions, 19 deletions
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index 60e440aedc8..c5cc6f80e10 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.261 2021/04/11 12:06:53 rillig Exp $ */ +/* $NetBSD: make.h,v 1.262 2021/04/14 17:39:11 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -131,6 +131,7 @@ #endif #define MAKE_INLINE static inline MAKE_ATTR_UNUSED +#define MAKE_STATIC static MAKE_ATTR_UNUSED #if __STDC_VERSION__ >= 199901L || defined(lint) || defined(USE_C99_BOOLEAN) #include <stdbool.h> diff --git a/usr.bin/make/str.h b/usr.bin/make/str.h index 5f7d1e6dbbe..483ce67917e 100644 --- a/usr.bin/make/str.h +++ b/usr.bin/make/str.h @@ -1,4 +1,4 @@ -/* $NetBSD: str.h,v 1.7 2021/04/14 16:59:34 rillig Exp $ */ +/* $NetBSD: str.h,v 1.8 2021/04/14 17:39:11 rillig Exp $ */ /* Copyright (c) 2021 Roland Illig <rillig@NetBSD.org> @@ -146,7 +146,7 @@ MFStr_Done(MFStr *mfstr) } -MAKE_INLINE Substring +MAKE_STATIC Substring Substring_Init(const char *start, const char *end) { Substring sub; @@ -162,13 +162,13 @@ Substring_InitStr(const char *str) return Substring_Init(str, str + strlen(str)); } -MAKE_INLINE size_t +MAKE_STATIC size_t Substring_Length(Substring sub) { return (size_t)(sub.end - sub.start); } -MAKE_INLINE bool +MAKE_STATIC bool Substring_IsEmpty(Substring sub) { return sub.start == sub.end; @@ -182,7 +182,7 @@ Substring_Equals(Substring sub, const char *str) memcmp(sub.start, str, len) == 0; } -MAKE_INLINE Substring +MAKE_STATIC Substring Substring_Sub(Substring sub, size_t start, size_t end) { assert(start <= Substring_Length(sub)); @@ -190,14 +190,14 @@ Substring_Sub(Substring sub, size_t start, size_t end) return Substring_Init(sub.start + start, sub.start + end); } -MAKE_INLINE bool +MAKE_STATIC bool Substring_HasPrefix(Substring sub, Substring prefix) { return Substring_Length(sub) >= Substring_Length(prefix) && memcmp(sub.start, prefix.start, Substring_Length(prefix)) == 0; } -MAKE_INLINE bool +MAKE_STATIC bool Substring_HasSuffix(Substring sub, Substring suffix) { size_t suffixLen = Substring_Length(suffix); @@ -206,7 +206,7 @@ Substring_HasSuffix(Substring sub, Substring suffix) } /* Returns an independent, null-terminated copy of the substring. */ -MAKE_INLINE FStr +MAKE_STATIC FStr Substring_Str(Substring sub) { if (Substring_IsEmpty(sub)) @@ -214,7 +214,7 @@ Substring_Str(Substring sub) return FStr_InitOwn(bmake_strsedup(sub.start, sub.end)); } -MAKE_INLINE const char * +MAKE_STATIC const char * Substring_SkipFirst(Substring sub, char ch) { const char *p; @@ -225,7 +225,7 @@ Substring_SkipFirst(Substring sub, char ch) return sub.start; } -MAKE_INLINE const char * +MAKE_STATIC const char * Substring_LastIndex(Substring sub, char ch) { const char *p; @@ -236,7 +236,7 @@ Substring_LastIndex(Substring sub, char ch) return NULL; } -MAKE_INLINE Substring +MAKE_STATIC Substring Substring_Dirname(Substring pathname) { const char *p; @@ -247,7 +247,7 @@ Substring_Dirname(Substring pathname) return Substring_InitStr("."); } -MAKE_INLINE Substring +MAKE_STATIC Substring Substring_Basename(Substring pathname) { const char *p; @@ -259,7 +259,7 @@ Substring_Basename(Substring pathname) } -MAKE_INLINE void +MAKE_STATIC void LazyBuf_Init(LazyBuf *buf, const char *expected) { buf->data = NULL; @@ -275,7 +275,7 @@ LazyBuf_Done(LazyBuf *buf) free(buf->freeIt); } -MAKE_INLINE void +MAKE_STATIC void LazyBuf_Add(LazyBuf *buf, char ch) { @@ -298,7 +298,7 @@ LazyBuf_Add(LazyBuf *buf, char ch) } } -MAKE_INLINE void +MAKE_STATIC void LazyBuf_AddStr(LazyBuf *buf, const char *str) { const char *p; @@ -307,7 +307,7 @@ LazyBuf_AddStr(LazyBuf *buf, const char *str) LazyBuf_Add(buf, *p); } -MAKE_INLINE void +MAKE_STATIC void LazyBuf_AddBytesBetween(LazyBuf *buf, const char *start, const char *end) { const char *p; @@ -322,14 +322,14 @@ LazyBuf_AddSubstring(LazyBuf *buf, Substring sub) LazyBuf_AddBytesBetween(buf, sub.start, sub.end); } -MAKE_INLINE Substring +MAKE_STATIC Substring LazyBuf_Get(const LazyBuf *buf) { const char *start = buf->data != NULL ? buf->data : buf->expected; return Substring_Init(start, start + buf->len); } -MAKE_INLINE FStr +MAKE_STATIC FStr LazyBuf_DoneGet(LazyBuf *buf) { if (buf->data != NULL) { |
