summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/gmon.c
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2013-06-18 09:45:37 +0000
committerCorinna Vinschen <corinna@vinschen.de>2013-06-18 09:45:37 +0000
commit943072f45ca34caf7b55db16f412bed94f7c27bc (patch)
treee796b9b0b1179779b5388554aa81d3198206ecb5 /winsup/cygwin/gmon.c
parentc38196884232bb12c0c4e04d1d31f6cbe1aca446 (diff)
downloadcygnal-943072f45ca34caf7b55db16f412bed94f7c27bc.tar.gz
cygnal-943072f45ca34caf7b55db16f412bed94f7c27bc.tar.bz2
cygnal-943072f45ca34caf7b55db16f412bed94f7c27bc.zip
* Makefile.in (VPATH): Drop CONFIG_DIR.
(EXTRA_DLL_OFILES): Remove. (DLL_OFILES): Remove EXTRA_DLL_OFILES. (ASFLAGS): Define as -D_WIN64 on x86_64. (GMON_OFILES): Add mcountFunc.o. ($(srcdir)/$(TLSOFFSETS_H)): Use target_cpu rather than CONFIG_DIR. * configure.ac (CONFIG_DIR): Remove definition. * configure: Regenerate. * gcrt0.c: Use latest version from Mingw-w64 project. * gmon.c: Ditto. * gmon.h: Ditto. * mcount.c: Ditto. * mcountFunc.S: Ditto, new file. * profil.c: Ditto. * profil.h: Ditto. * config: Remove entire directory.
Diffstat (limited to 'winsup/cygwin/gmon.c')
-rw-r--r--winsup/cygwin/gmon.c69
1 files changed, 42 insertions, 27 deletions
diff --git a/winsup/cygwin/gmon.c b/winsup/cygwin/gmon.c
index 56f9440dd..139aa4482 100644
--- a/winsup/cygwin/gmon.c
+++ b/winsup/cygwin/gmon.c
@@ -10,10 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
@@ -35,19 +31,39 @@
static char rcsid[] = "$OpenBSD: gmon.c,v 1.8 1997/07/23 21:11:27 kstailey Exp $";
#endif
-#include "winlean.h"
+/*
+ * This file is taken from Cygwin distribution. Please keep it in sync.
+ * The differences should be within __MINGW32__ guard.
+ */
+
#include <fcntl.h>
+#include <stdlib.h>
#include <stdio.h>
+#include <strings.h>
+#ifndef __MINGW32__
#include <unistd.h>
-#include <gmon.h>
-#include <stdlib.h>
-
-#include <profil.h>
+#include <sys/param.h>
+#endif
+#include <sys/types.h>
+#include "gmon.h"
+#include "profil.h"
/* XXX needed? */
//extern char *minbrk __asm ("minbrk");
-struct gmonparam _gmonparam = { GMON_PROF_OFF };
+#ifdef _WIN64
+#define MINUS_ONE_P (-1LL)
+#else
+#define MINUS_ONE_P (-1)
+#endif
+
+#ifdef __MINGW32__
+#include <string.h>
+#define bzero(ptr,size) memset (ptr, 0, size);
+#endif
+
+struct gmonparam _gmonparam = { GMON_PROF_OFF, NULL, 0, NULL, 0, NULL, 0, 0L,
+ 0, 0, 0, 0};
static int s_scale;
/* see profil(2) where this is describe (incorrectly) */
@@ -64,15 +80,15 @@ fake_sbrk(int size)
if (rv)
return rv;
else
- return (void *) -1;
+ return (void *) MINUS_ONE_P;
}
+void monstartup (size_t, size_t);
+
void
-monstartup(lowpc, highpc)
- u_long lowpc;
- u_long highpc;
+monstartup (size_t lowpc, size_t highpc)
{
- register int o;
+ register size_t o;
char *cp;
struct gmonparam *p = &_gmonparam;
@@ -94,13 +110,14 @@ monstartup(lowpc, highpc)
p->tossize = p->tolimit * sizeof(struct tostruct);
cp = fake_sbrk(p->kcountsize + p->fromssize + p->tossize);
- if (cp == (char *)-1) {
+ if (cp == (char *)MINUS_ONE_P) {
ERR("monstartup: out of memory\n");
return;
}
-#ifdef notdef
+
+ /* zero out cp as value will be added there */
bzero(cp, p->kcountsize + p->fromssize + p->tossize);
-#endif
+
p->tos = (struct tostruct *)cp;
cp += p->tossize;
p->kcount = (u_short *)cp;
@@ -133,22 +150,21 @@ monstartup(lowpc, highpc)
moncontrol(1);
}
+void _mcleanup (void);
void
-_mcleanup()
+_mcleanup(void)
{
+ static char gmon_out[] = "gmon.out";
int fd;
int hz;
int fromindex;
int endfrom;
- u_long frompc;
+ size_t frompc;
int toindex;
struct rawarc rawarc;
struct gmonparam *p = &_gmonparam;
struct gmonhdr gmonhdr, *hdr;
- char *proffile;
-#ifndef nope
- char gmon_out[] = "gmon.out";
-#endif
+ const char *proffile;
#ifdef DEBUG
int log, len;
char dbuf[200];
@@ -203,7 +219,7 @@ _mcleanup()
proffile = buf;
} else {
- proffile = "gmon.out";
+ proffile = gmon_out;
}
#else
proffile = gmon_out;
@@ -263,8 +279,7 @@ _mcleanup()
* all the data structures are ready.
*/
void
-moncontrol(mode)
- int mode;
+moncontrol(int mode)
{
struct gmonparam *p = &_gmonparam;