o Add stub support for some new futex operations,

so the annoying message is not printed.

	o	Don't warn about FUTEX_FD not being implemented
		and return ENOSYS instead of 0 (eg. success).

	o	Clear FUTEX_PRIVATE_FLAG as we actually implement
		only private futexes so there is no reason to
		return ENOSYS when app asks for a private futex.
		We don't reject shared futexes because they worked
		just fine with our implementation so far.

Approved by:	kib (mentor)
Tested by:	bsam
MFC after:	1 week
This commit is contained in:
Roman Divacky 2008-03-20 17:03:55 +00:00
parent 43b1161d4d
commit 6af821237d
2 changed files with 29 additions and 2 deletions

View File

@ -118,6 +118,15 @@ linux_sys_futex(struct thread *td, struct linux_sys_futex_args *args)
args->val, args->uaddr2, args->val3);
#endif
/*
* Our implementation provides only privates futexes. Most of the apps
* should use private futexes but don't claim so. Therefore we treat
* all futexes as private by clearing the FUTEX_PRIVATE_FLAG. It works
* in most cases (ie. when futexes are not shared on file descriptor
* or between different processes.).
*/
args->op = (args->op & ~LINUX_FUTEX_PRIVATE_FLAG);
switch (args->op) {
case LINUX_FUTEX_WAIT:
FUTEX_SYSTEM_LOCK;
@ -264,10 +273,11 @@ linux_sys_futex(struct thread *td, struct linux_sys_futex_args *args)
break;
case LINUX_FUTEX_FD:
/* XXX: Linux plans to remove this operation */
#ifdef DEBUG
printf("linux_sys_futex: unimplemented op %d\n",
args->op);
break;
#endif
return (ENOSYS);
case LINUX_FUTEX_WAKE_OP:
FUTEX_SYSTEM_LOCK;
@ -324,6 +334,18 @@ linux_sys_futex(struct thread *td, struct linux_sys_futex_args *args)
FUTEX_SYSTEM_UNLOCK;
break;
case LINUX_FUTEX_LOCK_PI:
/* not yet implemented */
return (ENOSYS);
case LINUX_FUTEX_UNLOCK_PI:
/* not yet implemented */
return (ENOSYS);
case LINUX_FUTEX_TRYLOCK_PI:
/* not yet implemented */
return (ENOSYS);
default:
printf("linux_sys_futex: unknown op %d\n",
args->op);

View File

@ -42,6 +42,11 @@
#define LINUX_FUTEX_REQUEUE 3
#define LINUX_FUTEX_CMP_REQUEUE 4
#define LINUX_FUTEX_WAKE_OP 5
#define LINUX_FUTEX_LOCK_PI 6
#define LINUX_FUTEX_UNLOCK_PI 7
#define LINUX_FUTEX_TRYLOCK_PI 8
#define LINUX_FUTEX_PRIVATE_FLAG 128
#define FUTEX_OP_SET 0 /* *(int *)UADDR2 = OPARG; */
#define FUTEX_OP_ADD 1 /* *(int *)UADDR2 += OPARG; */