Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140526211349.GJ12324@port70.net>
Date: Mon, 26 May 2014 23:13:49 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: [UGLY PATCH v2] Support for no-legacy-syscalls archs

* Rich Felker <dalias@...c.org> [2014-05-26 14:40:36 -0400]:
> +#ifdef SYS_fork
>  	ret = syscall(SYS_fork);
> +#else
> +	ret = syscall(SYS_clone, SIGCHLD);
> +#endif

clone has more args

>  int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, struct timeval *restrict tv)
>  {
> +#ifdef SYS_select
>  	return syscall_cp(SYS_select, n, rfds, wfds, efds, tv);
> +#else
> +	long data[2] = { 0, _NSIG/8 };
> +	struct timespec ts;
> +	if (tv) {
> +		ts.tv_sec = tv->tv_sec;
> +		ts.tv_nsec = tv->tv_usec > 999999 ?
> +			999999999 : tv->tv_usec * 1000;
> +	}
> +	return syscall_cp(SYS_pselect6, n, rfds, wfds, efds, tv ? &ts : 0, data);
> +#endif

tv_usec may be negative

isnt it better to adjust tv_sec if usec is large?
or fail with EINVAL like in futimensat:

> +	if (times) {
> +		int i;
> +		for (i=0; i<2; i++) {
> +			if (times[i].tv_usec >= 1000000U)
> +				return __syscall_ret(-EINVAL);
> +			ts[i].tv_sec = times[i].tv_sec;
> +			ts[i].tv_nsec = times[i].tv_usec * 1000;
> +		}
> +	}


> +	if (times) {
> +		struct timeval tmp[2];
> +		int i;
> +		tv = tmp;
> +		for (i=0; i<2; i++) {
> +			if (times[i].tv_nsec >= 1000000000U) {
> +				if (times[i].tv_nsec == UTIME_NOW &&
> +				    times[1-i].tv_nsec == UTIME_NOW) {
> +					tv = 0;
> +					break;
> +				}
> +				if (times[i].tv_nsec == UTIME_OMIT)
> +					return __syscall_ret(-ENOSYS);
> +				return __syscall_ret(-EINVAL);
> +			}
> +			tmp[i].tv_sec = times[i].tv_sec;
> +			tmp[i].tv_usec = times[i].tv_nsec / 1000;
> +		}
> +	}

(tv_nsec+500)/1000 would be better rounding

but i guess 500 ns does not matter much

>  pid_t getpgrp(void)
>  {
> +#ifdef SYS_getpgrp
>  	return __syscall(SYS_getpgrp);
> +#else
> +	return __syscall(SYS_getpgid, 0);
> +#endif

you said this can be just the new call

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.