Alexander Shiryaev 12 anni fa
parent
commit
dcbff92c04
50 ha cambiato i file con 1062 aggiunte e 14 eliminazioni
  1. 0 0
      BlackBox/_FreeBSDLinuxOpenBSD_/Host/Mod/Lang.odc
  2. 0 0
      BlackBox/_FreeBSDLinuxOpenBSD_/Host/Mod/PackedFiles.odc
  3. 0 0
      BlackBox/_FreeBSDLinuxOpenBSD_/Host/Mod/TextConv.odc
  4. 4 2
      BlackBox/_FreeBSDLinuxOpenBSD_/Lin/Mod/gen-Libc/Libc.txt.templ
  5. 0 0
      BlackBox/_FreeBSDLinuxOpenBSD_/Lin/Rsrc/loader/loader.c
  6. 0 0
      BlackBox/_FreeBSDLinuxOpenBSD_/System/Mod/Config.odc
  7. 0 0
      BlackBox/_FreeBSDLinuxOpenBSD_/System/Mod/Kernel_so_init.odc
  8. 0 0
      BlackBox/_FreeBSDLinuxOpenBSD_Interp/Host/Mod/DevPackedFiles.odc
  9. 0 0
      BlackBox/_FreeBSDLinuxOpenBSD_Interp/build
  10. 0 0
      BlackBox/_FreeBSDLinuxOpenBSD_Interp/pack-dev0
  11. 0 0
      BlackBox/_FreeBSDLinuxOpenBSD_Interp/tests
  12. BIN
      BlackBox/_FreeBSDLinux_/Host/Mod/Console.odc
  13. BIN
      BlackBox/_FreeBSDOpenBSD_/Host/Mod/Dates.odc
  14. BIN
      BlackBox/_FreeBSD_/Host/Mod/Files.odc
  15. 32 0
      BlackBox/_FreeBSD_/Lin/Mod/Dl.txt
  16. 22 0
      BlackBox/_FreeBSD_/Lin/Mod/Iconv.txt
  17. 657 0
      BlackBox/_FreeBSD_/Lin/Mod/Libc.txt
  18. 74 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/Makefile
  19. 6 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/custom
  20. 1 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/dumpdefs.py
  21. 6 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-dirent
  22. 4 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-sigaction
  23. 31 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-siginfo
  24. 4 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-stack
  25. 35 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-stat
  26. 12 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-tm
  27. 35 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-ucontext
  28. 1 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/libver
  29. 1 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/machine
  30. 1 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/mkdumpstrerrno.py
  31. 1 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/mkstrerrnocase.py
  32. 1 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/nsig
  33. 1 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/osname
  34. 1 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/sigstksz
  35. 88 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/sizeofs.c
  36. 1 0
      BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/untempl.py
  37. 15 0
      BlackBox/_FreeBSD_/Lin/Rsrc/loader/Makefile
  38. BIN
      BlackBox/_FreeBSD_/Lin/Rsrc/loader/loader
  39. BIN
      BlackBox/_FreeBSD_/System/Mod/Kernel.odc
  40. BIN
      BlackBox/_FreeBSD_/libBB.so
  41. BIN
      BlackBox/_FreeBSD_/libBB0.so
  42. 1 0
      BlackBox/_FreeBSD_/loader
  43. BIN
      BlackBox/_Linux_/Host/Mod/Console.odc
  44. 1 0
      BlackBox/_Linux_/Lin/Mod/gen-Libc/mkdumpstrerrno.py
  45. 1 0
      BlackBox/_Linux_/Lin/Mod/gen-Libc/mkstrerrnocase.py
  46. BIN
      BlackBox/_Linux_/System/Mod/Kernel.odc
  47. 5 3
      BlackBox/_OpenBSD_/Lin/Mod/Libc.txt
  48. BIN
      BlackBox/_OpenBSD_/System/Mod/Kernel.odc
  49. 19 9
      README
  50. 1 0
      TODO

+ 0 - 0
BlackBox/_LinuxOpenBSD_/Host/Mod/Lang.odc → BlackBox/_FreeBSDLinuxOpenBSD_/Host/Mod/Lang.odc


+ 0 - 0
BlackBox/_LinuxOpenBSD_/Host/Mod/PackedFiles.odc → BlackBox/_FreeBSDLinuxOpenBSD_/Host/Mod/PackedFiles.odc


+ 0 - 0
BlackBox/_LinuxOpenBSD_/Host/Mod/TextConv.odc → BlackBox/_FreeBSDLinuxOpenBSD_/Host/Mod/TextConv.odc


+ 4 - 2
BlackBox/_LinuxOpenBSD_/Lin/Mod/gen-Libc/Libc.txt.templ → BlackBox/_FreeBSDLinuxOpenBSD_/Lin/Mod/gen-Libc/Libc.txt.templ

@@ -64,18 +64,19 @@ MODULE LinLibc ["libc.so%%libver%%"];
 
 		tm* = POINTER TO tmDesc;
 		tmDesc* = RECORD [untagged]
+			(* NOTE: check record size *)
 			(* tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday [ , tm_gmtoff ] *)
 %%fields-tm%%
 		END;
 
 		Ptrsiginfo_t* = POINTER TO siginfo_t;
-		siginfo_t* = RECORD [untagged]
+		siginfo_t = RECORD [untagged]
 			(* si_code, fault address *)
 %%fields-siginfo%%
 		END;
 
 		Ptrucontext_t* = POINTER TO ucontext_t;
-		ucontext_t* = RECORD [untagged]
+		ucontext_t = RECORD [untagged]
 			(* IP, SP, FP *)
 %%fields-ucontext%%
 		END;
@@ -97,6 +98,7 @@ MODULE LinLibc ["libc.so%%libver%%"];
 
 		stat_t* = RECORD [untagged]
 (*
+			NOTE: check record size
 			st_mode*: mode_t, st_size*: off_t, st_mtime*: time_t
 *)
 %%fields-stat%%

+ 0 - 0
BlackBox/_LinuxOpenBSD_/Lin/Rsrc/loader/loader.c → BlackBox/_FreeBSDLinuxOpenBSD_/Lin/Rsrc/loader/loader.c


+ 0 - 0
BlackBox/_LinuxOpenBSD_/System/Mod/Config.odc → BlackBox/_FreeBSDLinuxOpenBSD_/System/Mod/Config.odc


+ 0 - 0
BlackBox/_LinuxOpenBSD_/System/Mod/Kernel_so_init.odc → BlackBox/_FreeBSDLinuxOpenBSD_/System/Mod/Kernel_so_init.odc


+ 0 - 0
BlackBox/_LinuxOpenBSD_Interp/Host/Mod/DevPackedFiles.odc → BlackBox/_FreeBSDLinuxOpenBSD_Interp/Host/Mod/DevPackedFiles.odc


+ 0 - 0
BlackBox/_LinuxOpenBSD_Interp/build → BlackBox/_FreeBSDLinuxOpenBSD_Interp/build


+ 0 - 0
BlackBox/_LinuxOpenBSD_Interp/pack-dev0 → BlackBox/_FreeBSDLinuxOpenBSD_Interp/pack-dev0


+ 0 - 0
BlackBox/_LinuxOpenBSD_Interp/tests → BlackBox/_FreeBSDLinuxOpenBSD_Interp/tests


BIN
BlackBox/_FreeBSDLinux_/Host/Mod/Console.odc


BIN
BlackBox/_OpenBSD_/Host/Mod/Dates.odc → BlackBox/_FreeBSDOpenBSD_/Host/Mod/Dates.odc


BIN
BlackBox/_FreeBSD_/Host/Mod/Files.odc


+ 32 - 0
BlackBox/_FreeBSD_/Lin/Mod/Dl.txt

@@ -0,0 +1,32 @@
+MODULE LinDl ["libc.so.7"];
+
+	(*
+		A. V. Shiryaev, 2012.11
+
+		FreeBSD 9.0
+		32-bit
+	*)
+
+	CONST
+		NULL* = 0H;
+
+		(* from FreeBSD 9.0 /usr/include/dlfcn.h *)
+			RTLD_LAZY* = 1;
+			RTLD_NOW* = 2;
+
+			RTLD_GLOBAL* = 100H;
+			RTLD_LOCAL* = 000H;
+			RTLD_TRACE* = 200H;
+
+	TYPE
+		PtrVoid* = INTEGER;
+		HANDLE* = PtrVoid;
+		PtrSTR* = POINTER TO ARRAY [untagged] OF SHORTCHAR;
+
+	PROCEDURE [ccall] dlopen* (file: PtrSTR; mode: INTEGER): HANDLE;
+	PROCEDURE [ccall] dlclose* (handle: HANDLE): INTEGER;
+	PROCEDURE [ccall] dlsym* (handle: HANDLE; symbol: PtrSTR): HANDLE;
+
+	PROCEDURE [ccall] dlerror* (): PtrSTR;
+
+END LinDl.

+ 22 - 0
BlackBox/_FreeBSD_/Lin/Mod/Iconv.txt

@@ -0,0 +1,22 @@
+MODULE LinIconv ["libiconv.so.3"];
+
+	IMPORT Libc := LinLibc;
+
+	TYPE
+		PtrVoid = Libc.PtrVoid;
+		PtrSTR* = Libc.PtrSTR;
+		PtrLSTR* = POINTER TO ARRAY [untagged] OF CHAR;
+		size_t* = Libc.size_t;
+
+		iconv_t* = PtrVoid;
+
+	PROCEDURE [ccall] iconv_open* ["libiconv_open"] (tocode, fromcode: PtrSTR): iconv_t;
+	PROCEDURE [ccall] iconv_close* ["libiconv_close"] (cd: iconv_t): INTEGER;
+
+	PROCEDURE [ccall] iconv* ["libiconv"] (cd: iconv_t; VAR [nil] inbuf: PtrSTR; VAR inbytesleft: size_t; VAR [nil] outbuf: PtrSTR; VAR outbytesleft: size_t): size_t;
+
+	PROCEDURE [ccall] iconv_encode* ["libiconv"] (cd: iconv_t; VAR [nil] inbuf: PtrLSTR; VAR inbytesleft: size_t; VAR [nil] outbuf: PtrSTR; VAR outbytesleft: size_t): size_t;
+
+	PROCEDURE [ccall] iconv_decode* ["libiconv"] (cd: iconv_t; VAR [nil] inbuf: PtrSTR; VAR inbytesleft: size_t; VAR [nil] outbuf: PtrLSTR; VAR outbytesleft: size_t): size_t;
+
+END LinIconv.

+ 657 - 0
BlackBox/_FreeBSD_/Lin/Mod/Libc.txt

