* RFA: gloss component extensions
@ 2001-01-06 18:59 matthew green
2001-01-07 18:03 ` Ben Elliston
0 siblings, 1 reply; 5+ messages in thread
From: matthew green @ 2001-01-06 18:59 UTC (permalink / raw)
To: sid
hi folks.
the following changes implement times() & gettimeofday(), finish the
time() syscall (it did not fill in it's argument, just returned the
time), and fix the open() flags to match what newlib uses.
OK to commit?
.mrg.
[component/ChangeLog]
2001-01-03 matthew green <mrg@redhat.com>
* configure.in (AC_HAVE_FUNCS): Also check for times(2).
* configure: Regenerate.
* config.in: Regenerate.
[component/gloss/ChangeLog]
2001-01-06 matthew green <mrg@redhat.com>
* gloss.cxx (gloss32::target_to_host_open_flags): Properly check for
valid open() flags.
2001-01-04 matthew green <mrg@redhat.com>
* gloss.cxx (gloss32::target_to_host_open_flags): Properly deal with
newlib open flags.
Need <sys/time.h> for gettimeofday(). Only include <sys/times.h> if
we have times().
2000-12-30 matthew green <mrg@redhat.com>
* gloss.cxx (do_sys_time): New function.
(do_sys_times): Likewise.
(do_sys_gettimeofday): Likewise.
(syscall_trap): Call do_sys_time(). Call new do_sys_times() and
do_sys_gettimeofday() for times() and .
* gloss.h (do_sys_time): Prototype.
(do_sys_times): Likewise.
(do_sys_gettimeofday): Likewise.
* libgloss.h (libgloss_syscall): Add `times' and `gettimeofday'.
Index: component/config.in
===================================================================
RCS file: /cvs/src/src/sid/component/config.in,v
retrieving revision 1.1
diff -p -r1.1 config.in
*** config.in 2000/12/07 19:30:45 1.1
--- config.in 2001/01/06 05:38:48
***************
*** 27,32 ****
--- 27,35 ----
/* Define if you have the strtoull function. */
#undef HAVE_STRTOULL
+ /* Define if you have the times function. */
+ #undef HAVE_TIMES
+
/* Define if you have the usleep function. */
#undef HAVE_USLEEP
Index: component/configure
===================================================================
RCS file: /cvs/src/src/sid/component/configure,v
retrieving revision 1.1
diff -p -r1.1 configure
*** configure 2000/12/07 19:30:45 1.1
--- configure 2001/01/06 05:38:50
*************** fi
*** 2652,2658 ****
! for ac_func in ftime gettimeofday usleep strtoul strtoull select
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:2659: checking for $ac_func" >&5
--- 2652,2658 ----
! for ac_func in ftime times gettimeofday usleep strtoul strtoull select
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:2659: checking for $ac_func" >&5
Index: component/configure.in
===================================================================
RCS file: /cvs/src/src/sid/component/configure.in,v
retrieving revision 1.1
diff -p -r1.1 configure.in
*** configure.in 2000/12/07 19:30:45 1.1
--- configure.in 2001/01/06 05:38:50
*************** AC_CHECK_LIB(nsl, gethostbyname, socket_
*** 38,44 ****
socket_libs="$socket_libs -lresolv"))
AC_SUBST(socket_libs)
! AC_CHECK_FUNCS(ftime gettimeofday usleep strtoul strtoull select)
old_libs="$LIBS"
LIBS="$LIBS $socket_libs"
--- 38,44 ----
socket_libs="$socket_libs -lresolv"))
AC_SUBST(socket_libs)
! AC_CHECK_FUNCS(ftime times gettimeofday usleep strtoul strtoull select)
old_libs="$LIBS"
LIBS="$LIBS $socket_libs"
Index: component/gloss/gloss.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/gloss/gloss.cxx,v
retrieving revision 1.1
diff -p -r1.1 gloss.cxx
*** gloss.cxx 2000/12/07 19:30:50 1.1
--- gloss.cxx 2001/01/06 05:38:51
***************
*** 10,15 ****
--- 10,21 ----
#include "libgloss.h"
// ??? For now. grep for newlib below.
#include "newlib.h"
+ #ifdef HAVE_TIMES
+ #include <sys/times.h>
+ #endif
+ #ifdef HAVE_GETTIMEOFDAY
+ #include <sys/time.h>
+ #endif
#include <cstdlib>
#include <unistd.h>
*************** gloss32::syscall_trap()
*** 570,577 ****
do_sys_open();
break;
case libgloss::SYS_time:
! set_int_result(time(NULL));
break;
default:
do_nonstandard_target_syscalls (syscall);
break;
--- 576,589 ----
do_sys_open();
break;
case libgloss::SYS_time:
! do_sys_time();
break;
+ case libgloss::SYS_gettimeofday:
+ do_sys_gettimeofday();
+ break;
+ case libgloss::SYS_times:
+ do_sys_times();
+ break;
default:
do_nonstandard_target_syscalls (syscall);
break;
*************** gloss32::do_nonstandard_target_syscalls
*** 588,593 ****
--- 600,672 ----
}
void
+ gloss32::do_sys_time()
+ {
+ int32 timetp, rv;
+
+ get_int_argument(1, timetp);
+ rv = time(NULL);
+ if (timetp)
+ set_word(timetp, rv);
+
+ set_int_result(rv);
+ }
+
+ void
+ gloss32::do_sys_gettimeofday()
+ {
+ #ifdef HAVE_GETTIMEOFDAY
+ int32 timevalp, rv, value;
+ struct timeval tv;
+
+ /* Ignore 2nd parameter to gettimeofday(). */
+ get_int_argument(1, timevalp);
+ rv = gettimeofday(&tv, NULL);
+ if (rv != -1)
+ {
+ value = tv.tv_sec;
+ set_word(timevalp, value);
+ value = tv.tv_usec;
+ set_word(timevalp + 4, value);
+ }
+ set_int_result(rv);
+ #else
+ set_int_result(-1);
+ #endif
+ }
+
+ void
+ gloss32::do_sys_times()
+ {
+ #ifdef HAVE_TIMES
+ int32 value, rv, tmsp;
+ struct tms tms;
+
+ get_int_argument(1, tmsp);
+ if (!tmsp)
+ {
+ set_int_result(EFAULT);
+ return;
+ }
+ rv = times(&tms);
+ if (rv != -1)
+ {
+ value = tms.tms_utime;
+ set_word(tmsp, value);
+ value = tms.tms_stime;
+ set_word(tmsp + 4, value);
+ value = tms.tms_cutime;
+ set_word(tmsp + 8, value);
+ value = tms.tms_cstime;
+ set_word(tmsp + 12, value);
+ }
+ set_int_result(rv);
+ #else
+ set_int_result(-1);
+ #endif
+ }
+
+ void
gloss32::do_sys_exit()
{
int32 value;
*************** gloss32::do_sys_open()
*** 758,807 ****
}
}
bool
gloss32::target_to_host_open_flags (int open_flags, int& flags)
{
! switch (open_flags)
{
! case 0:
! flags = hostops::open_read_only | hostops::open_text;
! break;
! case 1:
flags = hostops::open_read_only;
break;
! case 2:
! flags = hostops::open_read_write | hostops::open_text;
break;
! case 3:
flags = hostops::open_read_write;
break;
- case 4:
- flags = hostops::open_write_only | hostops::open_create | hostops::open_trunc | hostops::open_text;
- break;
- case 5:
- flags = hostops::open_write_only | hostops::open_create | hostops::open_trunc;
- break;
- case 6:
- flags = hostops::open_read_write | hostops::open_create | hostops::open_trunc | hostops::open_text;
- break;
- case 7:
- flags = hostops::open_read_write | hostops::open_create | hostops::open_trunc;
- break;
- case 8:
- flags = hostops::open_write_only | hostops::open_create | hostops::open_append | hostops::open_text;
- break;
- case 9:
- flags = hostops::open_write_only | hostops::open_create | hostops::open_append;
- break;
- case 10:
- flags = hostops::open_read_write | hostops::open_create | hostops::open_append | hostops::open_text;
- break;
- case 11:
- flags = hostops::open_read_write | hostops::open_create | hostops::open_append;
- break;
default:
return false;
}
return true;
}
--- 837,879 ----
}
}
+ // This only handles O_RDONLY, O_WRONLY, O_RDWR, O_APPEND, O_CREAT & O_TRUNC.
+ #define NEWLIB_O_RDONLY 0x0000
+ #define NEWLIB_O_WRONLY 0x0001
+ #define NEWLIB_O_RDWR 0x0002
+ #define NEWLIB_O_APPEND 0x0008
+ #define NEWLIB_O_CREAT 0x0200
+ #define NEWLIB_O_TRUNC 0x0400
bool
gloss32::target_to_host_open_flags (int open_flags, int& flags)
{
! switch (open_flags & 3)
{
! case NEWLIB_O_RDONLY:
flags = hostops::open_read_only;
break;
! case NEWLIB_O_WRONLY:
! flags = hostops::open_write_only;
break;
! case NEWLIB_O_RDWR:
flags = hostops::open_read_write;
break;
default:
return false;
}
+
+ if ((open_flags & ~(3|NEWLIB_O_APPEND|NEWLIB_O_CREAT|NEWLIB_O_TRUNC)) != 0)
+ return false;
+
+ if (open_flags & NEWLIB_O_APPEND)
+ flags |= hostops::open_append;
+
+ if (open_flags & NEWLIB_O_CREAT)
+ flags |= hostops::open_create;
+
+ if (open_flags & NEWLIB_O_TRUNC)
+ flags |= hostops::open_trunc;
+
return true;
}
Index: component/gloss/gloss.h
===================================================================
RCS file: /cvs/src/src/sid/component/gloss/gloss.h,v
retrieving revision 1.1
diff -p -r1.1 gloss.h
*** gloss.h 2000/12/07 19:30:50 1.1
--- gloss.h 2001/01/06 05:38:51
*************** protected:
*** 140,145 ****
--- 140,148 ----
void do_sys_open();
void do_sys_close();
void do_sys_lseek();
+ void do_sys_time();
+ void do_sys_gettimeofday();
+ void do_sys_times();
virtual void do_nonstandard_target_syscalls(int32 syscall);
virtual bool target_to_host_open_flags (int open_flags, int& flags);
virtual int32 target_to_host_syscall (int32 syscall);
Index: component/gloss/libgloss.h
===================================================================
RCS file: /cvs/src/src/sid/component/gloss/libgloss.h,v
retrieving revision 1.1
diff -p -r1.1 libgloss.h
*** libgloss.h 2000/12/07 19:30:50 1.1
--- libgloss.h 2001/01/06 05:38:51
*************** public:
*** 35,41 ****
SYS_stat = 15,
SYS_chmod = 16,
SYS_utime = 17,
! SYS_time = 18
};
};
--- 35,43 ----
SYS_stat = 15,
SYS_chmod = 16,
SYS_utime = 17,
! SYS_time = 18,
! SYS_gettimeofday = 19,
! SYS_times = 20
};
};
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RFA: gloss component extensions
2001-01-06 18:59 RFA: gloss component extensions matthew green
@ 2001-01-07 18:03 ` Ben Elliston
2001-01-07 18:38 ` matthew green
0 siblings, 1 reply; 5+ messages in thread
From: Ben Elliston @ 2001-01-07 18:03 UTC (permalink / raw)
To: matthew green; +Cc: sid
mrg wrote:
time() syscall (it did not fill in it's argument, just returned the
time), and fix the open() flags to match what newlib uses.
Before you commit, I have some questions:
2000-12-30 matthew green <mrg@redhat.com>
* gloss.cxx (do_sys_time): New function.
(do_sys_times): Likewise.
(do_sys_gettimeofday): Likewise.
(syscall_trap): Call do_sys_time(). Call new do_sys_times() and
do_sys_gettimeofday() for times() and .
`And ..' .. what?
+ #else
+ set_int_result(-1);
+ #endif
In the case of missing gettimeofday() and times() functions, the newlib stub
functions should set ENOSYS. Do they use the -1 to detect this?
Other than that, the only thing missing is your test cases to prove that
these work.
Ben
^ permalink raw reply [flat|nested] 5+ messages in thread
* re: RFA: gloss component extensions
2001-01-07 18:03 ` Ben Elliston
@ 2001-01-07 18:38 ` matthew green
2001-01-07 18:51 ` Ben Elliston
0 siblings, 1 reply; 5+ messages in thread
From: matthew green @ 2001-01-07 18:38 UTC (permalink / raw)
To: Ben Elliston; +Cc: sid
Before you commit, I have some questions:
actually, i already have as frank approved it.
2000-12-30 matthew green <mrg@redhat.com>
* gloss.cxx (do_sys_time): New function.
(do_sys_times): Likewise.
(do_sys_gettimeofday): Likewise.
(syscall_trap): Call do_sys_time(). Call new do_sys_times() and
do_sys_gettimeofday() for times() and .
`And ..' .. what?
` .. and gettimeofday, respectively.' is what the ChangeLog entry now says.
+ #else
+ set_int_result(-1);
+ #endif
In the case of missing gettimeofday() and times() functions, the newlib stub
functions should set ENOSYS. Do they use the -1 to detect this?
ah, i should probably also add a call:
set_error_result(newlib::eNoSys);
then?
Other than that, the only thing missing is your test cases to prove that
these work.
actually, the entire gloss32 component has no testsuite at all. :-(
(parts of the hardware specific ones do, but that is it.)
^ permalink raw reply [flat|nested] 5+ messages in thread
* re: RFA: gloss component extensions
2001-01-07 18:38 ` matthew green
@ 2001-01-07 18:51 ` Ben Elliston
2001-01-07 20:30 ` matthew green
0 siblings, 1 reply; 5+ messages in thread
From: Ben Elliston @ 2001-01-07 18:51 UTC (permalink / raw)
To: matthew green; +Cc: sid
mrg wrote:
` .. and gettimeofday, respectively.' is what the ChangeLog entry now says.
Okay.
In the case of missing gettimeofday() and times() functions, the newlib stub
functions should set ENOSYS. Do they use the -1 to detect this?
ah, i should probably also add a call:
set_error_result(newlib::eNoSys);
then?
Yes.
actually, the entire gloss32 component has no testsuite at all. :-(
(parts of the hardware specific ones do, but that is it.)
How did this happen? Which heathen wrote it? :-)
Ben
^ permalink raw reply [flat|nested] 5+ messages in thread
* re: RFA: gloss component extensions
2001-01-07 18:51 ` Ben Elliston
@ 2001-01-07 20:30 ` matthew green
0 siblings, 0 replies; 5+ messages in thread
From: matthew green @ 2001-01-07 20:30 UTC (permalink / raw)
To: Ben Elliston; +Cc: sid
In the case of missing gettimeofday() and times() functions, the newlib stub
functions should set ENOSYS. Do they use the -1 to detect this?
ah, i should probably also add a call:
set_error_result(newlib::eNoSys);
then?
Yes.
OK, i have commited the following. thanks.
2001-01-08 matthew green <mrg@redhat.com>
* gloss.cxx (do_sys_times): Set error value as well as return value
if times() does not exist on the host.
(do_sys_gettimeofday): Set error value as well as return value
if gettimeofday() does not exist on the host.
Index: gloss.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/gloss/gloss.cxx,v
retrieving revision 1.2
diff -p -r1.2 gloss.cxx
*** gloss.cxx 2001/01/07 04:51:31 1.2
--- gloss.cxx 2001/01/08 04:28:21
*************** gloss32::do_sys_gettimeofday()
*** 632,637 ****
--- 632,638 ----
set_int_result(rv);
#else
set_int_result(-1);
+ set_error_result(newlib::eNoSys);
#endif
}
*************** gloss32::do_sys_times()
*** 663,668 ****
--- 664,670 ----
set_int_result(rv);
#else
set_int_result(-1);
+ set_error_result(newlib::eNoSys);
#endif
}
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-01-07 20:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-06 18:59 RFA: gloss component extensions matthew green
2001-01-07 18:03 ` Ben Elliston
2001-01-07 18:38 ` matthew green
2001-01-07 18:51 ` Ben Elliston
2001-01-07 20:30 ` matthew green
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).