Subject: port-alpha/13071: COMPAT_OSF1 getitimer(2)
To: None <gnats-bugs@gnats.netbsd.org>
From: Kevin Schoedel <schoedel@kw.igs.net>
List: netbsd-bugs
Date: 05/30/2001 19:31:25
>Number:         13071
>Category:       port-alpha
>Synopsis:       getitimer(2) for COMPAT_OSF1
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-alpha-maintainer
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed May 30 16:32:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Kevin Schoedel
>Release:        1.5
>Organization:
>Environment:
System: NetBSD boron 1.5 NetBSD 1.5 (KPS3K600WS) #2: Wed May 30 18:11:00 EDT 2001 kevin@boron:/i/fs/home/source/1.5/sys/arch/alpha/compile/KPS3K600WS alpha


>Description:
	OSF/1 emulation does not provide the getitimer(2) call;
	I have a binary that wants it.
>How-To-Repeat:
>Fix:


*** osf1_syscall.h    	Wed May 30 17:46:05 2001
--- osf1_syscall.h	Wed May 30 17:48:10 2001
***************
*** 185,190 ****
--- 185,193 ----
  /* syscall: "setitimer" ret: "int" args: "u_int" "struct osf1_itimerval *" "struct osf1_itimerval *" */
  #define	OSF1_SYS_setitimer	83

+ /* syscall: "getitimer" ret: "int" args: "u_int" "struct osf1_itimerval *" */
+ #define	OSF1_SYS_getitimer	86
+
  /* syscall: "gethostname" ret: "int" args: "char *" "u_int" */
  #define	OSF1_SYS_gethostname	87

*** osf1_syscallargs.h    	Wed May 30 17:55:50 2001
--- osf1_syscallargs.h	Wed May 30 18:03:27 2001
***************
*** 157,162 ****
--- 157,167 ----
  	syscallarg(struct osf1_itimerval *) oitv;
  };

+ struct osf1_sys_getitimer_args {
+ 	syscallarg(u_int) which;
+ 	syscallarg(struct osf1_itimerval *) itv;
+ };
+
  struct osf1_sys_fstat_args {
  	syscallarg(int) fd;
  	syscallarg(void *) sb;
***************
*** 395,400 ****
--- 400,406 ----
  int	sys_setgroups	__P((struct proc *, void *, register_t *));
  int	sys_setpgid	__P((struct proc *, void *, register_t *));
  int	osf1_sys_setitimer	__P((struct proc *, void *, register_t *));
+ int	osf1_sys_getitimer	__P((struct proc *, void *, register_t *));
  int	compat_43_sys_gethostname	__P((struct proc *, void *, register_t *));
  int	compat_43_sys_sethostname	__P((struct proc *, void *, register_t *));
  int	compat_43_sys_getdtablesize	__P((struct proc *, void *, register_t *));
*** osf1_syscalls.c    	Wed May 30 17:48:27 2001
--- osf1_syscalls.c	Wed May 30 17:49:15 2001
***************
*** 106,112 ****
  	"setitimer",			/* 83 = setitimer */
  	"#84 (unimplemented old wait)",		/* 84 = unimplemented old wait */
  	"#85 (unimplemented table)",		/* 85 = unimplemented table */
! 	"#86 (unimplemented getitimer)",		/* 86 = unimplemented getitimer */
  	"gethostname",			/* 87 = gethostname */
  	"sethostname",			/* 88 = sethostname */
  	"getdtablesize",			/* 89 = getdtablesize */
--- 106,112 ----
  	"setitimer",			/* 83 = setitimer */
  	"#84 (unimplemented old wait)",		/* 84 = unimplemented old wait */
  	"#85 (unimplemented table)",		/* 85 = unimplemented table */
! 	"getitimer",			/* 86 = getitimer */
  	"gethostname",			/* 87 = gethostname */
  	"sethostname",			/* 88 = sethostname */
  	"getdtablesize",			/* 89 = getdtablesize */
*** osf1_sysent.c    	Wed May 30 17:48:36 2001
--- osf1_sysent.c	Wed May 30 17:50:09 2001
***************
*** 192,199 ****
  	    sys_nosys },			/* 84 = unimplemented old wait */
  	{ 0, 0,
  	    sys_nosys },			/* 85 = unimplemented table */
