Skip to content

Commit bd0c933

Browse files
committed
Plan 9 from Bell Labs 2014-05-15
1 parent 6d3b63b commit bd0c933

File tree

27 files changed

+234
-110
lines changed

27 files changed

+234
-110
lines changed

sys/doc/backup.ms

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ as the term is used by everyone but disk manufacturers.
3232
In the case of BDs,
3333
even that is an exaggeration, with the actual capacity being
3434
closer to $48.44 times 10 sup 9$ bytes,
35-
so the claimed capacity should be read as `50 VAX-gigabytes',
35+
so the claimed capacity should be read as `50 BD-gigabytes',
3636
where a
37-
.I VAX-gigabyte
37+
.I BD-gigabyte
3838
is 968,800,338 bytes.
3939
The default
4040
.I venti

sys/doc/backup.pdf

31.2 KB
Binary file not shown.

sys/doc/backup.ps

-2 Bytes
Binary file not shown.

sys/man/2/time

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,27 @@ should be stored in and treated as
3333
.BR ulong s;
3434
this extends the range of valid times into the year 2106.
3535
.PP
36-
These functions work by reading
36+
.I Time
37+
simply calls
38+
.I nsec
39+
and returns the value divided by 1000000000.
40+
.PP
41+
.I Nsec
42+
is a system call.
43+
Previous implementations read
3744
.BR /dev/bintime ,
38-
opening that file when they are first called.
45+
opening that file when first called,
46+
and maintaining a static file descriptor;
47+
however,
48+
the maintenance of file descriptors in the face
49+
of process forks is overly complex and prone to error.
3950
.SH SOURCE
4051
.B /sys/src/libc/9sys/time.c
4152
.br
42-
.B /sys/src/libc/9sys/nsec.c
53+
.B /sys/src/libc/9syscall
4354
.SH SEE ALSO
4455
.IR cputime (2),
4556
.IR cons (3)
4657
.SH DIAGNOSTICS
4758
Sets
4859
.IR errstr .
49-
.SH BUGS
50-
These routines maintain a static file descriptor.

sys/src/9/bcm/fns.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ extern int fpuemu(Ureg*);
9595
extern void delay(int); /* only scheddump() */
9696
extern int islo(void);
9797
extern void microdelay(int); /* only edf.c */
98-
extern void evenaddr(uintptr);
9998
extern void idlehands(void);
10099
extern void setkernur(Ureg*, Proc*); /* only devproc.c */
101100
extern void* sysexecregs(uintptr, ulong, int);
102101
extern void sysprocsetup(Proc*);
102+
extern void validalign(uintptr, unsigned);
103103

104104
extern void kexit(Ureg*);
105105

sys/src/9/kw/arch.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,32 @@ setkernur(Ureg* ureg, Proc* p)
2828
}
2929

