* RFA: Add ftruncate support to newlib/gdb-sim to unbreak -fprofile-arcs
@ 2003-07-09 19:27 Joern Rennecke
2003-07-09 20:02 ` Nathan Sidwell
2003-10-11 17:35 ` Andrew Cagney
0 siblings, 2 replies; 5+ messages in thread
From: Joern Rennecke @ 2003-07-09 19:27 UTC (permalink / raw)
To: newlib, gdb-patches; +Cc: gcc, nathan
The recent change to libgcov to use ftruncate has broken -fprofile-arcs
functionality for the newlib-based sh-elf toolchain. The appended patches
add ftruncate and truncate support to sh-elf newlib / gdb-sim .
2003-07-09 J"orn Rennecke <joern.rennecke@superh.com>
newlib:
* libc/include/sys/unistd.h (ftruncate, truncate): Also declare
for __sh__.
* libc/sys/sh/Makefile.am (lib_a_SOURCES): Add ftruncate.c and
truncate.c.
* libc/sys/sh/Makefile.in: Regenerate.
* libc/sys/sh/sys/syscall.h: (SYS_truncate, SYS_ftruncate): Define.
* libc/sys/sh/ftruncate.c: New file.
* libc/sys/sh/truncate.c: Likewise.
include/gdb:
* callback.h (struct host_callback_struct): New members ftruncate
and truncate.
gdb:
sim/common:
* callback.c (os_ftruncate, os_truncate): New functions.
(default_callback): Initialize ftruncate and truncate members.
sim/sh:
* syscall.h (SYS_truncate, SYS_ftruncate): Define.
* interp.c (trap): Add support for SYS_ftruncate and SYS_truncate.
Index: libc/include/sys/unistd.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/unistd.h,v
retrieving revision 1.43
diff -p -r1.43 unistd.h
*** libc/include/sys/unistd.h 15 Apr 2003 20:13:49 -0000 1.43
--- libc/include/sys/unistd.h 9 Jul 2003 18:48:12 -0000
*************** int _EXFUN(getdtablesize, (void));
*** 180,189 ****
--- 180,193 ----
int _EXFUN(setdtablesize, (int));
useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval));
unsigned _EXFUN(usleep, (unsigned int __useconds));
+ #endif
+ #if defined(__CYGWIN__) || defined(__rtems__) || defined(__sh__)
#if !defined(__INSIDE_CYGWIN__)
int _EXFUN(ftruncate, (int __fd, off_t __length));
int _EXFUN(truncate, (const char *, off_t __length));
#endif
+ #endif
+ #if defined(__CYGWIN__) || defined(__rtems__)
#if !(defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
/* winsock[2].h defines as __stdcall, and with int as 2nd arg */
int _EXFUN(gethostname, (char *__name, size_t __len));
Index: libc/sys/sh/Makefile.am
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sh/Makefile.am,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 Makefile.am
*** libc/sys/sh/Makefile.am 17 Feb 2000 19:39:50 -0000 1.1.1.1
--- libc/sys/sh/Makefile.am 9 Jul 2003 18:48:12 -0000
*************** INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLA
*** 6,12 ****
noinst_LIBRARIES = lib.a
! lib_a_SOURCES = syscalls.c trap.S creat.c
all: crt0.o
--- 6,12 ----
noinst_LIBRARIES = lib.a
! lib_a_SOURCES = syscalls.c trap.S creat.c ftruncate.c truncate.c
all: crt0.o
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sh/Makefile.in,v
retrieving revision 1.5
diff -p -r1.5 Makefile.in
*** Makefile.in 4 Jul 2002 19:57:51 -0000 1.5
--- Makefile.in 9 Jul 2003 18:54:29 -0000
***************
*** 1,6 ****
! # Makefile.in generated automatically by automake 1.4 from Makefile.am
! # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
--- 1,6 ----
! # Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
! # Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
*************** INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLA
*** 89,95 ****
noinst_LIBRARIES = lib.a
! lib_a_SOURCES = syscalls.c trap.S creat.c
ACLOCAL_AMFLAGS = -I ../../..
CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
--- 89,95 ----
noinst_LIBRARIES = lib.a
! lib_a_SOURCES = syscalls.c trap.S creat.c ftruncate.c truncate.c
ACLOCAL_AMFLAGS = -I ../../..
CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
*************** DEFS = @DEFS@ -I. -I$(srcdir)
*** 103,109 ****
CPPFLAGS = @CPPFLAGS@
LIBS = @LIBS@
lib_a_LIBADD =
! lib_a_OBJECTS = syscalls.o trap.o creat.o
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
--- 103,109 ----
CPPFLAGS = @CPPFLAGS@
LIBS = @LIBS@
lib_a_LIBADD =
! lib_a_OBJECTS = syscalls.o trap.o creat.o ftruncate.o truncate.o
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
Index: libc/sys/sh/sys/syscall.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sh/sys/syscall.h,v
retrieving revision 1.2
diff -p -r1.2 syscall.h
*** libc/sys/sh/sys/syscall.h 1 Feb 2001 21:25:56 -0000 1.2
--- libc/sys/sh/sys/syscall.h 9 Jul 2003 18:48:12 -0000
***************
*** 27,32 ****
--- 27,35 ----
#define SYS_pipe 42
#define SYS_execve 59
+ #define SYS_truncate 129
+ #define SYS_ftruncate 130
+
#define SYS_argc 172 /* == 0xAC, for Argument Count :-) */
#define SYS_argnlen 173
#define SYS_argn 174
*** /dev/null Thu Aug 30 21:30:55 2001
--- libc/sys/sh/ftruncate.c Wed Jul 9 17:05:05 2003
***************
*** 0 ****
--- 1,9 ----
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include "sys/syscall.h"
+
+ int
+ ftruncate (int file, off_t length)
+ {
+ return __trap34 (SYS_ftruncate, file, length, 0);
+ }
*** /dev/null Thu Aug 30 21:30:55 2001
--- libc/sys/sh/truncate.c Wed Jul 9 17:18:48 2003
***************
*** 0 ****
--- 1,9 ----
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include "sys/syscall.h"
+
+ int
+ truncate (const char *path, off_t length)
+ {
+ return __trap34 (SYS_ftruncate, path, length, 0);
+ }
Index: gdb/callback.h
===================================================================
RCS file: /cvs/src/src/include/gdb/callback.h,v
retrieving revision 1.1
diff -p -r1.1 callback.h
*** gdb/callback.h 9 Jun 2002 15:45:43 -0000 1.1
--- gdb/callback.h 9 Jul 2003 18:48:30 -0000
*************** struct host_callback_struct
*** 93,98 ****
--- 93,100 ----
void (*flush_stderr) PARAMS ((host_callback *));
int (*stat) PARAMS ((host_callback *, const char *, struct stat *));
int (*fstat) PARAMS ((host_callback *, int, struct stat *));
+ int (*ftruncate) PARAMS ((host_callback *, int, long));
+ int (*truncate) PARAMS ((host_callback *, const char *, long));
/* When present, call to the client to give it the oportunity to
poll any io devices for a request to quit (indicated by a nonzero
Index: common/callback.c
===================================================================
RCS file: /cvs/src/src/sim/common/callback.c,v
retrieving revision 1.5
diff -p -r1.5 callback.c
*** common/callback.c 9 Jun 2002 15:45:45 -0000 1.5
--- common/callback.c 9 Jul 2003 18:48:57 -0000
*************** os_fstat (p, fd, buf)
*** 399,404 ****
--- 399,428 ----
return wrap (p, fstat (fdmap (p, fd), buf));
}
+ static int
+ os_ftruncate (p, fd, len)
+ host_callback *p;
+ int fd;
+ long len;
+ {
+ int result;
+
+ result = fdbad (p, fd);
+ if (result)
+ return result;
+ result = wrap (p, ftruncate (fdmap (p, fd), len));
+ return result;
+ }
+
+ static int
+ os_truncate (p, file, len)
+ host_callback *p;
+ const char *file;
+ long len;
+ {
+ return wrap (p, stat (file, len));
+ }
+
static int
os_shutdown (p)
host_callback *p;
*************** host_callback default_callback =
*** 537,542 ****
--- 561,569 ----
os_stat,
os_fstat,
+
+ os_ftruncate,
+ os_truncate,
os_poll_quit,
Index: sh/interp.c
===================================================================
RCS file: /cvs/src/src/sim/sh/interp.c,v
retrieving revision 1.9
diff -p -r1.9 interp.c
*** sh/interp.c 27 Feb 2003 23:26:34 -0000 1.9
--- sh/interp.c 9 Jul 2003 18:48:57 -0000
*************** trap (i, regs, insn_ptr, memory, maskl,
*** 1151,1156 ****
--- 1151,1167 ----
case SYS_time:
regs[0] = get_now ();
break;
+ case SYS_ftruncate:
+ regs[0] = callback->ftruncate (callback, regs[5], regs[6]);
+ break;
+ case SYS_truncate:
+ {
+ int len = strswaplen (regs[5]);
+ strnswap (regs[5], len);
+ regs[0] = callback->truncate (callback, ptr (regs[5]), regs[6]);
+ strnswap (regs[5], len);
+ break;
+ }
default:
regs[0] = -1;
break;
Index: sh/syscall.h
===================================================================
RCS file: /cvs/src/src/sim/sh/syscall.h,v
retrieving revision 1.2
diff -p -r1.2 syscall.h
*** sh/syscall.h 30 Jan 2001 23:03:56 -0000 1.2
--- sh/syscall.h 9 Jul 2003 18:48:58 -0000
***************
*** 27,32 ****
--- 27,34 ----
#define SYS_stat 38
#define SYS_pipe 42
#define SYS_execve 59
+ #define SYS_truncate 129
+ #define SYS_ftruncate 130
#define SYS_argc 172
#define SYS_argnlen 173
#define SYS_argn 174
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RFA: Add ftruncate support to newlib/gdb-sim to unbreak -fprofile-arcs
2003-07-09 19:27 RFA: Add ftruncate support to newlib/gdb-sim to unbreak -fprofile-arcs Joern Rennecke
@ 2003-07-09 20:02 ` Nathan Sidwell
2003-07-09 20:12 ` Joern Rennecke
2003-10-11 17:35 ` Andrew Cagney
1 sibling, 1 reply; 5+ messages in thread
From: Nathan Sidwell @ 2003-07-09 20:02 UTC (permalink / raw)
To: Joern Rennecke; +Cc: newlib, gdb-patches, gcc
Joern Rennecke wrote:
> The recent change to libgcov to use ftruncate has broken -fprofile-arcs
> functionality for the newlib-based sh-elf toolchain. The appended patches
> add ftruncate and truncate support to sh-elf newlib / gdb-sim .
thanks!
> + #define SYS_truncate 129
> + #define SYS_ftruncate 130
> --- libc/sys/sh/truncate.c Wed Jul 9 17:18:48 2003
> ***************
> *** 0 ****
> --- 1,9 ----
> + #include <_ansi.h>
> + #include <sys/types.h>
> + #include "sys/syscall.h"
> +
> + int
> + truncate (const char *path, off_t length)
> + {
> + return __trap34 (SYS_ftruncate, path, length, 0);
^ typo?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RFA: Add ftruncate support to newlib/gdb-sim to unbreak -fprofile-arcs
2003-07-09 20:02 ` Nathan Sidwell
@ 2003-07-09 20:12 ` Joern Rennecke
2003-07-09 20:42 ` J. Johnston
0 siblings, 1 reply; 5+ messages in thread
From: Joern Rennecke @ 2003-07-09 20:12 UTC (permalink / raw)
To: Nathan Sidwell, newlib; +Cc: Joern Rennecke, gdb-patches, gcc
> > --- libc/sys/sh/truncate.c Wed Jul 9 17:18:48 2003
> > ***************
> > *** 0 ****
> > --- 1,9 ----
> > + #include <_ansi.h>
> > + #include <sys/types.h>
> > + #include "sys/syscall.h"
> > +
> > + int
> > + truncate (const char *path, off_t length)
> > + {
> > + return __trap34 (SYS_ftruncate, path, length, 0);
> ^ typo?
Oops, yes, that should be SYS_truncate. Please consider the newlib patch
thusly amended.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RFA: Add ftruncate support to newlib/gdb-sim to unbreak -fprofile-arcs
2003-07-09 20:12 ` Joern Rennecke
@ 2003-07-09 20:42 ` J. Johnston
0 siblings, 0 replies; 5+ messages in thread
From: J. Johnston @ 2003-07-09 20:42 UTC (permalink / raw)
To: Joern Rennecke; +Cc: Nathan Sidwell, newlib, gdb-patches, gcc
I would recommend separating out the ftruncate and truncate prototypes in
sys/unistd.h so as to keep the number of #if defined(x).. groupings to a minimum.
Other than that minor nit, no problems checking it in from the newlib perspective.
-- Jeff J.
Joern Rennecke wrote:
>>>--- libc/sys/sh/truncate.c Wed Jul 9 17:18:48 2003
>>>***************
>>>*** 0 ****
>>>--- 1,9 ----
>>>+ #include <_ansi.h>
>>>+ #include <sys/types.h>
>>>+ #include "sys/syscall.h"
>>>+
>>>+ int
>>>+ truncate (const char *path, off_t length)
>>>+ {
>>>+ return __trap34 (SYS_ftruncate, path, length, 0);
>>
>> ^ typo?
>
>
> Oops, yes, that should be SYS_truncate. Please consider the newlib patch
> thusly amended.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RFA: Add ftruncate support to newlib/gdb-sim to unbreak -fprofile-arcs
2003-07-09 19:27 RFA: Add ftruncate support to newlib/gdb-sim to unbreak -fprofile-arcs Joern Rennecke
2003-07-09 20:02 ` Nathan Sidwell
@ 2003-10-11 17:35 ` Andrew Cagney
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2003-10-11 17:35 UTC (permalink / raw)
To: Joern Rennecke; +Cc: gdb-patches
(Picking patches that were allowed to slip to the floor 6.0 :-()
> gdb:
> sim/common:
> * callback.c (os_ftruncate, os_truncate): New functions.
> (default_callback): Initialize ftruncate and truncate members.
> sim/sh:
> * syscall.h (SYS_truncate, SYS_ftruncate): Define.
> * interp.c (trap): Add support for SYS_ftruncate and SYS_truncate.
Joern, yes, ok.
Andrew
> Index: gdb/callback.h
> ===================================================================
> RCS file: /cvs/src/src/include/gdb/callback.h,v
> retrieving revision 1.1
> diff -p -r1.1 callback.h
> *** gdb/callback.h 9 Jun 2002 15:45:43 -0000 1.1
> --- gdb/callback.h 9 Jul 2003 18:48:30 -0000
> *************** struct host_callback_struct
> *** 93,98 ****
> --- 93,100 ----
> void (*flush_stderr) PARAMS ((host_callback *));
> int (*stat) PARAMS ((host_callback *, const char *, struct stat *));
> int (*fstat) PARAMS ((host_callback *, int, struct stat *));
> + int (*ftruncate) PARAMS ((host_callback *, int, long));
> + int (*truncate) PARAMS ((host_callback *, const char *, long));
>
> /* When present, call to the client to give it the oportunity to
> poll any io devices for a request to quit (indicated by a nonzero
> Index: common/callback.c
> ===================================================================
> RCS file: /cvs/src/src/sim/common/callback.c,v
> retrieving revision 1.5
> diff -p -r1.5 callback.c
> *** common/callback.c 9 Jun 2002 15:45:45 -0000 1.5
> --- common/callback.c 9 Jul 2003 18:48:57 -0000
> *************** os_fstat (p, fd, buf)
> *** 399,404 ****
> --- 399,428 ----
> return wrap (p, fstat (fdmap (p, fd), buf));
> }
>
> + static int
> + os_ftruncate (p, fd, len)
> + host_callback *p;
> + int fd;
> + long len;
> + {
> + int result;
> +
> + result = fdbad (p, fd);
> + if (result)
> + return result;
> + result = wrap (p, ftruncate (fdmap (p, fd), len));
> + return result;
> + }
> +
> + static int
> + os_truncate (p, file, len)
> + host_callback *p;
> + const char *file;
> + long len;
> + {
> + return wrap (p, stat (file, len));
> + }
> +
> static int
> os_shutdown (p)
> host_callback *p;
> *************** host_callback default_callback =
> *** 537,542 ****
> --- 561,569 ----
>
> os_stat,
> os_fstat,
> +
> + os_ftruncate,
> + os_truncate,
>
> os_poll_quit,
>
> Index: sh/interp.c
> ===================================================================
> RCS file: /cvs/src/src/sim/sh/interp.c,v
> retrieving revision 1.9
> diff -p -r1.9 interp.c
> *** sh/interp.c 27 Feb 2003 23:26:34 -0000 1.9
> --- sh/interp.c 9 Jul 2003 18:48:57 -0000
> *************** trap (i, regs, insn_ptr, memory, maskl,
> *** 1151,1156 ****
> --- 1151,1167 ----
> case SYS_time:
> regs[0] = get_now ();
> break;
> + case SYS_ftruncate:
> + regs[0] = callback->ftruncate (callback, regs[5], regs[6]);
> + break;
> + case SYS_truncate:
> + {
> + int len = strswaplen (regs[5]);
> + strnswap (regs[5], len);
> + regs[0] = callback->truncate (callback, ptr (regs[5]), regs[6]);
> + strnswap (regs[5], len);
> + break;
> + }
> default:
> regs[0] = -1;
> break;
> Index: sh/syscall.h
> ===================================================================
> RCS file: /cvs/src/src/sim/sh/syscall.h,v
> retrieving revision 1.2
> diff -p -r1.2 syscall.h
> *** sh/syscall.h 30 Jan 2001 23:03:56 -0000 1.2
> --- sh/syscall.h 9 Jul 2003 18:48:58 -0000
> ***************
> *** 27,32 ****
> --- 27,34 ----
> #define SYS_stat 38
> #define SYS_pipe 42
> #define SYS_execve 59
> + #define SYS_truncate 129
> + #define SYS_ftruncate 130
> #define SYS_argc 172
> #define SYS_argnlen 173
> #define SYS_argn 174
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-10-11 17:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-09 19:27 RFA: Add ftruncate support to newlib/gdb-sim to unbreak -fprofile-arcs Joern Rennecke
2003-07-09 20:02 ` Nathan Sidwell
2003-07-09 20:12 ` Joern Rennecke
2003-07-09 20:42 ` J. Johnston
2003-10-11 17:35 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox