summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ac1f030)
raw | patch | inline | side by side (parent: ac1f030)
author | Alexander Shiryaev <aixp@mail.ru> | |
Tue, 13 Nov 2012 12:48:15 +0000 (16:48 +0400) | ||
committer | Alexander Shiryaev <aixp@mail.ru> | |
Tue, 13 Nov 2012 12:48:15 +0000 (16:48 +0400) |
31 files changed:
diff --git a/Trurl-based/_LinuxOpenBSD_/Comm/Mod/V24.odc b/Trurl-based/_LinuxOpenBSD_/Comm/Mod/V24.odc
index 370d3d5c5e4be30c720d5b012cc0c987e55b25c5..be4d7a39db0b1ef9f873344cdbb009263f40f227 100644 (file)
Binary files a/Trurl-based/_LinuxOpenBSD_/Comm/Mod/V24.odc and b/Trurl-based/_LinuxOpenBSD_/Comm/Mod/V24.odc differ
Binary files a/Trurl-based/_LinuxOpenBSD_/Comm/Mod/V24.odc and b/Trurl-based/_LinuxOpenBSD_/Comm/Mod/V24.odc differ
index 9d1f951b2e8d466e7650b13a19e9d61f298c9353..e0fb2948043af507b0823e5e0471ac02b34b30e7 100644 (file)
CONST
(* /usr/include/i386-linux-gnu/bits/ioctl-types.h *)
- TIOCM_LE* = 001H;
- TIOCM_DTR* = 002H;
- TIOCM_RTS* = 004H;
- TIOCM_ST* = 008H;
- TIOCM_SR* = 010H;
- TIOCM_CTS* = 020H;
- TIOCM_CAR* = 040H;
- TIOCM_RNG* = 080H;
- TIOCM_DSR* = 100H;
+ TIOCM_LE* = {0};
+ TIOCM_DTR* = {1};
+ TIOCM_RTS* = {2};
+ TIOCM_ST* = {3};
+ TIOCM_SR* = {4};
+ TIOCM_CTS* = {5};
+ TIOCM_CAR* = {6};
+ TIOCM_RNG* = {7};
+ TIOCM_DSR* = {8};
FIOCLEX* = 21585;
FIONCLEX* = 21584;
index 789a23dbeefb315bd75c79d86dca745005ce9e24..aeb5949462af99cc9a84e5b15c6f6a441ecb7c0e 100644 (file)
VWERASE* = 14;
VLNEXT* = 15;
VEOL2* = 16;
- IGNBRK* = 1;
- BRKINT* = 2;
- IGNPAR* = 4;
- PARMRK* = 8;
- INPCK* = 16;
- ISTRIP* = 32;
- INLCR* = 64;
- IGNCR* = 128;
- ICRNL* = 256;
- IUCLC* = 512;
- IXON* = 1024;
- IXANY* = 2048;
- IXOFF* = 4096;
- IMAXBEL* = 8192;
- IUTF8* = 16384;
- OPOST* = 1;
- OLCUC* = 2;
- ONLCR* = 4;
- OCRNL* = 8;
- ONOCR* = 16;
- ONLRET* = 32;
- OFILL* = 64;
- OFDEL* = 128;
- VTDLY* = 16384;
- VT0* = 0;
- VT1* = 16384;
- B0* = 0; (* hang up *)
- B50* = 1;
- B75* = 2;
- B110* = 3;
- B134* = 4;
- B150* = 5;
- B200* = 6;
- B300* = 7;
- B600* = 8;
- B1200* = 9;
- B1800* = 10;
- B2400* = 11;
- B4800* = 12;
- B9600* = 13;
- B19200* = 14;
- B38400* = 15;
- CSIZE* = 48;
- CS5* = 0;
- CS6* = 16;
- CS7* = 32;
- CS8* = 48;
- CSTOPB* = 64;
- CREAD* = 128;
- PARENB* = 256;
- PARODD* = 512;
- HUPCL* = 1024;
- CLOCAL* = 2048;
- B57600* = 4097;
- B115200* = 4098;
- B230400* = 4099;
- B460800* = 4100;
- B500000* = 4101;
- B576000* = 4102;
- B921600* = 4103;
- B1000000* = 4104;
- B1152000* = 4105;
- B1500000* = 4106;
- B2000000* = 4107;
- B2500000* = 4108;
- B3000000* = 4109;
- B3500000* = 4110;
- B4000000* = 4111;
+ IGNBRK* = 1; (* {0} *)
+ BRKINT* = 2; (* {1} *)
+ IGNPAR* = 4; (* {2} *)
+ PARMRK* = 8; (* {3} *)
+ INPCK* = 16; (* {4} *)
+ ISTRIP* = 32; (* {5} *)
+ INLCR* = 64; (* {6} *)
+ IGNCR* = 128; (* {7} *)
+ ICRNL* = 256; (* {8} *)
+ IUCLC* = 512; (* {9} *)
+ IXON* = 1024; (* {10} *)
+ IXANY* = 2048; (* {11} *)
+ IXOFF* = 4096; (* {12} *)
+ IMAXBEL* = 8192; (* {13} *)
+ IUTF8* = 16384; (* {14} *)
+ OPOST* = 1; (* {0} *)
+ OLCUC* = 2; (* {1} *)
+ ONLCR* = 4; (* {2} *)
+ OCRNL* = 8; (* {3} *)
+ ONOCR* = 16; (* {4} *)
+ ONLRET* = 32; (* {5} *)
+ OFILL* = 64; (* {6} *)
+ OFDEL* = 128; (* {7} *)
+ VTDLY* = 16384; (* {14} *)
+ VT0* = 0; (* {} *)
+ VT1* = 16384; (* {14} *)
+ B0* = 0; (* {} *) (* hang up *)
+ B50* = 1; (* {0} *)
+ B75* = 2; (* {1} *)
+ B110* = 3; (* {0,1} *)
+ B134* = 4; (* {2} *)
+ B150* = 5; (* {0,2} *)
+ B200* = 6; (* {1,2} *)
+ B300* = 7; (* {0..2} *)
+ B600* = 8; (* {3} *)
+ B1200* = 9; (* {0,3} *)
+ B1800* = 10; (* {1,3} *)
+ B2400* = 11; (* {0,1,3} *)
+ B4800* = 12; (* {2,3} *)
+ B9600* = 13; (* {0,2,3} *)
+ B19200* = 14; (* {1..3} *)
+ B38400* = 15; (* {0..3} *)
+ CSIZE* = 48; (* {4,5} *)
+ CS5* = 0; (* {} *)
+ CS6* = 16; (* {4} *)
+ CS7* = 32; (* {5} *)
+ CS8* = 48; (* {4,5} *)
+ CSTOPB* = 64; (* {6} *)
+ CREAD* = 128; (* {7} *)
+ PARENB* = 256; (* {8} *)
+ PARODD* = 512; (* {9} *)
+ HUPCL* = 1024; (* {10} *)
+ CLOCAL* = 2048; (* {11} *)
+ B57600* = 4097; (* {0,12} *)
+ B115200* = 4098; (* {1,12} *)
+ B230400* = 4099; (* {0,1,12} *)
+ B460800* = 4100; (* {2,12} *)
+ B500000* = 4101; (* {0,2,12} *)
+ B576000* = 4102; (* {1,2,12} *)
+ B921600* = 4103; (* {0..2,12} *)
+ B1000000* = 4104; (* {3,12} *)
+ B1152000* = 4105; (* {0,3,12} *)
+ B1500000* = 4106; (* {1,3,12} *)
+ B2000000* = 4107; (* {0,1,3,12} *)
+ B2500000* = 4108; (* {2,3,12} *)
+ B3000000* = 4109; (* {0,2,3,12} *)
+ B3500000* = 4110; (* {1..3,12} *)
+ B4000000* = 4111; (* {0..3,12} *)
__MAX_BAUD* = B4000000;
- ISIG* = 1;
- ICANON* = 2;
- ECHO* = 8;
- ECHOE* = 16;
- ECHOK* = 32;
- ECHONL* = 64;
- NOFLSH* = 128;
- TOSTOP* = 256;
- IEXTEN* = 32768;
+ ISIG* = 1; (* {0} *)
+ ICANON* = 2; (* {1} *)
+ ECHO* = 8; (* {3} *)
+ ECHOE* = 16; (* {4} *)
+ ECHOK* = 32; (* {5} *)
+ ECHONL* = 64; (* {6} *)
+ NOFLSH* = 128; (* {7} *)
+ TOSTOP* = 256; (* {8} *)
+ IEXTEN* = 32768; (* {15} *)
TCOOFF* = 0;
TCOON* = 1;
TCIOFF* = 2;
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Ioctl/Ioctl.txt.templ b/Trurl-based/_Linux_/Lin/Mod/gen-Ioctl/Ioctl.txt.templ
--- /dev/null
@@ -0,0 +1,17 @@
+MODULE LinIoctl ["libc.so.6"];
+
+ (*
+ A. V. Shiryaev, 2012.11
+
+ Linux
+ i386
+ *)
+
+ CONST
+ (* /usr/include/i386-linux-gnu/bits/ioctl-types.h *)
+%%defs-ioctl1%%
+%%defs-ioctl%%
+ PROCEDURE [ccall] ioctl0* ["ioctl"] (d: INTEGER; req: INTEGER): INTEGER;
+ PROCEDURE [ccall] ioctl1* ["ioctl"] (d: INTEGER; req: INTEGER; VAR arg: INTEGER): INTEGER;
+
+END LinIoctl.
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Ioctl/Makefile b/Trurl-based/_Linux_/Lin/Mod/gen-Ioctl/Makefile
--- /dev/null
@@ -0,0 +1,22 @@
+# This is GNU Makefile
+# BSD GNU
+# ${.TARGET} $@
+# ${.ALLSRC} $^
+# ${.IMPSRC} $<
+
+all: mkioctl Ioctl.txt
+
+PY = python2.7
+DEFS = defs-ioctl1 defs-ioctl
+
+defs-ioctl: mkioctl
+ ./mkioctl > $@
+
+Ioctl.txt: Ioctl.txt.templ ${DEFS}
+ ${PY} ./untempl.py Ioctl.txt.templ $@
+
+defs-ioctl1:
+ ./dumpdefs.py 3 0 s /usr/include/i386-linux-gnu/bits/ioctl-types.h | grep TIOCM_ > $@
+
+clean:
+ rm -f mkioctl Ioctl.txt ${DEFS}
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Ioctl/dumpdefs.py b/Trurl-based/_Linux_/Lin/Mod/gen-Ioctl/dumpdefs.py
--- /dev/null
@@ -0,0 +1 @@
+../gen-Libc/dumpdefs.py
\ No newline at end of file
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Ioctl/mkioctl.c b/Trurl-based/_Linux_/Lin/Mod/gen-Ioctl/mkioctl.c
--- /dev/null
@@ -0,0 +1,30 @@
+#include <sys/ioctl.h>
+#include <stdio.h>
+
+#define PREFIX "\t\t"
+
+void D (const char *s, int ctl)
+{
+ printf("%s%s* = %d;\n", PREFIX, s, ctl);
+}
+
+int main (int argc, char *argv[])
+{
+ D("FIOCLEX", FIOCLEX);
+ D("FIONCLEX", FIONCLEX);
+ D("FIONREAD", FIONREAD);
+ D("FIONBIO", FIONBIO);
+ D("FIOASYNC", FIOASYNC);
+
+ D("TIOCMGET", TIOCMGET);
+ D("TIOCMSET", TIOCMSET);
+ D("TIOCEXCL", TIOCEXCL);
+ D("TIOCNXCL", TIOCNXCL);
+ D("TIOCOUTQ", TIOCOUTQ);
+ D("TIOCSBRK", TIOCSBRK);
+ D("TIOCCBRK", TIOCCBRK);
+ D("TIOCMBIS", TIOCMBIS);
+ D("TIOCMBIC", TIOCMBIC);
+
+ return 0;
+}
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Ioctl/untempl.py b/Trurl-based/_Linux_/Lin/Mod/gen-Ioctl/untempl.py
--- /dev/null
@@ -0,0 +1 @@
+../gen-Libc/untempl.py
\ No newline at end of file
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Libc/dumpdefs.py b/Trurl-based/_Linux_/Lin/Mod/gen-Libc/dumpdefs.py
--- /dev/null
@@ -0,0 +1 @@
+../../../../_OpenBSD_/Lin/Mod/gen-Libc/dumpdefs.py
\ No newline at end of file
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Libc/untempl.py b/Trurl-based/_Linux_/Lin/Mod/gen-Libc/untempl.py
--- /dev/null
@@ -0,0 +1 @@
+../../../../_OpenBSD_/Lin/Mod/gen-Libc/untempl.py
\ No newline at end of file
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Termios/Makefile b/Trurl-based/_Linux_/Lin/Mod/gen-Termios/Makefile
--- /dev/null
@@ -0,0 +1,19 @@
+# This is GNU Makefile
+# BSD GNU
+# ${.TARGET} $@
+# ${.ALLSRC} $^
+# ${.IMPSRC} $<
+
+all: Termios.txt
+
+PY = python2.7
+DEFS = defs-termios
+
+Termios.txt: Termios.txt.templ ${DEFS}
+ ${PY} ./untempl.py Termios.txt.templ $@
+
+defs-termios:
+ ./dumpdefs.py 2 0 i /usr/include/i386-linux-gnu/bits/termios.h > $@
+
+clean:
+ rm -f Termios.txt ${DEFS}
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Termios/Termios.txt.templ b/Trurl-based/_Linux_/Lin/Mod/gen-Termios/Termios.txt.templ
--- /dev/null
@@ -0,0 +1,40 @@
+MODULE LinTermios ["libc.so.6"];
+
+ (*
+ A. V. Shiryaev, 2012.11
+
+ Linux
+ i386
+ *)
+
+ CONST
+%%defs-termios%%
+ TYPE
+ tcflag_t* = INTEGER; (* unsigned int *)
+ cc_t* = SHORTCHAR; (* unsigned char *)
+ speed_t* = INTEGER; (* unsigned int *)
+ termios* = RECORD [untagged]
+ c_iflag*: tcflag_t; (* input mode flags *)
+ c_oflag*: tcflag_t; (* output mode flags *)
+ c_cflag*: tcflag_t; (* control mode flags *)
+ c_lflag*: tcflag_t; (* local mode flags *)
+ c_line*: cc_t; (* line discipline *)
+ cc_c*: ARRAY [untagged] NCCS OF cc_t; (* control chars *)
+ c_ispeed*: INTEGER; (* input speed *)
+ c_ospeed*: INTEGER; (* output speed *)
+ END;
+
+ (* POSIX.1 *)
+ PROCEDURE [ccall] cfgetispeed* (VAR tp: termios): speed_t;
+ PROCEDURE [ccall] cfsetispeed* (VAR tp: termios; ispeed: speed_t): INTEGER;
+ PROCEDURE [ccall] cfgetospeed* (VAR tp: termios): speed_t;
+ PROCEDURE [ccall] cfsetospeed* (VAR tp: termios; ospeed: speed_t): INTEGER;
+ PROCEDURE [ccall] tcgetattr* (fd: INTEGER; VAR tp: termios): INTEGER;
+ PROCEDURE [ccall] tcsetattr* (fd: INTEGER; action: INTEGER; VAR tp: termios): INTEGER;
+
+ PROCEDURE [ccall] tcdrain* (fd: INTEGER): INTEGER;
+ PROCEDURE [ccall] tcflow* (fd: INTEGER; action: INTEGER): INTEGER;
+ PROCEDURE [ccall] tcflush* (fd: INTEGER; action: INTEGER): INTEGER;
+ PROCEDURE [ccall] tcsendbreak* (fd: INTEGER; len: INTEGER): INTEGER;
+
+END LinTermios.
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Termios/dumpdefs.py b/Trurl-based/_Linux_/Lin/Mod/gen-Termios/dumpdefs.py
--- /dev/null
@@ -0,0 +1 @@
+../gen-Libc/dumpdefs.py
\ No newline at end of file
diff --git a/Trurl-based/_Linux_/Lin/Mod/gen-Termios/untempl.py b/Trurl-based/_Linux_/Lin/Mod/gen-Termios/untempl.py
--- /dev/null
@@ -0,0 +1 @@
+../gen-Libc/untempl.py
\ No newline at end of file
index e7bf69746f0f48b716b25a9d45933ff671ae7547..b3f0f061956f985a2fb34636d5c4aecb4091213e 100644 (file)
CONST
(* /usr/include/sys/ttycom.h *)
- TIOCM_LE* = 1; (* line enable *)
- TIOCM_DTR* = 2; (* data terminal ready *)
- TIOCM_RTS* = 4; (* request to send *)
- TIOCM_ST* = 8; (* secondary transmit *)
- TIOCM_SR* = 16; (* secondary receive *)
- TIOCM_CTS* = 32; (* clear to send *)
- TIOCM_CAR* = 64; (* carrier detect *)
- TIOCM_RNG* = 128; (* ring *)
- TIOCM_DSR* = 256; (* data set ready *)
+ TIOCM_LE* = {0}; (* line enable *)
+ TIOCM_DTR* = {1}; (* data terminal ready *)
+ TIOCM_RTS* = {2}; (* request to send *)
+ TIOCM_ST* = {3}; (* secondary transmit *)
+ TIOCM_SR* = {4}; (* secondary receive *)
+ TIOCM_CTS* = {5}; (* clear to send *)
+ TIOCM_CAR* = {6}; (* carrier detect *)
+ TIOCM_RNG* = {7}; (* ring *)
+ TIOCM_DSR* = {8}; (* data set ready *)
FIOCLEX* = 536897025;
FIONCLEX* = 536897026;
index e8a9294cc841870a29a65281fd715ffe2745fff1..ba1be6138d4c77ff0953162114b9520f20907646 100644 (file)
MODULE LinLibc ["libc.so.66.0"];
(*
- A. V. Shiryaev, 2012.09
+ A. V. Shiryaev, 2012.11
Based on Linux' LinLibc (OpenBUGS Lin/Mod/Libc.odc)
SIG_IGN* = 1; (* Ignore signal. *)
SIG_HOLD* = 3; (* Add signal to hold mask. *) (* OpenBSD 5.2 /usr/include/sys/signalvar.h *)
- (* Signals. *)
+ (* Signals. *)
(* OpenBSD /usr/include/sys/signal.h *)
_NSIG* = 33; (* counting 0 (mask is 1-32) *)
SIGHUP* = 1; (* hangup *)
SIGWINCH* = 28; (* window size changes *)
SIGTHR* = 32; (* thread library AST *)
+ (* Bits in `sa_flags'. *)
+ SA_NOCLDSTOP* = {3}; (* do not generate SIGCHLD on child stop *)
+ SA_ONSTACK* = {0}; (* take signal on signal stack *)
+ SA_RESTART* = {1}; (* restart system on signal return *)
+ SA_RESETHAND* = {2}; (* reset to SIG_DFL when taking signal *)
+ SA_NODEFER* = {4}; (* don't mask the signal we're delivering *)
+ SA_NOCLDWAIT* = {5}; (* don't create zombies (assign to pid 1) *)
+ SA_SIGINFO* = {6}; (* generate siginfo_t *)
- (* Bits in `sa_flags'. *)
- SA_NOCLDSTOP* = {3}; (* = 1 Don't send SIGCHLD when children stop. *) (* OpenBSD *)
- SA_NOCLDWAIT* = {5}; (* = 2 Don't create zombie on child death. *) (* OpenBSD *)
- SA_SIGINFO* = {6}; (* = 4 Invoke signal-catching function wth three arguments instead of one. *) (* OpenBSD *)
- SA_ONSTACK* = {0}; (* = 0x08000000 Use signal stack by using `sa_restorer'. *) (* OpenBSD *)
- SA_RESTART* = {1}; (* = 0x10000000 Restart syscall on signal return. *) (* OpenBSD *)
- SA_NODEFER* = {4}; (* = 0x40000000 Don't automatically block the signal when its handler is being executed. *) (* OpenBSD *)
- SA_RESETHAND* = {2}; (* = 0x80000000 Reset to SIG_DFL on entry to handler. *) (* OpenBSD *)
- (* SA_INTERRUPT* = {29}; (* = 0x20000000 Historical no-op. *) *) (* OpenBSD *)
(* Some aliases for the SA_ constants. *)
+(*
SA_NOMASK* = SA_NODEFER;
SA_ONESHOT* = SA_RESETHAND;
SA_STACK* = SA_ONSTACK;
+*)
(* code values for siginfo_t.si_code *)
(* OpenBSD /usr/include/sys/siginfo.h *)
_JBLEN = 10;
(* OpenBSD 5.2 /usr/include/sys/mman.h *)
- PROT_NONE* = {}; (* no permission *)
+ MAP_FAILED* = -1;
+ PROT_NONE* = {}; (* no permissions *)
PROT_READ* = {0}; (* pages can be read *)
PROT_WRITE* = {1}; (* pages can be written *)
PROT_EXEC* = {2}; (* pages can be executed *)
-
- (* OpenBSD 5.2 /usr/include/sys/mman.h *)
- MAP_FILE* = {}; (* map from file (default) *)
- MAP_ANON* = {12}; (* allocated from memory, swap space *)
+ MAP_SHARED* = {0}; (* share changes *)
+ MAP_PRIVATE* = {1}; (* changes are private *)
+ MAP_COPY* = {2}; (* "copy" region at mmap time *)
MAP_FIXED* = {4}; (* map addr must be exactly as requested *)
- MAP_HASSEMAPHORE* = {9}; (* region may contain semaphores *)
+ MAP_RENAME* = {5}; (* Sun: rename private pages to file *)
+ MAP_NORESERVE* = {6}; (* Sun: don't reserve needed swap area *)
MAP_INHERIT* = {7}; (* region is retained after exec *)
- MAP_PRIVATE* = {1}; (* changes are private *)
- MAP_SHARED* = {0}; (* share changes *)
+ MAP_NOEXTEND* = {8}; (* for MAP_FILE, don't change file size *)
+ MAP_HASSEMAPHORE* = {9}; (* region may contain semaphores *)
MAP_TRYFIXED* = {10}; (* attempt hint address, even within heap *)
- MAP_COPY* = {2}; (* "copy" region at mmap time *)
+ MAP_FILE* = {}; (* map from file (default) *)
+ MAP_ANON* = {12}; (* allocated from memory, swap space *)
+ MAP_FLAGMASK* = {0..2,4..12};
+ MAP_INHERIT_SHARE* = {}; (* share with child *)
+ MAP_INHERIT_COPY* = {0}; (* copy into child *)
+ MAP_INHERIT_NONE* = {1}; (* absent from child *)
- MAP_FAILED* = -1;
(* OpenBSD 5.2 /usr/include/i386/param.h *)
PAGE_SHIFT* = 12;
PAGE_MASK* = PAGE_SIZE - 1;
(* OpenBSD 5.2: /usr/include/fcntl.h *)
- O_RDONLY* = {};
- O_WRONLY* = {0};
- O_RDWR* = {1};
- O_ACCMODE* = {0,1};
-
- O_NONBLOCK* = {2}; (* Do not block on open or for data to become available *)
- O_APPEND* = {3}; (* Append on each write *)
- O_CREAT* = {9}; (* Create file if it does not exist *)
- O_TRUNC* = {10}; (* Truncate size to 0 *)
- O_EXCL* = {11}; (* Error if create and file exists *)
- O_SYNC* = {7}; (* Perform synchronous I/O operations *)
- O_SHLOCK* = {4}; (* Atomically obtain a shared lock *)
- O_EXLOCK* = {5}; (* Atomically obtain an exclusive lock *)
- O_NOFOLLOW* = {8}; (* If last path element is a symlink, don't follow it *)
- O_CLOEXEC* = {16}; (* Set FD_CLOEXEC on the new file descriptor *)
- O_DIRECTORY* = {17}; (* Error if path does not name a directory *)
+ O_SHLOCK* = {4}; (* open with shared file lock *)
+ O_EXLOCK* = {5}; (* open with exclusive file lock *)
+ O_ASYNC* = {6}; (* signal pgrp when data ready *)
+ O_NOFOLLOW* = {8}; (* if path is a symlink, don't follow *)
+ O_SYNC* = {7}; (* synchronous writes *)
+ O_RDONLY* = {}; (* open for reading only *)
+ O_WRONLY* = {0}; (* open for writing only *)
+ O_RDWR* = {1}; (* open for reading and writing *)
+ O_ACCMODE* = {0,1}; (* mask for above modes *)
+ O_NONBLOCK* = {2}; (* no delay *)
+ O_APPEND* = {3}; (* set append mode *)
+ O_CREAT* = {9}; (* create if nonexistent *)
+ O_TRUNC* = {10}; (* truncate to zero length *)
+ O_EXCL* = {11}; (* error if already exists *)
+ O_DSYNC* = O_SYNC; (* synchronous data writes *)
+ O_RSYNC* = O_SYNC; (* synchronous reads *)
+ O_NOCTTY* = {15}; (* don't assign controlling terminal *)
+ O_CLOEXEC* = {16}; (* atomically set FD_CLOEXEC *)
+ O_DIRECTORY* = {17}; (* fail if not a directory *)
+
(* OpenBSD 5.2 /usr/include/unistd.h *)
_SC_ARG_MAX* = 1;
SIG_UNBLOCK* = 2; (* unblock specified signal set *)
SIG_SETMASK* = 3; (* set specified signal set *)
+
TYPE
(* OpenBSD OK *)
__ftw_func_t* = PROCEDURE (fileName: PtrSTR; VAR [nil] stat: stat_t; flag: INTEGER): INTEGER; (* OpenBSD 5.2: OK *)
index d8f2fd26cbfd4fe8f5be5e13ba7c83e9a91bf076..459b6b605183f5e85227bb8a250c8a8e8d60c985 100644 (file)
MODULE LinTermios ["libc.so.66.0"];
(*
- A. V. Shiryaev, 2012.09
+ A. V. Shiryaev, 2012.11
OpenBSD 5.2
32-bit
VMIN* = 16; (* !ICANON *)
VTIME* = 17; (* !ICANON *)
NCCS* = 20;
- IGNBRK* = 00000001H; (* ignore BREAK condition *)
- BRKINT* = 00000002H; (* map BREAK to SIGINT *)
- IGNPAR* = 00000004H; (* ignore (discard) parity errors *)
- PARMRK* = 00000008H; (* mark parity and framing errors *)
- INPCK* = 00000010H; (* enable checking of parity errors *)
- ISTRIP* = 00000020H; (* strip 8th bit off chars *)
- INLCR* = 00000040H; (* map NL into CR *)
- IGNCR* = 00000080H; (* ignore CR *)
- ICRNL* = 00000100H; (* map CR to NL (ala CRMOD) *)
- IXON* = 00000200H; (* enable output flow control *)
- IXOFF* = 00000400H; (* enable input flow control *)
- OPOST* = 00000001H; (* enable following output processing *)
- CSIZE* = 00000300H; (* character size mask *)
- CS5* = 00000000H; (* 5 bits (pseudo) *)
- CS6* = 00000100H; (* 6 bits *)
- CS7* = 00000200H; (* 7 bits *)
- CS8* = 00000300H; (* 8 bits *)
- CSTOPB* = 00000400H; (* send 2 stop bits *)
- CREAD* = 00000800H; (* enable receiver *)
- PARENB* = 00001000H; (* parity enable *)
- PARODD* = 00002000H; (* odd parity, else even *)
- HUPCL* = 00004000H; (* hang up on last close *)
- CLOCAL* = 00008000H; (* ignore modem status lines *)
- ECHOE* = 00000002H; (* visually erase chars *)
- ECHOK* = 00000004H; (* echo NL after line kill *)
- ECHO* = 00000008H; (* enable echoing *)
- ECHONL* = 00000010H; (* echo NL even if ECHO is off *)
- ISIG* = 00000080H; (* enable signals INTR, QUIT, [D]SUSP *)
- ICANON* = 00000100H; (* canonicalize input lines *)
- IEXTEN* = 00000400H; (* enable DISCARD and LNEXT *)
- EXTPROC* = 00000800H; (* external processing *)
- TOSTOP* = 00400000H; (* stop background jobs from output *)
- NOFLSH* = 80000000H; (* don't flush after interrupt *)
+ IGNBRK* = 00000001H; (* {0} *) (* ignore BREAK condition *)
+ BRKINT* = 00000002H; (* {1} *) (* map BREAK to SIGINT *)
+ IGNPAR* = 00000004H; (* {2} *) (* ignore (discard) parity errors *)
+ PARMRK* = 00000008H; (* {3} *) (* mark parity and framing errors *)
+ INPCK* = 00000010H; (* {4} *) (* enable checking of parity errors *)
+ ISTRIP* = 00000020H; (* {5} *) (* strip 8th bit off chars *)
+ INLCR* = 00000040H; (* {6} *) (* map NL into CR *)
+ IGNCR* = 00000080H; (* {7} *) (* ignore CR *)
+ ICRNL* = 00000100H; (* {8} *) (* map CR to NL (ala CRMOD) *)
+ IXON* = 00000200H; (* {9} *) (* enable output flow control *)
+ IXOFF* = 00000400H; (* {10} *) (* enable input flow control *)
+ OPOST* = 00000001H; (* {0} *) (* enable following output processing *)
+ CSIZE* = 00000300H; (* {8,9} *) (* character size mask *)
+ CS5* = 00000000H; (* {} *) (* 5 bits (pseudo) *)
+ CS6* = 00000100H; (* {8} *) (* 6 bits *)
+ CS7* = 00000200H; (* {9} *) (* 7 bits *)
+ CS8* = 00000300H; (* {8,9} *) (* 8 bits *)
+ CSTOPB* = 00000400H; (* {10} *) (* send 2 stop bits *)
+ CREAD* = 00000800H; (* {11} *) (* enable receiver *)
+ PARENB* = 00001000H; (* {12} *) (* parity enable *)
+ PARODD* = 00002000H; (* {13} *) (* odd parity, else even *)
+ HUPCL* = 00004000H; (* {14} *) (* hang up on last close *)
+ CLOCAL* = 00008000H; (* {15} *) (* ignore modem status lines *)
+ ECHOE* = 00000002H; (* {1} *) (* visually erase chars *)
+ ECHOK* = 00000004H; (* {2} *) (* echo NL after line kill *)
+ ECHO* = 00000008H; (* {3} *) (* enable echoing *)
+ ECHONL* = 00000010H; (* {4} *) (* echo NL even if ECHO is off *)
+ ISIG* = 00000080H; (* {7} *) (* enable signals INTR, QUIT, [D]SUSP *)
+ ICANON* = 00000100H; (* {8} *) (* canonicalize input lines *)
+ IEXTEN* = 00000400H; (* {10} *) (* enable DISCARD and LNEXT *)
+ EXTPROC* = 00000800H; (* {11} *) (* external processing *)
+ TOSTOP* = 00400000H; (* {22} *) (* stop background jobs from output *)
+ NOFLSH* = 80000000H; (* {31} *) (* don't flush after interrupt *)
TCSANOW* = 0; (* make change immediate *)
TCSADRAIN* = 1; (* drain output, then change *)
TCSAFLUSH* = 2; (* drain output, flush input *)
VLNEXT* = 14; (* IEXTEN *)
VDISCARD* = 15; (* IEXTEN *)
VSTATUS* = 18; (* ICANON *)
- IXANY* = 00000800H; (* any char will restart after stop *)
- IUCLC* = 00001000H; (* translate upper to lower case *)
- IMAXBEL* = 00002000H; (* ring bell on input queue full *)
- ONLCR* = 00000002H; (* map NL to CR-NL (ala CRMOD) *)
- OXTABS* = 00000004H; (* expand tabs to spaces *)
- ONOEOT* = 00000008H; (* discard EOT's (^D) on output *)
- OCRNL* = 00000010H; (* map CR to NL *)
- OLCUC* = 00000020H; (* translate lower case to upper case *)
- ONOCR* = 00000040H; (* No CR output at column 0 *)
- ONLRET* = 00000080H; (* NL performs the CR function *)
- CIGNORE* = 00000001H; (* ignore control flags *)
- CRTSCTS* = 00010000H; (* RTS/CTS full-duplex flow control *)
- CRTS_IFLOW* = CRTSCTS; (* XXX compat *)
- CCTS_OFLOW* = CRTSCTS; (* XXX compat *)
- MDMBUF* = 00100000H; (* DTR/DCD hardware flow control *)
- ECHOKE* = 00000001H; (* visual erase for line kill *)
- ECHOPRT* = 00000020H; (* visual erase mode for hardcopy *)
- ECHOCTL* = 00000040H; (* echo control chars as ^(Char) *)
- ALTWERASE* = 00000200H; (* use alternate WERASE algorithm *)
- FLUSHO* = 00800000H; (* output being flushed (state) *)
- XCASE* = 01000000H; (* canonical upper/lower case *)
- NOKERNINFO* = 02000000H; (* no kernel output from VSTATUS *)
- PENDIN* = 20000000H; (* XXX retype pending input (state) *)
- TCSASOFT* = 10H; (* flag - don't alter h.w. state *)
+ IXANY* = 00000800H; (* {11} *) (* any char will restart after stop *)
+ IUCLC* = 00001000H; (* {12} *) (* translate upper to lower case *)
+ IMAXBEL* = 00002000H; (* {13} *) (* ring bell on input queue full *)
+ ONLCR* = 00000002H; (* {1} *) (* map NL to CR-NL (ala CRMOD) *)
+ OXTABS* = 00000004H; (* {2} *) (* expand tabs to spaces *)
+ ONOEOT* = 00000008H; (* {3} *) (* discard EOT's (^D) on output *)
+ OCRNL* = 00000010H; (* {4} *) (* map CR to NL *)
+ OLCUC* = 00000020H; (* {5} *) (* translate lower case to upper case *)
+ ONOCR* = 00000040H; (* {6} *) (* No CR output at column 0 *)
+ ONLRET* = 00000080H; (* {7} *) (* NL performs the CR function *)
+ CIGNORE* = 00000001H; (* {0} *) (* ignore control flags *)
+ CRTSCTS* = 00010000H; (* {16} *) (* RTS/CTS full-duplex flow control *)
+ MDMBUF* = 00100000H; (* {20} *) (* DTR/DCD hardware flow control *)
+ ECHOKE* = 00000001H; (* {0} *) (* visual erase for line kill *)
+ ECHOPRT* = 00000020H; (* {5} *) (* visual erase mode for hardcopy *)
+ ECHOCTL* = 00000040H; (* {6} *) (* echo control chars as ^(Char) *)
+ ALTWERASE* = 00000200H; (* {9} *) (* use alternate WERASE algorithm *)
+ FLUSHO* = 00800000H; (* {23} *) (* output being flushed (state) *)
+ XCASE* = 01000000H; (* {24} *) (* canonical upper/lower case *)
+ NOKERNINFO* = 02000000H; (* {25} *) (* no kernel output from VSTATUS *)
+ PENDIN* = 20000000H; (* {29} *) (* XXX retype pending input (state) *)
+ TCSASOFT* = 10H; (* {4} *) (* flag - don't alter h.w. state *)
B7200* = 7200;
B14400* = 14400;
B28800* = 28800;
c_oflag*: tcflag_t; (* output flags *)
c_cflag*: tcflag_t; (* control flags *)
c_lflag*: tcflag_t; (* local flags *)
- cc_t*: ARRAY [untagged] NCCS OF cc_t; (* control chars *)
+ c_cc*: ARRAY [untagged] NCCS OF cc_t; (* control chars *)
c_ispeed*: INTEGER; (* input speed *)
c_ospeed*: INTEGER; (* output speed *)
END;
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Ioctl/Ioctl.txt.templ b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Ioctl/Ioctl.txt.templ
--- /dev/null
@@ -0,0 +1,17 @@
+MODULE LinIoctl ["libc.so.66.0"];
+
+ (*
+ A. V. Shiryaev, 2012.11
+
+ OpenBSD 5.2
+ 32-bit
+ *)
+
+ CONST
+ (* /usr/include/sys/ttycom.h *)
+%%defs-ttycom%%
+%%defs-ioctl%%
+ PROCEDURE [ccall] ioctl0* ["ioctl"] (d: INTEGER; req: INTEGER): INTEGER;
+ PROCEDURE [ccall] ioctl1* ["ioctl"] (d: INTEGER; req: INTEGER; VAR arg: INTEGER): INTEGER;
+
+END LinIoctl.
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Ioctl/Makefile b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Ioctl/Makefile
--- /dev/null
@@ -0,0 +1,22 @@
+# This is BSD Makefile
+# BSD GNU
+# ${.TARGET} $@
+# ${.ALLSRC} $^
+# ${.IMPSRC} $<
+
+all: mkioctl Ioctl.txt
+
+PY = python2.7
+DEFS = defs-ttycom defs-ioctl
+
+defs-ioctl: mkioctl
+ ./mkioctl > ${.TARGET}
+
+Ioctl.txt: Ioctl.txt.templ ${DEFS}
+ ${PY} ./untempl.py Ioctl.txt.templ ${.TARGET}
+
+defs-ttycom:
+ ./dumpdefs.py 3 1 s /usr/include/sys/ttycom.h | grep TIOCM_ > ${.TARGET}
+
+clean:
+ rm -f mkioctl Ioctl.txt ${DEFS}
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Ioctl/dumpdefs.py b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Ioctl/dumpdefs.py
--- /dev/null
@@ -0,0 +1 @@
+../gen-Libc/dumpdefs.py
\ No newline at end of file
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Ioctl/mkioctl.c b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Ioctl/mkioctl.c
--- /dev/null
@@ -0,0 +1,36 @@
+#include <sys/ioctl.h>
+#include <stdio.h>
+
+#define PREFIX "\t\t"
+
+void D (const char *s, int ctl)
+{
+ printf("%s%s* = %d;\n", PREFIX, s, ctl);
+}
+
+int main (int argc, char *argv[])
+{
+ D("FIOCLEX", FIOCLEX);
+ D("FIONCLEX", FIONCLEX);
+ D("FIONREAD", FIONREAD);
+ D("FIONBIO", FIONBIO);
+ D("FIOASYNC", FIOASYNC);
+ D("FIOSETOWN", FIOSETOWN);
+ D("FIOGETOWN", FIOGETOWN);
+
+ D("TIOCMGET", TIOCMGET);
+ D("TIOCMSET", TIOCMSET);
+ D("TIOCEXCL", TIOCEXCL);
+ D("TIOCNXCL", TIOCNXCL);
+ D("TIOCFLUSH", TIOCFLUSH);
+ D("TIOCDRAIN", TIOCDRAIN);
+ D("TIOCOUTQ", TIOCOUTQ);
+ D("TIOCSBRK", TIOCSBRK);
+ D("TIOCCBRK", TIOCCBRK);
+ D("TIOCSDTR", TIOCSDTR);
+ D("TIOCCDTR", TIOCCDTR);
+ D("TIOCMBIS", TIOCMBIS);
+ D("TIOCMBIC", TIOCMBIC);
+
+ return 0;
+}
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Ioctl/untempl.py b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Ioctl/untempl.py
--- /dev/null
@@ -0,0 +1 @@
+../gen-Libc/untempl.py
\ No newline at end of file
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/Libc.txt.templ b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/Libc.txt.templ
--- /dev/null
@@ -0,0 +1,491 @@
+MODULE LinLibc ["libc.so.66.0"];
+
+ (*
+ A. V. Shiryaev, 2012.11
+
+ Based on Linux' LinLibc (OpenBUGS Lin/Mod/Libc.odc)
+
+ OpenBSD 5.2
+ 32-bit
+ *)
+
+ IMPORT SYSTEM;
+
+ CONST
+ NULL* = 0H;
+ TRUE* = 1;
+ FALSE* = 0;
+
+ (* file constants *)
+ SEEK_SET* = 0;
+ SEEK_CUR* = 1;
+ SEEK_END* = 2;
+ NAME_MAX* = 255; (* OpenBSD /usr/include/sys/syslimits.h *)
+
+ (* The value of CLOCKS_PER_SEC is required to be 1 million on all XSI-conformant systems.*)
+ CLOCKS_PER_SEC* = 100; (* OpenBSD 5.2 /usr/include/time.h CLOCKS_PER_SEC *)
+
+ (* temp directory defined in stdio.h *)
+ P_tmpdir* = "/tmp";
+
+ (* signal constants *) (* Fake signal functions. *)
+ (* OpenBSD 5.2 /usr/include/sys/signal.h *)
+ SIG_ERR* = -1; (* Error return. *)
+ SIG_DFL* = 0; (* Default action. *)
+ SIG_IGN* = 1; (* Ignore signal. *)
+ SIG_HOLD* = 3; (* Add signal to hold mask. *) (* OpenBSD 5.2 /usr/include/sys/signalvar.h *)
+
+ (* Signals. *)
+ (* OpenBSD /usr/include/sys/signal.h *)
+%%defs-signal%%
+ (* Bits in `sa_flags'. *)
+%%defs-sa%%
+ (* Some aliases for the SA_ constants. *)
+(*
+ SA_NOMASK* = SA_NODEFER;
+ SA_ONESHOT* = SA_RESETHAND;
+ SA_STACK* = SA_ONSTACK;
+*)
+
+ (* code values for siginfo_t.si_code *)
+ (* OpenBSD /usr/include/sys/siginfo.h *)
+%%defs-siginfo1%%
+
+ (* possible error constants for errno *)
+ (* OpenBSD /usr/include/sys/errno.h *)
+%%defs-errno%%
+
+ (* OpenBSD 5.2 /usr/include/i386/setjmp.h *)
+ _JBLEN = 10;
+
+ (* OpenBSD 5.2 /usr/include/sys/mman.h *)
+ MAP_FAILED* = -1;
+%%defs-mman%%
+
+ (* OpenBSD 5.2 /usr/include/i386/param.h *)
+ PAGE_SHIFT* = 12;
+ PAGE_SIZE* = 4096; (* LSL(1, PAGE_SHIFT) *)
+ PAGE_MASK* = PAGE_SIZE - 1;
+
+ (* OpenBSD 5.2: /usr/include/fcntl.h *)
+%%defs-fcntl%%
+
+ (* OpenBSD 5.2 /usr/include/unistd.h *)
+%%defs-sc%%
+
+ (* OpenBSD 5.2 /usr/include/sys/mman.h *)
+%%defs-madv%%
+ MADV_NORMAL* = POSIX_MADV_NORMAL;
+ MADV_RANDOM* = POSIX_MADV_RANDOM;
+ MADV_SEQUENTIAL* = POSIX_MADV_SEQUENTIAL;
+ MADV_WILLNEED* = POSIX_MADV_WILLNEED;
+ MADV_DONTNEED* = POSIX_MADV_DONTNEED;
+
+ (* OpenBSD 5.2 /usr/include/sys/signal.h *)
+ MINSIGSTKSZ* = 8192; (* minimum allowable stack *)
+ SIGSTKSZ* = MINSIGSTKSZ + 32768; (* recommended stack size *)
+
+ (* OpenBSD 5.2 /usr/include/sys/signal.h *)
+%%defs-sig%%
+
+ TYPE
+ (* OpenBSD OK *)
+ __ftw_func_t* = PROCEDURE (fileName: PtrSTR; VAR [nil] stat: stat_t; flag: INTEGER): INTEGER; (* OpenBSD 5.2: OK *)
+ PtrVoid* = INTEGER;
+ PtrSTR* = POINTER TO ARRAY [untagged] OF SHORTCHAR;
+ (* PtrWSTR* = POINTER TO ARRAY [untagged] OF CHAR; *)
+ PtrInt* = INTEGER;
+ StrArray* = POINTER TO ARRAY [untagged] OF PtrSTR;
+ PtrFILE* = INTEGER;
+ PtrDIR* = INTEGER;
+ PtrProc* = INTEGER;
+ clock_t* = INTEGER; (* OpenBSD 5.2 /usr/include/i386/_types.h: 32-bit *)
+
+ (* jmp_buf* = ARRAY [untagged] 6 OF INTEGER; (* bx, si, di, bp, sp, pc *) *)
+ jmp_buf* = ARRAY [untagged] _JBLEN OF INTEGER; (* OpenBSD 5.2 *)
+
+ mode_t* = SET; (* OpenBSD 5.2: 32-bit *)
+ off_t* = LONGINT; (* OpenBSD 5.2: 64-bit *)
+
+ SelectorFunc* = PROCEDURE (dirent: Dirent): INTEGER; (* OpenBSD 5.2: OK *)
+ CmpFunc* = PROCEDURE (VAR [nil] dirent1, dirent2: PtrDirent): INTEGER; (* OpenBSD 5.2: OK *)
+
+ size_t* = INTEGER; (* should be unsigned int *) (* OpenBSD 5.2: /usr/include/i386/_types.h: 32-bit *)
+ ssize_t* = INTEGER; (* signed int *) (* OpenBSD 5.2: /usr/include/i386/_types.h: 32-bit *)
+
+ sigjmp_buf* = RECORD [untagged] (* OpenBSD 5.2 *)
+ buf*: jmp_buf;
+
+ (* mask_was_saved*: INTEGER;
+ saved_mask*: sigset_t; *) (* OpenBSD *)
+
+ xxx: INTEGER;
+ END;
+
+ PtrDirent* = POINTER TO Dirent;
+ PtrDirentArray* = POINTER TO ARRAY [untagged] OF Dirent;
+
+ Dirent* = RECORD [untagged] (* OpenBSD 5.2 /usr/include/sys/dirent.h *)
+ (*
+ d_ino*: INTEGER; (* inode number *)
+ d_off*: off_t; (* offset to this dirent *)
+ d_reclen*: SHORTINT; (* length of this d_name *)
+ d_type*: BYTE;
+ d_name*: ARRAY[untagged] NAME_MAX+1 OF SHORTCHAR; (* file name (null-terminated) *)
+ *)
+
+ d_fileno*: INTEGER;
+ d_reclen*: SHORTINT;
+ d_type*: BYTE;
+ d_namlen*: BYTE;
+ d_name*: ARRAY [untagged] NAME_MAX + 1 (* 256 *) OF SHORTCHAR;
+ END;
+
+ pid_t* = INTEGER; (* OpenBSD 5.2: 32-bit *)
+ uid_t* = INTEGER; (* OpenBSD 5.2: 32-bit *)
+
+ sigval_t* = INTEGER; (* OpenBSD: 32-bit (union sigval) *)
+
+ siginfo_t* = RECORD [untagged] (* OpenBSD 5.2 /usr/include/sys/siginfo.h *)
+ si_signo*: INTEGER; (* Signal number *) (* OpenBSD: 32-bit *)
+ si_code*: INTEGER; (* Signal code *) (* OpenBSD: 32-bit *)
+ si_errno*: INTEGER; (* An errno value *) (* OpenBSD: 32-bit *)
+
+ (* OpenBSD 5.2: 29 * 4 B below *)
+
+ si_pid*: pid_t; (* Sending process ID *)
+ si_uid*: uid_t; (* Real user ID of sending process *)
+ si_status*: INTEGER; (* Exit value or signal *) (* OpenBSD 5.2: 32-bit *)
+
+ (* si_utime*: clock_t; (* User time consumed *) *) (* OpenBSD: XXX *)
+ si_stime*: clock_t; (* System time consumed *)
+ (* si_value*: sigval_t; (* Signal value *) *) (* OpenBSD: XXX *)
+ (* si_int*: INTEGER; (* POSIX.1b signal *) *) (* OpenBSD: XXX *)
+ (* si_ptr*: PtrVoid; (* POSIX.1b signal *) *) (* OpenBSD: XXX *)
+ (* si_addr*: PtrVoid; (* Memory location which caused fault *) *) (* OpenBSD: XXX *)
+ (* si_band*: INTEGER; (* Band event *) *) (* OpenBSD: XXX *)
+ (* si_fd*: INTEGER; (* File descriptor *) *) (* OpenBSD: XXX *)
+
+ xxx: ARRAY [untagged] 25 OF INTEGER; (* OpenBSD *)
+ END;
+ Ptrsiginfo_t* = POINTER TO siginfo_t;
+
+ (* sigset_t* = ARRAY [untagged] 128 OF BYTE; *)
+ (* OpenBSD 5.2 /usr/include/sys/signal.h *)
+ (* sigset_t* = ARRAY [untagged] 4 OF BYTE; *)
+ sigset_t* = SET;
+
+ Ptrsigset_t* = INTEGER;
+ sigaction_t* = RECORD [untagged] (* OpenBSD 5.2 /usr/include/sys/signal.h *)
+ sa_sigaction*: PROCEDURE [ccall] (sig: INTEGER; siginfo: Ptrsiginfo_t; ptr: Ptrucontext_t); (* union with sa_handler*: PtrProc;*)
+ sa_mask*: sigset_t;
+ sa_flags*: SET;
+ (* sa_restorer*: LONGINT; *) (* OpenBSD *)
+ END;
+
+ stack_t* = RECORD [untagged] (* OpenBSD 5.2 /usr/include/sys/signal.h *)
+ ss_sp*: PtrVoid;
+ ss_size*: size_t; (* OpenBSD *)
+ ss_flags*: INTEGER; (* OpenBSD *)
+ END;
+
+ dev_t* = INTEGER; (* OpenBSD: 32-bit *)
+ gid_t* = INTEGER; (* OpenBSD: 32-bit *)
+
+ stat_t* = RECORD [untagged] (* OpenBSD 5.2 /usr/include/sys/stat.h *)
+ st_dev*: dev_t; (* device *) (* OpenBSD: 32-bit *)
+ (* __pad1: SHORTINT; *) (* OpenBSD *)
+ st_ino*: INTEGER; (* 64? inode *) (* OpenBSD: 32-bit *)
+ st_mode*: mode_t; (* protection *) (* OpenBSD: 32-bit *)
+ st_nlink*: INTEGER; (* number of hard links *) (* OpenBSD: 32-bit *)
+ st_uid*: uid_t; (* user ID of owner *) (* OpenBSD: 32-bit *)
+ st_gid*: gid_t; (* group ID of owner *) (* OpenBSD: 32-bit *)
+ st_rdev*: dev_t; (* device type (if inode device) *) (* OpenBSD: 32-bit *)
+ st_lspare0*: INTEGER; (* OpenBSD *)
+ (* __pad2: SHORTINT; *) (* OpenBSD *)
+
+ (* OpenBSD *)
+ st_atime*: time_t;
+ st_atimensec*: INTEGER;
+ st_mtime*: time_t;
+ st_mtimensec*: INTEGER;
+ st_ctime*: time_t;
+ st_ctimensec*: INTEGER;
+
+ st_size*: off_t; (* 64? total size, in bytes *) (* OpenBSD *)
+ st_blocks*: LONGINT; (* OpenBSD: 64-bit *)
+ st_blksize*: INTEGER; (* blocksize for filesystem I/O *)
+ (* st_blocks*: INTEGER; (* 64? number of blocks allocated *) *) (* OpenBSD *)
+ st_flags*: INTEGER; (* OpenBSD: 32-bit *)
+ st_gen*: INTEGER; (* OpenBSD: 32-bit *)
+ st_lspare1*: INTEGER; (* OpenBSD: 32-bit *)
+
+ (* OpenBSD
+ st_atime*: INTEGER; (* time of last access *)
+ __unused1: INTEGER;
+ st_mtime*: INTEGER; (* time of last modification *)
+ __unused2: INTEGER;
+ st_ctime*: INTEGER; (* time of last change *)
+ __unused3: INTEGER;
+ __unused4: INTEGER;
+ __unused5: INTEGER;
+ *)
+
+ (* OpenBSD *)
+ __st_birthtime*: time_t;
+ __st_birthtimensec*: INTEGER;
+ st_qspare*: ARRAY [untagged] 2 OF LONGINT;
+ END;
+
+ (* OpenBSD
+ fpreg* = RECORD [untagged]
+ significand*: ARRAY [untagged] 4 OF CHAR;
+ exponent*: CHAR;
+ END;
+ *)
+
+ (* OpenBSD *)
+ (*
+ fpstate* = RECORD [untagged]
+ cw*: INTEGER; (* unsigned long int *)
+ sw*: INTEGER; (* unsigned long int *)
+ tag*: INTEGER; (* unsigned long int *)
+ ipoff*: INTEGER; (* unsigned long int *)
+ cssel*: INTEGER; (* unsigned long int *)
+ dataoff*: INTEGER; (* unsigned long int *)
+ datasel*: INTEGER; (* unsigned long int *)
+ _st: ARRAY [untagged] 8 OF fpreg;
+ status*: INTEGER; (* unsigned long int *)
+ END;
+ *)
+ envxmm* = RECORD [untagged] (* OpenBSD 5.2 /usr/include/i386/npx.h *)
+ (*0*)
+ en_cw*: SHORTINT; (* FPU Control Word *)
+ en_sw*: SHORTINT; (* FPU Status Word *)
+ en_tw*: BYTE; (* FPU Tag Word (abridged) *)
+ en_rsvd0*: BYTE;
+ en_opcode*: SHORTINT; (* FPU Opcode *)
+ en_fip*: INTEGER; (* FPU Instruction Pointer *)
+ en_fcs*: SHORTINT; (* FPU IP selector *)
+ en_rsvd1*: SHORTINT;
+ (*16*)
+ en_foo*: INTEGER; (* FPU Data pointer *)
+ en_fos*: SHORTINT; (* FPU Data pointer selector *)
+ en_rsvd2*: SHORTINT;
+ en_mxcsr*: INTEGER; (* MXCSR Register State *)
+ en_mxcsr_mask*: INTEGER; (* Mask for valid MXCSR bits (may be 0) *)
+ END;
+ (* FPU regsters in the extended save format. *)
+ fpaccxmm* = RECORD [untagged] (* OpenBSD 5.2 /usr/include/i386/npx.h *)
+ fp_bytes*: ARRAY [untagged] 10 OF BYTE;
+ fp_rsvd*: ARRAY [untagged] 6 OF BYTE;
+ END;
+ (* SSE/SSE2 registers. *)
+ xmmreg* = RECORD [untagged] (* OpenBSD 5.2 /usr/include/i386/npx.h *)
+ sse_bytes*: ARRAY [untagged] 16 OF BYTE;
+ END;
+ fpstate* = RECORD [untagged] (* OpenBSD 5.2 /usr/include/i386/npx.h savefpu.savexmm *)
+ sv_env*: envxmm; (* control/status context *)
+ sv_ac*: ARRAY [untagged] 8 OF fpaccxmm; (* ST/MM regs *)
+ sv_xmmregs*: ARRAY [untagged] 8 OF xmmreg; (* XMM regs *)
+ sv_rsvd*: ARRAY [untagged] 16 * 14 OF BYTE;
+ (* 512-bytes --- end of hardware portion of save area *)
+ sv_ex_sw*: INTEGER; (* saved SW from last exception *)
+ sv_ex_tw*: INTEGER; (* saved TW from last exception *)
+ END;
+
+ (* OpenBSD
+ gregset_t* = ARRAY [untagged] 19 OF INTEGER;
+ *)
+ fpregset_t* = POINTER TO fpstate;
+
+ (* OpenBSD
+ mcontext_t* = RECORD [untagged]
+ gregs*: gregset_t;
+ fpregs*: fpregset_t;
+ oldmask*: INTEGER; (* unsigned long int *)
+ cr2*: INTEGER; (* unsigned long int *)
+ END;
+ *)
+
+ Ptrucontext_t* = POINTER TO ucontext_t;
+ ucontext_t* = RECORD [untagged] (* OpenBSD 5.2 /usr/include/i386/signal.h struct sigcontext *)
+ (*
+ uc_flags*: INTEGER; (* unsigned long int *)
+ uc_link*: Ptrucontext_t;
+ uc_stack*: stack_t;
+ uc_mcontext*: mcontext_t;
+ uc_sigmask: sigset_t;
+ __fpregs_mem*: fpstate;
+ *)
+
+ sc_gs*: INTEGER;
+ sc_fs*: INTEGER;
+ sc_es*: INTEGER;
+ sc_ds*: INTEGER;
+ sc_edi*: INTEGER;
+ sc_esi*: INTEGER;
+ sc_ebp*: INTEGER;
+ sc_ebx*: INTEGER;
+ sc_edx*: INTEGER;
+ sc_ecx*: INTEGER;
+ sc_eax*: INTEGER;
+ (* XXX *)
+ sc_eip*: INTEGER;
+ sc_cs*: INTEGER;
+ sc_eflags*: INTEGER;
+ sc_esp*: INTEGER;
+ sc_ss*: INTEGER;
+
+ sc_onstack*: INTEGER; (* sigstack state to restore *)
+ sc_mask*: INTEGER; (* signal mask to restore *)
+ sc_trapno*: INTEGER; (* XXX should be above *)
+ sc_err*: INTEGER;
+
+ sc_fpstate*: fpregset_t; (* POINTER TO savefpu *)
+ END;
+
+ (* Times and Dates *)
+
+ tm* = POINTER TO tmDesc;
+ tmDesc* = RECORD [untagged] (* OpenBSD 5.2 /usr/include/time.h *)
+ tm_sec*: INTEGER; (* seconds *)
+ tm_min*: INTEGER; (* minutes *)
+ tm_hour*: INTEGER; (* hours *)
+ tm_mday*: INTEGER; (* day of the month *)
+ tm_mon*: INTEGER; (* month *)
+ tm_year*: INTEGER; (* year *)
+ tm_wday*: INTEGER; (* day of the week *)
+ tm_yday*: INTEGER; (* day in the year *)
+ tm_isdst*: INTEGER; (* daylight saving time *)
+
+ tm_gmtoff*: INTEGER; (* OpenBSD *)
+ tm_zone*: PtrSTR; (* OpenBSD *)
+ END;
+
+ time_t* = INTEGER; (* OpenBSD 5.2 /usr/include/i386/_types.h: 32-bit *)
+
+ FILE = ARRAY [untagged] 88 OF BYTE; (* OpenBSD 5.2 /usr/include/stdio.h *)
+
+ wchar_t* = INTEGER; (* OpenBSD 5.2: 32-bit *)
+ PtrWSTR* = POINTER TO ARRAY [untagged] OF wchar_t;
+
+ (* OpenBSD 5.2 *)
+ sigaltstack_t* = RECORD [untagged]
+ ss_sp*: PtrVoid;
+ ss_size*: size_t;
+ ss_flags*: INTEGER;
+ END;
+
+ VAR
+ (* timezone*: INTEGER; (* seconds from GMT *) *) (* OpenBSD: not present *)
+ (* stdin*, stdout*, stderr* : PtrFILE; (* OpenBSD: not present *) *)
+
+ (* OpenBSD: stdin, stdout, stderr *)
+ __sF*: ARRAY [untagged] 3 OF FILE; (* OpenBSD 5.2 /usr/include/stdio.h *)
+ (*
+ stdin = SYSTEM.ADR(__sF[0])
+ stdout = SYSTEM.ADR(__sF[1])
+ stderr = SYSTEM.ADR(__sF[2])
+ *)
+
+ PROCEDURE [ccall] calloc* (nmemb, size: size_t): PtrVoid;
+ PROCEDURE [ccall] clock* (): clock_t;
+
+ PROCEDURE [ccall] closedir* (dir: PtrDIR): INTEGER;
+
+ PROCEDURE [ccall] chmod* (path: PtrSTR; mode: mode_t);
+ PROCEDURE [ccall] exit* (status: INTEGER);
+
+ PROCEDURE [ccall] fclose* (fp: PtrFILE): INTEGER;
+ PROCEDURE [ccall] fflush* (fp: PtrFILE): INTEGER;
+ PROCEDURE [ccall] fopen* (filename, mode: PtrSTR): PtrFILE;
+ PROCEDURE [ccall] feof* (fp: PtrFILE): INTEGER;
+ PROCEDURE [ccall] fread* (ptr: PtrVoid; size, nmemb: size_t; stream: PtrFILE): size_t;
+ PROCEDURE [ccall] fseek* (stream: PtrFILE; offset, origin: INTEGER): INTEGER;
+ PROCEDURE [ccall] free* (p: PtrVoid);
+
+ PROCEDURE [ccall] ftell* (stream: PtrFILE): (* LONGINT; *) INTEGER; (* OpenBSD 5.2 *)
+
+ PROCEDURE [ccall] ftw* (filename: PtrSTR; func: __ftw_func_t; maxfds: INTEGER): INTEGER;
+ PROCEDURE [ccall] fwrite* (ptr: PtrVoid; size, nmemb: size_t; stream: PtrFILE): size_t;
+ PROCEDURE [ccall] getcwd* (buf: PtrSTR; size: size_t): PtrSTR;
+
+ (* PROCEDURE [ccall] getcontext* (ucontext_t: Ptrucontext_t): INTEGER; *) (* OpenBSD *)
+
+ (* PROCEDURE [ccall] gets* (s: PtrSTR); *)
+ PROCEDURE [ccall] gets* (s: PtrSTR): PtrSTR; (* OpenBSD 5.2 *)
+
+ PROCEDURE [ccall] fgets* (s: PtrSTR; n: INTEGER; fp: PtrFILE): PtrSTR;
+ PROCEDURE [ccall] gmtime* (VAR timep: time_t): tm;
+ PROCEDURE [ccall] kill* (pid: pid_t; sig: INTEGER): INTEGER;
+ PROCEDURE [ccall] localtime* (VAR timep: time_t): tm;
+ PROCEDURE [ccall] malloc* (size: size_t): PtrVoid;
+ PROCEDURE [ccall] mkdir* (path: PtrSTR; mode: mode_t): INTEGER;
+ PROCEDURE [ccall] mktime* (timeptr: tm): time_t;
+ PROCEDURE [ccall] opendir* (filename: PtrSTR): PtrDIR;
+ PROCEDURE [ccall] printf* (s: PtrSTR): INTEGER;
+ PROCEDURE [ccall] readdir* (dir: PtrDIR): PtrDirent;
+ PROCEDURE [ccall] remove* (path: PtrSTR): INTEGER;
+ PROCEDURE [ccall] rename* (from, to: PtrSTR): INTEGER;
+ PROCEDURE [ccall] scandir* (dir: PtrDIR; namelist: PtrDirentArray; selector: SelectorFunc; cmp: CmpFunc): INTEGER;
+
+ (* PROCEDURE [ccall] setcontext* (ucontext_t: Ptrucontext_t): INTEGER; *) (* OpenBSD *)
+
+ PROCEDURE [ccall] setjmp* (VAR env: jmp_buf): INTEGER;
+ PROCEDURE [ccall] sigaction* (sig_num: INTEGER; VAR [nil] act: sigaction_t; VAR [nil] oldact: sigaction_t): INTEGER;
+ PROCEDURE [ccall] sigaddset* (set: Ptrsigset_t; sig: INTEGER): INTEGER;
+ PROCEDURE [ccall] sigdelset* (set: Ptrsigset_t; sig: INTEGER): INTEGER;
+ PROCEDURE [ccall] sigemptyset* (set: Ptrsigset_t): INTEGER;
+ PROCEDURE [ccall] sigfillset* (set: Ptrsigset_t): INTEGER;
+ PROCEDURE [ccall] sigismemeber* (set: Ptrsigset_t; sig: INTEGER): INTEGER;
+ PROCEDURE [ccall] siglongjmp* (VAR env: sigjmp_buf; val: INTEGER);
+
+ PROCEDURE [ccall] signal* (sig_num: INTEGER; sighandler: PtrProc): PtrProc;
+ (* PROCEDURE [ccall] sigsetjmp* ["__sigsetjmp"] (VAR env: sigjmp_buf; savemask: INTEGER): INTEGER; *)
+ PROCEDURE [ccall] sigsetjmp* (VAR env: sigjmp_buf; savemask: INTEGER): INTEGER; (* OpenBSD *)
+
+ (* OpenBSD *)
+ PROCEDURE [ccall] stat* (filename: PtrSTR; VAR buf: stat_t): INTEGER; (* stat is a macro and expands to __xstat(3, filename, buf) *)
+(* OpenBSD: __xstat not present
+ PROCEDURE [ccall] __xstat* (version: INTEGER; filename: PtrSTR; VAR buf: stat_t): INTEGER;
+*)
+
+ PROCEDURE [ccall] strftime* (s: PtrSTR; max: size_t; format: PtrSTR; ptm: tm): size_t;
+ PROCEDURE [ccall] time* (VAR [nil] t: time_t): time_t;
+
+ (* PROCEDURE [ccall] __errno_location*(): INTEGER; *)
+ PROCEDURE [ccall] __errno_location* ["__errno"] (): INTEGER; (* OpenBSD *)
+
+ PROCEDURE [ccall] open* (path: PtrSTR; flags: SET; mode: mode_t): INTEGER;
+ PROCEDURE [ccall] close* (d: INTEGER): INTEGER;
+ PROCEDURE [ccall] read* (d: INTEGER; buf: PtrVoid; nbytes: size_t): ssize_t;
+ PROCEDURE [ccall] write* (d: INTEGER; buf: PtrVoid; nBytes: size_t): ssize_t;
+
+ (* OpenBSD *)
+ PROCEDURE [ccall] mprotect* (addr: PtrVoid; len: size_t; prot: SET): INTEGER;
+
+ (* OpenBSD 5.2 *)
+ PROCEDURE [ccall] madvise* (addr: PtrVoid; len: size_t; behav: INTEGER): INTEGER;
+
+ PROCEDURE [ccall] mmap* (addr: PtrVoid; len: size_t; prot: SET; flags: SET; fd: INTEGER; offset: off_t): PtrVoid;
+ PROCEDURE [ccall] munmap* (addr: PtrVoid; len: size_t): INTEGER;
+
+ PROCEDURE [ccall] getenv* (name: PtrSTR): PtrSTR;
+
+ (* OpenBSD 5.2: Ok *)
+ PROCEDURE [ccall] wctomb* (s: PtrSTR; wchar: wchar_t): INTEGER;
+ PROCEDURE [ccall] wcstombs* (s: PtrSTR; pwcs: PtrWSTR; n: size_t): size_t;
+ PROCEDURE [ccall] mbtowc* (pwc: PtrWSTR; s: PtrSTR; n: size_t): INTEGER;
+ PROCEDURE [ccall] mbstowcs* (pwcs: PtrWSTR; s: PtrSTR; n: size_t): size_t;
+
+ (* OpenBSD 5.2 *)
+ PROCEDURE [ccall] sysconf* (name: INTEGER): INTEGER;
+
+ PROCEDURE [ccall] sigaltstack* (VAR [nil] ss: sigaltstack_t; VAR [nil] oss: sigaltstack_t): INTEGER;
+
+ PROCEDURE [ccall] sigreturn* (ucontext_t: Ptrucontext_t): INTEGER;
+
+ PROCEDURE [ccall] sigprocmask* (how: INTEGER; VAR [nil] set: sigset_t; VAR [nil] oset: sigset_t): INTEGER;
+
+END LinLibc.
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/Makefile b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/Makefile
--- /dev/null
@@ -0,0 +1,62 @@
+# This is BSD Makefile
+# BSD GNU
+# ${.TARGET} $@
+# ${.ALLSRC} $^
+# ${.IMPSRC} $<
+
+PY = python2.7
+
+DEFS = defs-errno defs-signal defs-sc defs-madv defs-siginfo defs-siginfo1 defs-sa defs-mman defs-fcntl defs-sig
+
+all: Libc.txt ${DEFS}
+
+Libc.txt: Libc.txt.templ ${DEFS} sizeofs
+ ${PY} ./untempl.py Libc.txt.templ ${.TARGET}
+# ${PY} ./untempl2.py ${.TARGET}.tmp ${.TARGET}
+# rm -f ${.TARGET}.tmp
+
+sizeofs: sizeofs.c
+ ${CC} -O0 -g -o ${.TARGET} ${.ALLSRC}
+
+defs-errno:
+ ./dumpdefs.py 2 0 i /usr/include/sys/errno.h > ${.TARGET}
+
+defs-signal:
+ ./dumpdefs.py 2 1 i /usr/include/sys/signal.h > ${.TARGET}
+ ./dumpdefs.py 2 2 i /usr/include/sys/signal.h | grep SIGWINCH >> ${.TARGET}
+ ./dumpdefs.py 2 2 i /usr/include/sys/signal.h | grep SIGTHR >> ${.TARGET}
+
+defs-sig:
+ ./dumpdefs.py 2 2 i /usr/include/sys/signal.h | grep SIG_ > ${.TARGET}
+
+defs-sa:
+ ./dumpdefs.py 2 2 s /usr/include/sys/signal.h | grep " SA_" > ${.TARGET}
+ ./dumpdefs.py 2 3 s /usr/include/sys/signal.h | grep " SA_" >> ${.TARGET}
+
+defs-mman:
+ ./dumpdefs.py 2 0 s /usr/include/sys/mman.h | grep " PROT_" > ${.TARGET}
+ ./dumpdefs.py 2 0 s /usr/include/sys/mman.h | grep " MAP_" >> ${.TARGET}
+
+defs-fcntl:
+ ./dumpdefs.py 2 2 s /usr/include/fcntl.h | grep -v compat | grep " O_" > ${.TARGET}
+ ./dumpdefs.py 2 1 s /usr/include/fcntl.h | grep " O_" >> ${.TARGET}
+
+defs-siginfo:
+ ./dumpdefs.py 2 1 i /usr/include/sys/siginfo.h > ${.TARGET}
+ ./dumpdefs.py 2 2 i /usr/include/sys/siginfo.h >> ${.TARGET}
+
+defs-sc:
+ ./dumpdefs.py 2 1 i /usr/include/unistd.h | grep _SC_ > ${.TARGET}
+
+defs-madv:
+ ./dumpdefs.py 2 0 i /usr/include/sys/mman.h | grep MADV > ${.TARGET}
+ ./dumpdefs.py 2 1 i /usr/include/sys/mman.h | grep MADV >> ${.TARGET}
+
+defs-siginfo1:
+ ./dumpdefs.py 2 2 i /usr/include/sys/siginfo.h | grep FPE_ > ${.TARGET}
+ ./dumpdefs.py 2 2 i /usr/include/sys/siginfo.h | grep ILL_ >> ${.TARGET}
+ ./dumpdefs.py 2 2 i /usr/include/sys/siginfo.h | grep SEGV_ >> ${.TARGET}
+ ./dumpdefs.py 2 2 i /usr/include/sys/siginfo.h | grep BUS_ >> ${.TARGET}
+
+clean:
+ rm -f sizeofs ${DEFS} Libc.txt
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/dumpdefs.py b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/dumpdefs.py
--- /dev/null
@@ -0,0 +1,138 @@
+#! /usr/bin/env python2.7
+#
+# A. V. Shiryaev, 2012.09
+# simple *.h '#define' macro translator
+
+import sys, re
+
+INDENT = "\t"
+
+_p1 = re.compile('^#define\s+([^\s]+)\s+([A-Za-z0-9]+)\s*$')
+_p2 = re.compile('^#define\s+([^\s]+)\s+([^\s]+)\s+\/\*([^\*]+)\*\/\s*$')
+
+def mkset (x):
+ if x >= 0:
+ s = []
+ ss = 0
+ i = 0
+ while x != 0:
+ if x % 2 != 0:
+ if ss == 0:
+ si = i
+ sn = 1
+ ss = 1
+ elif i == si + sn:
+ sn = sn + 1
+ else:
+ if sn == 1:
+ s.append(str(si))
+ elif sn == 2:
+ s.append("%s,%s" % (si, si+1))
+ else:
+ s.append("%s..%s" % (si, si + sn - 1))
+ si = i
+ sn = 1
+ i = i + 1
+ x = x / 2
+ if ss == 1:
+ if sn == 1:
+ s.append(str(si))
+ elif sn == 2:
+ s.append("%s,%s" % (si, si+1))
+ else:
+ s.append("%s..%s" % (si, si + sn - 1))
+ return '{' + ','.join(s) + '}'
+ else:
+ return None
+
+def fixVal (x, tip):
+ if x.startswith('(') and x.endswith(')') and (x.count('(') == 1) and (x.count(')') == 1):
+ x = x[1:-1]
+
+ if x.startswith('0x'): # fix HEX
+ if tip == 'i':
+ if x[2] in ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'):
+ return x[2:].upper() + "H"
+ else:
+ return "0" + x[2:].upper() + "H"
+ else:
+ return mkset(int(x, 16))
+ elif x[0] == '0': # fix OCT
+ if tip == 'i':
+ return str(int(x, 8))
+ else:
+ return mkset(int(x, 8))
+ else:
+ if tip == 'i':
+ return x
+ else:
+ try:
+ y = int(x)
+ except:
+ return x
+ else:
+ return mkset(y)
+
+def p (nIndents, sym, val, comment, val1):
+ r = [ "%s%s* = %s;" % (INDENT*nIndents, sym, val) ]
+ if (val1 != None) and (val != val1):
+ r.append( "(* %s *)" % (val1,) )
+ if comment:
+ r.append( "(* %s *)" % (comment,) )
+ print ' '.join(r)
+
+def isBits (s):
+ return (len(s) > 1) and s.startswith('0') # HEX or OCT
+
+def main ():
+ if len(sys.argv) == 5:
+ nIndents = int(sys.argv[1])
+ if sys.argv[2] == '*':
+ level = None
+ else:
+ level = int(sys.argv[2])
+ tip = sys.argv[3]
+ assert tip in ('i', 's')
+
+ fh = open(sys.argv[4], 'r')
+ st = 0
+ for line in fh.readlines():
+ if line.startswith("#if"):
+ # print line,
+ st = st + 1
+ elif line.startswith("#endif"):
+ # print line,
+ st = st - 1
+ elif (level == None) or (st == level):
+ r = _p2.match(line)
+ if r:
+ sym = r.group(1)
+ val = fixVal(r.group(2), tip)
+ if isBits(r.group(2)):
+ val1 = fixVal(r.group(2), 's')
+ else:
+ val1 = None
+ comment = r.group(3).strip()
+ p(nIndents, sym, val, comment, val1)
+ else:
+ r = _p1.match(line)
+ if r:
+ sym = r.group(1)
+ val = fixVal(r.group(2), tip)
+ if isBits(r.group(2)):
+ val1 = fixVal(r.group(2), 's')
+ else:
+ val1 = None
+ comment = None
+ p(nIndents, sym, val, comment, val1)
+ else:
+ print "usage: %s nIndents level type file.h" % (sys.argv[0],)
+ print " level:"
+ print " number: selected level"
+ print " *: all levels"
+ print " type:"
+ print " i: integer"
+ print " s: set"
+
+if __name__ == '__main__':
+ main()
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/sizeofs.c b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/sizeofs.c
--- /dev/null
@@ -0,0 +1,25 @@
+#include <sys/types.h>
+
+#include <sys/signal.h>
+
+#include <stdlib.h>
+
+#include <stdio.h>
+
+#define SZ(A, B) printf("%s %d\n", A, sizeof(B));
+
+int main ()
+{
+ SZ("size_t", size_t);
+ SZ("ssize_t", ssize_t);
+ SZ("off_t", off_t);
+ SZ("clock_t", clock_t);
+ SZ("mode_t", mode_t);
+ SZ("pid_t", pid_t);
+ SZ("uid_t", uid_t);
+ SZ("sigset_t", sigset_t);
+
+ SZ("wchar_t", wchar_t);
+
+ return 0;
+}
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/untempl.py b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Libc/untempl.py
--- /dev/null
@@ -0,0 +1,39 @@
+#! /usr/bin/env python2.7
+
+import sys, re
+
+def readFile (fileName):
+ fh = open(fileName, 'rb')
+ x = fh.read()
+ fh.close()
+ return x
+
+def writeFile (fileName, x):
+ fh = open(fileName, 'wb')
+ fh.write(x)
+ fh.close()
+
+_p = re.compile('\%\%([^\%]+)\%\%')
+
+def untempl (x):
+ while True:
+ r = _p.search(x)
+ if r:
+ fileName = r.group(1)
+ y = readFile(fileName)
+ toRepl = "%%%%%s%%%%" % (fileName,)
+ x = x.replace(toRepl, y)
+ else:
+ break
+ return x
+
+def main ():
+ if len(sys.argv) != 3:
+ print "usage: %s oldfile newfile" % (sys.argv[0],)
+ else:
+ old = readFile(sys.argv[1])
+ new = untempl(old)
+ writeFile(sys.argv[2], new)
+
+if __name__ == '__main__':
+ main()
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Termios/Makefile b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Termios/Makefile
--- /dev/null
@@ -0,0 +1,21 @@
+# This is BSD Makefile
+# BSD GNU
+# ${.TARGET} $@
+# ${.ALLSRC} $^
+# ${.IMPSRC} $<
+
+all: Termios.txt
+
+PY = python2.7
+DEFS = defs-termios
+
+Termios.txt: Termios.txt.templ ${DEFS}
+ ${PY} ./untempl.py Termios.txt.templ ${.TARGET}
+
+defs-termios:
+ ./dumpdefs.py 2 0 i /usr/include/termios.h > ${.TARGET}
+ ./dumpdefs.py 2 1 i /usr/include/termios.h | grep -v compat >> ${.TARGET}
+ ./dumpdefs.py 2 2 i /usr/include/termios.h | grep -v compat | grep -v CHWFLOW >> ${.TARGET}
+
+clean:
+ rm -f Termios.txt ${DEFS}
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Termios/Termios.txt.templ b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Termios/Termios.txt.templ
--- /dev/null
@@ -0,0 +1,45 @@
+MODULE LinTermios ["libc.so.66.0"];
+
+ (*
+ A. V. Shiryaev, 2012.11
+
+ OpenBSD 5.2
+ 32-bit
+ *)
+
+ CONST
+%%defs-termios%%
+ TYPE
+ tcflag_t* = INTEGER; (* unsigned int *)
+ cc_t* = SHORTCHAR; (* unsigned char *)
+ speed_t* = INTEGER; (* unsigned int *)
+ termios* = RECORD [untagged]
+ c_iflag*: tcflag_t; (* input flags *)
+ c_oflag*: tcflag_t; (* output flags *)
+ c_cflag*: tcflag_t; (* control flags *)
+ c_lflag*: tcflag_t; (* local flags *)
+ c_cc*: ARRAY [untagged] NCCS OF cc_t; (* control chars *)
+ c_ispeed*: INTEGER; (* input speed *)
+ c_ospeed*: INTEGER; (* output speed *)
+ END;
+
+ (* POSIX.1 *)
+ PROCEDURE [ccall] cfgetispeed* (VAR tp: termios): speed_t;
+ PROCEDURE [ccall] cfsetispeed* (VAR tp: termios; ispeed: speed_t): INTEGER;
+ PROCEDURE [ccall] cfgetospeed* (VAR tp: termios): speed_t;
+ PROCEDURE [ccall] cfsetospeed* (VAR tp: termios; ospeed: speed_t): INTEGER;
+ PROCEDURE [ccall] tcgetattr* (fd: INTEGER; VAR tp: termios): INTEGER;
+ PROCEDURE [ccall] tcsetattr* (fd: INTEGER; action: INTEGER; VAR tp: termios): INTEGER;
+
+ PROCEDURE [ccall] tcdrain* (fd: INTEGER): INTEGER;
+ PROCEDURE [ccall] tcflow* (fd: INTEGER; action: INTEGER): INTEGER;
+ PROCEDURE [ccall] tcflush* (fd: INTEGER; action: INTEGER): INTEGER;
+ PROCEDURE [ccall] tcsendbreak* (fd: INTEGER; len: INTEGER): INTEGER;
+
+ (* extensions *)
+(*
+ PROCEDURE [ccall] cfsetspeed* (VAR tp: termios; speed: speed_t): INTEGER;
+ PROCEDURE [ccall] cfmakeraw* (VAR tp: termios);
+*)
+
+END LinTermios.
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Termios/dumpdefs.py b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Termios/dumpdefs.py
--- /dev/null
@@ -0,0 +1 @@
+../gen-Libc/dumpdefs.py
\ No newline at end of file
diff --git a/Trurl-based/_OpenBSD_/Lin/Mod/gen-Termios/untempl.py b/Trurl-based/_OpenBSD_/Lin/Mod/gen-Termios/untempl.py
--- /dev/null
@@ -0,0 +1 @@
+../gen-Libc/untempl.py
\ No newline at end of file