3030
/*
31-
* called in sysfile.c
31+
* called in syscallfmt.c, sysfile.c, sysproc.c
3232
*/
3333
void
34-
evenaddr(uintptr addr)
35-
{
36-
if(addr & 3){
37-
postnote(up, 1, "sys: odd address", NDebug);
38-
error(Ebadarg);
39-
}
34+
validalign(uintptr addr, unsigned align)
35+
{
36+
/*
37+
* Plan 9 is a 32-bit O/S, and the hardware it runs on
38+
* does not usually have instructions which move 64-bit
39+
* quantities directly, synthesizing the operations
40+
* with 32-bit move instructions. Therefore, the compiler
41+
* (and hardware) usually only enforce 32-bit alignment,
42+
* if at all.
43+
*
44+
* Take this out if the architecture warrants it.
45+
*/
46+
if(align == sizeof(vlong))
47+
align = sizeof(long);
48+
49+
/*
50+
* Check align is a power of 2, then addr alignment.
51+
*/
52+
if((align != 0 && !(align & (align-1))) && !(addr & (align-1)))
53+
return;
54+
postnote(up, 1, "sys: odd address", NDebug);
55+
error(Ebadarg);
56+
/*NOTREACHED*/
4057
}
4158

4259
/* go to user space */

sys/src/9/kw/fns.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ extern Block* uciallocb(int);
128128
extern void delay(int); /* only scheddump() */
129129
extern int islo(void);
130130
extern void microdelay(int); /* only edf.c */
131-
extern void evenaddr(uintptr);
132131
extern void idlehands(void);
133132
extern void setkernur(Ureg*, Proc*); /* only devproc.c */
134133
extern void spldone(void);
135134
extern int splfhi(void);
136135
extern int splflo(void);
137136
extern void sysprocsetup(Proc*);
137+
extern void validalign(uintptr, unsigned);
138138

139139
/*
140140
* PCI

sys/src/9/mtx/fns.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ void delay(int);
1515
void dumpregs(Ureg*);
1616
void delayloopinit(void);
1717
void eieio(void);
18-
void evenaddr(ulong);
1918
void faultpower(Ureg*, ulong addr, int read);
2019
void fprestore(FPsave*);
2120
void fpsave(FPsave*);
@@ -103,6 +102,7 @@ void trapvec(void);
103102
void tlbflush(ulong);
104103
void tlbflushall(void);
105104
#define userureg(ur) (((ur)->status & MSR_PR) != 0)
105+
void validalign(uintptr, unsigned);
106106
void watchreset(void);
107107

108108
#define waserror() (up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))

sys/src/9/mtx/trap.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -522,15 +522,32 @@ kprocchild(Proc *p, void (*func)(void*), void *arg)
522522
}
523523

524524
/*
525-
* called in sysfile.c
525+
* called in syscallfmt.c, sysfile.c, sysproc.c
526526
*/
527527
void
528-
evenaddr(ulong addr)
528+
validalign(uintptr addr, unsigned align)
529529
{
530-
if(addr & 3){
531-
postnote(up, 1, "sys: odd address", NDebug);
532-
error(Ebadarg);
533-
}
530+
/*
531+
* Plan 9 is a 32-bit O/S, and the hardware it runs on
532+
* does not usually have instructions which move 64-bit
533+
* quantities directly, synthesizing the operations
534+
* with 32-bit move instructions. Therefore, the compiler
535+
* (and hardware) usually only enforce 32-bit alignment,
536+
* if at all.
537+
*
538+
* Take this out if the architecture warrants it.
539+
*/
540+
if(align == sizeof(vlong))
541+
align = sizeof(long);
542+
543+
/*
544+
* Check align is a power of 2, then addr alignment.
545+
*/
546+
if((align != 0 && !(align & (align-1))) && !(addr & (align-1)))
547+
return;
548+
postnote(up, 1, "sys: odd address", NDebug);
549+
error(Ebadarg);
550+
/*NOTREACHED*/
534551
}
535552

536553
long

sys/src/9/omap/arch.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,32 @@ setkernur(Ureg* ureg, Proc* p)
2828
}
2929

3030
/*
31-
* called in sysfile.c
31+
* called in syscallfmt.c, sysfile.c, sysproc.c
3232
*/
3333
void
34-
evenaddr(uintptr addr)
35-
{
36-
if(addr & 3){
37-
postnote(up, 1, "sys: odd address", NDebug);
38-
error(Ebadarg);
39-
}
34+
validalign(uintptr addr, unsigned align)
35+
{
36+
/*
37+
* Plan 9 is a 32-bit O/S, and the hardware it runs on
38+
* does not usually have instructions which move 64-bit
39+
* quantities directly, synthesizing the operations
40+
* with 32-bit move instructions. Therefore, the compiler
41+
* (and hardware) usually only enforce 32-bit alignment,
42+
* if at all.
43+
*
44+
* Take this out if the architecture warrants it.
45+
*/
46+
if(align == sizeof(vlong))
47+
align = sizeof(long);
48+
49+
/*
50+
* Check align is a power of 2, then addr alignment.
51+
*/
52+
if((align != 0 && !(align & (align-1))) && !(addr & (align-1)))
53+
return;
54+
postnote(up, 1, "sys: odd address", NDebug);
55+
error(Ebadarg);
56+
/*NOTREACHED*/
4057
}
4158

4259
/* go to user space */

0 commit comments

Comments
 (0)