! 	{ 0, 0,
! 	    sys_nosys },			/* 86 = unimplemented getitimer */
  	{ 2, s(struct compat_43_sys_gethostname_args),
  	    compat_43_sys_gethostname },	/* 87 = gethostname */
  	{ 2, s(struct compat_43_sys_sethostname_args),
--- 192,199 ----
  	    sys_nosys },			/* 84 = unimplemented old wait */
  	{ 0, 0,
  	    sys_nosys },			/* 85 = unimplemented table */
! 	{ 2, s(struct osf1_sys_getitimer_args),
! 	    osf1_sys_getitimer },		/* 86 = getitimer */
  	{ 2, s(struct compat_43_sys_gethostname_args),
  	    compat_43_sys_gethostname },	/* 87 = gethostname */
  	{ 2, s(struct compat_43_sys_sethostname_args),
*** osf1_time.c    	Wed May 30 17:50:32 2001
--- osf1_time.c	Wed May 30 18:10:57 2001
***************
*** 176,181 ****
--- 176,239 ----
  }

  int
+ osf1_sys_getitimer(p, v, retval)
+ 	struct proc *p;
+ 	void *v;
+ 	register_t *retval;
+ {
+ 	struct osf1_sys_getitimer_args *uap = v;
+ 	struct sys_getitimer_args a;
+ 	struct osf1_itimerval o_oitv;
+ 	struct itimerval b_oitv;
+ 	caddr_t sg;
+ 	int error;
+
+ 	switch (SCARG(uap, which)) {
+ 	case OSF1_ITIMER_REAL:
+ 		SCARG(&a, which) = ITIMER_REAL;
+ 		break;
+
+ 	case OSF1_ITIMER_VIRTUAL:
+ 		SCARG(&a, which) = ITIMER_VIRTUAL;
+ 		break;
+
+ 	case OSF1_ITIMER_PROF:
+ 		SCARG(&a, which) = ITIMER_PROF;
+ 		break;
+
+ 	default:
+ 		return (EINVAL);
+ 	}
+
+ 	sg = stackgap_init(p->p_emul);
+
+ 	SCARG(&a, itv) = stackgap_alloc(&sg, sizeof b_oitv);
+
+ 	if (error == 0)
+ 		error = sys_getitimer(p, &a, retval);
+
+ 	if (error == 0 && SCARG(uap, itv) != NULL) {
+ 		/* get the NetBSD itimerval return value */
+ 		error = copyin((caddr_t)SCARG(&a, itv), (caddr_t)&b_oitv,
+ 		    sizeof b_oitv);
+ 		if (error == 0) {
+
+ 			/* fill in and copy out the NetBSD timeval */
+ 			memset(&o_oitv, 0, sizeof o_oitv);
+ 			o_oitv.it_interval.tv_sec = b_oitv.it_interval.tv_sec;
+ 			o_oitv.it_interval.tv_usec = b_oitv.it_interval.tv_usec;
+ 			o_oitv.it_value.tv_sec = b_oitv.it_value.tv_sec;
+ 			o_oitv.it_value.tv_usec = b_oitv.it_value.tv_usec;
+
+ 			error = copyout((caddr_t)&o_oitv,
+ 			    (caddr_t)SCARG(uap, itv), sizeof o_oitv);
+ 		}
+ 	}
+
+ 	return (error);
+ }
+
+ int
  osf1_sys_settimeofday(p, v, retval)
  	struct proc *p;
  	void *v;


>Release-Note:
>Audit-Trail:
>Unformatted: