Re: 2.1.5 compile errors

Linus Torvalds (torvalds@cs.helsinki.fi)
Fri, 18 Oct 1996 19:43:14 +0300 (EET DST)


On Fri, 18 Oct 1996, Mike Wangsmo wrote:
>
> Here is the error I get when compiling 2.1.5:

Yes. The sound drivers haven't been upgraded to the new user access
handling, and they won't compile. However, it shouldn't be too hard to do
the patches, there are essentially just a few simple rules on how to
change the old-style calls to new-style calls:

memcpy_fromfs -> copy_from_user
memcpy_tofs -> copy_to_user
x = get_user(y) -> get_user(x, y)
x = get_fs_byte(y) -> get_user(x, (unsigned char *) y)
x = get_fs_word(y) -> get_user(x, (unsigned short *) y)
x = get_fs_long(y) -> get_user(x, (unsigned int *) y)
put_fs_byte(x,y) -> put_user(x, (unsigned char *) y)
put_fs_word(x,y) -> put_user(x, (unsigned short *) y)
put_fs_long(x,y) -> put_user(x, (unsigned int *) y)

There are only a few subtle things to look out for:

- note the "get_fs_long/put_fs_long" translations. They should _not_ use
pointers to "long", but pointers to "int". This doesn't make any
difference on x86, but there is a clear difference on alpha
("get_fs_quad/put_fs_quad" are used for long pointer accesses, and
quite frankly, nothing uses that).

- The change from "x = get_user()" -> "get_user(x,y)" can lead to problems.
Notably, the old syntax is often used inside expressions, and sometimes
there is no variable to be set directly. So sometimes you may have to
change code like this:

do_function_call(get_user(user_ptr));

into something like this:

int variable;
get_user(variable, user_ptr);
do_function_call(variable);

The reason for the change to "get_user()" is that we also return an error
code these days (but for a first-order translation of the old code to the new
you can ignore the error code returned for now).

> The ppp compile problems of 2.1.4 were fixed, at least as far as
> compilation goes, it appears.

I'm told it should even work ;)

The reason I haven't changed the sound code is that while the process
isn't very complicated, it _is_ kind of tedious, and it also needs to be
tested for silly errors afterwards. I'm still hoping people will send me
patches..

Linus