@@ -0,0 +1,657 @@
+MODULE LinLibc ["libc.so.7"];
+
+	(*
+		FreeBSD 9.0
+		i386
+	*)
+
+	CONST
+		NULL* = 0H;
+		FALSE* = 0;
+		TRUE* = 1;
+
+		CLOCKS_PER_SEC* = 128;
+
+		MAP_FAILED* = -1;
+
+		(* MAP_PRIVATE, MAP_ANON (intFlags) *)
+		MAP_SHARED* = {0}; (* share changes *)
+		MAP_PRIVATE* = {1}; (* changes are private *)
+		MAP_FIXED* = {4}; (* map addr must be exactly as requested *)
+		MAP_COPY* = MAP_PRIVATE; (* Obsolete *)
+		MAP_RENAME* = {5}; (* Sun: rename private pages to file *)
+		MAP_NORESERVE* = {6}; (* Sun: don't reserve needed swap area *)
+		MAP_RESERVED0080* = {7}; (* previously misimplemented MAP_INHERIT *)
+		MAP_RESERVED0100* = {8}; (* previously unimplemented MAP_NOEXTEND *)
+		MAP_HASSEMAPHORE* = {9}; (* region may contain semaphores *)
+		MAP_STACK* = {10}; (* region grows down, like a stack *)
+		MAP_NOSYNC* = {11}; (* page to but do not sync underlying file *)
+		MAP_FILE* = {}; (* map from file (default) *)
+		MAP_ANON* = {12}; (* allocated from memory, swap space *)
+		MAP_NOCORE* = {17}; (* dont include these pages in a coredump *)
+		MAP_PREFAULT_READ* = {18}; (* prefault mapping for reading *)
+
+
+		(* PROT_READ, PROT_WRITE, PROT_EXEC (intFlags) *)
+		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 *)
+
+
+		(* SIG_UNBLOCK, SIG_SETMASK (int) *)
+		SIG_BLOCK* = 1; (* block specified signal set *)
+		SIG_UNBLOCK* = 2; (* unblock specified signal set *)
+		SIG_SETMASK* = 3; (* set specified signal set *)
+
+
+		(* FPE_INTDIV, FPE_INTOVF, FPE_FLTDIV, FPE_FLTOVF, FPE_FLTUND, FPE_FLTRES, FPE_FLTINV, FPE_FLTSUB (int) *)
+		FPE_INTOVF* = 1; (* Integer overflow. *)
+		FPE_INTDIV* = 2; (* Integer divide by zero. *)
+		FPE_FLTDIV* = 3; (* Floating point divide by zero. *)
+		FPE_FLTOVF* = 4; (* Floating point overflow. *)
+		FPE_FLTUND* = 5; (* Floating point underflow. *)
+		FPE_FLTRES* = 6; (* Floating point inexact result. *)
+		FPE_FLTINV* = 7; (* Invalid floating point operation. *)
+		FPE_FLTSUB* = 8; (* Subscript out of range. *)
+
+
+		(* SA_SIGINFO (intFlags) *)
+		SA_NOCLDSTOP* = {3}; (* do not generate SIGCHLD on child stop *)
+		SA_ONSTACK* = {0}; (* take signal on signal stack *)
+		SA_RESTART* = {1}; (* restart system call 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 keep zombies around *)
+		SA_SIGINFO* = {6}; (* signal handler with SA_SIGINFO args *)
+
+
+		(* SIGINT, SIGILL, SIGFPE, SIGSEGV, SIGKILL, SIGSTOP, SIGWINCH, SIGTHR (int) *)
+		SIGINT* = 2; (* interrupt *)
+		SIGILL* = 4; (* illegal instr. (not reset when caught) *)
+		SIGABRT* = 6; (* abort() *)
+		SIGFPE* = 8; (* floating point exception *)
+		SIGSEGV* = 11; (* segmentation violation *)
+		SIGTERM* = 15; (* software termination signal from kill *)
+		SIGRTMIN* = 65;
+		SIGRTMAX* = 126;
+		SIGHUP* = 1; (* hangup *)
+		SIGQUIT* = 3; (* quit *)
+		SIGTRAP* = 5; (* trace trap (not reset when caught) *)
+		SIGIOT* = SIGABRT; (* compatibility *)
+		SIGEMT* = 7; (* EMT instruction *)
+		SIGKILL* = 9; (* kill (cannot be caught or ignored) *)
+		SIGBUS* = 10; (* bus error *)
+		SIGSYS* = 12; (* non-existent system call invoked *)
+		SIGPIPE* = 13; (* write on a pipe with no one to read it *)
+		SIGALRM* = 14; (* alarm clock *)
+		SIGURG* = 16; (* urgent condition on IO channel *)
+		SIGSTOP* = 17; (* sendable stop signal not from tty *)
+		SIGTSTP* = 18; (* stop signal from tty *)
+		SIGCONT* = 19; (* continue a stopped process *)
+		SIGCHLD* = 20; (* to parent on child stop or exit *)
+		SIGTTIN* = 21; (* to readers pgrp upon background tty read *)
+		SIGTTOU* = 22; (* like TTIN if (tp->t_local&LTOSTOP) *)
+		SIGIO* = 23; (* input/output possible signal *)
+		SIGXCPU* = 24; (* exceeded CPU time limit *)
+		SIGXFSZ* = 25; (* exceeded file size limit *)
+		SIGVTALRM* = 26; (* virtual time alarm *)
+		SIGPROF* = 27; (* profiling time alarm *)
+		SIGWINCH* = 28; (* window size changes *)
+		SIGINFO* = 29; (* information request *)
+		SIGUSR1* = 30; (* user defined signal 1 *)
+		SIGUSR2* = 31; (* user defined signal 2 *)
+		SIGTHR* = 32; (* reserved by thread library. *)
+		SIGLWP* = SIGTHR;
+		SIGEV_NONE* = 0; (* No async notification. *)
+		SIGEV_SIGNAL* = 1; (* Generate a queued signal. *)
+		SIGEV_THREAD* = 2; (* Call back from another pthread. *)
+
+		_NSIG* = SIGTHR + 1;
+
+(*
+		PAGE_SIZE* = 4096;
+*)
+		_SC_ASYNCHRONOUS_IO* = 28;
+		_SC_MAPPED_FILES* = 29;
+		_SC_MEMLOCK* = 30;
+		_SC_MEMLOCK_RANGE* = 31;
+		_SC_MEMORY_PROTECTION* = 32;
+		_SC_MESSAGE_PASSING* = 33;
+		_SC_PRIORITIZED_IO* = 34;
+		_SC_PRIORITY_SCHEDULING* = 35;
+		_SC_REALTIME_SIGNALS* = 36;
+		_SC_SEMAPHORES* = 37;
+		_SC_FSYNC* = 38;
+		_SC_SHARED_MEMORY_OBJECTS* = 39;
+		_SC_SYNCHRONIZED_IO* = 40;
+		_SC_TIMERS* = 41;
+		_SC_AIO_LISTIO_MAX* = 42;
+		_SC_AIO_MAX* = 43;
+		_SC_AIO_PRIO_DELTA_MAX* = 44;
+		_SC_DELAYTIMER_MAX* = 45;
+		_SC_MQ_OPEN_MAX* = 46;
+		_SC_PAGESIZE* = 47;
+		_SC_RTSIG_MAX* = 48;
+		_SC_SEM_NSEMS_MAX* = 49;
+		_SC_SEM_VALUE_MAX* = 50;
+		_SC_SIGQUEUE_MAX* = 51;
+		_SC_TIMER_MAX* = 52;
+		_SC_2_PBS* = 59; (* user *)
+		_SC_2_PBS_ACCOUNTING* = 60; (* user *)
+		_SC_2_PBS_CHECKPOINT* = 61; (* user *)
+		_SC_2_PBS_LOCATE* = 62; (* user *)
+		_SC_2_PBS_MESSAGE* = 63; (* user *)
+		_SC_2_PBS_TRACK* = 64; (* user *)
+		_SC_ADVISORY_INFO* = 65;
+		_SC_BARRIERS* = 66; (* user *)
+		_SC_CLOCK_SELECTION* = 67;
+		_SC_CPUTIME* = 68;
+		_SC_FILE_LOCKING* = 69;
+		_SC_GETGR_R_SIZE_MAX* = 70; (* user *)
+		_SC_GETPW_R_SIZE_MAX* = 71; (* user *)
+		_SC_HOST_NAME_MAX* = 72;
+		_SC_LOGIN_NAME_MAX* = 73;
+		_SC_MONOTONIC_CLOCK* = 74;
+		_SC_MQ_PRIO_MAX* = 75;
+		_SC_READER_WRITER_LOCKS* = 76; (* user *)
+		_SC_REGEXP* = 77; (* user *)
+		_SC_SHELL* = 78; (* user *)
+		_SC_SPAWN* = 79; (* user *)
+		_SC_SPIN_LOCKS* = 80; (* user *)
+		_SC_SPORADIC_SERVER* = 81;
+		_SC_THREAD_ATTR_STACKADDR* = 82; (* user *)
+		_SC_THREAD_ATTR_STACKSIZE* = 83; (* user *)
+		_SC_THREAD_CPUTIME* = 84; (* user *)
+		_SC_THREAD_DESTRUCTOR_ITERATIONS* = 85; (* user *)
+		_SC_THREAD_KEYS_MAX* = 86; (* user *)
+		_SC_THREAD_PRIO_INHERIT* = 87; (* user *)
+		_SC_THREAD_PRIO_PROTECT* = 88; (* user *)
+		_SC_THREAD_PRIORITY_SCHEDULING* = 89; (* user *)
+		_SC_THREAD_PROCESS_SHARED* = 90; (* user *)
+		_SC_THREAD_SAFE_FUNCTIONS* = 91; (* user *)
+		_SC_THREAD_SPORADIC_SERVER* = 92; (* user *)
+		_SC_THREAD_STACK_MIN* = 93; (* user *)
+		_SC_THREAD_THREADS_MAX* = 94; (* user *)
+		_SC_TIMEOUTS* = 95; (* user *)
+		_SC_THREADS* = 96; (* user *)
+		_SC_TRACE* = 97; (* user *)
+		_SC_TRACE_EVENT_FILTER* = 98; (* user *)
+		_SC_TRACE_INHERIT* = 99; (* user *)
+		_SC_TRACE_LOG* = 100; (* user *)
+		_SC_TTY_NAME_MAX* = 101; (* user *)
+		_SC_TYPED_MEMORY_OBJECTS* = 102;
+		_SC_V6_ILP32_OFF32* = 103; (* user *)
+		_SC_V6_ILP32_OFFBIG* = 104; (* user *)
+		_SC_V6_LP64_OFF64* = 105; (* user *)
+		_SC_V6_LPBIG_OFFBIG* = 106; (* user *)
+		_SC_IPV6* = 118;
+		_SC_RAW_SOCKETS* = 119;
+		_SC_SYMLOOP_MAX* = 120;
+		_SC_ATEXIT_MAX* = 107; (* user *)
+		_SC_IOV_MAX* = 56;
+		_SC_XOPEN_CRYPT* = 108; (* user *)
+		_SC_XOPEN_ENH_I18N* = 109; (* user *)
+		_SC_XOPEN_LEGACY* = 110; (* user *)
+		_SC_XOPEN_REALTIME* = 111;
+		_SC_XOPEN_REALTIME_THREADS* = 112;
+		_SC_XOPEN_SHM* = 113;
+		_SC_XOPEN_STREAMS* = 114;
+		_SC_XOPEN_UNIX* = 115;
+		_SC_XOPEN_VERSION* = 116;
+		_SC_XOPEN_XCU_VERSION* = 117; (* user *)
+		_SC_NPROCESSORS_CONF* = 57;
+		_SC_NPROCESSORS_ONLN* = 58;
+		_SC_CPUSET_SIZE* = 122;
+
+
+		SIGSTKSZ* = 512 * 4 + 32768 (* FreeBSD 9.0 /usr/include/sys/signal.h *);
+
+		(* ENOENT, EEXIST, EACCES, ENOMEM, EDQUOT, EMFILE, ENOTDIR (int) *)
+		EPERM* = 1; (* Operation not permitted *)
+		ENOENT* = 2; (* No such file or directory *)
+		ESRCH* = 3; (* No such process *)
+		EINTR* = 4; (* Interrupted system call *)
+		EIO* = 5; (* Input/output error *)
+		ENXIO* = 6; (* Device not configured *)
+		E2BIG* = 7; (* Argument list too long *)
+		ENOEXEC* = 8; (* Exec format error *)
+		EBADF* = 9; (* Bad file descriptor *)
+		ECHILD* = 10; (* No child processes *)
+		EDEADLK* = 11; (* Resource deadlock avoided *)
+		ENOMEM* = 12; (* Cannot allocate memory *)
+		EACCES* = 13; (* Permission denied *)
+		EFAULT* = 14; (* Bad address *)
+		EBUSY* = 16; (* Device busy *)
+		EEXIST* = 17; (* File exists *)
+		EXDEV* = 18; (* Cross-device link *)
+		ENODEV* = 19; (* Operation not supported by device *)
+		ENOTDIR* = 20; (* Not a directory *)
+		EISDIR* = 21; (* Is a directory *)
+		EINVAL* = 22; (* Invalid argument *)
+		ENFILE* = 23; (* Too many open files in system *)
+		EMFILE* = 24; (* Too many open files *)
+		ENOTTY* = 25; (* Inappropriate ioctl for device *)
+		EFBIG* = 27; (* File too large *)
+		ENOSPC* = 28; (* No space left on device *)
+		ESPIPE* = 29; (* Illegal seek *)
+		EROFS* = 30; (* Read-only filesystem *)
+		EMLINK* = 31; (* Too many links *)
+		EPIPE* = 32; (* Broken pipe *)
+		EDOM* = 33; (* Numerical argument out of domain *)
+		ERANGE* = 34; (* Result too large *)
+		EAGAIN* = 35; (* Resource temporarily unavailable *)
+		ENAMETOOLONG* = 63; (* File name too long *)
+		ENOTEMPTY* = 66; (* Directory not empty *)
+		ENOLCK* = 77; (* No locks available *)
+		ENOSYS* = 78; (* Function not implemented *)
+		EBADMSG* = 89; (* Bad message *)
+		EMULTIHOP* = 90; (* Multihop attempted *)
+		ENOLINK* = 91; (* Link has been severed *)
+		EPROTO* = 92; (* Protocol error *)
+		ENOTBLK* = 15; (* Block device required *)
+		ETXTBSY* = 26; (* Text file busy *)
+		EWOULDBLOCK* = EAGAIN; (* Operation would block *)
+		EINPROGRESS* = 36; (* Operation now in progress *)
+		EALREADY* = 37; (* Operation already in progress *)
+		ENOTSOCK* = 38; (* Socket operation on non-socket *)
+		EDESTADDRREQ* = 39; (* Destination address required *)
+		EMSGSIZE* = 40; (* Message too long *)
+		EPROTOTYPE* = 41; (* Protocol wrong type for socket *)
+		ENOPROTOOPT* = 42; (* Protocol not available *)
+		EPROTONOSUPPORT* = 43; (* Protocol not supported *)
+		ESOCKTNOSUPPORT* = 44; (* Socket type not supported *)
+		EOPNOTSUPP* = 45; (* Operation not supported *)
+		ENOTSUP* = EOPNOTSUPP; (* Operation not supported *)
+		EPFNOSUPPORT* = 46; (* Protocol family not supported *)
+		EAFNOSUPPORT* = 47; (* Address family not supported by protocol family *)
+		EADDRINUSE* = 48; (* Address already in use *)
+		EADDRNOTAVAIL* = 49; (* Can't assign requested address *)
+		ENETDOWN* = 50; (* Network is down *)
+		ENETUNREACH* = 51; (* Network is unreachable *)
+		ENETRESET* = 52; (* Network dropped connection on reset *)
+		ECONNABORTED* = 53; (* Software caused connection abort *)
+		ECONNRESET* = 54; (* Connection reset by peer *)
+		ENOBUFS* = 55; (* No buffer space available *)
+		EISCONN* = 56; (* Socket is already connected *)
+		ENOTCONN* = 57; (* Socket is not connected *)
+		ESHUTDOWN* = 58; (* Can't send after socket shutdown *)
+		ETOOMANYREFS* = 59; (* Too many references: can't splice *)
+		ETIMEDOUT* = 60; (* Operation timed out *)
+		ECONNREFUSED* = 61; (* Connection refused *)
+		ELOOP* = 62; (* Too many levels of symbolic links *)
+		EHOSTDOWN* = 64; (* Host is down *)
+		EHOSTUNREACH* = 65; (* No route to host *)
+		EPROCLIM* = 67; (* Too many processes *)
+		EUSERS* = 68; (* Too many users *)
+		EDQUOT* = 69; (* Disc quota exceeded *)
+		ESTALE* = 70; (* Stale NFS file handle *)
+		EREMOTE* = 71; (* Too many levels of remote in path *)
+		EBADRPC* = 72; (* RPC struct is bad *)
+		ERPCMISMATCH* = 73; (* RPC version wrong *)
+		EPROGUNAVAIL* = 74; (* RPC prog. not avail *)
+		EPROGMISMATCH* = 75; (* Program version wrong *)
+		EPROCUNAVAIL* = 76; (* Bad procedure for program *)
+		EFTYPE* = 79; (* Inappropriate file type or format *)
+		EAUTH* = 80; (* Authentication error *)
+		ENEEDAUTH* = 81; (* Need authenticator *)
+		EIDRM* = 82; (* Identifier removed *)
+		ENOMSG* = 83; (* No message of desired type *)
+		EOVERFLOW* = 84; (* Value too large to be stored in data type *)
+		ECANCELED* = 85; (* Operation canceled *)
+		EILSEQ* = 86; (* Illegal byte sequence *)
+		ENOATTR* = 87; (* Attribute not found *)
+		EDOOFUS* = 88; (* Programming error *)
+		ENOTCAPABLE* = 93; (* Capabilities insufficient *)
+		ECAPMODE* = 94; (* Not permitted in capability mode *)
+		ELAST* = 94; (* Must be equal largest errno *)
+		ERESTART* = -1; (* restart syscall *)
+		EJUSTRETURN* = -2; (* don't modify regs, just return *)
+		ENOIOCTL* = -3; (* ioctl not handled by this layer *)
+		EDIRIOCTL* = -4; (* do direct ioctl in GEOM *)
+
+
+		NAME_MAX* = 255;
+
+		SEEK_SET* = 0;
+		SEEK_CUR* = 1;
+		SEEK_END* = 2;
+
+		P_tmpdir* = "/tmp";
+
+		(* O_RDWR, O_NONBLOCK (intFlags) *)
+		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_FSYNC* = {7}; (* synchronous writes *)
+		O_NOFOLLOW* = {8}; (* don't follow symlinks *)
+		O_DIRECT* = {16};
+		O_DIRECTORY* = {17}; (* Fail if not directory *)
+		O_EXEC* = {18}; (* Open for execute only *)
+		O_TTY_INIT* = {19}; (* Restore default termios attributes *)
+		O_CLOEXEC* = {20};
+		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_SYNC* = {7}; (* POSIX synonym for O_FSYNC *)
+		O_CREAT* = {9}; (* create if nonexistent *)
+		O_TRUNC* = {10}; (* truncate to zero length *)
+		O_EXCL* = {11}; (* error if already exists *)
+		O_NOCTTY* = {15}; (* don't assign controlling terminal *)
+
+
+	TYPE
+		StrArray* = POINTER TO ARRAY [untagged] OF PtrSTR;
+		PtrSTR* = POINTER TO ARRAY [untagged] OF SHORTCHAR;
+
+		(* PtrVoid, int, long, size_t, ssize_t, off_t, time_t, clock_t, sigjmp_buf *)
+		(* mode_t, intFlags, sigset_t (set) *)
+		PtrVoid* = INTEGER;
+		int* = INTEGER;
+		long* = INTEGER;
+		ulong* = INTEGER;
+		size_t* = INTEGER;
+		ssize_t* = INTEGER;
+		off_t* = LONGINT;
+		clock_t* = INTEGER;
+		time_t* = INTEGER;
+		mode_t* = SHORTINT;
+		pid_t* = INTEGER;
+		uid_t* = INTEGER;
+		gid_t* = INTEGER;
+		dev_t* = INTEGER;
+		ino_t* = INTEGER;
+		nlink_t* = SHORTINT;
+		int8_t* = SHORTCHAR;
+		uint8_t* = SHORTCHAR;
+		int16_t* = SHORTINT;
+		uint16_t* = SHORTINT;
+		int32_t* = INTEGER;
+		uint32_t* = INTEGER;
+		int64_t* = LONGINT;
+		uint64_t* = LONGINT;
+		wchar_t* = INTEGER;
+		sigset_t* = ARRAY [untagged] 4 OF SET;
+		sigjmp_buf* = ARRAY [untagged] 12 OF INTEGER;
+		intFlags* = SET;
+		blkcnt_t* = LONGINT;
+		blksize_t* = INTEGER;
+		fflags_t* = SET;
+
+
+		tm* = POINTER TO tmDesc;
+		tmDesc* = RECORD [untagged]
+			(* NOTE: check record size *)
+			(* tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday [ , tm_gmtoff ] *)
+			(* FreeBSD 9.0 /usr/include/time.h *)
+				tm_sec*: int; (* seconds after the minute [0-60] *)
+				tm_min*: int; (* minutes after the hour [0-59] *)
+				tm_hour*: int; (* hours since midnight [0-23] *)
+				tm_mday*: int; (* day of the month [1-31] *)
+				tm_mon*: int; (* months since January [0-11] *)
+				tm_year*: int; (* years since 1900 *)
+				tm_wday*: int; (* days since Sunday [0-6] *)
+				tm_yday*: int; (* days since January 1 [0-365] *)
+				tm_isdst*: int; (* Daylight Savings Time flag *)
+				tm_gmtoff*: long; (* offset from UTC in seconds *)
+				tm_zone*: PtrSTR; (* timezone abbreviation *)
+		END;
+
+		Ptrsiginfo_t* = POINTER TO siginfo_t;
+		siginfo_t = RECORD [untagged]
+			(* si_code, fault address *)
+			(* FreeBSD 9.0 /usr/include/sys/signal.h *)
+				si_signo*: int; (* signal number *)
+				si_errno*: int; (* errno association *)
+				si_code*: int; (* signal code *)
+				si_pid*: pid_t; (* sending process *)
+				si_uid*: uid_t; (* sender's ruid *)
+				si_status*: int; (* exit value *)
+				si_addr*: PtrVoid; (* faulting instruction *)
+(*
+				si_value*: sigval; (* signal value *)
+*)
+				si_value*: PtrVoid;
+				_reason*: RECORD [union]
+					_fault*: RECORD [untagged]
+						_trapno*: int; (* machine specific trap code *)
+					END;
+					_timer*: RECORD [untagged]
+						_timerid*: int;
+						_overrun*: int;
+					END;
+					_mesgq*: RECORD [untagged]
+						_mqd*: int;
+					END;
+					_poll*: RECORD [untagged]
+						_band*: long; (* band event for SIGPOLL *)
+					END;
+					__spare__: RECORD [untagged]
+						__spare1__: long;
+						__spare2__: ARRAY [untagged] 7 OF int;
+					END;
+				END;
+		END;
+
+		Ptrucontext_t* = POINTER TO ucontext_t;
+		ucontext_t = RECORD [untagged]
+			(* IP, SP, FP *)
+			(* FreeBSD 9.0 /usr/include/machine/signal.h *)
+				sc_mask*: sigset_t; (* signal mask to restore *)
+				sc_onstack*: int; (* sigstack state to restore *)
+				sc_gs*: int;  (* machine state (struct trapframe) *)
+				sc_fs*: int;
+				sc_es*: int;
+				sc_ds*: int;
+				sc_edi*: int;
+				sc_esi*: int;
+				sc_ebp*: int;
+				sc_isp*: int;
+				sc_ebx*: int;
+				sc_edx*: int;
+				sc_ecx*: int;
+				sc_eax*: int;
+				sc_trapno*: int;
+				sc_err*: int;
+				sc_eip*: int;
+				sc_cs*: int;
+				sc_efl*: int;
+				sc_esp*: int;
+				sc_ss*: int;
+				sc_len*: int; (* sizeof(mcontext_t) *)
+				
+				(*
+				 * XXX - See <machine/ucontext.h> and <machine/npx.h> for
+				 *       the following fields.
+				 *)
+				sc_fpformat: int;
+				sc_ownedfp: int;
+				sc_spare1: ARRAY [untagged] 1 OF int;
+				sc_fpstate: ARRAY [untagged] 128 OF int; (* FIXME: __aligned(16) *)
+				sc_fsbase: int;
+				sc_gsbase: int;
+				sc_spare2: ARRAY 6 OF int;
+		END;
+
+		sigaction_t* = RECORD [untagged]
+(*
+			sa_sigaction*: PROCEDURE [ccall] (sig: INTEGER; siginfo: Ptrsiginfo_t; context: Ptrucontext_t),
+			sa_flags*: intFlags, sa_mask*: sigset_t
+*)
+			(* FreeBSD 9.0 /usr/include/sys/signal.h *)
+				sa_sigaction*: PROCEDURE [ccall] (sig: int; siginfo: Ptrsiginfo_t; ptr: Ptrucontext_t); (* signal handler *)
+				sa_flags*: intFlags; (* see options *)
+				sa_mask*: sigset_t; (* signal mask to apply *)
+		END;
+
+		stack_t* = RECORD [untagged]
+(*
+			ss_sp*: PtrVoid, ss_size*: size_t, ss_flags*: intFlags
+*)
+			(* FreeBSD 9.0 /usr/include/sys/signal.h *)
+				ss_sp*: PtrVoid; (* signal stack base *)
+				ss_size*: size_t; (* signal stack length *)
+				ss_flags*: intFlags; (* SS_DISABLE and/or SS_ONSTACK *)
+		END;
+
+		stat_t* = RECORD [untagged]
+(*
+			NOTE: check record size
+			st_mode*: mode_t, st_size*: off_t, st_mtime*: time_t
+*)
+			(* FreeBSD 9.0 /usr/include/sys/stat.h *)
+				st_dev*: dev_t; (* inode's device *)
+				st_ino*: ino_t; (* inode's number *)
+				st_mode*: mode_t; (* inode protection mode *)
+				st_nlink*: nlink_t; (* number of hard links *)
+				st_uid*: uid_t; (* user ID of the file's owner *)
+				st_gid*: gid_t; (* group ID of the file's group *)
+				st_rdev*: dev_t; (* device type *)
+
+(*
+				st_atim: timespec_t; (* time of last access *)
+				st_mtim: timespec_t; (* time of last data modification *)
+				st_ctim: timespec_t; (* time of last file status change *)
+*)
+				st_atime*: time_t;
+				st_atimensec*: long;
+				st_mtime*: time_t;
+				st_mtimensec*: long;
+				st_ctime*: time_t;
+				st_ctimensec*: long;
+
+				st_size*: off_t; (* file size, in bytes *)
+				st_blocks*: blkcnt_t; (* blocks allocated for file *)
+				st_blksize*: blksize_t; (* optimal blocksize for I/O *)
+				st_flags*: fflags_t; (* user defined flags for file *)
+				st_gen*: uint32_t; (* file generation number *)
+				st_lspare*: int32_t;
+
+(*
+				st_birthtim: timespec_t; (* time of file creation *)
+*)
+				__st_birthtime*: time_t;
+				__st_birthtimensec*: long;
+
+				___pad: ARRAY [untagged] 2 OF INTEGER; (* FreeBSD 9.0: sizeof(struct stat) = 96 B *)
+		END;
+
+		PtrFILE* = PtrVoid;
+		PtrDIR* = PtrVoid;
+
+		PtrDirent* = POINTER TO Dirent;
+		Dirent = RECORD [untagged]
+(*
+			d_name*: ARRAY [untagged] NAME_MAX + 1 OF SHORTCHAR
+*)
+			(* FreeBSD 9.0 /usr/include/sys/dirent.h *)
+				d_fileno*: uint32_t; (* file number of entry *)
+				d_reclen*: uint16_t; (* length of this record *)
+				d_type*: uint8_t; (* file type, see below *)
+				d_namlen*: uint8_t; (* length of string in d_name *)
+				d_name*: ARRAY [untagged] 255 + 1 (* 256 *) OF SHORTCHAR;
+		END;
+
+(*
+	VAR
+		stdin*: INTEGER;
+		timezone*: INTEGER; (* or tm.tm_gmtoff *)
+*)
+(*
+	PROCEDURE [ccall] __errno_location* (): PtrVoid;
+*)
+(*
+	(* POSIX.1 *)
+		PROCEDURE [ccall] stat* (path: PtrSTR; VAR sp: stat_t): int;
+*)
+	VAR
+		errno*: INTEGER;
+		stdin* ["__stdinp"]: PtrFILE;
+
+	(* POSIX.1 *)
+		PROCEDURE [ccall] stat* (path: PtrSTR; VAR sp: stat_t): int;
+
+
+	(* ANSI C 89 *)
+		PROCEDURE [ccall] clock* (): clock_t;
+
+	PROCEDURE [ccall] mmap* (adr: PtrVoid; len: size_t; prot: intFlags; flags: intFlags; fd: int; offset: off_t): PtrVoid;
+	(* BSD *)
+		PROCEDURE [ccall] munmap* (adr: PtrVoid; len: size_t): int;
+		PROCEDURE [ccall] mprotect* (adr: PtrVoid; len: size_t; prot: intFlags): int;
+
+(*
+	PROCEDURE [ccall] calloc* (nmemb: size_t; size: size_t): PtrVoid;
+	(* ANSI C 89 *)
+		PROCEDURE [ccall] malloc* (size: size_t): PtrVoid;
+*)
+		PROCEDURE [ccall] free* (ptr: PtrVoid);
+
+	(* AT&T *)
+		PROCEDURE [ccall] time* (VAR [nil] t: time_t): time_t;
+	PROCEDURE [ccall] gmtime* (VAR [nil] t: time_t): tm;
+	PROCEDURE [ccall] localtime* (VAR [nil] t: time_t): tm;
+
+	(* POSIX.1 *)
+		PROCEDURE [ccall] sigsetjmp* (VAR env: sigjmp_buf; savemask: int): int;
+		PROCEDURE [ccall] siglongjmp* (VAR env: sigjmp_buf; val: int);
+
+	(* POSIX.1 *)
+		PROCEDURE [ccall] sigemptyset* (VAR set: sigset_t): int;
+		PROCEDURE [ccall] sigfillset* (VAR set: sigset_t): int;
+		PROCEDURE [ccall] sigaddset* (VAR set: sigset_t; signo: int): int;
+		PROCEDURE [ccall] sigprocmask* (how: int; VAR [nil] set: sigset_t; VAR [nil] oset: sigset_t): int;
+
+	(* POSIX.1 *)
+		PROCEDURE [ccall] sigaction* (sig: int; VAR [nil] act: sigaction_t; VAR [nil] oact: sigaction_t): int;
+
+	(* BSD *)
+		PROCEDURE [ccall] sigaltstack* (VAR [nil] ss: stack_t; VAR [nil] oss: stack_t): int;
+
+	(* ANSI C 89 *)
+		PROCEDURE [ccall] getenv* (s: PtrSTR): PtrSTR;
+
+	(* ANSI C 89 *)
+		PROCEDURE [ccall] fopen* (path, mode: PtrSTR): PtrFILE;
+		PROCEDURE [ccall] fclose* (stream: PtrFILE): int;
+		PROCEDURE [ccall] fread* (ptr: PtrVoid; size: size_t; nmemb: size_t; stream: PtrFILE): size_t;
+		PROCEDURE [ccall] fwrite* (ptr: PtrVoid; size: size_t; nmemb: size_t; stream: PtrFILE): size_t;
+		PROCEDURE [ccall] fflush* (s: PtrFILE): int;
+		PROCEDURE [ccall] printf* (s: PtrSTR): int;
+	(* ANSI C 89, XPG4 *)
+		PROCEDURE [ccall] fseek* (stream: PtrFILE; offset: long; whence: int): int;
+
+	(* POSIX.1 *)
+		PROCEDURE [ccall] rename* (from, to: PtrSTR): int;
+		PROCEDURE [ccall] mkdir* (path: PtrSTR; mode: mode_t): int;
+		PROCEDURE [ccall] opendir* (filename: PtrSTR): PtrDIR;
+		PROCEDURE [ccall] readdir* (dirp: PtrDIR): PtrDirent;
+		PROCEDURE [ccall] closedir* (dirp: PtrDIR): int;
+	(* ANSI C 89, XPG4.2 *)
+		PROCEDURE [ccall] remove* (path: PtrSTR): int;
+
+	(* POSIX.1 *)
+		PROCEDURE [ccall] getcwd* (buf: PtrSTR; size: size_t): PtrSTR;
+
+	(* ANSI C 99 *)
+		PROCEDURE [ccall] exit* (status: int);
+
+	(* ANSI C 89 *)
+		PROCEDURE [ccall] strftime* (buf: PtrSTR; maxsize: size_t; format: PtrSTR; timeptr: tm): size_t;
+
+	(* XXX: use fread instead *)
+		PROCEDURE [ccall] fgets* (str: PtrSTR; size: int; stream: PtrFILE): PtrSTR;
+
+	(* POSIX.1 *)
+		PROCEDURE [ccall] open* (path: PtrSTR; flags: intFlags; mode: mode_t): int;
+		PROCEDURE [ccall] write* (d: int; buf: PtrVoid; nbytes: size_t): ssize_t;
+		PROCEDURE [ccall] read* (d: int; buf: PtrVoid; nbytes: size_t): ssize_t;
+		PROCEDURE [ccall] close* (d: int): int;
+
+	(* POSIX.1 *)
+		PROCEDURE [ccall] sysconf* (name: int): long;
+
+END LinLibc.

+ 74 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/Makefile

@@ -0,0 +1,74 @@
+# This is BSD Makefile
+#    BSD       GNU
+# ${.TARGET}    $@
+# ${.ALLSRC}    $^
+# ${.IMPSRC}    $<
+
+PY = python2.7
+
+DEFS = clockspersec defs-map defs-prot defs-sigmask defs-signo defs-fpe defs-sa defs-errno namemax defs-fcntlo defs-basictypes defs-sc
+
+all: Libc.txt ${DEFS} strerrnocase.txt
+
+Libc.txt: Libc.txt.templ ${DEFS} libver osname machine custom fields-dirent fields-sigaction fields-siginfo fields-stack fields-stat fields-tm fields-ucontext
+	${PY} ./untempl.py Libc.txt.templ ${.TARGET}
+
+clockspersec: /usr/include/time.h
+	grep CLOCKS_PER_SEC ${.ALLSRC} | head -1 | awk '{print $$3}' | tr -d '\n' > ${.TARGET}
+
+defs-map: /usr/include/sys/mman.h
+	./dumpdefs.py 2 1 s ${.ALLSRC} | grep "	MAP_" > ${.TARGET}
+	./dumpdefs.py 2 2 s ${.ALLSRC} | grep "	MAP_" >> ${.TARGET}
+
+defs-prot: /usr/include/sys/mman.h
+	./dumpdefs.py 2 1 s ${.ALLSRC} | grep "	PROT_" > ${.TARGET}
+
+defs-sigmask: /usr/include/sys/signal.h
+	./dumpdefs.py 2 2 i ${.ALLSRC} | grep "	SIG_" > ${.TARGET}
+
+defs-signo: /usr/include/sys/signal.h
+	./dumpdefs.py 2 1 i ${.ALLSRC} | grep "	SIG" > ${.TARGET}
+	./dumpdefs.py 2 2 i ${.ALLSRC} | grep "	SIG" | grep -v SIG_ >> ${.TARGET}
+
+defs-fpe: /usr/include/sys/signal.h
+	./dumpdefs.py 2 2 i ${.ALLSRC} | grep "	FPE_" > ${.TARGET}
+
+defs-sa: /usr/include/sys/signal.h
+	./dumpdefs.py 2 2 s ${.ALLSRC} | grep "	SA_" > ${.TARGET}
+
+defs-errno: /usr/include/sys/errno.h
+	./dumpdefs.py 2 0 i ${.ALLSRC} > ${.TARGET}
+	./dumpdefs.py 2 1 i ${.ALLSRC} >> ${.TARGET}
+	./dumpdefs.py 2 2 i ${.ALLSRC} >> ${.TARGET}
+
+namemax: /usr/include/sys/syslimits.h
+	grep "	NAME_MAX	" ${.ALLSRC} | head -1 | awk '{print $$3}' | tr -d '\n' > ${.TARGET}
+
+defs-fcntlo: /usr/include/fcntl.h
+	./dumpdefs.py 2 2 s ${.ALLSRC} | grep -v compat | grep "	O_" > ${.TARGET}
+	./dumpdefs.py 2 1 s ${.ALLSRC} | grep "	O_" >> ${.TARGET}
+
+defs-basictypes: sizeofs
+	./sizeofs > ${.TARGET}
+
+defs-sc: /usr/include/unistd.h
+	./dumpdefs.py 2 1 i ${.ALLSRC} | grep _SC_ > ${.TARGET}
+	./dumpdefs.py 2 2 i ${.ALLSRC} | grep _SC_ > ${.TARGET}
+
+#defs-madv:
+#	./dumpdefs.py 2 1 i /usr/include/sys/mman.h | grep MADV | sed 's/_//' > ${.TARGET}
+#	./dumpdefs.py 2 2 i /usr/include/sys/mman.h | grep MADV >> ${.TARGET}
+#
+#defs-signal1:
+#	./dumpdefs.py 2 2 i /usr/include/sys/signal.h | grep ILL_ >> ${.TARGET}
+#	./dumpdefs.py 2 2 i /usr/include/sys/signal.h | grep SEGV_ >> ${.TARGET}
+#	./dumpdefs.py 2 2 i /usr/include/sys/signal.h | grep BUS_ >> ${.TARGET}
+
+dumpstrerrno.c: defs-errno
+	grep -v ERESTART ${.ALLSRC} | grep -v EJUSTRETURN | grep -v ENOIOCTL | grep -v EDIRIOCTL | ./mkdumpstrerrno.py > ${.TARGET}
+
+strerrnocase.txt: dumpstrerrno
+	./dumpstrerrno | ./mkstrerrnocase.py > ${.TARGET}
+
+clean:
+	rm -f ${DEFS} Libc.txt dumpstrerrno dumpstrerrno.c strerrnocase.txt sizeofs

+ 6 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/custom

@@ -0,0 +1,6 @@
+	VAR
+		errno*: INTEGER;
+		stdin* ["__stdinp"]: PtrFILE;
+
+	(* POSIX.1 *)
+		PROCEDURE [ccall] stat* (path: PtrSTR; VAR sp: stat_t): int;

+ 1 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/dumpdefs.py

@@ -0,0 +1 @@
+../../../../_OpenBSD_/Lin/Mod/gen-Libc/dumpdefs.py

+ 6 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-dirent

@@ -0,0 +1,6 @@
+			(* FreeBSD 9.0 /usr/include/sys/dirent.h *)
+				d_fileno*: uint32_t; (* file number of entry *)
+				d_reclen*: uint16_t; (* length of this record *)
+				d_type*: uint8_t; (* file type, see below *)
+				d_namlen*: uint8_t; (* length of string in d_name *)
+				d_name*: ARRAY [untagged] 255 + 1 (* 256 *) OF SHORTCHAR;

+ 4 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-sigaction

@@ -0,0 +1,4 @@
+			(* FreeBSD 9.0 /usr/include/sys/signal.h *)
+				sa_sigaction*: PROCEDURE [ccall] (sig: int; siginfo: Ptrsiginfo_t; ptr: Ptrucontext_t); (* signal handler *)
+				sa_flags*: intFlags; (* see options *)
+				sa_mask*: sigset_t; (* signal mask to apply *)

+ 31 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-siginfo

@@ -0,0 +1,31 @@
+			(* FreeBSD 9.0 /usr/include/sys/signal.h *)
+				si_signo*: int; (* signal number *)
+				si_errno*: int; (* errno association *)
+				si_code*: int; (* signal code *)
+				si_pid*: pid_t; (* sending process *)
+				si_uid*: uid_t; (* sender's ruid *)
+				si_status*: int; (* exit value *)
+				si_addr*: PtrVoid; (* faulting instruction *)
+(*
+				si_value*: sigval; (* signal value *)
+*)
+				si_value*: PtrVoid;
+				_reason*: RECORD [union]
+					_fault*: RECORD [untagged]
+						_trapno*: int; (* machine specific trap code *)
+					END;
+					_timer*: RECORD [untagged]
+						_timerid*: int;
+						_overrun*: int;
+					END;
+					_mesgq*: RECORD [untagged]
+						_mqd*: int;
+					END;
+					_poll*: RECORD [untagged]
+						_band*: long; (* band event for SIGPOLL *)
+					END;
+					__spare__: RECORD [untagged]
+						__spare1__: long;
+						__spare2__: ARRAY [untagged] 7 OF int;
+					END;
+				END;

+ 4 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-stack

@@ -0,0 +1,4 @@
+			(* FreeBSD 9.0 /usr/include/sys/signal.h *)
+				ss_sp*: PtrVoid; (* signal stack base *)
+				ss_size*: size_t; (* signal stack length *)
+				ss_flags*: intFlags; (* SS_DISABLE and/or SS_ONSTACK *)

+ 35 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-stat

@@ -0,0 +1,35 @@
+			(* FreeBSD 9.0 /usr/include/sys/stat.h *)
+				st_dev*: dev_t; (* inode's device *)
+				st_ino*: ino_t; (* inode's number *)
+				st_mode*: mode_t; (* inode protection mode *)
+				st_nlink*: nlink_t; (* number of hard links *)
+				st_uid*: uid_t; (* user ID of the file's owner *)
+				st_gid*: gid_t; (* group ID of the file's group *)
+				st_rdev*: dev_t; (* device type *)
+
+(*
+				st_atim: timespec_t; (* time of last access *)
+				st_mtim: timespec_t; (* time of last data modification *)
+				st_ctim: timespec_t; (* time of last file status change *)
+*)
+				st_atime*: time_t;
+				st_atimensec*: long;
+				st_mtime*: time_t;
+				st_mtimensec*: long;
+				st_ctime*: time_t;
+				st_ctimensec*: long;
+
+				st_size*: off_t; (* file size, in bytes *)
+				st_blocks*: blkcnt_t; (* blocks allocated for file *)
+				st_blksize*: blksize_t; (* optimal blocksize for I/O *)
+				st_flags*: fflags_t; (* user defined flags for file *)
+				st_gen*: uint32_t; (* file generation number *)
+				st_lspare*: int32_t;
+
+(*
+				st_birthtim: timespec_t; (* time of file creation *)
+*)
+				__st_birthtime*: time_t;
+				__st_birthtimensec*: long;
+
+				___pad: ARRAY [untagged] 2 OF INTEGER; (* FreeBSD 9.0: sizeof(struct stat) = 96 B *)

+ 12 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-tm

@@ -0,0 +1,12 @@
+			(* FreeBSD 9.0 /usr/include/time.h *)
+				tm_sec*: int; (* seconds after the minute [0-60] *)
+				tm_min*: int; (* minutes after the hour [0-59] *)
+				tm_hour*: int; (* hours since midnight [0-23] *)
+				tm_mday*: int; (* day of the month [1-31] *)
+				tm_mon*: int; (* months since January [0-11] *)
+				tm_year*: int; (* years since 1900 *)
+				tm_wday*: int; (* days since Sunday [0-6] *)
+				tm_yday*: int; (* days since January 1 [0-365] *)
+				tm_isdst*: int; (* Daylight Savings Time flag *)
+				tm_gmtoff*: long; (* offset from UTC in seconds *)
+				tm_zone*: PtrSTR; (* timezone abbreviation *)

+ 35 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/fields-ucontext

@@ -0,0 +1,35 @@
+			(* FreeBSD 9.0 /usr/include/machine/signal.h *)
+				sc_mask*: sigset_t; (* signal mask to restore *)
+				sc_onstack*: int; (* sigstack state to restore *)
+				sc_gs*: int;  (* machine state (struct trapframe) *)
+				sc_fs*: int;
+				sc_es*: int;
+				sc_ds*: int;
+				sc_edi*: int;
+				sc_esi*: int;
+				sc_ebp*: int;
+				sc_isp*: int;
+				sc_ebx*: int;
+				sc_edx*: int;
+				sc_ecx*: int;
+				sc_eax*: int;
+				sc_trapno*: int;
+				sc_err*: int;
+				sc_eip*: int;
+				sc_cs*: int;
+				sc_efl*: int;
+				sc_esp*: int;
+				sc_ss*: int;
+				sc_len*: int; (* sizeof(mcontext_t) *)
+				
+				(*
+				 * XXX - See <machine/ucontext.h> and <machine/npx.h> for
+				 *       the following fields.
+				 *)
+				sc_fpformat: int;
+				sc_ownedfp: int;
+				sc_spare1: ARRAY [untagged] 1 OF int;
+				sc_fpstate: ARRAY [untagged] 128 OF int; (* FIXME: __aligned(16) *)
+				sc_fsbase: int;
+				sc_gsbase: int;
+				sc_spare2: ARRAY 6 OF int;

+ 1 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/libver

@@ -0,0 +1 @@
+.7

+ 1 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/machine

@@ -0,0 +1 @@
+i386

+ 1 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/mkdumpstrerrno.py

@@ -0,0 +1 @@
+../../../../_OpenBSD_/Lin/Mod/gen-Libc/mkdumpstrerrno.py

+ 1 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/mkstrerrnocase.py

@@ -0,0 +1 @@
+../../../../_OpenBSD_/Lin/Mod/gen-Libc/mkstrerrnocase.py

+ 1 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/nsig

@@ -0,0 +1 @@
+SIGTHR + 1

+ 1 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/osname

@@ -0,0 +1 @@
+FreeBSD 9.0

+ 1 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/sigstksz

@@ -0,0 +1 @@
+512 * 4 + 32768 (* FreeBSD 9.0 /usr/include/sys/signal.h *)

+ 88 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/sizeofs.c

@@ -0,0 +1,88 @@
+#include <sys/types.h>
+#include <sys/signal.h>
+#include <setjmp.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define TABS "\t\t"
+
+#define FALSE (0)
+#define TRUE (1)
+
+static void D (const char *s, int sz, int set, int export)
+{
+	int res;
+
+	res = printf("%s%s", TABS, s);
+	if (export) {
+		res = printf("*");
+	}
+	res = printf(" = ");
+	if (sz == 1) {
+		res = printf("SHORTCHAR");
+	} else if (sz == 2) {
+		res = printf("SHORTINT");
+	} else if (sz == 4) {
+		if (set) {
+			res = printf("SET");
+		} else {
+			res = printf("INTEGER");
+		}
+	} else if (sz == 8) {
+		if (set) {
+			res = printf("ARRAY [untagged] 2 OF SET");
+		} else {
+			res = printf("LONGINT");
+		}
+	} else {
+		res = printf("ARRAY [untagged] ");
+		if (sz % 4 == 0) {
+			if (set) {
+				res = printf("%d OF SET", sz / 4);
+			} else {
+				res = printf("%d OF INTEGER", sz / 4);
+			}
+		} else {
+			res = printf("%d OF SHORTCHAR", sz);
+		}
+	}
+	res = printf(";\n");
+}
+
+int main ()
+{
+	D("PtrVoid", sizeof(void *), FALSE, TRUE);
+	D("int", sizeof(int), FALSE, TRUE);
+	D("long", sizeof(long), FALSE, TRUE);
+	D("ulong", sizeof(unsigned long), FALSE, TRUE);
+	D("size_t", sizeof(size_t), FALSE, TRUE);
+	D("ssize_t", sizeof(ssize_t), FALSE, TRUE);
+	D("off_t", sizeof(off_t), FALSE, TRUE);
+	D("clock_t", sizeof(clock_t), FALSE, TRUE);
+	D("time_t", sizeof(time_t), FALSE, TRUE);
+	D("mode_t", sizeof(mode_t), TRUE, TRUE);
+	D("pid_t", sizeof(pid_t), FALSE, TRUE);
+	D("uid_t", sizeof(uid_t), FALSE, TRUE);
+	D("gid_t", sizeof(gid_t), FALSE, TRUE);
+	D("dev_t", sizeof(dev_t), FALSE, TRUE);
+	D("ino_t", sizeof(ino_t), FALSE, TRUE);
+	D("nlink_t", sizeof(nlink_t), FALSE, TRUE);
+	D("int8_t", sizeof(int8_t), FALSE, TRUE);
+	D("uint8_t", sizeof(u_int8_t), FALSE, TRUE);
+	D("int16_t", sizeof(int16_t), FALSE, TRUE);
+	D("uint16_t", sizeof(u_int16_t), FALSE, TRUE);
+	D("int32_t", sizeof(int32_t), FALSE, TRUE);
+	D("uint32_t", sizeof(u_int32_t), FALSE, TRUE);
+	D("int64_t", sizeof(int64_t), FALSE, TRUE);
+	D("uint64_t", sizeof(u_int64_t), FALSE, TRUE);
+	D("wchar_t", sizeof(wchar_t), FALSE, TRUE);
+	D("sigset_t", sizeof(sigset_t), TRUE, TRUE);
+	D("sigjmp_buf", sizeof(sigjmp_buf), FALSE, TRUE);
+	D("intFlags", sizeof(int), TRUE, TRUE);
+	/* D("FILE", sizeof(FILE), FALSE, FALSE); */
+	D("blkcnt_t", sizeof(blkcnt_t), FALSE, TRUE);
+	D("blksize_t", sizeof(blksize_t), FALSE, TRUE);
+	D("fflags_t", sizeof(fflags_t), TRUE, TRUE);
+
+	return 0;
+}

+ 1 - 0
BlackBox/_FreeBSD_/Lin/Mod/gen-Libc/untempl.py

@@ -0,0 +1 @@
+../../../../_OpenBSD_/Lin/Mod/gen-Libc/untempl.py

+ 15 - 0
BlackBox/_FreeBSD_/Lin/Rsrc/loader/Makefile

@@ -0,0 +1,15 @@
+# This is BSD Makefile
+#    BSD       GNU
+# ${.TARGET}    $@
+# ${.ALLSRC}    $^
+# ${.IMPSRC}    $<
+
+CFLAGS += -Wall -O0 -g
+
+all: loader
+
+loader: loader.c
+	${CC} ${CFLAGS} -o ${.TARGET} ${.ALLSRC}
+
+clean:
+	rm -f loader

BIN
BlackBox/_FreeBSD_/Lin/Rsrc/loader/loader


BIN
BlackBox/_FreeBSD_/System/Mod/Kernel.odc


BIN
BlackBox/_FreeBSD_/libBB.so


BIN
BlackBox/_FreeBSD_/libBB0.so


+ 1 - 0
BlackBox/_FreeBSD_/loader

@@ -0,0 +1 @@
+Lin/Rsrc/loader/loader

BIN
BlackBox/_Linux_/Host/Mod/Console.odc


+ 1 - 0
BlackBox/_Linux_/Lin/Mod/gen-Libc/mkdumpstrerrno.py

@@ -0,0 +1 @@
+../../../../_OpenBSD_/Lin/Mod/gen-Libc/mkdumpstrerrno.py

+ 1 - 0
BlackBox/_Linux_/Lin/Mod/gen-Libc/mkstrerrnocase.py

@@ -0,0 +1 @@
+../../../../_OpenBSD_/Lin/Mod/gen-Libc/mkstrerrnocase.py

BIN
BlackBox/_Linux_/System/Mod/Kernel.odc


+ 5 - 3
BlackBox/_OpenBSD_/Lin/Mod/Libc.txt

@@ -67,7 +67,6 @@ MODULE LinLibc ["libc.so.66.0"];
 		SA_SIGINFO* = {6}; (* generate siginfo_t *)
 
 
-		_NSIG* = 33;
 		(* SIGINT, SIGILL, SIGFPE, SIGSEGV, SIGKILL, SIGSTOP, SIGWINCH, SIGTHR (int) *)
 		SIGHUP* = 1; (* hangup *)
 		SIGINT* = 2; (* interrupt *)
@@ -99,6 +98,7 @@ MODULE LinLibc ["libc.so.66.0"];
 		SIGWINCH* = 28; (* window size changes *)
 		SIGTHR* = 32; (* thread library AST *)
 
+		_NSIG* = 33;
 
 (*
 		PAGE_SIZE* = 4096;
@@ -404,6 +404,7 @@ MODULE LinLibc ["libc.so.66.0"];
 
 		tm* = POINTER TO tmDesc;
 		tmDesc* = RECORD [untagged]
+			(* NOTE: check record size *)
 			(* tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday [ , tm_gmtoff ] *)
 			(* OpenBSD 5.2 /usr/include/time.h *)
 				tm_sec*: int; (* seconds after the minute [0-60] *)
@@ -420,7 +421,7 @@ MODULE LinLibc ["libc.so.66.0"];
 		END;
 
 		Ptrsiginfo_t* = POINTER TO siginfo_t;
-		siginfo_t* = RECORD [untagged]
+		siginfo_t = RECORD [untagged]
 			(* si_code, fault address *)
 			(* OpenBSD 5.2 /usr/include/sys/siginfo.h *)
 				si_signo*: int; (* signal from signal.h *)
@@ -453,7 +454,7 @@ MODULE LinLibc ["libc.so.66.0"];
 		END;
 
 		Ptrucontext_t* = POINTER TO ucontext_t;
-		ucontext_t* = RECORD [untagged]
+		ucontext_t = RECORD [untagged]
 			(* IP, SP, FP *)
 			(* OpenBSD 5.2 /usr/include/i386/signal.h struct sigcontext *)
 				sc_gs*: int;
@@ -516,6 +517,7 @@ MODULE LinLibc ["libc.so.66.0"];
 
 		stat_t* = RECORD [untagged]
 (*
+			NOTE: check record size
 			st_mode*: mode_t, st_size*: off_t, st_mtime*: time_t
 *)
 			(* OpenBSD 5.2 /usr/include/sys/stat.h *)

BIN
BlackBox/_OpenBSD_/System/Mod/Kernel.odc


+ 19 - 9
README

@@ -1,7 +1,7 @@
 Oberon Microsystems BlackBox Component Builder (http://www.oberon.ch/)
-Port for OpenBSD/i386, GNU/Linux/i386
+Port for OpenBSD/i386, GNU/Linux/i386, FreeBSD/i386
 
-Tested on OpenBSD 5.2, Fedora Core 17, Ubuntu 12.04 LTS
+Tested on OpenBSD 5.2, Fedora Core 17, Ubuntu 12.04 LTS, FreeBSD 9.0
 
 Some significant parts taken from OpenBUGS (http://www.openbugs.info/)
 
@@ -73,6 +73,11 @@ Files:
 				mmap: use "/dev/zero" device instead of -1
 				mprotect addresses must be page-aligned
 				do not show warning message if signal install failed
+		_FreeBSD_/System/Mod/Kernel.odc:
+			_OpenBSD_/System/Mod/Kernel.odc modified for FreeBSD:
+				Time*
+				TrapHandler
+				SetupModListAccess: initial module list must be writeable (read only by default in FreeBSD)
 		_Linux_/Host/Mod/Files.odc:
 			OpenBUGS Lin/Mod/linHostFiles.odc:
 				synchronized with BlackBox 1.6-rc6
@@ -83,9 +88,12 @@ Files:
 				OpenBSD-specific:
 					size_t
 					__xstat -> stat
-		_OpenBSD_/Lin/Mod/Libc.odc:
-			OpenBUGS Lin/Mod/Libc.odc:
-				OpenBSD-specific
+		_FreeBSD_/Host/Mod/Files.odc:
+			_Linux_/Host/Mod/Files.odc:
+				FreeBSD-specific:
+					size_t
+					__xstat -> stat
+					mode_t
 		_Linux_/Lin/Mod/Libc.odc:
 			OpenBUGS Lin/Mod/Libc.odc:
 				PROT_*, MAP_*, O_*, _SC_PAGESIZE, SIGSTKSZ CONSTs added
@@ -93,8 +101,8 @@ Files:
 		_Linux_/Lin/Mod/Dl.odc:
 			OpenBUGS Lin/Mod/Dl.odc
 		_Linux_/Host/Mod/Dates.odc: from http://oberoncore.ru/
-		_OpenBSD_/Host/Mod/Dates.odc:
-			_Linux_/Host/Mod/Dates.odc: OpenBSD-specific
+		_FreeBSDOpenBSD_/Host/Mod/Dates.odc:
+			_Linux_/Host/Mod/Dates.odc: OpenBSD and FreeBSD specific
 		_LinuxOpenBSD_/Host/Mod/TextConv.odc:
 			BlackBox 1.6-rc6 Host/Mod/TextConv.odc:
 				Windows-specific converters removed
@@ -111,7 +119,7 @@ Files:
 	new:
 		Console:
 			System/Mod/Console.odc: Console interface
-			_Linux_/Host/Mod/Console.odc: Console implementation for Linux
+			_FreeBSDLinux_/Host/Mod/Console.odc: Console implementation for Linux and FreeBSD
 			_OpenBSD_/Host/Mod/Console.odc:
 				_Linux_/Host/Mod/Console.odc: stdin -> SYSTEM.ADR(__sF[0]) (OpenBSD-specific)
 			_Windows_/Host/Mod/Console.odc:
@@ -120,7 +128,9 @@ Files:
 			Interp.odc: console interpreter
 			Compiler.odc: console interface to Dev compiler
 			Log.odc: Log.Hook console implementation
-		{_Linux_,_OpenBSD_}/Lin/Mod/Iconv.odc: interface to libiconv system library
+		{_OpenBSD_,_FreeBSD_}/Lin/Mod/Libc.odc: OpenBSD and FreeBSD specific libc interface
+		{_OpenBSD_,_FreeBSD_}/Lin/Mod/Dl.odc: OpenBSD and FreeBSD specific interface to dl
+		{_Linux_,_OpenBSD_,_FreeBSD_}/Lin/Mod/Iconv.odc: interface to iconv
 		{_Linux_,_OpenBSD_}/Lin/Mod/Ioctl.odc: interface to ioctl
 		{_Linux_,_OpenBSD_}/Lin/Mod/Termios.odc: interface to termios
 		{_Linux_,_OpenBSD_}/Lin/Mod/Net.odc: interface to network functionality

+ 1 - 0
TODO

@@ -20,6 +20,7 @@ By priority:
 		Linux: no sigaltstack & siglongjmp problem,
 			but, before stack overflow SEGV signal, memory of shared library
 			on low (active) stack border, is corrupted
+		FreeBSD: ???
 
 	GUI:
 		...