Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make: let the compiler decide whether to inline...
details: https://anonhg.NetBSD.org/src/rev/a412da1f3db3
branches: trunk
changeset: 961657:a412da1f3db3
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Apr 14 17:39:11 2021 +0000
description:
make: let the compiler decide whether to inline string functions
On x86_64, this reduces the binary size by 2 kB.
diffstat:
usr.bin/make/make.h | 3 ++-
usr.bin/make/str.h | 36 ++++++++++++++++++------------------
2 files changed, 20 insertions(+), 19 deletions(-)
diffs (175 lines):
diff -r fd6d171c06a3 -r a412da1f3db3 usr.bin/make/make.h
--- a/usr.bin/make/make.h Wed Apr 14 17:24:48 2021 +0000
+++ b/usr.bin/make/make.h Wed Apr 14 17:39:11 2021 +0000
@@ -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 -r fd6d171c06a3 -r a412da1f3db3 usr.bin/make/str.h
--- a/usr.bin/make/str.h Wed Apr 14 17:24:48 2021 +0000
+++ b/usr.bin/make/str.h Wed Apr 14 17:39:11 2021 +0000
@@ -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@localhost>
@@ -146,7 +146,7 @@
}
-MAKE_INLINE Substring
+MAKE_STATIC Substring
Substring_Init(const char *start, const char *end)
{
Substring sub;
@@ -162,13 +162,13 @@
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 @@
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 @@
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 @@
}
/* 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 @@
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 @@
return sub.start;
}
-MAKE_INLINE const char *
+MAKE_STATIC const char *
Substring_LastIndex(Substring sub, char ch)
{
const char *p;
@@ -236,7 +236,7 @@
return NULL;
}
-MAKE_INLINE Substring
+MAKE_STATIC Substring
Substring_Dirname(Substring pathname)
{
const char *p;
@@ -247,7 +247,7 @@
return Substring_InitStr(".");
}
-MAKE_INLINE Substring
+MAKE_STATIC Substring
Substring_Basename(Substring pathname)
{
const char *p;
@@ -259,7 +259,7 @@
}
-MAKE_INLINE void
+MAKE_STATIC void
LazyBuf_Init(LazyBuf *buf, const char *expected)
{
buf->data = NULL;
@@ -275,7 +275,7 @@
free(buf->freeIt);
}
-MAKE_INLINE void
+MAKE_STATIC void
LazyBuf_Add(LazyBuf *buf, char ch)
{
@@ -298,7 +298,7 @@
}
}
-MAKE_INLINE void
+MAKE_STATIC void
LazyBuf_AddStr(LazyBuf *buf, const char *str)
{
const char *p;
@@ -307,7 +307,7 @@
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_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) {
Home |
Main Index |
Thread Index |
Old Index