File: os.md

package info (click to toggle)
iraf 2.18.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,000 kB
  • sloc: ansic: 115,890; fortran: 74,576; lisp: 18,888; yacc: 5,642; sh: 961; lex: 596; makefile: 509; asm: 159; csh: 54; xml: 33; sed: 4
file content (87 lines) | stat: -rw-r--r-- 1,845 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# OS specific function is host$os

## ZGMTCO

ZGMTCO returns the correction, in seconds, from local standard
time. This may have some issues with daylight saving time.

File: `gmtcotest.x`
```
task gmtcotest = t_gmtcotest
procedure t_gmtcotest ()
int corr
begin
    call zgmtco(corr)
	if ((corr < - 86400) || (corr > 86400)) {
	    call printf("Unreasonable correction %d\n")
		    call pargi(corr)
	} else {
	    call printf("OK")
	}
end
```

The test program should just return OK:

```
cl> softools
cl> xc -w gmtcotest.x
cl> task $gmtcotest = gmtcotest.e
cl> gmtcotest
OK
```

## Non-local goto

IRAF uses its own version of a "long jump" (non-local goto), which needs a
small piece of code to be written in assembler (`zsvjmp.s`). This is highly
CPU and OS specific. Here is some test code:

File: `jmptest.x`
```
include <config.h>
task jmptest = t_jmptest
procedure t_jmptest ()
int jmp_buf[LEN_JUMPBUF]
int status, step
begin
    status = 0
    step = 0

    call zsvjmp(jmp_buf, status)
    call printf("status = %d, step = %d\n")
    call pargi(status)
    call pargi(step)
    if (status == 0) {
        if (step == 1) {
	    call printf("Error: Called zsvjmp a second time\n")
            return
	 }
         step = 1
         call printf("Calling zdojmp\n")
         call zdojmp(jmp_buf, status)
         call printf("Error: return from ZDOJMP\n")
         return
      }
      if (step == 0) {
         call printf("Error: ZSVJMP was not called successfully\n")
         return
      }
      call printf("All OK\n")
end
```

`ZSVJMP` saves the processor registers in a buffer, while a following `ZDOJMP`
restores them (and therefore goes back to the place where `ZSVJMP was called).

```
cl> softools
cl> xc -w jmptest.x
cl> task $jmptest = jmptest.e
cl> jmptest
status = 0, step = 0
Calling zdojmp
status = 1, step = 1
All OK
```