[PATCH 1/6] libgloss: i386: cygmon-gmon.c: add missing libc headers

Vincent Mailhol <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <20251029-fix-libgloss-i386-compile-issues-v1-1-26edcb02f69c@kernel.org>
Add includes for stdlib.h, string.h and unistd.h. This resolves below
GCC errors:

  cygmon-gmon.c: In function 'monstartup':
  cygmon-gmon.c:109:21: error: implicit declaration of function 'sbrk' [-Wimplicit-function-declaration]
    109 |   buffer = (char *) sbrk (monsize);
        |                     ^~~~
  cygmon-gmon.c:112:7: error: implicit declaration of function 'write'; did you mean 'fwrite'? [-Wimplicit-function-declaration]
    112 |       write (2, MSG , sizeof(MSG));
        |       ^~~~~
        |       fwrite
  cygmon-gmon.c:115:3: error: implicit declaration of function 'bzero' [-Wimplicit-function-declaration]
    115 |   bzero (buffer, monsize);
        |   ^~~~~
  cygmon-gmon.c: In function '_mcount':
  cygmon-gmon.c:224:7: error: implicit declaration of function 'atexit' [-Wimplicit-function-declaration]
    224 |       atexit(_mcleanup);
        |       ^~~~~~
  cygmon-gmon.c:66:1: note: 'atexit' is defined in header '<stdlib.h>'; this is probably fixable by adding '#include <stdlib.h>'
     65 | #include "cygmon-gmon.h"
    +++ |+#include <stdlib.h>
     66 |

Signed-off-by: Vincent Mailhol <[email protected]>
---
 libgloss/i386/cygmon-gmon.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libgloss/i386/cygmon-gmon.c b/libgloss/i386/cygmon-gmon.c
index 3c15b70d3..ac3af30a6 100644
--- a/libgloss/i386/cygmon-gmon.c
+++ b/libgloss/i386/cygmon-gmon.c
@@ -62,6 +62,10 @@ static char sccsid[] = "@(#)gmon.c	5.3 (Berkeley) 5/22/91";
 #include <stdio.h>
 #endif
 
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
 #include "cygmon-gmon.h"
 
 /*

-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.