|
|
21bee5 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
21bee5 |
From: Merlin Mathesius <mmathesi@redhat.com>
|
|
|
21bee5 |
Date: Wed, 13 May 2020 11:58:37 -0500
|
|
|
21bee5 |
Subject: [PATCH] Replace builtin strlen that appears to get optimized away
|
|
|
21bee5 |
|
|
|
21bee5 |
---
|
|
|
21bee5 |
dos/string.h | 12 +++++++++++-
|
|
|
21bee5 |
1 file changed, 11 insertions(+), 1 deletion(-)
|
|
|
21bee5 |
|
|
|
21bee5 |
diff --git a/dos/string.h b/dos/string.h
|
|
|
21bee5 |
index f648de2d..407d0233 100644
|
|
|
21bee5 |
--- a/dos/string.h
|
|
|
21bee5 |
+++ b/dos/string.h
|
|
|
21bee5 |
@@ -5,12 +5,22 @@
|
|
|
21bee5 |
#ifndef _STRING_H
|
|
|
21bee5 |
#define _STRING_H
|
|
|
21bee5 |
|
|
|
21bee5 |
+#include <stddef.h>
|
|
|
21bee5 |
+
|
|
|
21bee5 |
/* Standard routines */
|
|
|
21bee5 |
#define memcpy(a,b,c) __builtin_memcpy(a,b,c)
|
|
|
21bee5 |
#define memmove(a,b,c) __builtin_memmove(a,b,c)
|
|
|
21bee5 |
#define memset(a,b,c) __builtin_memset(a,b,c)
|
|
|
21bee5 |
#define strcpy(a,b) __builtin_strcpy(a,b)
|
|
|
21bee5 |
-#define strlen(a) __builtin_strlen(a)
|
|
|
21bee5 |
+#define strlen(a) inline_strlen(a)
|
|
|
21bee5 |
+
|
|
|
21bee5 |
+/* replacement for builtin strlen that appears to get optimized away */
|
|
|
21bee5 |
+static inline size_t inline_strlen(const char *str)
|
|
|
21bee5 |
+{
|
|
|
21bee5 |
+ size_t l;
|
|
|
21bee5 |
+ for (l = 0; *str++; l++);
|
|
|
21bee5 |
+ return l;
|
|
|
21bee5 |
+}
|
|
|
21bee5 |
|
|
|
21bee5 |
/* This only returns true or false */
|
|
|
21bee5 |
static inline int memcmp(const void *__m1, const void *__m2, unsigned int __n)
|