Let kernel POSIX timer code and mqueue code to use integer as a resource

handle, the timer_t and mqd_t types will be a pointer which userland
will define it.
This commit is contained in:
David Xu 2006-03-01 06:29:34 +00:00
parent b8211fabf1
commit 61d3a4efc2
4 changed files with 49 additions and 49 deletions

View File

@ -85,7 +85,7 @@ static int itimer_init(void *, int, int);
static void itimer_fini(void *, int); static void itimer_fini(void *, int);
static void itimer_enter(struct itimer *); static void itimer_enter(struct itimer *);
static void itimer_leave(struct itimer *); static void itimer_leave(struct itimer *);
static struct itimer *itimer_find(struct proc *, timer_t, int); static struct itimer *itimer_find(struct proc *, int, int);
static void itimers_alloc(struct proc *); static void itimers_alloc(struct proc *);
static void itimers_event_hook(void *arg, struct proc *p); static void itimers_event_hook(void *arg, struct proc *p);
static int realtimer_create(struct itimer *); static int realtimer_create(struct itimer *);
@ -97,8 +97,8 @@ static void realtimer_clocktime(clockid_t, struct timespec *);
static void realtimer_expire(void *); static void realtimer_expire(void *);
static void realtimer_event_hook(struct proc *, clockid_t, int event); static void realtimer_event_hook(struct proc *, clockid_t, int event);
static int kern_timer_create(struct thread *, clockid_t, static int kern_timer_create(struct thread *, clockid_t,
struct sigevent *, timer_t *, timer_t); struct sigevent *, int *, int);
static int kern_timer_delete(struct thread *, timer_t); static int kern_timer_delete(struct thread *, int);
int register_posix_clock(int, struct kclock *); int register_posix_clock(int, struct kclock *);
void itimer_fire(struct itimer *it); void itimer_fire(struct itimer *it);
@ -947,18 +947,18 @@ itimer_leave(struct itimer *it)
} }
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct timer_create_args { struct ktimer_create_args {
clockid_t clock_id; clockid_t clock_id;
struct sigevent * evp; struct sigevent * evp;
timer_t * timerid; int * timerid;
}; };
#endif #endif
int int
timer_create(struct thread *td, struct timer_create_args *uap) ktimer_create(struct thread *td, struct ktimer_create_args *uap)
{ {
struct sigevent *evp1, ev; struct sigevent *evp1, ev;
timer_t id; int id;
int error; int error;
if (uap->evp != NULL) { if (uap->evp != NULL) {
@ -972,7 +972,7 @@ timer_create(struct thread *td, struct timer_create_args *uap)
error = kern_timer_create(td, uap->clock_id, evp1, &id, -1); error = kern_timer_create(td, uap->clock_id, evp1, &id, -1);
if (error == 0) { if (error == 0) {
error = copyout(&id, uap->timerid, sizeof(timer_t)); error = copyout(&id, uap->timerid, sizeof(int));
if (error != 0) if (error != 0)
kern_timer_delete(td, id); kern_timer_delete(td, id);
} }
@ -981,7 +981,7 @@ timer_create(struct thread *td, struct timer_create_args *uap)
static int static int
kern_timer_create(struct thread *td, clockid_t clock_id, kern_timer_create(struct thread *td, clockid_t clock_id,
struct sigevent *evp, timer_t *timerid, timer_t preset_id) struct sigevent *evp, int *timerid, int preset_id)
{ {
struct proc *p = td->td_proc; struct proc *p = td->td_proc;
struct itimer *it; struct itimer *it;
@ -1089,19 +1089,19 @@ out:
} }
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct timer_delete_args { struct ktimer_delete_args {
timer_t timerid; int timerid;
}; };
#endif #endif
int int
timer_delete(struct thread *td, struct timer_delete_args *uap) ktimer_delete(struct thread *td, struct ktimer_delete_args *uap)
{ {
return (kern_timer_delete(td, uap->timerid)); return (kern_timer_delete(td, uap->timerid));
} }
static struct itimer * static struct itimer *
itimer_find(struct proc *p, timer_t timerid, int include_deleting) itimer_find(struct proc *p, int timerid, int include_deleting)
{ {
struct itimer *it; struct itimer *it;
@ -1119,7 +1119,7 @@ itimer_find(struct proc *p, timer_t timerid, int include_deleting)
} }
static int static int
kern_timer_delete(struct thread *td, timer_t timerid) kern_timer_delete(struct thread *td, int timerid)
{ {
struct proc *p = td->td_proc; struct proc *p = td->td_proc;
struct itimer *it; struct itimer *it;
@ -1151,8 +1151,8 @@ kern_timer_delete(struct thread *td, timer_t timerid)
} }
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct timer_settime_args { struct ktimer_settime_args {
timer_t timerid; int timerid;
int flags; int flags;
const struct itimerspec * value; const struct itimerspec * value;
struct itimerspec * ovalue; struct itimerspec * ovalue;
@ -1160,7 +1160,7 @@ struct timer_settime_args {
#endif #endif
int int
timer_settime(struct thread *td, struct timer_settime_args *uap) ktimer_settime(struct thread *td, struct ktimer_settime_args *uap)
{ {
struct proc *p = td->td_proc; struct proc *p = td->td_proc;
struct itimer *it; struct itimer *it;
@ -1195,14 +1195,14 @@ timer_settime(struct thread *td, struct timer_settime_args *uap)
} }
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct timer_gettime_args { struct ktimer_gettime_args {
timer_t timerid; int timerid;
struct itimerspec * value; struct itimerspec * value;
}; };
#endif #endif
int int
timer_gettime(struct thread *td, struct timer_gettime_args *uap) ktimer_gettime(struct thread *td, struct ktimer_gettime_args *uap)
{ {
struct proc *p = td->td_proc; struct proc *p = td->td_proc;
struct itimer *it; struct itimer *it;
@ -1229,12 +1229,12 @@ timer_gettime(struct thread *td, struct timer_gettime_args *uap)
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct timer_getoverrun_args { struct timer_getoverrun_args {
timer_t timerid; int timerid;
}; };
#endif #endif
int int
timer_getoverrun(struct thread *td, struct timer_getoverrun_args *uap) ktimer_getoverrun(struct thread *td, struct ktimer_getoverrun_args *uap)
{ {
struct proc *p = td->td_proc; struct proc *p = td->td_proc;
struct itimer *it; struct itimer *it;
@ -1348,7 +1348,7 @@ realtimer_clocktime(clockid_t id, struct timespec *ts)
} }
int int
itimer_accept(struct proc *p, timer_t timerid, ksiginfo_t *ksi) itimer_accept(struct proc *p, int timerid, ksiginfo_t *ksi)
{ {
struct itimer *it; struct itimer *it;

View File

@ -438,15 +438,15 @@
const struct timespec *tp); } const struct timespec *tp); }
234 AUE_NULL MSTD { int clock_getres(clockid_t clock_id, \ 234 AUE_NULL MSTD { int clock_getres(clockid_t clock_id, \
struct timespec *tp); } struct timespec *tp); }
235 AUE_NULL MSTD { int timer_create(clockid_t clock_id, \ 235 AUE_NULL MSTD { int ktimer_create(clockid_t clock_id, \
struct sigevent *evp, timer_t *timerid); } struct sigevent *evp, int *timerid); }
236 AUE_NULL MSTD { int timer_delete(timer_t timerid); } 236 AUE_NULL MSTD { int ktimer_delete(int timerid); }
237 AUE_NULL MSTD { int timer_settime(timer_t timerid, int flags, \ 237 AUE_NULL MSTD { int ktimer_settime(int timerid, int flags, \
const struct itimerspec *value, \ const struct itimerspec *value, \
struct itimerspec *ovalue); } struct itimerspec *ovalue); }
238 AUE_NULL MSTD { int timer_gettime(timer_t timerid, struct \ 238 AUE_NULL MSTD { int ktimer_gettime(int timerid, struct \
itimerspec *value); } itimerspec *value); }
239 AUE_NULL MSTD { int timer_getoverrun(timer_t timerid); } 239 AUE_NULL MSTD { int ktimer_getoverrun(int timerid); }
240 AUE_NULL MSTD { int nanosleep(const struct timespec *rqtp, \ 240 AUE_NULL MSTD { int nanosleep(const struct timespec *rqtp, \
struct timespec *rmtp); } struct timespec *rmtp); }
241 AUE_NULL UNIMPL nosys 241 AUE_NULL UNIMPL nosys
@ -799,22 +799,22 @@
455 AUE_NULL MSTD { int thr_new(struct thr_param *param, \ 455 AUE_NULL MSTD { int thr_new(struct thr_param *param, \
int param_size); } int param_size); }
456 AUE_NULL MSTD { int sigqueue(pid_t pid, int signum, void *value); } 456 AUE_NULL MSTD { int sigqueue(pid_t pid, int signum, void *value); }
457 AUE_NULL MNOSTD { int mq_open(const char *path, int flags, \ 457 AUE_NULL MNOSTD { int kmq_open(const char *path, int flags, \
mode_t mode, const struct mq_attr *attr); } mode_t mode, const struct mq_attr *attr); }
458 AUE_NULL MNOSTD { int mq_setattr(mqd_t mqd, \ 458 AUE_NULL MNOSTD { int kmq_setattr(int mqd, \
const struct mq_attr *attr, \ const struct mq_attr *attr, \
struct mq_attr *oattr); } struct mq_attr *oattr); }
459 AUE_NULL MNOSTD { int mq_timedreceive(mqd_t mqd, \ 459 AUE_NULL MNOSTD { int kmq_timedreceive(int mqd, \
char *msg_ptr, size_t msg_len, \ char *msg_ptr, size_t msg_len, \
unsigned *msg_prio, \ unsigned *msg_prio, \
const struct timespec *abs_timeout); } const struct timespec *abs_timeout); }
460 AUE_NULL MNOSTD { int mq_timedsend(mqd_t mqd, \ 460 AUE_NULL MNOSTD { int kmq_timedsend(int mqd, \
const char *msg_ptr, size_t msg_len,\ const char *msg_ptr, size_t msg_len,\
unsigned msg_prio, \ unsigned msg_prio, \
const struct timespec *abs_timeout);} const struct timespec *abs_timeout);}
461 AUE_NULL MNOSTD { int mq_notify(mqd_t mqd, \ 461 AUE_NULL MNOSTD { int kmq_notify(int mqd, \
const struct sigevent *sigev); } const struct sigevent *sigev); }
462 AUE_NULL MNOSTD { int mq_unlink(const char *path); } 462 AUE_NULL MNOSTD { int kmq_unlink(const char *path); }
463 AUE_NULL MSTD { int abort2(const char *why, int nargs, void **args); } 463 AUE_NULL MSTD { int abort2(const char *why, int nargs, void **args); }
464 AUE_NULL MSTD { int thr_set_name(long id, const char *name); } 464 AUE_NULL MSTD { int thr_set_name(long id, const char *name); }
; Please copy any additions and changes to the following compatability tables: ; Please copy any additions and changes to the following compatability tables:

View File

@ -1893,7 +1893,7 @@ notifier_remove(struct proc *p, struct mqueue *mq, int fd)
* Syscall to open a message queue * Syscall to open a message queue
*/ */
int int
mq_open(struct thread *td, struct mq_open_args *uap) kmq_open(struct thread *td, struct kmq_open_args *uap)
{ {
char path[MQFS_NAMELEN + 1]; char path[MQFS_NAMELEN + 1];
struct mq_attr attr, *pattr; struct mq_attr attr, *pattr;
@ -2007,7 +2007,7 @@ mq_open(struct thread *td, struct mq_open_args *uap)
* Syscall to unlink a message queue * Syscall to unlink a message queue
*/ */
int int
mq_unlink(struct thread *td, struct mq_unlink_args *uap) kmq_unlink(struct thread *td, struct kmq_unlink_args *uap)
{ {
char path[MQFS_NAMELEN+1]; char path[MQFS_NAMELEN+1];
struct mqfs_node *pn; struct mqfs_node *pn;
@ -2083,7 +2083,7 @@ getmq_write(struct thread *td, int fd, struct file **fpp,
* Syscall * Syscall
*/ */
int int
mq_setattr(struct thread *td, struct mq_setattr_args *uap) kmq_setattr(struct thread *td, struct kmq_setattr_args *uap)
{ {
struct mqueue *mq; struct mqueue *mq;
struct file *fp; struct file *fp;
@ -2120,7 +2120,7 @@ mq_setattr(struct thread *td, struct mq_setattr_args *uap)
* Syscall * Syscall
*/ */
int int
mq_timedreceive(struct thread *td, struct mq_timedreceive_args *uap) kmq_timedreceive(struct thread *td, struct kmq_timedreceive_args *uap)
{ {
struct mqueue *mq; struct mqueue *mq;
struct file *fp; struct file *fp;
@ -2141,7 +2141,7 @@ mq_timedreceive(struct thread *td, struct mq_timedreceive_args *uap)
* Syscall * Syscall
*/ */
int int
mq_timedsend(struct thread *td, struct mq_timedsend_args *uap) kmq_timedsend(struct thread *td, struct kmq_timedsend_args *uap)
{ {
struct mqueue *mq; struct mqueue *mq;
struct file *fp; struct file *fp;
@ -2161,7 +2161,7 @@ mq_timedsend(struct thread *td, struct mq_timedsend_args *uap)
* Syscall * Syscall
*/ */
int int
mq_notify(struct thread *td, struct mq_notify_args *uap) kmq_notify(struct thread *td, struct kmq_notify_args *uap)
{ {
struct sigevent ev; struct sigevent ev;
struct filedesc *fdp; struct filedesc *fdp;
@ -2471,12 +2471,12 @@ static struct vfsops mqfs_vfsops = {
.vfs_statfs = mqfs_statfs, .vfs_statfs = mqfs_statfs,
}; };
SYSCALL_MODULE_HELPER(mq_open); SYSCALL_MODULE_HELPER(kmq_open);
SYSCALL_MODULE_HELPER(mq_setattr); SYSCALL_MODULE_HELPER(kmq_setattr);
SYSCALL_MODULE_HELPER(mq_timedsend); SYSCALL_MODULE_HELPER(kmq_timedsend);
SYSCALL_MODULE_HELPER(mq_timedreceive); SYSCALL_MODULE_HELPER(kmq_timedreceive);
SYSCALL_MODULE_HELPER(mq_notify); SYSCALL_MODULE_HELPER(kmq_notify);
SYSCALL_MODULE_HELPER(mq_unlink); SYSCALL_MODULE_HELPER(kmq_unlink);
VFS_SET(mqfs_vfsops, mqueuefs, VFCF_SYNTHETIC); VFS_SET(mqfs_vfsops, mqueuefs, VFCF_SYNTHETIC);
MODULE_VERSION(mqueuefs, 1); MODULE_VERSION(mqueuefs, 1);

View File

@ -57,8 +57,8 @@ typedef __int64_t __rlim_t; /* resource limit - intentionally */
typedef __uint8_t __sa_family_t; typedef __uint8_t __sa_family_t;
typedef __uint32_t __socklen_t; typedef __uint32_t __socklen_t;
typedef long __suseconds_t; /* microseconds (signed) */ typedef long __suseconds_t; /* microseconds (signed) */
typedef __int32_t __timer_t; /* timer_gettime()... */ typedef struct __timer *__timer_t; /* timer_gettime()... */
typedef __int32_t __mqd_t; /* mq_open()... */ typedef struct __mq *__mqd_t; /* mq_open()... */
typedef __uint32_t __uid_t; typedef __uint32_t __uid_t;
typedef unsigned int __useconds_t; /* microseconds (unsigned) */ typedef unsigned int __useconds_t; /* microseconds (unsigned) */