syslocal(2) on 3b1 sick?
Alex S. Crain
alex at umbc3.UMD.EDU
Thu Nov 24 03:51:51 AEST 1988
In article <130 at zebra.UUCP> vern at zebra.UUCP (Vernon C. Hoxie) writes:
>
> I'm trying to write a program to reset the clock on the 3b1.
>First, I want to be able to read the clock to see if things work.
>This has to be done in the quickest time possible, so I am trying the
>syslocal(2) call special to the 3b1. It has the form:
> int syslocal(cmd, [, arg]
>From the manual (ugh) and the syslocal.h file, I get the command to be
>"SYSL_RDRTC" and the argument to be of struct rtc *x_rtc. Now:
> int x = syslocal(SYSL_RDRTC, x_rtc);
>gives x = -1. So I added perror("Error id"); as the next instruction
>and got a "Bad address" response.
syslocal wants the address of a structure, not a pointer, so the
correct calling format would be:
rtc x_rtc;
int x = syslocal(SYSL_RDRTC, &x_rtc);
This is not terribly obvious, but makes sence if you think about it long
enough, keeping in mind that C uses call-by-value argument passing.
> How does a system function provide a bad address. Oh! This is
>an AT&T machine (:>).
This is a common mistake, and is more a characteristic of C and Unix
documentation than the vendor. rtx *x_rtc implies "the address of a structure"
without being specific about where that address comes from. The natural
response is to use a pointer in that situation, and expect the system call to
return an address via the pointer. But a second glance shows that that would
be impossible, because of call-by-value, and the correct method is to pass
the address of an existing structure.
--
:alex.
Systems Programmer
nerwin!alex at umbc3.umd.edu UMBC
alex at umbc3.umd.edu
More information about the Unix-pc.general
mailing list