Mail Archives: djgpp-workers/1999/08/01/10:39:28
These are the patches for the gprof subdirectory.
1999-07-30 Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
* gmon_io.h (SET_BINARY) [O_BINARY]: Define.
* gmon_io.c (gmon_out_read) [SET_BINARY]: Switch stdin into binary
mode.
* source.c: Include filenames.h and sys/stat.h.
(source_file_lookup_path, source_file_lookup_name): Use
FILENAME_CMP to compare file names.
(annotate_source) [__MSDOS__]: If "filename-ann" would overwrite
"filename", replace the extension with ".ann".
[DOSISH_FILENAMES]: Support file names with backslashes and drive
letters.
Use IS_ABSOLUTE.
1999-07-27 Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
* search_list.h (PATH_SEP_CHAR): Define.
* search_list.c (search_list_append): Use PATH_SEP_CHAR.
* hertz.c (HERTZ) [__MSDOS__]: Don't define unless they have
neither HAVE_SETITIMER nor HAVE_SYSCONF.
[HAVE_SETITIMER]: If they define both HAVE_SETITIMER and
HAVE_SYSCONF, try setitimer and fall back on sysconf.
*** gprof/gmon_io.h1~ Fri May 1 18:49:42 1998
--- gprof/gmon_io.h Fri Jul 30 19:32:16 1999
***************
*** 4,9 ****
--- 4,25 ----
#include "bfd.h"
#include "gmon.h"
+ /* Some platforms need to put stdin into binary mode, to read
+ binary files. */
+ #include "sysdep.h"
+ #ifndef O_BINARY
+ #ifdef _O_BINARY
+ #define O_BINARY _O_BINARY
+ #define setmode _setmode
+ #else
+ #define O_BINARY 0
+ #endif
+ #endif
+ #if O_BINARY
+ #include <io.h>
+ #define SET_BINARY(f) do { if (!isatty(f)) setmode(f,O_BINARY); } while (0)
+ #endif
+
#define INPUT_HISTOGRAM (1<<0)
#define INPUT_CALL_GRAPH (1<<1)
#define INPUT_BB_COUNTS (1<<2)
*** gprof/gmon_io.c1~ Fri May 1 18:49:42 1998
--- gprof/gmon_io.c Tue Jul 27 19:15:50 1999
*************** DEFUN (gmon_out_read, (filename), const
*** 72,77 ****
--- 72,80 ----
if (strcmp (filename, "-") == 0)
{
ifp = stdin;
+ #ifdef SET_BINARY
+ SET_BINARY (fileno (stdin));
+ #endif
}
else
{
*** gprof/source.c1~ Fri May 1 18:49:42 1998
--- gprof/source.c Sat Jul 31 13:53:52 1999
***************
*** 1,8 ****
--- 1,11 ----
/*
* Keeps track of source files.
*/
+ #include <sys/stat.h>
+
#include "gprof.h"
#include "libiberty.h"
+ #include "filenames.h"
#include "search_list.h"
#include "source.h"
*************** DEFUN (source_file_lookup_path, (path),
*** 25,31 ****
for (sf = first_src_file; sf; sf = sf->next)
{
! if (strcmp (path, sf->name) == 0)
{
break;
}
--- 28,34 ----
for (sf = first_src_file; sf; sf = sf->next)
{
! if (FILENAME_CMP (path, sf->name) == 0)
{
break;
}
*************** DEFUN (source_file_lookup_name, (filenam
*** 66,72 ****
{
fname = sf->name;
}
! if (strcmp (filename, fname) == 0)
{
break;
}
--- 69,75 ----
{
fname = sf->name;
}
! if (FILENAME_CMP (filename, fname) == 0)
{
break;
}
*************** DEFUN (annotate_source, (sf, max_width,
*** 95,101 ****
* open succeeds or reaching end of list:
*/
strcpy (fname, sf->name);
! if (sf->name[0] == '/')
{
sle = 0; /* don't use search list for absolute paths */
}
--- 98,104 ----
* open succeeds or reaching end of list:
*/
strcpy (fname, sf->name);
! if (IS_ABSOLUTE (sf->name))
{
sle = 0; /* don't use search list for absolute paths */
}
*************** DEFUN (annotate_source, (sf, max_width,
*** 112,117 ****
--- 115,128 ----
if (!sle && !name_only)
{
name_only = strrchr (sf->name, '/');
+ #ifdef DOSISH_FILENAMES
+ if (!name_only || strchr (name_only, '\\'))
+ {
+ name_only = strrchr (sf->name, '\\');
+ if (!name_only && sf->name[0] && sf->name[1] == ':')
+ name_only = (char *)sf->name + 1;
+ }
+ #endif
if (name_only)
{
/* try search-list again, but this time with name only: */
*************** DEFUN (annotate_source, (sf, max_width,
*** 122,127 ****
--- 133,143 ----
if (sle)
{
strcpy (fname, sle->path);
+ #ifdef DOSISH_FILENAMES
+ /* d:foo is not the same thing as d:/foo! */
+ if (fname[strlen (fname) - 1] == ':')
+ strcat (fname, ".");
+ #endif
strcat (fname, "/");
if (name_only)
{
*************** DEFUN (annotate_source, (sf, max_width,
*** 156,161 ****
--- 172,185 ----
/* create annotation files in the current working directory: */
filename = strrchr (sf->name, '/');
+ #ifdef DOSISH_FILENAMES
+ if (!filename || strchr (filename, '\\'))
+ {
+ filename = strrchr (sf->name, '\\');
+ if (!filename && sf->name[0] && sf->name[1] == ':')
+ filename = sf->name + 1;
+ }
+ #endif
if (filename)
{
++filename;
*************** DEFUN (annotate_source, (sf, max_width,
*** 167,172 ****
--- 191,213 ----
strcpy (fname, filename);
strcat (fname, EXT_ANNO);
+ #ifdef __MSDOS__
+ {
+ /* foo.cpp-ann can overwrite foo.cpp due to silent truncation of
+ file names on 8+3 filesystems. Their `stat' better be good... */
+ struct stat buf1, buf2;
+
+ if (stat (filename, &buf1) == 0 && stat (fname, &buf2) == 0
+ && buf1.st_ino == buf2.st_ino)
+ {
+ char *dot = strrchr (fname, '.');
+
+ if (dot)
+ *dot = '\0';
+ strcat (fname, ".ann");
+ }
+ }
+ #endif
ofp = fopen (fname, "w");
if (!ofp)
{
*** gprof/search_list.h1~ Fri May 1 18:49:42 1998
--- gprof/search_list.h Tue Jul 27 19:15:50 1999
***************
*** 1,6 ****
--- 1,14 ----
#ifndef search_list_h
#define search_list_h
+ /* Non-Posix systems use semi-colon as directory separator in lists,
+ since colon is part of drive letter spec. */
+ #if defined (__MSDOS__) || defined (_WIN32)
+ #define PATH_SEP_CHAR ';'
+ #else
+ #define PATH_SEP_CHAR ':'
+ #endif
+
typedef struct search_list_elem
{
struct search_list_elem *next;
*** gprof/search_list.c1~ Fri May 1 18:49:42 1998
--- gprof/search_list.c Tue Jul 27 19:15:50 1999
*************** DEFUN (search_list_append, (list, paths)
*** 15,21 ****
do
{
beg = colon + 1;
! colon = strchr (beg, ':');
if (colon)
{
len = colon - beg;
--- 15,21 ----
do
{
beg = colon + 1;
! colon = strchr (beg, PATH_SEP_CHAR);
if (colon)
{
len = colon - beg;
*** gprof/hertz.c1~ Fri May 1 18:49:42 1998
--- gprof/hertz.c Tue Jul 27 19:15:50 1999
***************
*** 19,28 ****
#include "hertz.h"
- #ifdef __MSDOS__
- #define HERTZ 18
- #endif
-
int
hertz ()
{
--- 19,24 ----
*************** hertz ()
*** 38,54 ****
tim.it_value.tv_usec = 0;
setitimer (ITIMER_REAL, &tim, 0);
setitimer (ITIMER_REAL, 0, &tim);
! if (tim.it_interval.tv_usec < 2)
{
! return HZ_WRONG;
}
! return 1000000 / tim.it_interval.tv_usec;
! #else /* ! defined (HAVE_SETITIMER) */
#if defined (HAVE_SYSCONF) && defined (_SC_CLK_TCK)
return sysconf (_SC_CLK_TCK);
#else /* ! defined (HAVE_SYSCONF) || ! defined (_SC_CLK_TCK) */
return HZ_WRONG;
#endif /* ! defined (HAVE_SYSCONF) || ! defined (_SC_CLK_TCK) */
- #endif /* ! defined (HAVE_SETITIMER) */
#endif /* ! defined (HERTZ) */
}
--- 34,52 ----
tim.it_value.tv_usec = 0;
setitimer (ITIMER_REAL, &tim, 0);
setitimer (ITIMER_REAL, 0, &tim);
! if (tim.it_interval.tv_usec >= 2)
{
! return 1000000 / tim.it_interval.tv_usec;
}
! #endif /* ! defined (HAVE_SETITIMER) */
#if defined (HAVE_SYSCONF) && defined (_SC_CLK_TCK)
return sysconf (_SC_CLK_TCK);
#else /* ! defined (HAVE_SYSCONF) || ! defined (_SC_CLK_TCK) */
+ #ifdef __MSDOS__
+ return 18;
+ #else /* ! defined (__MSDOS__) */
return HZ_WRONG;
+ #endif /* ! defined (__MSDOS__) */
#endif /* ! defined (HAVE_SYSCONF) || ! defined (_SC_CLK_TCK) */
#endif /* ! defined (HERTZ) */
}
- Raw text -