[4/6] libgloss: i386: move profil_write() from cygmon-salib.c to cygmon-gmon.c
Commit Message
_mcleanup() uses profil_write(). However, there is no prior
declaration of profil_write() in cygmon-gmon.c leading to below GCC
error:
cygmon-gmon.c: In function '_mcleanup':
cygmon-gmon.c:203:3: error: implicit declaration of function 'profil_write' [-Wimplicit-function-declaration]
203 | profil_write (1, sbuf, ssiz);
| ^~~~~~~~~~~~
As a matter of facts, profil_write() is never used elsewhere than
cygmon-gmon.c. Move profil_write() from cygmon-salib.c to
cygmon-gmon.c. Add the required fcntl.h include. Also, change the
type of profil_write()'s buffer parameter from char * to void * to
prevent an incompatible pointer type warning. Finally, mark
profil_write() as being a static function to make it clear that it is
not used outside of the translation unit.
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
libgloss/i386/cygmon-gmon.c | 20 ++++++++++++++++++++
libgloss/i386/cygmon-salib.c | 19 -------------------
2 files changed, 20 insertions(+), 19 deletions(-)
@@ -62,6 +62,7 @@ static char sccsid[] = "@(#)gmon.c 5.3 (Berkeley) 5/22/91";
#include <stdio.h>
#endif
+#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -193,6 +194,25 @@ monstartup(lowpc, highpc)
moncontrol (1);
}
+static void
+profil_write (int type, void *buffer, int len)
+{
+ static int des = -1;
+
+ if (des < 0)
+ {
+ des = open ("gmon.out", O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ }
+ if (len == 0)
+ {
+ close (des);
+ }
+ else
+ {
+ write (des, buffer, len);
+ }
+}
+
void
_mcleanup()
{
@@ -161,22 +161,3 @@ __do_global_dtors ()
}
}
#endif
-
-void
-profil_write (int type, char *buffer, int len)
-{
- static int des = -1;
-
- if (des < 0)
- {
- des = open ("gmon.out", O_WRONLY | O_CREAT | O_TRUNC, 0644);
- }
- if (len == 0)
- {
- close (des);
- }
- else
- {
- write (des, buffer, len);
- }
-}