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

Message ID 20251029-fix-libgloss-i386-compile-issues-v1-1-26edcb02f69c@kernel.org
State New
Headers
Series libgloss: i386: fix compilation issues |

Commit Message

Vincent Mailhol Oct. 29, 2025, 6:58 a.m. UTC
  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 <mailhol@kernel.org>
---
 libgloss/i386/cygmon-gmon.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Patch

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"
 
 /*