├── COPYING ├── Changes ├── Contributors ├── GNUmakefile ├── MAGIC ├── Makefile ├── Mk_dist ├── README ├── ar ├── Makefile ├── alloca.c └── ar.c ├── as ├── 6809 │ └── const.h ├── Makefile ├── address.h ├── align.h ├── alloc.c ├── as.c ├── as86_encap.sh ├── as86_to_data ├── asm │ ├── calljmp.asm │ ├── ea.asm │ ├── each.asm │ ├── easlow.as │ ├── f.asm │ ├── fadd.asm │ ├── farcall.asm │ ├── group1.asm │ ├── group6.asm │ ├── group7.asm │ ├── imul.asm │ ├── incdec.asm │ ├── inher.asm │ ├── inout.asm │ ├── movspec.asm │ ├── pushpop.asm │ ├── seg.asm │ ├── shdouble.asm │ ├── shift.asm │ ├── summary.as │ └── xchg.asm ├── assemble.c ├── bin │ ├── calljmp.bin │ ├── ea.bin │ ├── each.bin │ ├── f.bin │ ├── fadd.bin │ ├── farcall.bin │ ├── group1.bin │ ├── group6.bin │ ├── group7.bin │ ├── imul.bin │ ├── incdec.bin │ ├── inher.bin │ ├── inout.bin │ ├── movspec.bin │ ├── pushpop.bin │ ├── seg.bin │ ├── shdouble.bin │ ├── shift.bin │ └── xchg.bin ├── byteord.h ├── chk ├── const.h ├── errors.c ├── errors.h ├── express.c ├── file.h ├── flag.h ├── genbin.c ├── genlist.c ├── genobj.c ├── gensym.c ├── globvar.h ├── keywords.c ├── macro.c ├── macro.h ├── mops.c ├── obj1 │ ├── calljmp.obj │ ├── ea.obj │ ├── each.obj │ ├── f.obj │ ├── fadd.obj │ ├── farcall.obj │ ├── group1.obj │ ├── group6.obj │ ├── group7.obj │ ├── imul.obj │ ├── incdec.obj │ ├── inher.obj │ ├── inout.obj │ ├── movspec.obj │ ├── pushpop.obj │ ├── seg.obj │ ├── shdouble.obj │ ├── shift.obj │ └── xchg.obj ├── opcode.h ├── pops.c ├── proto.h ├── readsrc.c ├── scan.c ├── scan.h ├── source.h ├── syshead.h ├── table.c ├── type.h └── typeconv.c ├── bcc ├── 6809 │ └── const.h ├── Makefile ├── align.h ├── assign.c ├── bcc-cc1.c ├── bcc.c ├── bcc.doc ├── bcc.h ├── byteord.h ├── codefrag.c ├── condcode.h ├── const.h ├── dbnode.c ├── dbprintf.c ├── debug.c ├── debug.h ├── declare.c ├── express.c ├── exptree.c ├── floatop.c ├── function.c ├── gencode.c ├── gencode.h ├── genloads.c ├── glogcode.c ├── hardop.c ├── hashcmd.c ├── input.c ├── input.h ├── label.c ├── label.h ├── loadexp.c ├── longop.c ├── os.h ├── output.c ├── output.h ├── parse.h ├── preproc.c ├── preserve.c ├── proto.h ├── reg.h ├── sc.h ├── scan.c ├── scan.h ├── sizes.h ├── softop.c ├── state.c ├── sysproto.h ├── table.c ├── table.h ├── type.c ├── type.h └── types.h ├── bin86 ├── ChangeLog ├── Makefile ├── README └── README-0.4 ├── bootblocks ├── Makefile ├── README ├── bb_init1.s ├── bb_init2.s ├── bb_linux.s ├── boot_fpy.s ├── boot_win.c ├── buffer.c ├── bzimage.c ├── commands.c ├── freedos.h ├── freedosboot.zip ├── fs.c ├── fs_dos.c ├── fs_min.c ├── fs_tar.c ├── help.c ├── i86_funcs.c ├── i86_funcs.h ├── killhd.s ├── lsys.c ├── makeboot.c ├── mbr.s ├── mbr_dm.s ├── minix.c ├── minix.h ├── minix_elks.c ├── monitor.c ├── monitor.h ├── msdos.s ├── noboot.s ├── nombr.s ├── readfs.h ├── relocate.c ├── skip.s ├── sysboot.s ├── sysboot16.s ├── sysmbr.s ├── sysmbrtail.s ├── tarboot.s ├── unix.c └── zimage.s ├── copt ├── Makefile ├── README ├── copt.c ├── rules.186 ├── rules.386 ├── rules.86 ├── rules.end ├── rules.i ├── rules.net └── rules.start ├── cpp ├── Makefile ├── cc.h ├── cpp.c ├── hash.c ├── main.c ├── token1.c ├── token1.h ├── token1.tok ├── token2.c ├── token2.h ├── token2.tok └── torture.c ├── dis88 ├── Makefile ├── README ├── ansi.h ├── dis.h ├── dis88.1 ├── disfp.c ├── dishand.c ├── dismain.c ├── disrel.c ├── distabs.c └── old_a.out.h ├── doselks ├── Makefile ├── coroutine.c ├── doselks.c ├── doselks.h ├── syscalls.c └── syscalls.h ├── elksemu ├── Kernel_patch ├── Makefile ├── README ├── Security ├── binfmt_elks.c ├── elks.c ├── elks.h ├── elks_signal.c ├── elks_sys.c ├── minix.c └── mkefile ├── ifdef.c ├── ld ├── 6809 │ └── config.h ├── Makefile ├── align.h ├── bindef.h ├── byteord.h ├── catimage.c ├── config.h ├── const.h ├── dumps.c ├── globvar.h ├── io.c ├── ld.c ├── ld86r.c ├── linksyms.c ├── mkar.c ├── obj.h ├── objchop.c ├── objdump86.c ├── readobj.c ├── rel_aout.h ├── syshead.h ├── table.c ├── type.h ├── typeconv.c ├── v7_aout.h ├── writebin.c ├── writeemu.c ├── writex86.c ├── x86_aout.h └── x86_cpm86.h ├── libbsd ├── Make.defs ├── Makefile ├── README ├── README.HLU ├── cfsetspeed.c ├── checkrhosts.c ├── daemon.c ├── login_tty.c ├── logout.c ├── logwtmp.c ├── pty.c ├── revoke.c ├── setpassent.c ├── sgtty.c └── snprintf.c ├── libc ├── COPYING ├── Config.dflt ├── Config_sh ├── KERNEL ├── Make.defs ├── Makefile ├── New_subdir ├── Pre_main ├── README ├── bcc │ ├── Config │ ├── Makefile │ ├── __ldivmod.c │ ├── alloca.c │ ├── bcc_bsw.c │ ├── bcc_i386.c │ ├── bcc_int.c │ ├── bcc_io.c │ ├── bcc_long.c │ ├── heap.c │ └── ldiv.c ├── bios │ ├── Config │ ├── Makefile │ ├── README │ ├── ansi.c │ ├── bios.c │ ├── bios_disk.c │ ├── bios_min.c │ ├── bios_vid.c │ ├── fileops.c │ ├── fs_dos.c │ ├── io.h │ ├── rawio.c │ ├── rawio.h │ ├── time.c │ └── vt52.c ├── conio │ ├── Config │ ├── Makefile │ ├── conio.c │ └── cprintf.c ├── crt0.c ├── error │ ├── Config │ ├── Makefile │ ├── README │ ├── __assert.c │ ├── error.c │ ├── error2.c │ ├── liberror.txt │ ├── mktab.sh │ ├── perror.c │ ├── sys_errlist.c │ └── sys_siglist.c ├── getent │ ├── Config │ ├── Makefile │ ├── __getgrent.c │ ├── __getpwent.c │ ├── config-grp.h │ ├── config.h │ ├── fgetgrent.c │ ├── fgetpwent.c │ ├── getgrgid.c │ ├── getgrnam.c │ ├── getpw.c │ ├── getpwnam.c │ ├── getpwuid.c │ ├── grent.c │ ├── initgroups.c │ ├── putpwent.c │ ├── pwent.c │ ├── test_grp.c │ ├── test_pwd.c │ └── utent.c ├── gnu_i386 │ ├── Config │ ├── Makefile │ ├── cstartup.s │ ├── dirent.c │ ├── exec.c │ ├── heap.c │ ├── mksyscall │ ├── syscall.dat │ └── syscall.s ├── gtermcap │ ├── COPYING │ ├── ChangeLog │ ├── Config │ ├── Makefile │ ├── NEWS │ ├── README │ ├── termcap.c │ ├── tparam.c │ └── version.c ├── i386fp │ ├── Config │ ├── Makefile │ ├── bccfp.tex │ ├── changes │ ├── ecvt.c │ ├── fabs.x │ ├── fadd.x │ ├── fcomp.x │ ├── fdiv.x │ ├── fmul.x │ ├── fpbsr.x │ ├── fperr.c │ ├── fperr.h │ ├── fperror.x │ ├── fplib.h │ ├── fptoi.x │ ├── fpulld.x │ ├── fpullf.x │ ├── fpushd.x │ ├── fpushf.x │ ├── fpushi.x │ ├── frexp.x │ ├── ftst.x │ ├── ldexp.x │ ├── modf.c │ └── test.c ├── i386sys │ ├── Config │ ├── Makefile │ ├── cstartup.c │ ├── dirent.c │ ├── exec.c │ ├── mksyscall │ ├── setjmp3.c │ └── syscall.dat ├── include │ ├── a.out.h │ ├── ar.h │ ├── asm │ │ ├── limits.h │ │ └── types.h │ ├── assert.h │ ├── bios.h │ ├── bsd │ │ ├── bsd.h │ │ ├── errno.h │ │ ├── sgtty.h │ │ ├── signal.h │ │ ├── stdlib.h │ │ ├── sys │ │ │ └── ttychars.h │ │ ├── tzfile.h │ │ └── unistd.h │ ├── conio.h │ ├── ctype.h │ ├── dirent.h │ ├── dos.h │ ├── errno.h │ ├── fcntl.h │ ├── features.h │ ├── generic │ │ ├── errno.h │ │ ├── fcntl.h │ │ └── types.h │ ├── getopt.h │ ├── grp.h │ ├── limits.h │ ├── linux │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── ioctl.h │ │ ├── mman.h │ │ ├── resource.h │ │ ├── stat.h │ │ ├── termios.h │ │ ├── types.h │ │ ├── utsname.h │ │ └── vm86.h │ ├── math.h │ ├── memory.h │ ├── msdos │ │ ├── errno.h │ │ ├── fcntl.h │ │ └── types.h │ ├── paths.h │ ├── pwd.h │ ├── search.h │ ├── setjmp.h │ ├── signal.h │ ├── stdarg.h │ ├── stddef.h │ ├── stdint.h │ ├── stdlib.h │ ├── strings.h │ ├── sys │ │ ├── cdefs.h │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── file.h │ │ ├── ioctl.h │ │ ├── mman.h │ │ ├── param.h │ │ ├── resource.h │ │ ├── signal.h │ │ ├── socket.h │ │ ├── stat.h │ │ ├── time.h │ │ ├── times.h │ │ ├── types.h │ │ ├── utsname.h │ │ ├── vm86.h │ │ └── wait.h │ ├── termcap.h │ ├── termio.h │ ├── termios.h │ ├── time.h │ ├── unistd.h │ ├── utime.h │ ├── utmp.h │ └── varargs.h ├── kinclude │ ├── Config │ ├── Makefile │ ├── arch │ │ ├── errno.h │ │ ├── ioctl.h │ │ ├── stat.h │ │ └── types.h │ └── linuxmt │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── ioctl.h │ │ ├── resource.h │ │ ├── stat.h │ │ ├── termios.h │ │ └── types.h ├── malloc │ ├── Config │ ├── Makefile │ ├── README │ ├── malloc.c │ └── malloc.h ├── misc │ ├── Config │ ├── Makefile │ ├── aliases.c │ ├── atexit.c │ ├── atof.c │ ├── atoi.c │ ├── atol.c │ ├── bsearch.c │ ├── cputype.c │ ├── crypt.c │ ├── ctype.c │ ├── ctypefn.c │ ├── getcwd.c │ ├── getenv.c │ ├── getopt.c │ ├── itoa.c │ ├── lsearch.c │ ├── ltoa.c │ ├── ltostr.c │ ├── popen.c │ ├── putenv.c │ ├── qsort.c │ ├── rand.c │ ├── setenv.c │ ├── strtod.c │ ├── strtol.c │ ├── syslib.c │ ├── system.c │ └── tmpnam.c ├── msdos │ ├── Config │ ├── Makefile │ ├── Notes │ ├── TODO │ ├── dirent.c │ ├── dosound.c │ ├── i86.c │ ├── intr.c │ ├── msdos.c │ ├── mslib.c │ ├── new86.c │ ├── sound.c │ └── time.c ├── regexp │ ├── Config │ ├── Makefile │ ├── Makefile.org │ ├── README │ ├── README.rdb │ ├── patch.1 │ ├── patch.2 │ ├── patch.3 │ ├── patch.4 │ ├── regerror.c │ ├── regexp.3 │ ├── regexp.c │ ├── regexp.h │ ├── regmagic.h │ ├── regsub.c │ ├── tests │ ├── timer.c │ └── try.c ├── stdio │ ├── Config │ ├── Makefile │ ├── printf.c │ ├── scanf.c │ ├── stdio.c │ └── stdio.h ├── string │ ├── Config │ ├── Makefile │ ├── strcasecmp.c │ ├── strcspn.c │ ├── string.c │ ├── string.h │ ├── strncasecmp.c │ ├── strpbrk.c │ ├── strsep.c │ ├── strspn.c │ ├── strstr.c │ └── strtok.c ├── syscall │ ├── Config │ ├── Makefile │ ├── TODO │ ├── dirent.c │ ├── exec.c │ ├── mkentry.sh │ ├── mksyscall │ ├── setjmp.c │ ├── signal.c │ ├── syscall.dev86 │ └── syslib0.c ├── termios │ ├── Config │ ├── Makefile │ ├── README │ ├── termios.c │ └── ttyname.c └── time │ ├── Config │ ├── Makefile │ ├── README │ ├── asc_conv.c │ ├── asctime.c │ ├── ctime.c │ ├── gmtime.c │ ├── localtime.c │ └── tm_conv.c ├── libcompat ├── makefile.in ├── man ├── Makefile ├── as86.1 ├── bcc.1 ├── elks.1 ├── elksemu.1 └── ld86.1 ├── mkcompile ├── tests ├── Makefile ├── README ├── a.out ├── compr.c ├── env.c ├── ft.c ├── grab.c ├── hd.c ├── hello_world.s ├── line2.c ├── lines.c ├── ouch.c ├── rand.c ├── sync.c ├── ucomp.c └── wc.c └── unproto ├── Makefile ├── README ├── Sharheader ├── acc.sh ├── cpp.sh ├── error.c ├── error.h ├── example.c ├── example.out ├── hash.c ├── stdarg.h ├── stddef.h ├── stdlib.h ├── strsave.c ├── symbol.c ├── symbol.h ├── tok_class.c ├── tok_io.c ├── tok_pool.c ├── token.h ├── unproto.1 ├── unproto.c ├── varargs.c ├── vstring.c └── vstring.h /Contributors: -------------------------------------------------------------------------------- 1 | Top of the list, without whom this wouldn't be here... 2 | 3 | Bruce Evans 4 | 5 | Then there's me, I'm controlling the releases of Dev86 and have 6 | the master files. 7 | 8 | Robert de Bath 9 | 10 | The files are available at linux.mit.edu with the source and yesterday's 11 | patch file available via http://cix.co.uk/~mayday/ 12 | 13 | We're all available through the Linux-8086 mailing list at: 14 | linux-8086@vger.kernel.org 15 | 16 | Rob. 17 | 18 | Finally the list itself, if you're missing send me a patch :-) 19 | 20 | Alan Cox 21 | Nat Friedman 22 | Steven Huang 23 | Steffen Kaiser 24 | Shane Kerr 25 | Gero Kuhlmann 26 | Chad Page 27 | Dick Porter 28 | Dale Schumacher 29 | Wietse Venema 30 | Joel Weber II 31 | Claudio Matsuoka 32 | Andrew Chittenden 33 | John Coffman 34 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | # 2 | # Flag that we're using GNU make. 3 | # 4 | 5 | all: phony 6 | @$(MAKE) $(MAKEARG) -f Makefile IFDEFFLAGS=-DGNUMAKE IFDEFNAME=ifdefg $@ 7 | 8 | %: phony 9 | @$(MAKE) $(MAKEARG) -f Makefile IFDEFFLAGS=-DGNUMAKE IFDEFNAME=ifdefg $@ 10 | 11 | phony: ; 12 | 13 | GNUmakefile: ; 14 | -------------------------------------------------------------------------------- /MAGIC: -------------------------------------------------------------------------------- 1 | Useful bits for /etc/magic: 2 | 3 | #------------------------------------------------------------------------------ 4 | # Linux 8086 executable 5 | 0 lelong&0xFF0000FF 0xC30000E9 Linux-8086 executable, headerless 6 | >5 string . 7 | >>4 string >\0 \b, libc version %s 8 | 9 | 0 lelong&0xFF00FFFF 0x04000301 Linux-8086 executable 10 | >2 byte&0x01 !0 \b, unmapped zero page 11 | >2 byte&0x20 0 \b, impure 12 | >2 byte&0x20 !0 13 | >>2 byte&0x10 !0 \b, A_EXEC 14 | >2 byte&0x02 !0 \b, A_PAL 15 | >2 byte&0x04 !0 \b, A_NSYM 16 | >2 byte&0x08 !0 \b, A_STAND 17 | >2 byte&0x40 !0 \b, A_PURE 18 | >2 byte&0x80 !0 \b, A_TOVLY 19 | >28 long !0 \b, not stripped 20 | >37 string . 21 | >>36 string >\0 \b, libc version %s 22 | 23 | # Other ld86 executable formats ... 24 | 0 lelong 0x10200301 Minix-386 executable 25 | >28 long !0 not stripped 26 | 27 | 0 lelong 0x10100301 Minix-386 impure executable 28 | >28 long !0 not stripped 29 | 30 | 0 lelong&0xFF00FFFF 0x10000301 ld86 I80386 executable 31 | >28 long !0 not stripped 32 | 33 | # Never seen formats. 34 | # 0 belong&0xFFFF00FF 0x0103000B ld86 M68K executable 35 | # 0 belong&0xFFFF00FF 0x0103000C ld86 NS16K executable 36 | # 0 belong&0xFFFF00FF 0x01030017 ld86 SPARC executable 37 | 38 | # AS86/LD86 object files. 39 | # There is _no_ difference between 16 and 32 bit .o files that file can see. 40 | 0 string \243\206\001\0 Linux-8086 object file 41 | -------------------------------------------------------------------------------- /ar/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 1999 Greg Haerr 2 | # This file is part of the Linux-8086 Development environment and is 3 | # distributed under the GNU General Public License. 4 | 5 | LIBDIR =/usr/bin 6 | CFLAGS =-O 7 | LDFLAGS = 8 | DEFS = 9 | OBJS= ar.o alloca.o 10 | 11 | all: ar86 12 | 13 | ar86: $(OBJS) 14 | $(CC) $(LDFLAGS) $(OBJS) -o $@ 15 | 16 | install: ar86 17 | install -d $(LIBDIR) 18 | install -m 755 ar86 $(LIBDIR) 19 | 20 | clean realclean clobber: 21 | rm -f *.o ar86 ar ar.h rel_aout.h 22 | 23 | $(OBJS): ar.h rel_aout.h 24 | 25 | ar.h: 26 | test -f ar.h || \ 27 | { rm -f ar.h ; ln -s ../libc/include/ar.h . ; } || \ 28 | ln ../libc/include/ar.h . 29 | 30 | rel_aout.h: 31 | test -f rel_aout.h || \ 32 | { rm -f rel_aout.h ; ln -s ../ld/rel_aout.h . ; } || \ 33 | ln ../ld/rel_aout.h . 34 | 35 | .c.o: 36 | $(CC) $(CFLAGS) $(DEFS) -c $< -o $@ 37 | -------------------------------------------------------------------------------- /as/address.h: -------------------------------------------------------------------------------- 1 | /* address.h - global variables involving addresses for assembler */ 2 | 3 | EXTERN struct address_s lastexp;/* last expression parsed */ 4 | 5 | EXTERN union 6 | { 7 | char fcbuf[LINLEN - 6]; /* buffer for fcb and fcc data */ 8 | /* data is absolute in 1 char pieces */ 9 | /* limited by FCC\t"" etc on line */ 10 | struct address_s fdbuf[(LINLEN - 4) / 2]; 11 | /* buffer for fdb data */ 12 | /* data can be of any 2-byte adr type */ 13 | /* limited by FDB\t and commas on line */ 14 | #if SIZEOF_OFFSET_T > 2 15 | struct address_s fqbuf[(LINLEN - 4) / 4]; 16 | /* buffer for fqb data */ 17 | /* data can be of any 4-byte adr type */ 18 | /* limited by FQB\t and commas on line */ 19 | #endif 20 | } 21 | databuf; 22 | 23 | EXTERN bool_t fcflag; 24 | EXTERN bool_t fdflag; 25 | #if SIZEOF_OFFSET_T > 2 26 | EXTERN bool_t fqflag; 27 | #endif 28 | 29 | EXTERN struct address_s immadr; 30 | EXTERN smallcount_t immcount; 31 | -------------------------------------------------------------------------------- /as/align.h: -------------------------------------------------------------------------------- 1 | /* align.h - memory alignment requirements for linker */ 2 | 3 | /* Copyright (C) 1994 Bruce Evans */ 4 | 5 | #ifndef S_ALIGNMENT 6 | # define align(x) 7 | #else 8 | 9 | #if defined(__STDC__) && defined(_POSIX_SOURCE) 10 | # define align(x) ((x)=(void *) \ 11 | (((ssize_t)(x) + (S_ALIGNMENT-1)) & ~(S_ALIGNMENT-1))) 12 | #else 13 | # define align(x) ((x)=(void *) \ 14 | ((char *)(x) + ((S_ALIGNMENT-(char)(x)) & (S_ALIGNMENT-1)))) 15 | #endif 16 | #endif 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /as/asm/calljmp.asm: -------------------------------------------------------------------------------- 1 | CALL 0x10:0x20 ; not implemented 2 | CALL AL; ; illeg 3 | CALL DS ; illeg 4 | 5 | CALL REL16 6 | 7 | CALL AX 8 | CALL BX 9 | CALL CX 10 | CALL DX 11 | CALL SP 12 | CALL BP 13 | CALL SI 14 | CALL DI 15 | 16 | CALL BYTE [BX] ; illeg 17 | CALL [BX] 18 | CALL WORD [BX] 19 | 20 | USE32 21 | CALL REL32 22 | 23 | USE16 24 | CALL EAX 25 | CALL EBX 26 | CALL ECX 27 | CALL EDX 28 | CALL ESP 29 | CALL EBP 30 | CALL ESI 31 | CALL EDI 32 | 33 | CALL DWORD [BX] 34 | 35 | JMP 0x10:0x20 ; not implemented 36 | JMP AL; ; illeg 37 | JMP DS ; illeg 38 | 39 | JMP REL16 40 | 41 | JMP AX 42 | JMP BX 43 | JMP CX 44 | JMP DX 45 | JMP SP 46 | JMP BP 47 | JMP SI 48 | JMP DI 49 | 50 | JMP BYTE [BX] ; illeg 51 | JMP [BX] 52 | JMP WORD [BX] 53 | 54 | USE32 55 | JMP REL32 56 | 57 | USE16 58 | JMP EAX 59 | JMP EBX 60 | JMP ECX 61 | JMP EDX 62 | JMP ESP 63 | JMP EBP 64 | JMP ESI 65 | JMP EDI 66 | 67 | JMP DWORD [BX] 68 | 69 | REL16: 70 | REL32: 71 | -------------------------------------------------------------------------------- /as/asm/farcall.asm: -------------------------------------------------------------------------------- 1 | call 1:2 2 | call far [1] 3 | use32 4 | call far [1] 5 | 6 | use16 7 | jmp 1:2 8 | jmp far [1] 9 | use32 10 | jmp far [1] 11 | -------------------------------------------------------------------------------- /as/asm/group1.asm: -------------------------------------------------------------------------------- 1 | ADD AL,#3 2 | ADD AX,#$1234 3 | ADD EAX,#$12345678 4 | ADD BL,#3 5 | ADD BX,#$1234 6 | ADD EBX,#$12345678 7 | ADD BYTE [BX],#3 8 | ADD BYTE 3[BX],#4 9 | ADD BYTE [BX+SI],#4 10 | ADD WORD [BX],#$1234 11 | ADD DWORD [BX],#$12345678 12 | ADD BYTE [BX],#3 13 | ADD WORD [BX],#-3 14 | ADD DWORD [BX],#-3 15 | ADD CL,BL 16 | ADD CX,BX 17 | ADD ECX,EBX 18 | ADD [BX],CL 19 | ADD [BX],CX 20 | ADD [BX],ECX 21 | ADD CL,[BX] 22 | ADD CX,[BX] 23 | ADD ECX,[BX] 24 | 25 | ADC CL,BL 26 | AND CL,BL 27 | CMP CL,BL 28 | OR CL,BL 29 | SUB CL,BL 30 | SBB CL,BL 31 | XOR CL,BL 32 | -------------------------------------------------------------------------------- /as/asm/group6.asm: -------------------------------------------------------------------------------- 1 | ; group6.asm 2 | ; 0F 00 /nnn 3 | 4 | ; LLDT r/m16 nnn = 010 5 | ; LTR r/m16 nnn = 011 6 | ; SLDT r/m16 nnn = 000 7 | ; STR r/m16 nnn = 001 8 | ; VERR r/m16 nnn = 100 9 | ; VERW r/m16 nnn = 101 10 | 11 | LLDT AL ; illeg size 12 | LLDT EAX ; illeg size 13 | LLDT WORD $1234 ; immed not allowed 14 | LLDT DS ; segreg not allowed 15 | 16 | LLDT AX 17 | LLDT [BX] 18 | LLDT [EAX] 19 | 20 | LTR BX 21 | SLDT [BP] 22 | STR [EBX] 23 | VERR CX 24 | VERW [SI] 25 | -------------------------------------------------------------------------------- /as/asm/group7.asm: -------------------------------------------------------------------------------- 1 | ; group7.asm 2 | ; 0F 01 /nnn 3 | 4 | ; INVLPG m nnn = 111 5 | ; LGDT m16&32 nnn = 010 6 | ; LIDT m16&32 nnn = 011 7 | ; LMSW r/m16 nnn = 110 8 | ; SGDT m nnn = 000 9 | ; SIDT m nnn = 001 10 | ; SMSW r/m16 nnn = 100 11 | 12 | LGDT EAX ; register not allowed 13 | LGDT #$1234 ; immed not allowed 14 | LGDT WORD PTR [BX] ; illegal size 15 | 16 | LGDT [BX] 17 | LGDT PWORD PTR [BX] 18 | LGDT FWORD PTR [BX] 19 | LGDT [EAX] 20 | 21 | INVLPG [EDI] 22 | SGDT [BP] 23 | SIDT [EBX] 24 | 25 | LMSW AL ; illeg size 26 | LMSW EAX ; illeg size 27 | LMSW #$1234 ; immed not allowed 28 | LMSW DS ; segreg not allowed 29 | 30 | LMSW AX 31 | LMSW [BX] 32 | LMSW [EAX] 33 | 34 | SMSW BX 35 | -------------------------------------------------------------------------------- /as/asm/imul.asm: -------------------------------------------------------------------------------- 1 | use32 2 | 3 | imul bl 4 | imul byte ptr [esi] 5 | imul bx 6 | imul word ptr [esi] 7 | imul ebx 8 | imul dword ptr [esi] 9 | 10 | imul ax,bx 11 | imul ax,[esi] 12 | imul eax,ebx 13 | imul eax,[esi] 14 | 15 | imul ax,bx,22 16 | imul ax,[esi],22 17 | imul eax,ebx,22 18 | imul eax,[esi],22 19 | 20 | imul ax,[22] 21 | imul eax,[22] 22 | imul ax,#22 23 | imul eax,#22 24 | 25 | imul ax,bx,300 26 | imul ax,[esi],300 27 | imul eax,ebx,300000 28 | imul eax,[esi],300000 29 | 30 | imul ax,[300] 31 | imul eax,[300000] 32 | imul ax,#300 33 | imul eax,#300000 34 | -------------------------------------------------------------------------------- /as/asm/incdec.asm: -------------------------------------------------------------------------------- 1 | INC AL 2 | INC AH 3 | INC BL 4 | INC BH 5 | INC CL 6 | INC CH 7 | INC DL 8 | INC DH 9 | INC #1 ; illeg 10 | INC BYTE #1 ; illeg 11 | INC [BX] ; illeg 12 | INC BYTE [BX] 13 | 14 | INC AX 15 | INC BX 16 | INC CX 17 | INC DX 18 | INC SP 19 | INC BP 20 | INC SI 21 | INC DI 22 | INC CS ; illeg 23 | INC DS ; illeg 24 | INC ES ; illeg 25 | INC FS ; illeg 26 | INC GS ; illeg 27 | INC #$1234 ; illeg 28 | INC WORD #$1234 ; illeg 29 | INC WORD [BX] 30 | 31 | INC EAX 32 | INC EBX 33 | INC ECX 34 | INC EDX 35 | INC ESP 36 | INC EBP 37 | INC ESI 38 | INC EDI 39 | INC #$12345678 ; illeg 40 | INC DWORD #$12345678 ; illeg 41 | INC DWORD [BX] 42 | 43 | DEC AL 44 | DEC AH 45 | DEC BL 46 | DEC BH 47 | DEC CL 48 | DEC CH 49 | DEC DL 50 | DEC DH 51 | DEC #1 ; illeg 52 | DEC BYTE #1 ; illeg 53 | DEC [BX] ; illeg 54 | DEC BYTE [BX] 55 | 56 | DEC AX 57 | DEC BX 58 | DEC CX 59 | DEC DX 60 | DEC SP 61 | DEC BP 62 | DEC SI 63 | DEC DI 64 | DEC CS ; illeg 65 | DEC DS ; illeg 66 | DEC ES ; illeg 67 | DEC FS ; illeg 68 | DEC GS ; illeg 69 | DEC #$1234 ; illeg 70 | DEC WORD #$1234 ; illeg 71 | DEC WORD [BX] 72 | 73 | DEC EAX 74 | DEC EBX 75 | DEC ECX 76 | DEC EDX 77 | DEC ESP 78 | DEC EBP 79 | DEC ESI 80 | DEC EDI 81 | DEC #$12345678 ; illeg 82 | DEC DWORD #$12345678 ; illeg 83 | DEC DWORD [BX] 84 | -------------------------------------------------------------------------------- /as/asm/inher.asm: -------------------------------------------------------------------------------- 1 | ; INHER.ASM 2 | 3 | ; INHER opcodes 4 | 5 | AAA 6 | AAS 7 | 8 | CLC 9 | CLD 10 | CLI 11 | CLTS 12 | CMC 13 | CMPSB 14 | 15 | DAA 16 | DAS 17 | 18 | HLT 19 | 20 | INTO 21 | INSB 22 | 23 | LAHF 24 | LEAVE 25 | LOCK 26 | LODSB 27 | 28 | MOVSB 29 | 30 | NOP 31 | 32 | OUTSB 33 | 34 | REP 35 | REPE 36 | REPNE 37 | 38 | SAHF 39 | SCASB 40 | STC 41 | STD 42 | STI 43 | STOSB 44 | 45 | WAIT 46 | 47 | ; INHER16 and INHER32 opcodes 48 | 49 | USE16 50 | 51 | CBW 52 | CWD 53 | CWDE 54 | CDQ 55 | CMPSW 56 | CMPSD 57 | 58 | INSW 59 | INSD 60 | IRET 61 | IRETD 62 | 63 | LODSW 64 | LODSD 65 | 66 | MOVSW 67 | MOVSD 68 | 69 | OUTSW 70 | OUTSD 71 | 72 | POPA 73 | POPAD 74 | POPF 75 | POPFD 76 | PUSHA 77 | PUSHAD 78 | PUSHF 79 | PUSHFD 80 | 81 | SCASW 82 | SCASD 83 | STOSW 84 | STOSW 85 | 86 | XLAT 87 | XLATB 88 | 89 | USE32 90 | 91 | CBW 92 | CWD 93 | CWDE 94 | CDQ 95 | CMPSW 96 | CMPSD 97 | 98 | INSW 99 | INSD 100 | IRET 101 | IRETD 102 | 103 | LODSW 104 | LODSD 105 | 106 | MOVSW 107 | MOVSD 108 | 109 | OUTSW 110 | OUTSD 111 | 112 | POPA 113 | POPAD 114 | POPF 115 | POPFD 116 | PUSHA 117 | PUSHAD 118 | PUSHF 119 | PUSHFD 120 | 121 | SCASW 122 | SCASD 123 | STOSW 124 | STOSW 125 | 126 | XLAT 127 | XLATB 128 | -------------------------------------------------------------------------------- /as/asm/inout.asm: -------------------------------------------------------------------------------- 1 | IN EAX,DX ; plain IN is no longer allowed 2 | INB 3 | IN AL,DX 4 | INW 5 | IN AX,DX 6 | IN EAX,DX 7 | IN AL,$20 8 | IN AL,$101 9 | IN AX,$20 10 | IN AX,$101 11 | IN EAX,$20 12 | IN EAX,$101 13 | 14 | OUTB DX,EAX ; plain OUT is no longer allowed 15 | OUTB 16 | OUT DX,AL 17 | OUTW 18 | OUT DX,AX 19 | OUT DX,EAX 20 | OUT $20,AL 21 | OUT $101,AL 22 | OUT $20,AX 23 | OUT #101,AX 24 | OUT $20,EAX 25 | OUT $101,EAX 26 | -------------------------------------------------------------------------------- /as/asm/seg.asm: -------------------------------------------------------------------------------- 1 | SEG CS 2 | SEG DS 3 | SEG ES 4 | SEG FS 5 | SEG GS 6 | SEG SS 7 | -------------------------------------------------------------------------------- /as/asm/shdouble.asm: -------------------------------------------------------------------------------- 1 | ; SHDOUBLE.ASM 2 | 3 | ILLEGALS EQU 1 4 | 5 | ; 0F A4 SHLD r/m16,r16,imm8 3/7 6 | ; 0F A4 SHLD r/m32,r32,imm8 3/7 7 | ; 0F A5 SHLD r/m16,r16,CL 3/7 8 | ; 0F A5 SHLD r/m32,r32,CL 3/7 9 | 10 | ; 0F AC SHRD r/m16,r16,imm8 3/7 11 | ; 0F AC SHRD r/m32,r32,imm8 3/7 12 | ; 0F AD SHRD r/m16,r16,CL 3/7 13 | ; 0F AD SHRD r/m32,r32,CL 3/7 14 | 15 | IF ILLEGALS 16 | SHLD AL,BL,8 ; byte size 17 | SHLD AX,8,8 ; immediate source 18 | SHLD AX,DS,8 ; segment register 19 | SHLD AX,[BX],8 ; non-register source 20 | SHLD AX,BX,256 ; shift count too big 21 | SHLD AL,BL,8 ; byte size 22 | ENDIF 23 | 24 | SHLD BX,CX,3 25 | SHLD EDX,ESI,1 26 | SHLD CX,BX,CL 27 | SHLD ESI,EDX,1 28 | SHLD [BX],CX,3 29 | SHLD [BX],ECX,1 30 | SHLD [SI],BX,CL 31 | SHLD [SI],EBX,CL 32 | 33 | SHRD BX,CX,3 34 | SHRD CX,BX,CL 35 | -------------------------------------------------------------------------------- /as/bin/calljmp.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/calljmp.bin -------------------------------------------------------------------------------- /as/bin/ea.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/ea.bin -------------------------------------------------------------------------------- /as/bin/each.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/each.bin -------------------------------------------------------------------------------- /as/bin/f.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/f.bin -------------------------------------------------------------------------------- /as/bin/fadd.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/fadd.bin -------------------------------------------------------------------------------- /as/bin/farcall.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/farcall.bin -------------------------------------------------------------------------------- /as/bin/group1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/group1.bin -------------------------------------------------------------------------------- /as/bin/group6.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/group6.bin -------------------------------------------------------------------------------- /as/bin/group7.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/group7.bin -------------------------------------------------------------------------------- /as/bin/imul.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/imul.bin -------------------------------------------------------------------------------- /as/bin/incdec.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/incdec.bin -------------------------------------------------------------------------------- /as/bin/inher.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/inher.bin -------------------------------------------------------------------------------- /as/bin/inout.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/inout.bin -------------------------------------------------------------------------------- /as/bin/movspec.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/movspec.bin -------------------------------------------------------------------------------- /as/bin/pushpop.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/pushpop.bin -------------------------------------------------------------------------------- /as/bin/seg.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/seg.bin -------------------------------------------------------------------------------- /as/bin/shdouble.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/shdouble.bin -------------------------------------------------------------------------------- /as/bin/shift.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/shift.bin -------------------------------------------------------------------------------- /as/bin/xchg.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/bin/xchg.bin -------------------------------------------------------------------------------- /as/byteord.h: -------------------------------------------------------------------------------- 1 | /* byteord.h - byte order dependencies for C compiler, assembler, linker */ 2 | 3 | /* These are for the targets of everything and for linker source too. */ 4 | 5 | #ifdef I8086 6 | # define INT_BIG_ENDIAN 0 7 | # define LONG_BIG_ENDIAN 0 /* except longs are back to front for Xenix */ 8 | #endif 9 | 10 | #ifdef I80386 11 | # define INT_BIG_ENDIAN 0 12 | # define LONG_BIG_ENDIAN 0 13 | #endif 14 | 15 | #ifdef MC6809 16 | # define INT_BIG_ENDIAN 1 /* byte order in words is high-low */ 17 | # define LONG_BIG_ENDIAN 1 /* byte order in longs is high-low */ 18 | #endif 19 | -------------------------------------------------------------------------------- /as/chk: -------------------------------------------------------------------------------- 1 | 2 | compile() 3 | { 4 | # /lib/elksemu ./as86 -3 -k "$@" 5 | ./as86 -3 -k "$@" 6 | } 7 | 8 | for i in `ls asm/*.asm` 9 | do 10 | j=`basename $i .asm` 11 | compile asm/$j.asm -b $j.bin -o $j.obj > /dev/null 12 | cmp $j.obj obj1/$j.obj 13 | 14 | # compile asm/$j.asm -b $j.bin > /dev/null 15 | # cmp $j.bin bin/$j.bin 16 | 17 | rm -f $j.bin $j.obj $j.asm 18 | done 19 | 20 | -------------------------------------------------------------------------------- /as/file.h: -------------------------------------------------------------------------------- 1 | /* file.h - global variables involving files for assembler */ 2 | 3 | EXTERN char *filnamptr; /* file name pointer */ 4 | EXTERN char *truefilename; /* in case actual source name is a tmpname */ 5 | 6 | EXTERN fd_t infil; /* current input file (stacked, 0 = memory) */ 7 | 8 | /* Output fds */ 9 | EXTERN unsigned char outfd; /* output fd for writer fns */ 10 | EXTERN fd_t binfil; /* binary output file (0 = memory) */ 11 | EXTERN fd_t lstfil; /* list output file (0 = standard) */ 12 | EXTERN fd_t objfil; /* object output file */ 13 | EXTERN fd_t symfil; /* symbol table output file */ 14 | 15 | /* readsrc internals */ 16 | EXTERN unsigned infil0; /* Number of first input area */ 17 | EXTERN unsigned infiln; /* Number of current input area */ 18 | -------------------------------------------------------------------------------- /as/flag.h: -------------------------------------------------------------------------------- 1 | /* flag.h - global structured-flag variables for assembler */ 2 | 3 | EXTERN struct flags_s list; /* listing on/off */ 4 | EXTERN struct flags_s maclist; /* list macros on/off */ 5 | EXTERN struct flags_s as_warn; /* warnings on/off */ 6 | -------------------------------------------------------------------------------- /as/macro.h: -------------------------------------------------------------------------------- 1 | /* macro.h - global variables for macro expansion for assembler */ 2 | 3 | EXTERN bool_t macflag; /* inside macro flag */ 4 | EXTERN bool_t macload; /* loading macro flag */ 5 | EXTERN unsigned macnum; /* macro call counter */ 6 | 7 | EXTERN unsigned char maclevel; /* nesting level */ 8 | EXTERN struct schain_s *macpar; /* parameter save buffer */ 9 | EXTERN struct schain_s *macptop; /* top of param buffer (+1) */ 10 | EXTERN struct macro_s *macstak; /* stack ptr */ 11 | -------------------------------------------------------------------------------- /as/obj1/calljmp.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/calljmp.obj -------------------------------------------------------------------------------- /as/obj1/ea.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/ea.obj -------------------------------------------------------------------------------- /as/obj1/each.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/each.obj -------------------------------------------------------------------------------- /as/obj1/f.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/f.obj -------------------------------------------------------------------------------- /as/obj1/fadd.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/fadd.obj -------------------------------------------------------------------------------- /as/obj1/farcall.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/farcall.obj -------------------------------------------------------------------------------- /as/obj1/group1.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/group1.obj -------------------------------------------------------------------------------- /as/obj1/group6.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/group6.obj -------------------------------------------------------------------------------- /as/obj1/group7.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/group7.obj -------------------------------------------------------------------------------- /as/obj1/imul.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/imul.obj -------------------------------------------------------------------------------- /as/obj1/incdec.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/incdec.obj -------------------------------------------------------------------------------- /as/obj1/inher.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/inher.obj -------------------------------------------------------------------------------- /as/obj1/inout.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/inout.obj -------------------------------------------------------------------------------- /as/obj1/movspec.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/movspec.obj -------------------------------------------------------------------------------- /as/obj1/pushpop.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/pushpop.obj -------------------------------------------------------------------------------- /as/obj1/seg.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/seg.obj -------------------------------------------------------------------------------- /as/obj1/shdouble.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/shdouble.obj -------------------------------------------------------------------------------- /as/obj1/shift.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/shift.obj -------------------------------------------------------------------------------- /as/obj1/xchg.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/as/obj1/xchg.obj -------------------------------------------------------------------------------- /as/scan.h: -------------------------------------------------------------------------------- 1 | /* scan.h - global variables for scanner for assembler */ 2 | 3 | #define EOLCHAR '\n' 4 | 5 | EXTERN struct sym_s *gsymptr; /* global symbol ptr */ 6 | EXTERN char lindirect; /* left symbol for indirect addressing */ 7 | EXTERN char *lineptr; /* current line position */ 8 | EXTERN offset_t number; /* constant number */ 9 | EXTERN char * rindexp; /* error code for missing rindirect */ 10 | EXTERN char rindirect; /* right symbol for indirect addressing */ 11 | EXTERN char sym; /* current symbol */ 12 | EXTERN char *symname; /* current symbol name */ 13 | -------------------------------------------------------------------------------- /as/source.h: -------------------------------------------------------------------------------- 1 | /* source.h - global variables for source handlers for assembler */ 2 | 3 | EXTERN unsigned linum; /* line # */ 4 | EXTERN bool_t listpre; /* flag to show line has already been listed */ 5 | -------------------------------------------------------------------------------- /bcc/align.h: -------------------------------------------------------------------------------- 1 | /* align.h - memory alignment requirements for bcc */ 2 | 3 | /* Copyright (C) 1992 Bruce Evans */ 4 | 5 | #ifndef S_ALIGNMENT 6 | # define align(x) (x) 7 | #else 8 | # if defined(__STDC__) && defined(_POSIX_SOURCE) 9 | # define align(x) (((ssize_t) (x) + (S_ALIGNMENT-1)) & ~(S_ALIGNMENT-1)) 10 | # else 11 | # define align(x) ((char *) (x) + (- (char) (x) & (S_ALIGNMENT-1))) 12 | # endif 13 | #endif 14 | 15 | extern uoffset_T alignmask; /* general alignment mask */ 16 | -------------------------------------------------------------------------------- /bcc/bcc-cc1.c: -------------------------------------------------------------------------------- 1 | /* bcc-cc1.c - "pass 1" for bcc */ 2 | 3 | /* Copyright (C) 1992 Bruce Evans */ 4 | 5 | #include "bcc.h" 6 | 7 | PUBLIC int main(argc, argv) 8 | int argc; 9 | char **argv; 10 | { 11 | debug(1, "Start"); 12 | growheap(0); /* init order is important */ 13 | syminit(); 14 | etreeinit(); 15 | #ifdef BUILTIN_CPP 16 | ifinit(); 17 | predefine(); 18 | #endif 19 | openio(argc, argv); 20 | codeinit(); 21 | typeinit(); 22 | program(); 23 | finishup(); 24 | 25 | /* NOTREACHED */ 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /bcc/bcc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1997 Robert de Bath 2 | * This file is part of the Linux-8086 Development environment and is 3 | * distributed under the GNU General Public License. */ 4 | 5 | #ifdef _AIX 6 | #include /* AIX 4.1 + GCC seems to need this */ 7 | #endif 8 | 9 | /* Ansi C has certain guarentees ... except under MSdross :-( */ 10 | 11 | #ifdef __STDC__ 12 | #ifndef MSDOS 13 | #include 14 | #include 15 | #include 16 | #include 17 | #endif 18 | 19 | #define P(x) x 20 | 21 | #else 22 | #define P(x) () 23 | #endif 24 | 25 | #include "const.h" 26 | #include "types.h" 27 | #include "proto.h" 28 | 29 | #if !defined(__STDC__) || defined(MSDOS) 30 | #include "sysproto.h" 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /bcc/byteord.h: -------------------------------------------------------------------------------- 1 | /* byteord.h - byte order dependencies for bcc */ 2 | 3 | /* Copyright (C) 1992 Bruce Evans */ 4 | 5 | #ifdef I8088 6 | # define INT_BIG_ENDIAN 0 7 | # define LONG_BIG_ENDIAN 1 /* longs are back to front for Xenix */ 8 | #endif 9 | 10 | #ifdef MC6809 11 | # define INT_BIG_ENDIAN 1 /* byte order in words is high-low */ 12 | # define LONG_BIG_ENDIAN 1 /* byte order in longs is high-low */ 13 | #endif 14 | -------------------------------------------------------------------------------- /bcc/condcode.h: -------------------------------------------------------------------------------- 1 | /* condcode.h - condition codes for bcc */ 2 | 3 | /* Copyright (C) 1992 Bruce Evans */ 4 | 5 | #define EQ 0 6 | #define NE 1 7 | #define RA 2 8 | #define RN 3 9 | #define LT 4 10 | #define GE 5 11 | #define LE 6 12 | #define GT 7 13 | #define LO 8 14 | #define HS 9 15 | #define LS 10 16 | #define HI 11 17 | -------------------------------------------------------------------------------- /bcc/debug.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DEBUG_H_ 3 | #define _DEBUG_H_ 4 | 5 | #if __STDC__ 6 | void debug_do_setlevel(char * fname, int lineno, int level); 7 | int debug_pos(char * file, int lineno); 8 | int debug_msg(int level, char * name, ...); 9 | int debug_never(int level, char * name, ...); 10 | #else 11 | void debug_do_setlevel(); 12 | int debug_pos(); 13 | int debug_msg(); 14 | int debug_never(); 15 | #endif /* __STDC__ */ 16 | 17 | /* The new CPP has these. */ 18 | #if defined(__BCC__) && (__BCC_VERSION__ >= 0x001011L) 19 | #define VARARG_MACROS 20 | #endif 21 | 22 | #ifdef DEBUG 23 | 24 | extern int debug_level; 25 | #define debug !debug_level?0:debug_pos(__FILE__,__LINE__)+debug_msg 26 | #define debug_setlevel(lvl) debug_do_setlevel(__FILE__, __LINE__, lvl) 27 | 28 | #else /* !DEBUG */ 29 | 30 | #ifdef VARARG_MACROS 31 | # define debug(junk ...) 0 32 | #else 33 | # define debug 1?0:debug_never 34 | #endif 35 | # define debug_setlevel(lvl) 36 | 37 | #endif /* DEBUG */ 38 | #endif /* _DEBUG_H_ */ 39 | -------------------------------------------------------------------------------- /bcc/label.h: -------------------------------------------------------------------------------- 1 | /* label.h - assembler-specific label characters for bcc */ 2 | 3 | /* Copyright (C) 1992 Bruce Evans */ 4 | 5 | /* defaults */ 6 | 7 | #define CCNAMEPREFIX '_' 8 | # define LABELENDCHAR ':' /* last char of ALL labels */ 9 | #define LABELSTARTCHAR '.' /* first char of names of generated labels */ 10 | #define LOCALSTARTCHAR '.' /* first char of local names */ 11 | #define PUBLICENDCHAR ':' 12 | 13 | /* adjustments for other assemblers */ 14 | 15 | #ifdef AS09 16 | # undef LABELENDCHAR 17 | #endif 18 | 19 | #ifdef XENIX_AS 20 | # undef LABELSTARTCHAR 21 | # define LABELSTARTCHAR 'L' 22 | # undef LOCALSTARTCHAR 23 | # define LOCALSTARTCHAR 'L' 24 | #endif 25 | -------------------------------------------------------------------------------- /bcc/os.h: -------------------------------------------------------------------------------- 1 | /* os.h - source/target operating system dependencies for bcc */ 2 | 3 | /* Copyright (C) 1992 Bruce Evans */ 4 | 5 | /* 6 | must have unix-near-compatible creat, open, read, write and close 7 | 8 | source O/S's supported: 9 | default: 10 | *IX 11 | special: 12 | EDOS (#define SOS_EDOS if required) 13 | MSDOS (#define SOS_MSDOS) 14 | target O/S's supported: 15 | default: 16 | *IX 17 | MSDOS 18 | special: 19 | EDOS (#define TOS_EDOS) 20 | */ 21 | 22 | /* defaults */ 23 | 24 | #define CREATPERMS 0666 /* permissions for creat */ 25 | #define EOL 10 /* source newline */ 26 | #define EOLTO 10 /* target newline */ 27 | #define DIRCHAR '/' 28 | #define DIRSTRING "/" 29 | #define isabspath(fnameptr, tempcptr) \ 30 | ((*(tempcptr) = *(fnameptr)) == DIRCHAR) 31 | 32 | /* special */ 33 | 34 | #ifdef SOS_EDOS 35 | # undef DEFAULT_INCLUDE_DIR 36 | # define DEFAULT_INCLUDE_DIR "3" 37 | # undef DIRCHAR 38 | # define DIRCHAR ':' 39 | # undef DIRSTRING 40 | # define DIRSTRING ":" 41 | # define AS09 42 | # undef EOL 43 | # define EOL 13 44 | # undef isabspath 45 | # define isabspath(fnameptr, tempcptr) \ 46 | ((*(tempcptr) = *(fnameptr)) >= '0' && *(tempcptr) <= '9' && \ 47 | (fnameptr)[1] == DIRCHAR) 48 | #endif 49 | 50 | #ifdef TOS_EDOS 51 | # undef EOLTO 52 | # define EOLTO 13 53 | #endif 54 | 55 | /* don't let names dealt with here affect anything outside this file */ 56 | 57 | #undef SOS_EDOS 58 | #undef SOS_MSDOS 59 | -------------------------------------------------------------------------------- /bcc/output.h: -------------------------------------------------------------------------------- 1 | /* output.h - output for bcc */ 2 | 3 | /* Copyright (C) 1992 Bruce Evans */ 4 | 5 | #define OUTBYTE(ch) \ 6 | do {register char *outp = outbufptr; *outp++ = (ch); \ 7 | outbufptr = outp; if (outp >= outbuftop) flushout(); } while (0) 8 | 9 | EXTERN bool_t ctext; /* nonzero to intermix C source */ 10 | /* depends on zero init */ 11 | EXTERN char *outbufptr; /* current spot in output buffer */ 12 | EXTERN char *outbuftop; /* top of current output buffer */ 13 | EXTERN bool_t watchlc; /* nonzero to print lc after every line */ 14 | /* depends on zero init */ 15 | -------------------------------------------------------------------------------- /bcc/parse.h: -------------------------------------------------------------------------------- 1 | /* parse.h - parser for bcc */ 2 | 3 | /* Copyright (C) 1992 Bruce Evans */ 4 | 5 | /* possible scope levels */ 6 | 7 | #define ARGLEVEL 1 8 | #define GLBLEVEL 0 9 | #define MAXLEVEL 125 10 | #define MINLOCLEVEL 1 11 | 12 | /* possible node flags */ 13 | 14 | #define LVALUE (1 << 0) 15 | 16 | EXTERN struct nodestruct *etptr; /* ptr to next entry in expression tree */ 17 | EXTERN struct symstruct *gvarsymptr; /* gsymptr for last identifier declared */ 18 | EXTERN scopelev_t level; /* scope level */ 19 | /* depends on zero init */ 20 | #ifndef VERY_SMALL_MEMORY 21 | EXTERN bool_t ancient; /* undersand ancient K&R */ 22 | #endif 23 | -------------------------------------------------------------------------------- /bcc/sc.h: -------------------------------------------------------------------------------- 1 | /* sc.h - storage classes for bcc */ 2 | 3 | /* Copyright (C) 1992 Bruce Evans */ 4 | 5 | #ifdef MC6809 6 | #define DIRECTPAGE 0x01 /* modifier on global to show in dpseg */ 7 | #endif 8 | #define EXTERNAL 0x02 /* external */ 9 | #define STATIC 0x04 10 | 11 | /* symbols with flags above the 1st initialised value are not to be dumped */ 12 | 13 | #define MAXDUMPFLAG 0x07 14 | #define INITIALIZED 0x08 /* modifier on global to show initialized */ 15 | #define LABELLED 0x10 /* modifier on static to show labelled */ 16 | /* and on STRING to show labelled */ 17 | 18 | /* remaining "flags" are numbers, not flags */ 19 | /* they are disjoint from all combinations of flags above */ 20 | /* except STRING => LABELLED (and no other flags) */ 21 | 22 | #define DEFINITION 0x20 /* #defined name */ 23 | #define KEYWORD 0x40 /* reserved word for C */ 24 | #define STRUCTNAME 0x60 /* struct/union name or member name */ 25 | #define REGVAR 0x80 /* register variable */ 26 | #define TEMP 0xa0 /* temporary on stack expression eval */ 27 | #define STRING 0xc0 /* string constant (=> LABELLED) */ 28 | -------------------------------------------------------------------------------- /bcc/sysproto.h: -------------------------------------------------------------------------------- 1 | 2 | /* library - fcntl.h */ 3 | int creat P((const char *_path, int _mode)); 4 | int open P((const char *_path, int _oflag, ...)); 5 | 6 | /* library - stdlib.h */ 7 | double atof P((const char *_str)); 8 | void exit P((int _status)); 9 | 10 | /* library - string.h */ 11 | void *memcpy P((void *_t, const void *_s, unsigned _length)); 12 | void *memset P((void *_s, int _c, unsigned _nbytes)); 13 | char *strcat P((char *_target, const char *_source)); 14 | char *strchr P((const char *_s, int _ch)); 15 | int strcmp P((const char *_s1, const char *_s2)); 16 | char *strcpy P((char *_target, const char *_source)); 17 | unsigned strlen P((const char *_s)); 18 | char *strncpy P((char *_target, const char *_source, unsigned _maxlength)); 19 | char *strrchr P((const char *_s, int _ch)); 20 | 21 | /* library - unistd.h */ 22 | int close P((int _fd)); 23 | int isatty P((int _fd)); 24 | long lseek P((int _fd, long _offset, int _whence)); 25 | int read P((int _fd, char *_buf, unsigned _nbytes)); 26 | int write P((int _fd, char *_buf, unsigned _nbytes)); 27 | 28 | -------------------------------------------------------------------------------- /bin86/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CFLAGS=-O2 -D_POSIX_SOURCE 3 | LDFLAGS= 4 | DIRS=ld as 5 | 6 | PREFIX=/usr/local 7 | BINDIR=$(PREFIX)/bin 8 | LIBDIR=$(PREFIX)/lib 9 | ifeq ($(PREFIX),/usr) 10 | MANDIR=$(PREFIX)/share/man/man1 11 | else 12 | MANDIR=$(PREFIX)/man/man1 13 | endif 14 | SUF=86 15 | 16 | INSTALL_OPT=-m 755 17 | INSTALL_OPTS=-m 755 -s 18 | MAN_OPTS =-m 644 19 | 20 | MFLAGS= "LIBS=$(LIBS)" \ 21 | "CFLAGS=$(CFLAGS)" \ 22 | "LDFLAGS=$(LDFLAGS)" \ 23 | "BINDIR=$(BINDIR)" \ 24 | "LIBDIR=$(LIBDIR)" \ 25 | "CC=$(CC)" 26 | 27 | all: 28 | set -e ; for d in $(DIRS); do \ 29 | (cd $$d && $(MAKE) $(MFLAGS) $@;); \ 30 | done 31 | 32 | install: all 33 | install $(INSTALL_OPTS) as/as86 $(BINDIR)/as$(SUF) 34 | install $(INSTALL_OPTS) ld/ld86 $(BINDIR)/ld$(SUF) 35 | install $(INSTALL_OPTS) ld/objdump86 $(BINDIR)/objdump$(SUF) 36 | install $(MAN_OPTS) man/*.1 $(MANDIR) 37 | ln -sf objdump$(SUF) $(BINDIR)/nm$(SUF) 38 | ln -sf objdump$(SUF) $(BINDIR)/size$(SUF) 39 | 40 | depend clean clobber: 41 | set -e ; for d in $(DIRS); do \ 42 | (cd $$d && $(MAKE) $(MFLAGS) $@;); \ 43 | done 44 | 45 | ungrab: ../as/as.c 46 | rm -rf as ld man 47 | grab: 48 | cp -a ../as ../ld . 49 | rm -f ld/ar.h && cp -p ../libc/include/ar.h ld/ar.h 50 | mkdir man 51 | cp -p ../man/ld86.1 man 52 | cp -p ../man/as86.1 man 53 | touch -r ../Changes . as ld man 54 | 55 | -------------------------------------------------------------------------------- /bin86/README: -------------------------------------------------------------------------------- 1 | 2 | This is a simple assember and linker for 8086 - 80386 machine code. 3 | There have been a large number of changes since bin86-0.4 so I strongly 4 | suggest you read the manpages. 5 | 6 | To install: 7 | make PREFIX=/usr install 8 | or 9 | make PREFIX=/usr/local install 10 | 11 | This version has been tested under Linux, older versions were also tested 12 | and working under SunOS and AIX. 13 | 14 | ------------- 15 | 16 | This is based on the as86 and ld86 distribution written by Bruce Evans. 17 | Bruce has released this under the GPL and the changes I've made are 18 | also under the same license 19 | 20 | The BCC components that were distributed in this package are now in 21 | the dev86 package along with a working C compiler and libc for 8086 22 | ELKS, DOS and standalone code. 23 | 24 | The most recent address I have for Bruce is 25 | 26 | Robert de Bath 27 | 1998/7/31 28 | -------------------------------------------------------------------------------- /bootblocks/bb_init1.s: -------------------------------------------------------------------------------- 1 | ORGADDR=0x0600 ! $0500..0600 stack or move ORGADDR down. 2 | 3 | .org ORGADDR 4 | entry start 5 | public start 6 | start: 7 | cld 8 | xor ax,ax 9 | mov si,#$7C00 10 | mov di,#ORGADDR 11 | 12 | mov ss,ax 13 | mov sp,si ! ax, di or si 14 | 15 | push ax 16 | pop ds 17 | push ax 18 | pop es 19 | 20 | mov cx,#256 21 | rep 22 | movsw 23 | jmpi go,#0 24 | go: 25 | 26 | -------------------------------------------------------------------------------- /bootblocks/bb_init2.s: -------------------------------------------------------------------------------- 1 | ORGADDR=$0500 2 | 3 | org ORGADDR 4 | cld 5 | mov bx,#$7C00 ! Pointer to start of BB. 6 | xor ax,ax ! Segs all to zero 7 | mov ds,ax 8 | mov es,ax 9 | mov ss,ax 10 | mov sp,bx ! SP Just below BB 11 | mov cx,#$100 ! Move 256 words 12 | mov si,bx ! From default BB 13 | mov di,#ORGADDR ! To the correct address. 14 | rep 15 | movsw 16 | jmpi cont,#0 ! Set CS:IP correct. 17 | cont: 18 | -------------------------------------------------------------------------------- /bootblocks/bb_linux.s: -------------------------------------------------------------------------------- 1 | 2 | INITSEG = $9000 3 | 4 | org 0 5 | mov ax,#$07c0 6 | mov ds,ax 7 | mov ax,#INITSEG 8 | mov es,ax 9 | mov cx,#256 10 | sub si,si 11 | sub di,di 12 | cld 13 | rep 14 | movsw 15 | jmpi go,INITSEG 16 | go: 17 | 18 | mov di,#0x4000-12 19 | mov ds,ax 20 | mov ss,ax ! put stack at INITSEG:0x4000-12. 21 | mov sp,di 22 | 23 | -------------------------------------------------------------------------------- /bootblocks/freedosboot.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/bootblocks/freedosboot.zip -------------------------------------------------------------------------------- /bootblocks/i86_funcs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * These are bios and hardware functions for the 8086 IBM PC 3 | */ 4 | 5 | extern int x86; /* CPU major number (0-3) */ 6 | extern char *x86_name; /* and it's name */ 7 | extern int x86_emu; /* Is this a PC emulator ? */ 8 | extern int x86_fpu; 9 | extern int x86_test; /* Running in test mode ? */ 10 | 11 | extern unsigned boot_mem_top; /* Top of RAM below 1M */ 12 | extern long main_mem_top; /* Top of RAM above 1M */ 13 | 14 | void cpu_check(); 15 | void mem_check(); 16 | int ext_put(); 17 | int ext_get(); 18 | -------------------------------------------------------------------------------- /bootblocks/killhd.s: -------------------------------------------------------------------------------- 1 | ! 2 | ! This program destroys the MBR and the start of the first partition of 3 | ! the hard disk. IT DOES NOT HAVE AN 'ARE YOU SURE?' 4 | ! 5 | 6 | org $7c00 7 | 8 | include sysboot.s 9 | 10 | org dos_sysid 11 | .ascii "DEATH" ! System ID 12 | 13 | org codestart 14 | 15 | cld 16 | xor ax,ax 17 | mov es,ax 18 | mov ds,ax 19 | mov ss,ax 20 | mov sp,ax 21 | 22 | mov di,#$8000 23 | mov cx,#$0800 24 | rep 25 | stosw ! Zap a space. 26 | 27 | mov dx,#$0080 28 | mov cx,#$0001 29 | mov bx,#$8000 30 | mov ax,#$0308 31 | int $13 ! Zap the MBR (and a disk manager?) 32 | 33 | mov dx,#$0180 34 | mov cx,#$0001 35 | mov bx,#$8000 36 | mov ax,#$0308 37 | int $13 ! Zap the first partition boot and super. 38 | 39 | !---------------------------------------------------------------- 40 | 41 | prtmsg: ! SI = pointer to error message 42 | mov si,#boot_message 43 | 44 | nextc: 45 | lodsb 46 | cmp al,#0 47 | jz eos 48 | mov bx,#7 49 | mov ah,#$E ! Can't use $13 cause that's AT+ only! 50 | int $10 51 | jmp nextc 52 | 53 | !---------------------------------------------------------------- 54 | 55 | eos: ! Wait for a key then reboot 56 | reboot: 57 | xor ax,ax 58 | int $16 59 | jmpi $0,$FFFF ! Wam! Try or die! 60 | 61 | export boot_message 62 | boot_message: 63 | .asciz "PANIC! OS Destroyed!\r\n" 64 | 65 | -------------------------------------------------------------------------------- /bootblocks/monitor.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "i86_funcs.h" 8 | #include "readfs.h" 9 | 10 | #define X_TARFLOPPY 11 | #define X_DOSFLOPPY 12 | #define X_CALC_CRC 13 | 14 | #ifdef __STANDALONE__ 15 | #define NO_COLOUR 16 | 17 | extern union REGS __argr; 18 | #endif 19 | 20 | #ifdef TARFLOPPY 21 | #define SINGLEFS 22 | 23 | #define open_file tar_open_file 24 | #define rewind_file tar_rewind_file 25 | #define close_file tar_close_file 26 | #define file_length tar_file_length 27 | #define read_block tar_read_block 28 | #endif 29 | 30 | #ifdef MINFLOPPY 31 | #define SINGLEFS 32 | 33 | #define open_file min_open_file 34 | #define rewind_file min_rewind_file 35 | #define close_file min_close_file 36 | #define file_length min_file_length 37 | #define read_block min_read_block 38 | #endif 39 | 40 | #ifdef DOSFLOPPY 41 | #define SINGLEFS 42 | 43 | #define open_file dos_open_file 44 | #define rewind_file dos_rewind_file 45 | #define close_file dos_close_file 46 | #define file_length dos_file_length 47 | #define read_block dos_read_block 48 | #endif 49 | 50 | #ifdef SINGLEFS 51 | /* #define NOCOMMAND */ 52 | #define NOMONITOR 53 | #endif 54 | 55 | #ifdef __STANDALONE__ 56 | #undef putchar 57 | #define putchar putch 58 | #define printf cprintf 59 | #define fflush(x) 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /bootblocks/noboot.s: -------------------------------------------------------------------------------- 1 | 2 | org $7c00 3 | 4 | include sysboot.s 5 | 6 | org dos_sysid 7 | .ascii "PANIC" ! System ID 8 | 9 | org codestart 10 | xor ax,ax 11 | mov ds,ax 12 | mov ss,ax 13 | mov sp,ax 14 | jmpi code,#0 15 | 16 | code: ! SI = pointer to error message 17 | mov si,#boot_message 18 | nextc: 19 | lodsb 20 | cmp al,#0 21 | jz eos 22 | mov bx,#7 23 | mov ah,#$E ! Can't use $13 cause that's AT+ only! 24 | int $10 25 | jmp nextc 26 | eos: ! Wait for a key then reboot 27 | xor ax,ax 28 | int $16 29 | jmpi $0,$FFFF ! Wam! Try or die! 30 | 31 | export boot_message 32 | boot_message: 33 | .asciz "PANIC! NO OS Found!\r\n" 34 | 35 | -------------------------------------------------------------------------------- /bootblocks/nombr.s: -------------------------------------------------------------------------------- 1 | 2 | include sysmbr.s 3 | 4 | org codestart 5 | mov si,#message 6 | nextc: 7 | lodsb 8 | cmp al,#0 9 | jz eos 10 | mov bx,#7 11 | mov ah,#$E ! Can't use $13 cause that's AT+ only! 12 | int $10 13 | jmp nextc 14 | eos: ! Wait for a key then reboot 15 | xor ax,ax 16 | int $16 17 | jmpi $0,$FFFF ! Wam! Try or die! 18 | 19 | export message 20 | message: 21 | .asciz "MBR loaded but not bootable.\r\n" 22 | 23 | include sysmbrtail.s 24 | -------------------------------------------------------------------------------- /bootblocks/readfs.h: -------------------------------------------------------------------------------- 1 | 2 | /* Functions for reading from one file at a time in the root directory 3 | * of a raw filesystem. 4 | */ 5 | 6 | #ifdef __STDC__ 7 | #define P(x) x 8 | #else 9 | #define P(x) () 10 | #endif 11 | 12 | int open_file P((char * fname)); 13 | int rewind_file P((void)); 14 | int close_file P((void)); 15 | long file_length P((void)); 16 | int read_block P((char * buffer)); 17 | 18 | int tar_open_file P((char * fname)); 19 | int tar_rewind_file P((void)); 20 | int tar_close_file P((void)); 21 | long tar_file_length P((void)); 22 | int tar_read_block P((char * buffer)); 23 | 24 | int min_open_file P((char * fname)); 25 | int min_rewind_file P((void)); 26 | int min_close_file P((void)); 27 | long min_file_length P((void)); 28 | int min_read_block P((char * buffer)); 29 | 30 | int dos_open_file P((char * fname)); 31 | int dos_rewind_file P((void)); 32 | int dos_close_file P((void)); 33 | long dos_file_length P((void)); 34 | int dos_read_block P((char * buffer)); 35 | 36 | #define read_sector(__sect) read_lsector((unsigned long)(__sect)) 37 | char * read_lsector P((long sector)); 38 | void reset_disk P((void)); 39 | 40 | extern char * track_buffer; 41 | extern int disk_drive; 42 | extern int disk_cyls; 43 | extern int disk_heads; 44 | extern int disk_spt; 45 | -------------------------------------------------------------------------------- /bootblocks/sysmbrtail.s: -------------------------------------------------------------------------------- 1 | 2 | ! Now make sure this isn't too big! 3 | end_of_code: 4 | if *>table_start 5 | fail! Partition table overlaps 6 | endif 7 | 8 | !-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 9 | ! Clear the sector to the bottom of the partition table. 10 | if * 5 | Subject: Re: 8086 Development environment 6 | 7 | Hello again, 8 | 9 | And one hint for using the optimizer I sent you in an earlier mail: the 10 | order of the rules files matters! You should try: 11 | 12 | copt -c! -h"use16 386" rules.start rules.386 rules.86 rules.end 13 | 14 | If you don't want to optimize for 386 long integer operations, you 15 | can leave out the -h option and the rules.386 file. The rules.net file 16 | is only necessary for my bootrom code, and does some optimizations I 17 | can't do with preprocessor commands. 18 | 19 | gero. 20 | 21 | >-- 22 | Life sucks, but it's better than the alternative. 23 | - Peter da Silva 24 | -- 25 | Gero Kuhlmann, Hannover 0511/6497525 (Voice) gero@gkminix.han.de 26 | -------------------------------------------------------------------------------- /copt/rules.186: -------------------------------------------------------------------------------- 1 | # Enter and leave ... 2 | 3 | mov sp,bp 4 | pop bp 5 | = 6 | leave 7 | 8 | push bp 9 | mov bp,sp 10 | add sp,#-%1 11 | = 12 | enter %1,0 13 | 14 | push bp 15 | mov bp,sp 16 | dec sp 17 | dec sp 18 | = 19 | enter 2,0 20 | 21 | mov ax,#%1 22 | push ax 23 | = 24 | push #%1 25 | 26 | mov bx,#%1 27 | push bx 28 | = 29 | push #%1 30 | 31 | mov ax,*%1 32 | push ax 33 | = 34 | push *%1 35 | 36 | mov bx,*%1 37 | push bx 38 | = 39 | push *%1 40 | 41 | -------------------------------------------------------------------------------- /copt/rules.end: -------------------------------------------------------------------------------- 1 | # Rules to optimize BCC assembler output 2 | 3 | # Undo the changes done in rules.start 4 | 5 | proc_start 6 | = 7 | push bp 8 | mov bp,sp 9 | push di 10 | push si 11 | 12 | proc_end 13 | = 14 | pop si 15 | pop di 16 | pop bp 17 | ret 18 | -------------------------------------------------------------------------------- /copt/rules.net: -------------------------------------------------------------------------------- 1 | # Rules for optimizing BCC assembler output 2 | 3 | # Rules for converting short number from host to network order 4 | 5 | push word %[#|*]0%1 6 | call __htons 7 | inc sp 8 | inc sp 9 | = 10 | mov ax,#((%1 & $00FF) << 8) + ((%1 & $FF00) >> 8) 11 | 12 | mov ax,%[#|*]0%1 13 | push ax 14 | call __htons 15 | inc sp 16 | inc sp 17 | = 18 | mov ax,#((%1 & $00FF) << 8) + ((%1 & $FF00) >> 8) 19 | 20 | push %0[%1] 21 | call __htons 22 | inc sp 23 | inc sp 24 | = 25 | mov ax,%0[%1] 26 | xchg al,ah 27 | 28 | push ax 29 | call __htons 30 | inc sp 31 | inc sp 32 | = 33 | xchg al,ah 34 | 35 | push %[bx|cx|dx]1 36 | call __htons 37 | inc sp 38 | inc sp 39 | = 40 | mov ax,%1 41 | xchg al,ah 42 | 43 | -------------------------------------------------------------------------------- /copt/rules.start: -------------------------------------------------------------------------------- 1 | # Rules to optimize BCC assembler output 2 | 3 | # The following rules protect the procedure prolog and epilogue from 4 | # getting optimized away in later steps 5 | 6 | push bp 7 | mov bp,sp 8 | push di 9 | push si 10 | = 11 | proc_start 12 | 13 | pop si 14 | pop di 15 | pop bp 16 | ret 17 | = 18 | proc_end 19 | 20 | -------------------------------------------------------------------------------- /cpp/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS=-Wall -Wstrict-prototypes 2 | 3 | all: bcc-cpp 4 | 5 | bcc-cpp: main.o cpp.o hash.o token1.o token2.o 6 | $(CC) $(CFLAGS) -o bcc-cpp main.o cpp.o hash.o token1.o token2.o 7 | 8 | clean realclean: 9 | rm -f bcc-cpp main.o cpp.o hash.o token1.o token2.o tmp.h 10 | 11 | maintclean: realclean 12 | rm -f token1.h token2.h 13 | 14 | main.o: cc.h 15 | cpp.o: cc.h 16 | hash.o: cc.h 17 | tree.o: cc.h 18 | 19 | token1.o: token1.h 20 | token2.o: token2.h 21 | 22 | token1.h: token1.tok 23 | gperf -aptTc -N is_ctok -H hash1 token1.tok > tmp.h 24 | mv tmp.h token1.h 25 | 26 | token2.h: token2.tok 27 | gperf -aptTc -k1,3 -N is_ckey -H hash2 token2.tok > tmp.h 28 | mv tmp.h token2.h 29 | -------------------------------------------------------------------------------- /cpp/token1.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "cc.h" 5 | 6 | #ifdef __GNUC__ 7 | __inline 8 | #endif 9 | static unsigned int hash1 P((register const char *, register unsigned int)); 10 | 11 | #include "token1.h" 12 | -------------------------------------------------------------------------------- /cpp/token1.tok: -------------------------------------------------------------------------------- 1 | struct token_trans { char * name; int token; }; 2 | %% 3 | ..., TK_ELLIPSIS 4 | >>=, TK_RIGHT_ASSIGN 5 | <<=, TK_LEFT_ASSIGN 6 | +=, TK_ADD_ASSIGN 7 | -=, TK_SUB_ASSIGN 8 | *=, TK_MUL_ASSIGN 9 | /=, TK_DIV_ASSIGN 10 | %=, TK_MOD_ASSIGN 11 | &=, TK_AND_ASSIGN 12 | ^=, TK_XOR_ASSIGN 13 | |=, TK_OR_ASSIGN 14 | >>, TK_RIGHT_OP 15 | <<, TK_LEFT_OP 16 | ++, TK_INC_OP 17 | --, TK_DEC_OP 18 | ->, TK_PTR_OP 19 | &&, TK_AND_OP 20 | ||, TK_OR_OP 21 | <=, TK_LE_OP 22 | >=, TK_GE_OP 23 | ==, TK_EQ_OP 24 | !=, TK_NE_OP 25 | .., TK_WORD 26 | -------------------------------------------------------------------------------- /cpp/token2.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "cc.h" 5 | 6 | #ifdef __GNUC__ 7 | __inline 8 | #endif 9 | static unsigned int hash2 P((register const char *, register unsigned int)); 10 | 11 | #include "token2.h" 12 | -------------------------------------------------------------------------------- /cpp/token2.tok: -------------------------------------------------------------------------------- 1 | struct token_trans { char * name; int token; }; 2 | %% 3 | auto, TK_AUTO 4 | break, TK_BREAK 5 | case, TK_CASE 6 | char, TK_CHAR 7 | const, TK_CONST 8 | continue, TK_CONTINUE 9 | default, TK_DEFAULT 10 | do, TK_DO 11 | double, TK_DOUBLE 12 | else, TK_ELSE 13 | enum, TK_ENUM 14 | extern, TK_EXTERN 15 | float, TK_FLOAT 16 | for, TK_FOR 17 | goto, TK_GOTO 18 | if, TK_IF 19 | int, TK_INT 20 | long, TK_LONG 21 | register, TK_REGISTER 22 | return, TK_RETURN 23 | short, TK_SHORT 24 | signed, TK_SIGNED 25 | sizeof, TK_SIZEOF 26 | static, TK_STATIC 27 | struct, TK_STRUCT 28 | switch, TK_SWITCH 29 | typedef, TK_TYPEDEF 30 | union, TK_UNION 31 | unsigned, TK_UNSIGNED 32 | void, TK_VOID 33 | volatile, TK_VOLATILE 34 | while, TK_WHILE 35 | __FILE__, TK_FILE 36 | __LINE__, TK_LINE 37 | -------------------------------------------------------------------------------- /cpp/torture.c: -------------------------------------------------------------------------------- 1 | /\ 2 | * \ This _evil_ little file is compilable Ansi C. 3 | * / There are NO extensions ... Waddya think ? 4 | \/ 5 | 6 | // ***/ func() { printf("Hello /* world */ %d ???/?=\n" ??/ 7 | , 1? 8 | '\\ 9 | 007': 10 | '??/"'/*"*/ 11 | );} 12 | 13 | 14 | main() 15 | { 16 | func(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /dis88/disrel.c: -------------------------------------------------------------------------------- 1 | static char *copyright = 2 | "@(#) Copyright (C) 1987 G. M. Harding, all rights reserved"; 3 | 4 | #ifdef __linux__ 5 | char *release = 6 | "released with Dev86 for Linux, based on minix 2.1"; 7 | #else 8 | static char *sccsid = 9 | "@(#) disrel.c, Ver. 2.1 created 00:00:00 87/09/01"; 10 | 11 | char *release = 12 | "release 2.1 (MINIX)"; 13 | #endif 14 | 15 | /* 16 | ** 17 | ** This file documents the major revisions to the 8088 sym- 18 | ** bolic disassembler. It also contains the release string 19 | ** which is output at the head of each disassembly, and the 20 | ** copyright string which must be incorporated in any code 21 | ** distribution. 22 | ** 23 | ** Permission to copy and redistribute is hereby granted, 24 | ** provided full source code, with all copyright notices, 25 | ** accompanies any redistribution. 26 | ** 27 | ** REVISION HISTORY: 28 | ** 29 | ** SEP 87: 30 | ** After internal shakeout, released on Usenet. 31 | ** 32 | ** JUN 88: 33 | ** Ported to MINIX 34 | */ 35 | 36 | -------------------------------------------------------------------------------- /doselks/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CC=$(BCC) 3 | BCC=bcc 4 | CFLAGS=-Md 5 | LDFLAGS=-Md -s 6 | 7 | DISTFILES=Makefile syscalls.h doselks.h coroutine.c doselks.c syscalls.c 8 | 9 | # NB coroutine.o first then we can find it easily for breakpoints in CV.EXE 10 | OBJ=coroutine.o doselks.o syscalls.o 11 | 12 | all: doselks.com 13 | 14 | install: 15 | # Err, Ok, but where do I install a dos program ? 16 | 17 | doselks.com: $(OBJ) 18 | $(CC) $(LDFLAGS) -o doselks.com $(OBJ) 19 | 20 | syscalls.o: call_tab.v 21 | $(OBJ): doselks.h 22 | 23 | call_tab.v: dummy 24 | -cp -p ../libc/syscall/call_tab.v . 2>/dev/null 25 | -cp -p ../libc/syscall/defn_tab.v . 2>/dev/null 26 | 27 | distribution: 28 | tar czf /tmp/doselks.tar.gz $(DISTFILES) 29 | 30 | dummy: 31 | 32 | clean: 33 | rm -f $(OBJ) doselks.com 34 | 35 | realclean: 36 | rm -f call_tab.v defn_tab.v 37 | rm -f $(OBJ) doselks.com 38 | 39 | VVV=xx 40 | $(VVV).o: $(VVV).c 41 | $(CC) $(CFLAGS) -A-l -A$(VVV).lst -c $(VVV).c 42 | 43 | -------------------------------------------------------------------------------- /elksemu/Kernel_patch: -------------------------------------------------------------------------------- 1 | This kernel patch allows you to run Linux-8086 executables transparently 2 | on a Linux-i386 (1.2.13) system. 3 | It requires V0.0.2 or better of elksemu in the file "/lib/elksemu". 4 | 5 | If you are using kernel 1.3.* or later try the module: binfmt_elks.o 6 | If you are using 2.0.36, 2.1.43 or 2.2.0 and later use binfmt_misc. 7 | 8 | --- orig-13/fs/exec.c Sun Sep 24 13:22:37 1995 9 | +++ linux/fs/exec.c Sun Feb 11 20:11:47 1996 10 | @@ -615,6 +615,12 @@ 11 | set_fs(old_fs); 12 | if (retval < 0) 13 | goto exec_error2; 14 | +#ifndef NO_ELKSEMU 15 | + /* What a horrible hack! :-) */ 16 | + if ((bprm.buf[0] == 1) && (bprm.buf[1] == 3) && 17 | + (bprm.buf[2] == 0x20 || bprm.buf[2] == 0x10) && (bprm.buf[3] == 4)) 18 | + memcpy(bprm.buf, "#!/lib/elksemu\n", 16); 19 | +#endif 20 | if ((bprm.buf[0] == '#') && (bprm.buf[1] == '!') && (!sh_bang)) { 21 | /* 22 | * This section does the #! interpretation. 23 | -------------------------------------------------------------------------------- /elksemu/README: -------------------------------------------------------------------------------- 1 | 2 | Elksemu is an emulator for the environment that elks will provide on a 3 | real ELKS machine. The emulator only runs on linux-i386 or similar. 4 | 5 | If you're using a 2.0.36, 2.1.43, 2.2.0 or later kernel then the 6 | binfmt_misc driver is in the stock kernel and all you need to do is 7 | add the following line into the relevent /etc/rc* file. 8 | 9 | echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/usr/bin/elksemu:' \ 10 | > /proc/sys/fs/binfmt_misc/register 11 | 12 | Note, however, if binfmt_misc is compiled as a module it will not auto 13 | load so you will have to do this manually. 14 | 15 | If your kernel version is 1.2.13 then apply the patch in the Kernel_patch 16 | file. 17 | 18 | If you're using one of the other 2.0.X series then the binfmt_elks.c module 19 | should be able to compile and install. BUT do note you need the modules 20 | and probably modversions options and you _may_ have to alter the compile 21 | command to match those seen when you compile modules that come with the 22 | kernel. 23 | 24 | Rob. 25 | -------------------------------------------------------------------------------- /elksemu/Security: -------------------------------------------------------------------------------- 1 | Is is possible to install /usr/bin/elksemu as a suid-root executable. 2 | This gives two additional facilities when running elks executables. 3 | 4 | 1) It is now possible to run programs that are execute only, without 5 | read permission, as the file is opened while we have superuser 6 | access. 7 | 8 | 2) If the ELKS executable has suid or sgid bits set these will be honoured. 9 | 10 | The user now needs execute access to run an executable, this is checked. 11 | 12 | If the executable does not have either suid/sgid bits set then all 13 | extra permissions will be dropped within the first few lines of the 14 | main() function. Because of this you need only check this tiny 15 | piece of code if you intend never to use suid. 16 | 17 | If you have any problem with elksemu being suid-root the program will 18 | run as before, with no complaints, if you remove the suid permission. 19 | 20 | Rob. 21 | -------------------------------------------------------------------------------- /elksemu/binfmt_elks.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/elksemu/binfmt_elks.c -------------------------------------------------------------------------------- /elksemu/elks_signal.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "elks.h" 12 | 13 | static int elks_sigtrap= -1; 14 | 15 | void sig_trap(int signo) 16 | { 17 | elks_cpu.regs.esp -= 2; 18 | ELKS_POKE(unsigned short, elks_cpu.regs.esp, signo); 19 | elks_cpu.regs.esp -= 2; 20 | ELKS_POKE(unsigned short, elks_cpu.regs.esp, elks_cpu.regs.eip); 21 | elks_cpu.regs.eip = elks_sigtrap; 22 | } 23 | 24 | int elks_signal(int bx,int cx,int dx,int di,int si) 25 | { 26 | void (*oldsig)(int) = 0; 27 | if( bx < 0 || bx >= NSIG ) { errno = EINVAL; return -1; } 28 | if( cx == 0 ) oldsig = signal(bx, SIG_DFL); 29 | else if( cx == 1 ) oldsig = signal(bx, SIG_IGN); 30 | else 31 | { 32 | elks_sigtrap = cx; 33 | oldsig = signal(bx, sig_trap); 34 | } 35 | if( oldsig == SIG_ERR) return -1; 36 | if( oldsig == SIG_DFL) return 0; 37 | if( oldsig == SIG_IGN) return 1; 38 | return 2; 39 | } 40 | -------------------------------------------------------------------------------- /elksemu/mkefile: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | 3 | awk ' 4 | BEGIN { 5 | printf "char efile[] =\n" 6 | } 7 | { printf " \"%s\\n\"\n", $0 } 8 | END{ 9 | printf ";\n"; 10 | } 11 | ' < "$1" > efile.h 12 | -------------------------------------------------------------------------------- /ld/6809/config.h: -------------------------------------------------------------------------------- 1 | /* config.h - configuration for linker */ 2 | 3 | /* Copyright (C) 1994 Bruce Evans */ 4 | 5 | /* one of these target processors must be defined */ 6 | 7 | #undef I8086 /* Intel 8086 */ 8 | #undef I80386 /* Intel 80386 */ 9 | #define MC6809 /* Motorola 6809 */ 10 | 11 | /* one of these target operating systems must be defined */ 12 | 13 | #define EDOS /* generate EDOS executable */ 14 | #undef MINIX /* generate Minix executable */ 15 | 16 | /* these may need to be defined to suit the source processor */ 17 | 18 | #define HOST_8BIT /* enable some 8-bit optimizations */ 19 | 20 | /* #define S_ALIGNMENT 4 */ /* source memory alignment, power of 2 */ 21 | /* don't use for 8 bit processors */ 22 | /* don't use even for 80386 - overhead for */ 23 | /* alignment cancels improved access */ 24 | 25 | /* these must be defined to suit the source libraries */ 26 | 27 | #define CREAT_PERMS 0666 /* permissions for creat() */ 28 | #define EXEC_PERMS 0111 /* extra permissions to set for executable */ 29 | -------------------------------------------------------------------------------- /ld/Makefile: -------------------------------------------------------------------------------- 1 | 2 | LIBDIR =/usr/bin 3 | CFLAGS =-O 4 | LDFLAGS = 5 | 6 | # Will need some of these if you want native executables on non-Linux/i386 7 | # -DDETECTAOUT # Turn on detection. 8 | # -DV7_A_OUT # a.out.h is like V7 9 | # -DBSD_A_OUT # a.out.h is like BSD 10 | # -DSTANDARD_GNU_A_OUT # a.out.h is like GNU normal. 11 | # 12 | # -DREL_OUTPUT -DBUGCOMPAT # -r Produces weird *.o files. 13 | # 14 | DEFS =-DREL_OUTPUT 15 | 16 | # An alternative file for a non-standard a.out.h (eg i386 linux on an Alpha) 17 | # 18 | # NATIVE=-DA_OUT_INCL='"a_out_local.h"' 19 | 20 | OBJS= dumps.o io.o ld.o readobj.o table.o typeconv.o linksyms.o mkar.o \ 21 | writex86.o writebin.o writeemu.o 22 | 23 | all: ld86 objchop catimage objdump86 24 | 25 | ld86: $(OBJS) 26 | $(CC) $(LDFLAGS) $(OBJS) -o $@ 27 | 28 | install: ld86 29 | install -d $(LIBDIR) 30 | install -m 755 ld86 $(LIBDIR) 31 | 32 | clean realclean clobber: 33 | rm -f *.o ld86 ld86r objchop catimage objdump86 34 | 35 | $(OBJS): align.h ar.h bindef.h byteord.h config.h const.h globvar.h obj.h \ 36 | syshead.h type.h x86_aout.h 37 | 38 | ar.h: 39 | test -f ar.h || \ 40 | { rm -f ar.h ; ln -s ../libc/include/ar.h . ; } || \ 41 | ln ../libc/include/ar.h . 42 | 43 | writebin.o: writebin.c 44 | $(CC) $(CFLAGS) $(DEFS) $(NATIVE) -c $< 45 | 46 | writerel.o: writebin.c 47 | 48 | .c.o: 49 | $(CC) $(CFLAGS) $(DEFS) -c $< -o $@ 50 | -------------------------------------------------------------------------------- /ld/align.h: -------------------------------------------------------------------------------- 1 | /* align.h - memory alignment requirements for linker */ 2 | 3 | /* Copyright (C) 1994 Bruce Evans */ 4 | 5 | #ifndef S_ALIGNMENT 6 | # define align(x) 7 | #else 8 | 9 | #if defined(__STDC__) && defined(_POSIX_SOURCE) 10 | # define align(x) ((x)=(void *) \ 11 | (((ssize_t)(x) + (S_ALIGNMENT-1)) & ~(S_ALIGNMENT-1))) 12 | #else 13 | # define align(x) ((x)=(void *) \ 14 | ((char *)(x) + ((S_ALIGNMENT-(char)(x)) & (S_ALIGNMENT-1)))) 15 | #endif 16 | #endif 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ld/byteord.h: -------------------------------------------------------------------------------- 1 | /* byteord.h - byte order dependencies for C compiler, assembler, linker */ 2 | 3 | /* Copyright (C) 1994 Bruce Evans */ 4 | 5 | /* These are for the targets of everything and for linker source too. */ 6 | 7 | #ifdef I8086 8 | # define INT_BIG_ENDIAN 0 9 | # define LONG_BIG_ENDIAN 0 /* except longs are back to front for Xenix */ 10 | #endif 11 | 12 | #ifdef I80386 13 | # define INT_BIG_ENDIAN 0 14 | # define LONG_BIG_ENDIAN 0 15 | #endif 16 | 17 | #ifdef MC6809 18 | # define INT_BIG_ENDIAN 1 /* byte order in words is high-low */ 19 | # define LONG_BIG_ENDIAN 1 /* byte order in longs is high-low */ 20 | #endif 21 | -------------------------------------------------------------------------------- /ld/config.h: -------------------------------------------------------------------------------- 1 | /* config.h - configuration for linker */ 2 | 3 | /* Copyright (C) 1994 Bruce Evans */ 4 | 5 | /* one of these target processors must be defined */ 6 | 7 | #undef I8086 /* Intel 8086 */ 8 | #define I80386 /* Intel 80386 */ 9 | #undef MC6809 /* Motorola 6809 */ 10 | 11 | /* one of these target operating systems must be defined */ 12 | 13 | #undef EDOS /* generate EDOS executable */ 14 | #define MINIX /* generate Minix executable */ 15 | 16 | /* these may need to be defined to suit the source processor */ 17 | 18 | #undef HOST_8BIT /* enable some 8-bit optimizations */ 19 | 20 | #ifndef __AS386_16__ 21 | #define S_ALIGNMENT 4 /* source memory alignment, power of 2 */ 22 | /* don't use for 8 bit processors */ 23 | /* don't use even for 80386 - overhead for */ 24 | /* alignment cancels improved access */ 25 | #endif 26 | 27 | /* Any machine can use long offsets but i386 needs them */ 28 | #ifdef I80386 29 | #define LONG_OFFSETS 30 | #endif 31 | 32 | /* these must be defined to suit the source libraries */ 33 | 34 | #define CREAT_PERMS 0666 /* permissions for creat() */ 35 | #define EXEC_PERMS 0111 /* extra permissions to set for executable */ 36 | -------------------------------------------------------------------------------- /ld/const.h: -------------------------------------------------------------------------------- 1 | /* const.h - constants for linker */ 2 | 3 | /* Copyright (C) 1994 Bruce Evans */ 4 | 5 | #define FALSE 0 6 | #define NUL_PTR ((void*)0) 7 | #define TRUE 1 8 | 9 | #define EXTERN extern 10 | #define FORWARD static 11 | #define PRIVATE static 12 | #define PUBLIC 13 | 14 | #include "config.h" 15 | -------------------------------------------------------------------------------- /ld/globvar.h: -------------------------------------------------------------------------------- 1 | /* globvar.h - global variables for linker */ 2 | 3 | /* Copyright (C) 1994 Bruce Evans */ 4 | 5 | #ifndef EXTERN 6 | #define EXTERN 7 | #endif 8 | EXTERN unsigned errcount; /* count of errors */ 9 | EXTERN struct entrylist *entryfirst; /* first on list of entry symbols */ 10 | EXTERN struct modstruct *modfirst; /* data for 1st module */ 11 | EXTERN struct redlist *redfirst; /* first on list of redefined symbols */ 12 | 13 | /* K&R _explicitly_ says extern followed by public is OK */ 14 | extern char hexdigit[]; /* constant */ 15 | extern int headerless; /* Don't output header on exe */ 16 | #ifndef VERY_SMALL_MEMORY 17 | extern int v7; /* Generate an UNIX v7 a.out header */ 18 | #endif 19 | #ifndef MSDOS 20 | extern int cpm86; /* Generate CP/M-86 CMD header */ 21 | #endif 22 | 23 | extern bin_off_t text_base_value; /* Base address of text seg */ 24 | extern bin_off_t data_base_value; /* Base or alignment of data seg */ 25 | extern bin_off_t heap_top_value; /* Minimum 'total' value in x86 header */ 26 | -------------------------------------------------------------------------------- /ld/obj.h: -------------------------------------------------------------------------------- 1 | /* obj.h - constants for Introl object modules */ 2 | 3 | /* Copyright (C) 1994 Bruce Evans */ 4 | 5 | #define OBJ_H 6 | 7 | #ifndef OMAGIC 8 | # ifdef I80386 9 | # define OMAGIC 0x86A3 10 | # endif 11 | 12 | # ifdef I8086 13 | # define OMAGIC 0x86A0 14 | # endif 15 | 16 | # ifdef MC6809 17 | # define OMAGIC 0x5331 18 | # endif 19 | #endif 20 | 21 | #ifdef LONG_OFFSETS 22 | # define cntooffset cnu4 23 | # define offtocn u4cn 24 | #else 25 | # define cntooffset cnu2 26 | # define offtocn u2cn 27 | #endif 28 | 29 | #ifdef MC6809 /* temp don't support alignment at all */ 30 | # define ld_roundup( num, boundary, type ) (num) 31 | #else 32 | # define ld_roundup( num, boundary, type ) \ 33 | (((num) + ((boundary) - 1)) & (type) ~((boundary) - 1)) 34 | #endif 35 | 36 | #define MAX_OFFSET_SIZE 4 37 | #define NSEG 16 38 | 39 | /* flag values |SZ|LXXXX|N|E|I|R|A|SEGM|, X not used */ 40 | 41 | #define A_MASK 0x0010 /* absolute */ 42 | #define C_MASK 0x0020 /* common (internal only) */ 43 | #define E_MASK 0x0080 /* exported */ 44 | #define I_MASK 0x0040 /* imported */ 45 | #define N_MASK 0x0100 /* entry point */ 46 | #define R_MASK 0x0020 /* relative (in text only) */ 47 | #define SEGM_MASK 0x000F /* segment (if not absolute) */ 48 | #define SA_MASK 0x2000 /* offset is storage allocation */ 49 | #define SZ_MASK 0xC000 /* size descriptor for value */ 50 | #define SZ_SHIFT 14 51 | -------------------------------------------------------------------------------- /ld/v7_aout.h: -------------------------------------------------------------------------------- 1 | /* Header format of 16-bit 2 | * Seventh edition UNIX executables */ 3 | 4 | #ifndef _V7_A_OUT_H 5 | #define _V7_A_OUT_H 6 | 7 | #define V7_MAGIC4 0405 /* v7 overlay */ 8 | #define V7_OMAGIC 0407 /* I&D in one segment (impure) */ 9 | #define V7_NMAGIC 0410 /* read-only text */ 10 | #define V7_MAGIC3 0411 /* v7 separate I&D (pure) */ 11 | #define V7_ZMAGIC 0413 /* v8 demand load */ 12 | 13 | #define V7_HEADERLEN 16 14 | 15 | struct v7_exec { 16 | short magic; 17 | unsigned short textsize; 18 | unsigned short datasize; 19 | unsigned short bsssize; 20 | unsigned short symtabsize; 21 | unsigned short entry; 22 | unsigned short pad; 23 | unsigned short noreloc; 24 | }; 25 | 26 | #endif /* _V7_A_OUT_H */ 27 | -------------------------------------------------------------------------------- /ld/writeemu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This uses a special version of writebin for bug compatibility with 3 | * the old bin86 package. 4 | * 5 | * This _should_ be replaced by a function that writes out a as86 object 6 | * but then it would completely **** up dosemu compiles. 7 | * 8 | * NOTE: A some time I intend to replace this with a routine that generates 9 | * an as86 object file. 10 | */ 11 | 12 | #undef A_OUT_INCL 13 | #define A_OUT_INCL "rel_aout.h" 14 | #define BSD_A_OUT 1 15 | #define FILEHEADERLENGTH 32 16 | #define ELF_SYMS 0 17 | 18 | #define FUNCNAME write_dosemu 19 | 20 | #include "writebin.c" 21 | -------------------------------------------------------------------------------- /ld/x86_cpm86.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 2 | * This file is part of the ld86 command for Linux-86 3 | * It is distributed under the GNU Library General Public License. 4 | * 5 | * CP/M-86 CMD file header 6 | */ 7 | 8 | #ifndef __CPM86_H 9 | #define __CPM86_H 10 | 11 | typedef char Short16[2]; 12 | 13 | struct cpm86_group { 14 | unsigned char cg_type; /* 1=Code 2=Data */ 15 | Short16 cg_len; /* Group length, paragraphs */ 16 | Short16 cg_base; /* Group address, normally 0 for relocatable */ 17 | Short16 cg_min; /* Minimum size, normally = group length */ 18 | Short16 cg_max; /* Maximum size, normally 0x1000 (64k) */ 19 | }; 20 | 21 | 22 | struct cpm86_exec { /* CP/M-86 header */ 23 | struct cpm86_group ce_group[8]; 24 | unsigned char ce_spare[51]; 25 | Short16 ce_rsxs; /* Record with RSX list */ 26 | Short16 ce_fixups; /* Record with fixups */ 27 | unsigned char ce_flags; /* Concurrent CP/M flags */ 28 | }; 29 | 30 | /* Group types */ 31 | #define CG_EMPTY 0 32 | #define CG_CODE 1 33 | #define CG_DATA 2 34 | #define CG_EXTRA 3 35 | #define CG_STACK 4 36 | #define CG_AUX1 5 37 | #define CG_AUX2 6 38 | #define CG_AUX3 7 39 | #define CG_AUX4 8 40 | #define CG_PURE 9 /* Code that is known to be pure */ 41 | 42 | #define CPM86_HEADERLEN 0x80 43 | 44 | #endif /* _CPM86_H */ 45 | -------------------------------------------------------------------------------- /libbsd/Makefile: -------------------------------------------------------------------------------- 1 | # libbsd A collection of library modules similar or equal to their 2 | # BSD UNIX equivalents, to make the job of porting BSD pro- 3 | # grams to LINUX easier. 4 | # 5 | # Author: Rick Sladkey, 6 | # Ported to linux-86 (by removing select.c): Dick Porter 7 | # 8 | # This file is part of the Linux-8086 C library and is distributed 9 | # under the GNU Library General Public License. 10 | 11 | TOP=$(TOPDIR) 12 | include Make.defs 13 | 14 | LIBBSD=libbsd.a 15 | TARGETS=$(LIBBSD) 16 | SRCS= daemon.c logwtmp.c logout.c pty.c login_tty.c \ 17 | sgtty.c cfsetspeed.c revoke.c setpassent.c \ 18 | checkrhosts.c 19 | OBJS=$(SRCS:.c=.o) 20 | 21 | TXT=COPYING Changes Contributors MAGIC \ 22 | Make.defs Makefile New_subdir Pre_main README TODO KERNEL 23 | 24 | all: $(TARGETS) 25 | 26 | install: all 27 | install -d $(BCCHOME) 28 | install -d $(LIBDIR)/i86 29 | install -m 644 $(LIBBSD) $(LIBDIR)/i86 30 | 31 | tests: dummy 32 | make -C tests 33 | 34 | $(LIBBSD): $(OBJS) 35 | $(AR) rc $(LIBBSD) $(OBJS) 36 | 37 | realclean: clean 38 | clean: dummy 39 | rm -f *.o 40 | rm -f $(LIBBSD) 41 | 42 | dummy: 43 | -------------------------------------------------------------------------------- /libbsd/README.HLU: -------------------------------------------------------------------------------- 1 | HJ, 2 | 3 | This is the source of the current "libbsd.a" as I have it 4 | next to the libc 4.3.2. You can safely ignore the blahblah 5 | in the other README- throw it away after you added this stuff 6 | to the rest of libc... 7 | 8 | I think the best way to add this to the standard set of C 9 | libraries is to keep it in the form of a single non-sharable 10 | library (/usr/lib/libbsd.a) that only gets linked if the user 11 | asks for it by typing "-lbsd". I don't know if this is pos- 12 | sible, but I don't think it should be added to the "shared" 13 | image, because it might cause other problems in that case... 14 | 15 | Fred. 16 | -------------------------------------------------------------------------------- /libbsd/cfsetspeed.c: -------------------------------------------------------------------------------- 1 | /* cfsetspeed.c - emulate BSD cfsetspeed with cfset[io]speed - rick sladkey */ 2 | 3 | #include 4 | 5 | struct { 6 | int flag, val; 7 | } xref[] = { 8 | B0, 0, 9 | B50, 50, 10 | B75, 75, 11 | B110, 110, 12 | B134, 134, 13 | B150, 150, 14 | B200, 200, 15 | B300, 300, 16 | B600, 600, 17 | B1200, 1200, 18 | B1800, 1800, 19 | B2400, 2400, 20 | B4800, 4800, 21 | B9600, 9600, 22 | B19200, 19200, 23 | B38400, 38400, 24 | #ifdef B57600 25 | B57600, 57600, 26 | #endif 27 | #ifdef B115200 28 | B115200,115200, 29 | #endif 30 | 0, -1, 31 | }; 32 | 33 | int cfsetspeed(p,speed) 34 | struct termios *p; 35 | int speed; 36 | { 37 | int i; 38 | 39 | for (i = 0; xref[i].val != -1; i++) { 40 | if (xref[i].val == speed) { 41 | speed = xref[i].flag; 42 | cfsetispeed(p, speed); 43 | cfsetospeed(p, speed); 44 | return 0; 45 | } 46 | } 47 | return -1; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /libbsd/checkrhosts.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* This is not functional. Oh well. */ 4 | int _check_rhosts_file; 5 | -------------------------------------------------------------------------------- /libbsd/revoke.c: -------------------------------------------------------------------------------- 1 | /* revoke.c - can't quite emulate BSD revoke? - rick sladkey */ 2 | 3 | 4 | int revoke(line) 5 | char *line; 6 | { 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /libbsd/setpassent.c: -------------------------------------------------------------------------------- 1 | /* setpassent.c - vacuous setpassent for BSD - rick sladkey */ 2 | 3 | void setpassent(i) 4 | int i; 5 | { 6 | } 7 | -------------------------------------------------------------------------------- /libbsd/snprintf.c: -------------------------------------------------------------------------------- 1 | /* snprintf.c - emulate BSD snprintf with sprintf - rick sladkey */ 2 | 3 | #include 4 | #include 5 | 6 | int snprintf(char *s, int len, char *format, ...) 7 | { 8 | va_list args; 9 | int result; 10 | 11 | va_start(args, format); 12 | result = vsprintf(s, format, args); 13 | va_end(args); 14 | return result; 15 | } 16 | -------------------------------------------------------------------------------- /libc/Config.dflt: -------------------------------------------------------------------------------- 1 | bcc:+: 2 | bios:+: 3 | conio:+: 4 | error:+: 5 | getent:+: 6 | gtermcap:+: 7 | i386fp:+: 8 | i386sys:+: 9 | malloc:+: 10 | misc:+: 11 | msdos:+: 12 | regexp:+: 13 | stdio:+: 14 | string:+: 15 | syscall:+: 16 | termios:+: 17 | time:+: 18 | -------------------------------------------------------------------------------- /libc/KERNEL: -------------------------------------------------------------------------------- 1 | 2 | KERNEL SYSTEM CALL INTERFACE: 3 | The kernel system calls are all done through interrupt 0x80 4 | All parameters are passed in the 'AX,BX,CX,DX,DI,SI' registers. 5 | The AX register contains the system call number. 6 | The BX,CX,DX,DI,SI registers contain the first 5 arguments from the stack. 7 | (NB If the syscall is know to have less than 5 args the rest are not loaded) 8 | On return from the syscall AX has the return value. 9 | If AX is -ve then errno= -AX and return val = -1; 10 | 11 | The system calls are named in syscall/syscall.dat. 12 | There is a script syscall/mksyscall which generates the assembler for the 13 | system calls, near the top there is a line: 14 | COMPACT=1 15 | If this is changed to 16 | COMPACT=0 17 | the code generated will be slightly faster and larger. 18 | 19 | -RDB 20 | 21 | KERNEL SIGNAL INTERFACE: 22 | It is assumed the kernel will never pass a signal to the userspace 23 | routine unless it's _explicitly_ asked for! 24 | 25 | The Kernel need only save space for _one_ function pointer 26 | (to system_signal) and must deal with SIG_DFL and SIG_IGN 27 | in kernel space. 28 | 29 | When a signal is required the kernel must set all the registers as if 30 | returning from a interrupt normally then push the number of the signal 31 | to be generated, push the current pc value, then set the pc to the 32 | address of the 'system_signal' function. 33 | 34 | This is in syscall/signal.c 35 | 36 | -RDB 37 | 38 | -------------------------------------------------------------------------------- /libc/bcc/Config: -------------------------------------------------------------------------------- 1 | 2 | bcclib: Library of bcc helper functions 3 | -------------------------------------------------------------------------------- /libc/bcc/ldiv.c: -------------------------------------------------------------------------------- 1 | /************************************************************************/ 2 | /* This file contains the BCC compiler helper functions */ 3 | /* (C) Copyright Bruce Evans */ 4 | 5 | #ifdef __AS386_16__ 6 | #asm 7 | .text 8 | export _ldiv 9 | _ldiv: 10 | push bp 11 | mov bp,sp 12 | push di 13 | push si 14 | mov ax,[bp+6] 15 | mov bx,[bp+8] 16 | mov cx,[bp+10] 17 | mov di,[bp+12] 18 | call ldivmod 19 | mov si,[bp+4] 20 | mov [si],cx 21 | mov [si+2],di 22 | mov [si+4],ax 23 | mov [si+6],bx 24 | mov ax,si 25 | pop si 26 | pop di 27 | pop bp 28 | ret 29 | .data 30 | .bss 31 | #endasm 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /libc/bios/Config: -------------------------------------------------------------------------------- 1 | bios: Minimal syscalls for BIOS level 2 | -------------------------------------------------------------------------------- /libc/bios/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | ifeq ($(LIB_OS),BIOS) 6 | ASRC=bios.c 7 | AOBJ=bios_start.o bios_isatty.o bios_abort.o bios_nofiles.o \ 8 | bios_read.o bios_write.o bios_lseek.o bios_close.o 9 | 10 | BSRC=bios_vid.c 11 | BOBJ=bios_putch.o bios_getch.o bios_getche.o bios_cputs.o bios_kbhit.o \ 12 | bios_rdline.o 13 | 14 | CSRC=bios_min.c 15 | COBJ=bios_putc.o bios_getc.o bios_khit.o 16 | 17 | DSRC=bios_disk.c 18 | DOBJ=bios_disk_rd.o bios_disk_wr.o bios_disk_rs.o bios_get_dpt.o 19 | 20 | OBJ=$(AOBJ) $(BOBJ) $(COBJ) $(DOBJ) \ 21 | time.o fileops.o fs_dos.o rawio.o vt52.o ansi.o 22 | 23 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 24 | 25 | all: $(LIBC)($(OBJ)) 26 | @$(RM) $(OBJ) 27 | 28 | $(LIBC)($(AOBJ)): $(ASRC) 29 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 30 | $(AR) $(ARFLAGS) $@ $*.o 31 | 32 | $(LIBC)($(BOBJ)): $(BSRC) 33 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 34 | $(AR) $(ARFLAGS) $@ $*.o 35 | 36 | $(LIBC)($(COBJ)): $(CSRC) 37 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 38 | $(AR) $(ARFLAGS) $@ $*.o 39 | 40 | $(LIBC)($(DOBJ)): $(DSRC) 41 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 42 | $(AR) $(ARFLAGS) $@ $*.o 43 | else 44 | all: 45 | @: 46 | endif 47 | 48 | clean: 49 | rm -f *.o libc.a 50 | -------------------------------------------------------------------------------- /libc/bios/README: -------------------------------------------------------------------------------- 1 | Copyright (C) 1996 Robert de Bath 2 | This file is part of the Linux-8086 C library and is distributed 3 | under the GNU Library General Public License. 4 | 5 | This is a very simple set of functions for standalone executables. 6 | 7 | There is a choice as to which console type you want to use, I think 8 | the VT52 clone is best. To activate it you have to call 'vt52_putc' 9 | at least once. 10 | 11 | -Robert 12 | -------------------------------------------------------------------------------- /libc/bios/bios_min.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | #ifdef __AS386_16__ 7 | #ifdef __STANDALONE__ 8 | 9 | #include 10 | 11 | #ifdef L_bios_putc 12 | bios_putc(c) 13 | { 14 | #asm 15 | #if !__FIRST_ARG_IN_AX__ 16 | mov bx,sp 17 | mov ax,[bx+2] 18 | #endif 19 | mov ah,#$0E 20 | mov bx,#7 21 | int $10 22 | #endasm 23 | } 24 | #endif 25 | 26 | /****************************************************************************/ 27 | 28 | #ifdef L_bios_getc 29 | bios_getc() 30 | { 31 | #asm 32 | xor ax,ax 33 | int $16 34 | #endasm 35 | } 36 | #endif 37 | 38 | /****************************************************************************/ 39 | 40 | #ifdef L_bios_khit 41 | bios_khit() 42 | { 43 | #asm 44 | mov ah,#1 45 | int $16 46 | jz nokey 47 | cmp ax,#0 48 | jnz dort 49 | mov ax,#3 50 | dort: 51 | ret 52 | nokey: 53 | xor ax,ax 54 | #endasm 55 | } 56 | #endif 57 | 58 | /****************************************************************************/ 59 | 60 | #endif 61 | #endif 62 | -------------------------------------------------------------------------------- /libc/bios/io.h: -------------------------------------------------------------------------------- 1 | #ifndef __io_h__ 2 | #define __io_h__ 3 | 4 | typedef struct { 5 | /* 6 | * both block_read/block_write should be defined as 7 | * int x(ioblock* iob, char* buffer, int blockno) 8 | * and it reads/writes 1k blocks 9 | * 10 | * close should be defined as int x(ioblock* ioblock); 11 | */ 12 | int (*block_read)(); /* read routine */ 13 | int (*block_write)(); /* write routine - not supported yet*/ 14 | int (*close)(); /* close routine */ 15 | long offset; /* current offset in file to read/write */ 16 | int flags; 17 | long amount_left; /* amount left in buffer */ 18 | char buffer[1024]; 19 | void* context; 20 | } ioblock; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /libc/bios/rawio.h: -------------------------------------------------------------------------------- 1 | #ifndef __readfs_h__ /* multi-inclusion protection */ 2 | #define __readfs_h__ 3 | 4 | #ifdef __STDC__ 5 | #define P(x) x 6 | #else 7 | #define P(x) () 8 | #endif 9 | 10 | #define rawio_read_sector(__sect, __buffer) rawio_read_lsector((unsigned long)__sect, __buffer) 11 | int rawio_read_lsector P((long sector, char* buffer)); 12 | 13 | extern int rawio_disk_cyls; 14 | extern int rawio_disk_heads; 15 | extern int rawio_disk_spt; 16 | #endif 17 | -------------------------------------------------------------------------------- /libc/conio/Config: -------------------------------------------------------------------------------- 1 | conio: Console io functions for BIOS and DOS. 2 | -------------------------------------------------------------------------------- /libc/conio/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | ASRC=conio.c 6 | AOBJ=getch.o getche.o kbhit.o putch.o cputs.o gotoxy.o 7 | 8 | BIOSOBJ=cprintf.o 9 | DOSOBJ=$(AOBJ) cprintf.o 10 | 11 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 12 | 13 | ifeq ($(LIB_CPU)-$(LIB_OS),i86-BIOS) 14 | all: $(LIBC)($(BIOSOBJ)) 15 | @$(RM) $(BIOSOBJ) 16 | else 17 | ifeq ($(LIB_CPU)-$(LIB_OS),i86-DOS) 18 | all: $(LIBC)($(DOSOBJ)) 19 | @$(RM) $(DOSOBJ) 20 | else 21 | all: 22 | @: 23 | endif 24 | endif 25 | 26 | $(LIBC)($(AOBJ)): $(ASRC) 27 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 28 | $(AR) $(ARFLAGS) $@ $*.o 29 | 30 | $(LIBC)($(BOBJ)): $(BSRC) 31 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 32 | $(AR) $(ARFLAGS) $@ $*.o 33 | 34 | $(LIBC)(cprintf.o): cprintf.c 35 | $(CC) -c -ansi $(ARCH) $(CCFLAGS) $(DEFS) $*.c 36 | $(AR) $(ARFLAGS) $@ $*.o 37 | 38 | clean: 39 | rm -f *.o libc.a 40 | -------------------------------------------------------------------------------- /libc/error/Config: -------------------------------------------------------------------------------- 1 | 2 | error: Unix error functions 3 | -------------------------------------------------------------------------------- /libc/error/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 6 | 7 | ifeq ($(LIB_OS),ELKS) 8 | 9 | ifneq ($(LIB_CPU),i86) 10 | OBJ=error2.o perror.o sys_siglist.o __assert.o 11 | else 12 | OBJ=error.o sys_errlist.o perror.o sys_siglist.o __assert.o 13 | endif 14 | 15 | else 16 | OBJ=__assert.o 17 | endif 18 | 19 | all: $(LIBC)($(OBJ)) 20 | @$(RM) $(OBJ) 21 | 22 | clean: 23 | rm -f *.o libc.a error_list.h 24 | 25 | $(LIBC)(error2.o): error_list.h 26 | 27 | error_list.h: liberror.txt 28 | sh mktab.sh 29 | -------------------------------------------------------------------------------- /libc/error/README: -------------------------------------------------------------------------------- 1 | Copyright (C) 1996,2004 Robert de Bath 2 | This file is part of the Linux-8086 C library and is distributed 3 | under the GNU Library General Public License. 4 | 5 | The file "liberror.txt" is the master list of errors for ELKS only. 6 | 7 | WARNING: 8 | If you use the -Mf compile style this file must be in the filessystem 9 | as "/lib/liberror.txt" unless you're using elksemu. 10 | 11 | -Robert 12 | -------------------------------------------------------------------------------- /libc/error/__assert.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | #include 7 | 8 | static void errput(str) 9 | const char * str; 10 | { 11 | write(2, str, strlen(str)); 12 | } 13 | 14 | void 15 | __assert(assertion, filename, linenumber) 16 | const char * assertion; 17 | const char * filename; 18 | int linenumber; 19 | { 20 | errput("Failed assertion '"); 21 | errput(assertion); 22 | errput("' in file "); 23 | errput(filename); 24 | errput(" at line "); 25 | errput(itoa(linenumber)); 26 | errput(".\n"); 27 | abort(); 28 | } 29 | -------------------------------------------------------------------------------- /libc/error/error.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | #include 6 | 7 | char **__sys_errlist =0; 8 | int __sys_nerr = 0; 9 | 10 | char * 11 | strerror(err) 12 | int err; 13 | { 14 | int fd; 15 | static char retbuf[80]; 16 | char inbuf[256]; 17 | int cc; 18 | int bufoff = 0; 19 | 20 | if( __sys_nerr ) 21 | { 22 | if( err < 0 || err >= __sys_nerr ) goto unknown; 23 | return __sys_errlist[err]; 24 | } 25 | 26 | if( err <= 0 ) goto unknown; /* NB the <= allows comments in the file */ 27 | fd = open("/lib/liberror.txt", 0); 28 | if( fd < 0 ) goto unknown; 29 | 30 | while( (cc=read(fd, inbuf, sizeof(inbuf))) > 0 ) 31 | { 32 | int i; 33 | for(i=0; i= 0 ) close(fd); 54 | strcpy(retbuf, "Unknown error "); 55 | strcpy(retbuf+14, itoa(err)); 56 | return retbuf; 57 | } 58 | -------------------------------------------------------------------------------- /libc/error/error2.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996,2004 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | #include 6 | 7 | #include "error_list.h" 8 | 9 | char * 10 | strerror(err) 11 | int err; 12 | { 13 | static char retbuf[20]; 14 | 15 | if( err > 0 && err <= sys_nerr ) 16 | return sys_errlist[err]; 17 | 18 | strcpy(retbuf, "Error "); 19 | strcpy(retbuf+6, itoa(err)); 20 | return retbuf; 21 | } 22 | -------------------------------------------------------------------------------- /libc/error/mktab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | 3 | awk '{ 4 | e=$0; 5 | sub("^[^ ]* ", "", e); 6 | sub(" [^ ]*$", "", e); 7 | n=0+$1; 8 | if (!(n in errlist)) 9 | errlist[n] = e; 10 | if(n > maxerr) maxerr=n; 11 | } 12 | END{ 13 | printf ("#define NR_ERRORS\t%d\n", maxerr+1); 14 | printf ("int sys_nerr = NR_ERRORS;\n"); 15 | printf ("char *sys_errlist[NR_ERRORS] = {\n"); 16 | 17 | for(i=0; i<=maxerr; i++) { 18 | if (errlist[i] == "") 19 | printf(" \"Error %d\"", i); 20 | else 21 | printf(" \"%s\"", errlist[i]); 22 | if (i != maxerr) printf(",\n"); else printf("\n"); 23 | } 24 | printf ("};\n"); 25 | }' < liberror.txt > error_list.h 26 | -------------------------------------------------------------------------------- /libc/error/perror.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void 5 | perror(str) 6 | __const char * str; 7 | { 8 | register char * ptr; 9 | if(str) 10 | { 11 | write(2, str, strlen(str)); 12 | write(2, ": ", 2); 13 | } 14 | else write(2, "perror: ", 8); 15 | 16 | ptr = strerror(errno); 17 | write(2, ptr, strlen(ptr)); 18 | write(2, "\n", 1); 19 | } 20 | -------------------------------------------------------------------------------- /libc/error/sys_siglist.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | __const char * __const sys_siglist[NSIG] = 5 | { 6 | "Unknown signal", 7 | "Hangup", 8 | "Interrupt", 9 | "Quit", 10 | "Illegal instruction", 11 | "Trace/breakpoint trap", 12 | "IOT trap/Abort", 13 | "Bus error", 14 | "Floating point exception", 15 | "Killed", 16 | "User defined signal 1", 17 | "Segmentation fault", 18 | "User defined signal 2", 19 | "Broken pipe", 20 | "Alarm clock", 21 | "Terminated", 22 | "Stack fault", 23 | "Child exited", 24 | "Continued", 25 | "Stopped (signal)", 26 | "Stopped", 27 | "Stopped (tty input)", 28 | "Stopped (tty output)", 29 | "Possible I/O", 30 | "CPU time limit exceeded", 31 | "File size limit exceeded", 32 | "Virtual time alarm", 33 | "Profile signal", 34 | "Window size changed", 35 | "File lock lost", 36 | "Power failure", 37 | "Unused signal" 38 | }; 39 | -------------------------------------------------------------------------------- /libc/getent/Config: -------------------------------------------------------------------------------- 1 | getent: Managment for /etc/passwd /etc/group /etc/utmp 2 | -------------------------------------------------------------------------------- /libc/getent/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1996 Nat Friedman 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | ifeq ($(PLATFORM),i386-ELKS) 6 | CFLAGS=$(ARCH) $(WALL) $(CCFLAGS) $(DEFS) 7 | else 8 | CFLAGS=$(ARCH) -ansi $(CCFLAGS) $(DEFS) 9 | endif 10 | 11 | PSRC=__getpwent.c pwent.c getpwnam.c getpwuid.c putpwent.c getpw.c fgetpwent.c 12 | GSRC=__getgrent.c grent.c getgrnam.c getgrgid.c fgetgrent.c initgroups.c \ 13 | config-grp.h 14 | USRC=utent.c 15 | 16 | POBJ=__getpwent.o pwent.o getpwnam.o getpwuid.o putpwent.o getpw.o fgetpwent.o 17 | GOBJ=__getgrent.o grent.o getgrnam.o getgrgid.o fgetgrent.o initgroups.o 18 | UOBJ=utent.o 19 | 20 | ifeq ($(LIB_OS),ELKS) 21 | 22 | OBJ=$(POBJ) $(GOBJ) $(UOBJ) 23 | 24 | all: $(LIBC)($(OBJ)) 25 | @$(RM) $(OBJ) 26 | 27 | $(LIBC)($(GOBJ)): config-grp.h 28 | 29 | else 30 | all: 31 | @: 32 | endif 33 | 34 | clean: 35 | rm -f *.o libc.a 36 | 37 | -------------------------------------------------------------------------------- /libc/getent/fgetgrent.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fgetgrent.c - This file is part of the libc-8086/grp package for ELKS, 3 | * Copyright (C) 1995, 1996 Nat Friedman . 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free 17 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | struct group * 26 | fgetgrent(FILE * file) 27 | { 28 | if (file==NULL) 29 | { 30 | errno=EINTR; 31 | return NULL; 32 | } 33 | 34 | return __getgrent(fileno(file)); 35 | } 36 | -------------------------------------------------------------------------------- /libc/getent/fgetpwent.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fgetpwent.c - This file is part of the libc-8086/pwd package for ELKS, 3 | * Copyright (C) 1995, 1996 Nat Friedman . 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free 17 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | struct passwd * 26 | fgetpwent(FILE * file) 27 | { 28 | if (file==NULL) 29 | { 30 | errno=EINTR; 31 | return NULL; 32 | } 33 | 34 | return __getpwent(fileno(file)); 35 | } 36 | -------------------------------------------------------------------------------- /libc/getent/getgrgid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getgrgid.c - This file is part of the libc-8086/grp package for ELKS, 3 | * Copyright (C) 1995, 1996 Nat Friedman . 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free 17 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | struct group * 27 | getgrgid(const gid_t gid) 28 | { 29 | struct group * group; 30 | int grp_fd; 31 | 32 | if ((grp_fd=open("/etc/group", O_RDONLY))<0) 33 | return NULL; 34 | 35 | while ((group=__getgrent(grp_fd))!=NULL) 36 | if (group->gr_gid==gid) 37 | { 38 | close(grp_fd); 39 | return group; 40 | } 41 | 42 | close(grp_fd); 43 | return NULL; 44 | } 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /libc/getent/getpwuid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getpwuid.c - This file is part of the libc-8086/pwd package for ELKS, 3 | * Copyright (C) 1995, 1996 Nat Friedman . 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free 17 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | struct passwd * 27 | getpwuid(uid_t uid) 28 | { 29 | int passwd_fd; 30 | struct passwd * passwd; 31 | 32 | if ((passwd_fd=open("/etc/passwd", O_RDONLY))<0) 33 | return NULL; 34 | 35 | while ((passwd=__getpwent(passwd_fd))!=NULL) 36 | if (passwd->pw_uid==uid) 37 | { 38 | close(passwd_fd); 39 | return passwd; 40 | } 41 | 42 | close (passwd_fd); 43 | return NULL; 44 | } 45 | -------------------------------------------------------------------------------- /libc/getent/putpwent.c: -------------------------------------------------------------------------------- 1 | /* 2 | * putpwent.c - This file is part of the libc-8086/pwd package for ELKS, 3 | * Copyright (C) 1995, 1996 Nat Friedman . 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the Free 17 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | int 26 | putpwent(const struct passwd * passwd, FILE * f) 27 | { 28 | if (passwd == NULL || f == NULL) 29 | { 30 | errno=EINVAL; 31 | return -1; 32 | } 33 | if (fprintf(f, "%s:%s:%u:%u:%s:%s:%s\n", passwd->pw_name, passwd->pw_passwd, 34 | passwd->pw_gid, passwd->pw_uid, passwd->pw_gecos, 35 | passwd->pw_dir, passwd->pw_shell)<0) 36 | return -1; 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /libc/gnu_i386/Config: -------------------------------------------------------------------------------- 1 | gnu386: Linux-i386 system call routines GCC 2 | -------------------------------------------------------------------------------- /libc/gnu_i386/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1995,1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | CSRC=cstartup.s 6 | COBJ=cstartup.o 7 | 8 | ESRC=exec.c 9 | EOBJ=execl.o execv.o execle.o execlp.o execvp.o 10 | 11 | DSRC=dirent.c 12 | DOBJ=opendir.o closedir.o readdir.o 13 | 14 | HSRC=heap.c 15 | HOBJ=__brk_addr.o brk.o sbrk.o 16 | 17 | ifeq ($(LIB_CPU)-$(LIB_OS),g386-ELKS) 18 | OBJ=$(COBJ) $(EOBJ) $(DOBJ) $(HOBJ) 19 | SYSCALLS=syscalls 20 | 21 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 22 | 23 | all: $(SYSCALLS) $(LIBC)($(OBJ)) 24 | @$(RM) $(OBJ) 25 | 26 | syscalls: syscall.mak 27 | $(MAKE) -f syscall.mak LIBC="$(LIBC)" CFLAGS="$(CFLAGS)" 28 | 29 | syscall.mak: mksyscall syscall.dat 30 | sh mksyscall 31 | 32 | $(LIBC)($(LOBJ)): $(LSRC) 33 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 34 | $(AR) $(ARFLAGS) $@ $*.o 35 | 36 | $(LIBC)($(COBJ)): $(CSRC) 37 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 38 | $(AR) $(ARFLAGS) $@ $*.o 39 | 40 | $(LIBC)($(DOBJ)): $(DSRC) 41 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 42 | $(AR) $(ARFLAGS) $@ $*.o 43 | 44 | $(LIBC)($(EOBJ)): $(ESRC) 45 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 46 | $(AR) $(ARFLAGS) $@ $*.o 47 | 48 | $(LIBC)($(HOBJ)): $(HSRC) 49 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 50 | $(AR) $(ARFLAGS) $@ $*.o 51 | else 52 | all: 53 | @: 54 | endif 55 | 56 | clean: 57 | rm -f *.o libc.a 58 | rm -f syscall.c syscall.mak 59 | 60 | -------------------------------------------------------------------------------- /libc/gtermcap/Config: -------------------------------------------------------------------------------- 1 | gtermcap:GNU termcap routines 2 | -------------------------------------------------------------------------------- /libc/gtermcap/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1995,1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 6 | 7 | ifeq ($(LIB_OS),ELKS) 8 | OBJ=termcap.o tparam.o 9 | 10 | all: $(LIBC)($(OBJ)) 11 | @$(RM) $(OBJ) 12 | else 13 | all: 14 | @: 15 | endif 16 | 17 | clean: 18 | rm -f *.o libc.a 19 | 20 | -------------------------------------------------------------------------------- /libc/gtermcap/NEWS: -------------------------------------------------------------------------------- 1 | Major changes in release 1.2: 2 | 3 | For `%.', only set the high bit on NUL. 4 | Fix a file descriptor and memory leak. 5 | Add const in termcap.h prototypes. 6 | Configuration improvements. 7 | 8 | Major changes in release 1.1: 9 | 10 | Fix portability problems. 11 | Improve configuration and installation. 12 | Fix compiler warnings. 13 | -------------------------------------------------------------------------------- /libc/gtermcap/README: -------------------------------------------------------------------------------- 1 | This is the GNU termcap library -- a library of C functions that 2 | enable programs to send control strings to terminals in a way 3 | independent of the terminal type. Most of this package is also 4 | distributed with GNU Emacs, but it is available in this separate 5 | distribution to make it easier to install as -ltermcap. 6 | 7 | The GNU termcap library does not place an arbitrary limit on the size 8 | of termcap entries, unlike most other termcap libraries. 9 | 10 | See the file INSTALL for compilation and installation instructions. 11 | 12 | Please report any bugs in this library to bug-gnu-emacs@prep.ai.mit.edu. 13 | You can check which version of the library you have by using the RCS 14 | `ident' command on libtermcap.a. 15 | -------------------------------------------------------------------------------- /libc/gtermcap/version.c: -------------------------------------------------------------------------------- 1 | /* Make the library identifiable with the RCS ident command. */ 2 | static char *version_string = "\n$Version: GNU termcap 1.2.2 $\n"; 3 | -------------------------------------------------------------------------------- /libc/i386fp/Config: -------------------------------------------------------------------------------- 1 | 386fp: Bcc 386 floating point 2 | -------------------------------------------------------------------------------- /libc/i386fp/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for bcc 386 software floating point library 2 | 3 | .SUFFIXES: .x # .x files are .s files that need C-preprocessing 4 | .x.o: 5 | $(CC) $(CFLAGS) -c $< -o $@ 6 | 7 | FPDIST =Makefile $(FPSRC) test.c bccfp.tex 8 | FPSRC =fadd.x fcomp.x fdiv.x fmul.x fbsr.x \ 9 | fperr.c fperror.x fptoi.x fpushd.x fpulld.x \ 10 | fpushi.x fpushf.x fpullf.x frexp.x ftst.x \ 11 | gcclib.x \ 12 | fabs.x ldexp.x ecvt.c \ 13 | fperr.h fplib.h 14 | FPOBJ =fadd.o fcomp.o fdiv.o fmul.o fpbsr.o \ 15 | fperr.o fperror.o fptoi.o fpushd.o fpulld.o \ 16 | fpushi.o fpushf.o fpullf.o frexp.o ftst.o \ 17 | fabs.o ldexp.o ecvt.o 18 | LIB =. 19 | 20 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 21 | 22 | ifeq ($(LIB_CPU),i386) 23 | all: $(LIBC)($(FPOBJ)) 24 | rm -f $(FPOBJ) 25 | else 26 | all: 27 | @: 28 | endif 29 | 30 | $(LIBC)($(FPOBJ)): fplib.h 31 | $(LIBC)(fperr.o fperror.o): fperr.h 32 | 33 | clean: 34 | rm -f $(FPOBJ) test 35 | rm -f $(LIB)/libfp.a bccfp.tar.Z bccfp.uue 36 | -------------------------------------------------------------------------------- /libc/i386fp/bccfp.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/libc/i386fp/bccfp.tex -------------------------------------------------------------------------------- /libc/i386fp/changes: -------------------------------------------------------------------------------- 1 | fcomp: 2 | Fixes for negative 0 (perhaps this shouldn't be generated, like denormals 3 | and infinities (these would cause even more trouble) but Fsub routine or 4 | something generated one). 5 | 6 | frexp.x: 7 | Deleted 3rd arg (used to return value when bcc wasn't doing it right). 8 | 9 | Fixed frexp(value = 0) and ldexp(value = 0) returning nonzero. 10 | 11 | Most files: 12 | Changed comment symbol to '!' for new assembler (not the native ';' in 13 | case this is ported to ACK someday). 14 | 15 | Avoided using ebp and unnecessary register saves. 16 | 17 | Changed assembler style to make it a bit more portable or like I do it 18 | (no '$' for hex, 8[esp] instead of [esp+8], use only .define and not export 19 | or .globl, use '#' (could use nothing) instead of '*' for immediate). 20 | The partly-supported 8(ebp) and .globl would be still more portable. 21 | 22 | Changed terminology 'mantissa' to 'fraction'. 23 | 24 | Round to even. Required for 'paranioa' not to find any defects. 25 | 26 | Used preprocessor. 27 | 28 | Parametrized most of the magic numbers. Phew! 29 | 30 | Supported denormals. Now 'paranioa' doesn't find any flaws. 31 | -------------------------------------------------------------------------------- /libc/i386fp/fabs.x: -------------------------------------------------------------------------------- 1 | ! bcc 386 floating point routines (version 2) -- _fabs 2 | ! author: Bruce Evans 3 | 4 | #include "fplib.h" 5 | 6 | ! double fabs(double value); 7 | ! returns the absolute value of a number 8 | ! this works for all NaNs, like the 80*87 fabs, but perhaps we should check 9 | ! for exceptions that can happen when an 80*87 register is loaded 10 | 11 | .globl _fabs 12 | .align ALIGNMENT 13 | _fabs: 14 | mov eax,PC_SIZE+D_LOW[esp] 15 | mov edx,PC_SIZE+D_HIGH[esp] 16 | and edx,~D_SIGN_MASK 17 | ret 18 | -------------------------------------------------------------------------------- /libc/i386fp/fpbsr.x: -------------------------------------------------------------------------------- 1 | ! bcc 386 floating point routines (version 2) -- bsr_table 2 | ! author: Bruce Evans 3 | 4 | #include "fplib.h" 5 | 6 | .globl bsr_table 7 | .data 8 | .align ALIGNMENT 9 | bsr_table: ! table to replace bsr on range 0-255 10 | .byte -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 11 | .byte 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 12 | .byte 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 13 | .byte 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 14 | .byte 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 15 | .byte 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 16 | .byte 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 17 | .byte 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 18 | .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 19 | .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 20 | .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 21 | .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 22 | .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 23 | .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 24 | .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 25 | .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 26 | -------------------------------------------------------------------------------- /libc/i386fp/fperr.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "fperr.h" 5 | 6 | void fperr(errno) 7 | int errno; 8 | { 9 | 10 | #if defined(DEBUG) || 0 11 | switch(errno) { 12 | 13 | case EFDENORMAL: 14 | fputs("\nDenormal - ", stderr); 15 | break; 16 | 17 | case EFINFINITY: 18 | fputs("\nInfinity - ", stderr); 19 | break; 20 | 21 | case EFNAN: 22 | fputs("\nNaN - ", stderr); 23 | break; 24 | 25 | case EFOVERFLOW: 26 | fputs("\nOverflow - ", stderr); 27 | break; 28 | 29 | case EFUNDERFLOW: 30 | fputs("\nUnderflow - ", stderr); 31 | break; 32 | 33 | case EFDIVZERO: 34 | fputs("\nZero divide - ", stderr); 35 | break; 36 | 37 | default: 38 | fprintf(stderr, "\nUnknown error 0x%x - ", errno); 39 | } 40 | fflush(stderr); 41 | #endif 42 | 43 | kill(getpid(), SIGFPE); 44 | } 45 | -------------------------------------------------------------------------------- /libc/i386fp/fperr.h: -------------------------------------------------------------------------------- 1 | /* fperr.h */ 2 | 3 | #define EFDENORMAL 1 4 | #define EFINFINITY 2 5 | #define EFNAN 3 6 | #define EFOVERFLOW 4 7 | #define EFUNDERFLOW 5 8 | #define EFDIVZERO 6 9 | -------------------------------------------------------------------------------- /libc/i386fp/fpulld.x: -------------------------------------------------------------------------------- 1 | ! bcc 386 floating point routines (version 2) -- Fpulld 2 | ! authors: Timothy Murphy (tim@maths.tcd.ie), Bruce Evans 3 | 4 | #include "fplib.h" 5 | 6 | ! Pop double from stack and store at address [ebx] 7 | 8 | .globl Fpulld 9 | .align ALIGNMENT 10 | Fpulld: 11 | pop ecx 12 | pop dword D_LOW[ebx] 13 | pop dword D_HIGH[ebx] 14 | jmp ecx ! return 15 | 16 | ! This popping method is much slower on 486's because popping to memory 17 | ! takes 5+ while moving twice takes 2 and the return address doesn't 18 | ! have to be moved. However, popping is a little faster on a non-cached 19 | ! 386/20 with static column RAM although the memory access pattern is 20 | ! better for a double-width move than for popping. What about a cached 386? 21 | -------------------------------------------------------------------------------- /libc/i386fp/ftst.x: -------------------------------------------------------------------------------- 1 | ! bcc 386 floating point routines (version 2) -- Ftst, Ftstd, Ftstf 2 | ! authors: Timothy Murphy (tim@maths.tcd.ie), Bruce Evans 3 | 4 | #include "fplib.h" 5 | 6 | #if 0 /* bcc doesn't generate Ftst (but it might in future) */ 7 | .globl Ftst 8 | #endif 9 | .align ALIGNMENT 10 | Ftst: 11 | cmp dword PC_SIZE+D_HIGH[esp],#0 ! need only test upper dword of x 12 | ret #D_SIZE 13 | 14 | ! Compare double at address [ebx] with 0 15 | 16 | .globl Ftstd 17 | .align ALIGNMENT 18 | Ftstd: 19 | cmp dword D_HIGH[ebx],#0 ! need only test upper dword of x 20 | ret 21 | 22 | ! Compare float at address [ebx] with 0 23 | 24 | .globl Ftstf 25 | .align ALIGNMENT 26 | Ftstf: 27 | cmp dword F_HIGH[ebx],#0 28 | ret 29 | -------------------------------------------------------------------------------- /libc/i386fp/modf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Slooow version. */ 4 | 5 | double modf(x, pint) 6 | double x; 7 | double *pint; 8 | { 9 | if (x >= 0) 10 | *pint = floor(x); 11 | else 12 | *pint = ceil(x); 13 | return x - *pint; 14 | } 15 | -------------------------------------------------------------------------------- /libc/i386sys/Config: -------------------------------------------------------------------------------- 1 | sys386: Linux-i386 system call routines 2 | -------------------------------------------------------------------------------- /libc/i386sys/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1995,1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | LSRC=cstartup.c 6 | LOBJ=__cstart3.o 7 | 8 | ESRC=exec.c 9 | EOBJ=execl.o execv.o execle.o execlp.o execvp.o 10 | 11 | DSRC=dirent.c 12 | DOBJ=opendir.o closedir.o readdir.o 13 | 14 | ifeq ($(LIB_CPU)-$(LIB_OS),i386-ELKS) 15 | OBJ=$(LOBJ) $(EOBJ) $(DOBJ) setjmp3.o 16 | SYSCALLS=syscalls 17 | 18 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 19 | 20 | all: $(SYSCALLS) $(LIBC)($(OBJ)) 21 | @$(RM) $(OBJ) 22 | 23 | syscalls: syscall.mak 24 | $(MAKE) -f syscall.mak LIBC="$(LIBC)" CFLAGS="$(CFLAGS)" 25 | 26 | syscall.mak: mksyscall syscall.dat 27 | sh mksyscall 28 | 29 | $(LIBC)($(LOBJ)): $(LSRC) 30 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 31 | $(AR) $(ARFLAGS) $@ $*.o 32 | 33 | $(LIBC)($(DOBJ)): $(DSRC) 34 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 35 | $(AR) $(ARFLAGS) $@ $*.o 36 | 37 | $(LIBC)($(EOBJ)): $(ESRC) 38 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 39 | $(AR) $(ARFLAGS) $@ $*.o 40 | else 41 | all: 42 | @: 43 | endif 44 | 45 | clean: 46 | rm -f *.o libc.a 47 | rm -f syscall.c syscall.mak 48 | 49 | -------------------------------------------------------------------------------- /libc/i386sys/setjmp3.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #if __AS386_32__ 5 | 6 | int 7 | setjmp(env) 8 | jmp_buf env; 9 | { 10 | #asm 11 | export __setjmp 12 | __setjmp: 13 | 14 | pop ecx ! PC 15 | #if __FIRST_ARG_IN_AX__ 16 | mov ebx,eax 17 | #else 18 | mov ebx,esp 19 | mov ebx,[ebx] ! TOS is prt -> env 20 | #endif 21 | mov [ebx+0],ecx ! PC 22 | mov [ebx+4],esp ! This registers are all that may be constant. 23 | mov [ebx+8],ebp 24 | mov [ebx+12],esi ! Is saving these the "right thing" ? 25 | mov [ebx+16],edi 26 | xor eax,eax 27 | jmp ecx 28 | #endasm 29 | } 30 | 31 | void 32 | longjmp(env, rv) 33 | jmp_buf env; 34 | int rv; 35 | { 36 | #asm 37 | export __longjmp 38 | __longjmp: 39 | 40 | pop ecx ! pc 41 | #if __FIRST_ARG_IN_AX__ 42 | mov ebx,eax ! env-> 43 | #else 44 | pop ebx ! env-> 45 | #endif 46 | pop eax ! rv 47 | mov ecx,[ebx+0] ! PC 48 | mov esp,[ebx+4] 49 | mov ebp,[ebx+8] 50 | mov esi,[ebx+12] 51 | mov edi,[ebx+16] 52 | jmp ecx 53 | #endasm 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /libc/include/ar.h: -------------------------------------------------------------------------------- 1 | #ifndef __AR_H 2 | #define __AR_H 3 | 4 | #define ARMAG "!\n" 5 | #define SARMAG 8 6 | #define ARFMAG "`\n" 7 | 8 | struct ar_hdr { 9 | char ar_name[16], 10 | ar_date[12], 11 | ar_uid[6], 12 | ar_gid[6], 13 | ar_mode[8], 14 | ar_size[10], 15 | ar_fmag[2]; 16 | }; 17 | 18 | #endif /* __AR_H */ 19 | -------------------------------------------------------------------------------- /libc/include/asm/types.h: -------------------------------------------------------------------------------- 1 | 2 | /* asm/types.h - Basic sized C data types. */ 3 | 4 | #ifndef __ASM_8086_TYPES 5 | #define __ASM_8086_TYPES 6 | 7 | /* First we define all of the __u and __s types...*/ 8 | 9 | typedef unsigned char __u8; 10 | typedef unsigned char * __pu8; 11 | 12 | #ifndef __BCC__ /* NOTE! BCC does _not_ have a signed char type! */ 13 | typedef char __s8; 14 | typedef char * __ps8; 15 | #endif 16 | 17 | typedef unsigned short __u16; 18 | typedef unsigned short * __pu16; 19 | typedef short __s16; 20 | typedef short * __ps16; 21 | 22 | typedef unsigned long __u32; 23 | typedef unsigned long * __pu32; 24 | typedef long __s32; 25 | typedef long * __ps32; 26 | 27 | /* __uint == 16bit on 8086 32bit on i386 */ 28 | 29 | typedef unsigned int __uint; 30 | typedef int __sint; 31 | typedef unsigned int * __puint; 32 | typedef int * __psint; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libc/include/assert.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASSERT_H 2 | #define __ASSERT_H 3 | #include 4 | 5 | /* If NDEBUG is defined, do nothing. 6 | If not, and EXPRESSION is zero, print an error message and abort. */ 7 | 8 | #ifdef NDEBUG 9 | 10 | #define assert(expr) ((void) 0) 11 | 12 | #else /* Not NDEBUG. */ 13 | 14 | extern void __assert __P((const char *, const char *, int)); 15 | 16 | #define assert(expr) \ 17 | ((void) ((expr) || \ 18 | (__assert (__STRING(expr), \ 19 | __FILE__, __LINE__), 0))) 20 | 21 | #endif /* NDEBUG. */ 22 | 23 | #endif /* __ASSERT_H */ 24 | -------------------------------------------------------------------------------- /libc/include/bios.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __BIOS_H 3 | #define __BIOS_H 4 | #include 5 | 6 | union REGS 7 | { 8 | struct { unsigned int ax, bx, cx, dx, si, di, cflag, flags; } x; 9 | struct { unsigned char al, ah, bl, bh, cl, ch, dl, dh; } h; 10 | }; 11 | 12 | struct SREGS 13 | { 14 | unsigned int es, cs, ss, ds; 15 | }; 16 | 17 | unsigned int __get_cs __P((void)); 18 | unsigned int __get_ds __P((void)); 19 | unsigned int __get_es __P((void)); 20 | void __set_es __P((unsigned int seg)); 21 | int __peek_es __P((unsigned int off)); 22 | int __deek_es __P((unsigned int off)); 23 | 24 | #define movedata __movedata 25 | long _bios_get_dpt(drive); 26 | 27 | #ifdef __LIBC__ 28 | 29 | extern int __nofiles(); 30 | extern int (*__files)(); 31 | 32 | #define CMD_OPEN 0 33 | #define CMD_READ 1 34 | #define CMD_WRITE 2 35 | #define CMD_LSEEK 3 36 | #define CMD_CLOSE 4 37 | 38 | #endif 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /libc/include/bsd/bsd.h: -------------------------------------------------------------------------------- 1 | /* bsd.h - simplify porting BSD programs to Linux - rick sladkey */ 2 | 3 | /* make sure BSD features are enabled, i.e. __USE_BSD and _FAVOR_BSD */ 4 | 5 | /* cpp in gcc 2.3.3 is broken. 6 | #ifndef _BSD_BSD_H 7 | #define _BSD_BSD_H 8 | */ 9 | 10 | #define _BSD_SOURCE 1 11 | #include 12 | #include 13 | 14 | /* some BSD progs expect MIN and MAX to be defined */ 15 | 16 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) 17 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) 18 | 19 | /* make sure we get L_SET and L_INCR, which is in a different place */ 20 | 21 | #include 22 | 23 | /* BSD has slight non-POSIX names (and meanings :-) for some things */ 24 | 25 | #define FAPPEND O_APPEND 26 | 27 | #include 28 | 29 | /* (absolute) max # characters in exec arglist */ 30 | 31 | #define NCARGS ARG_MAX 32 | 33 | /* ftpd uses this as bits per byte, I don't know why it's called NBBY */ 34 | 35 | #define NBBY CHAR_BIT 36 | 37 | /* gloss over slight differences between BSD direct and POSIX dirent */ 38 | 39 | #define d_namlen d_reclen 40 | 41 | #if 0 42 | 43 | /* See */ 44 | 45 | typedef void sig_t; 46 | 47 | #endif 48 | 49 | /* #endif _BSD_BSD_H */ 50 | -------------------------------------------------------------------------------- /libc/include/bsd/errno.h: -------------------------------------------------------------------------------- 1 | /* make sure EWOULDBLOCK doesn't screw us up */ 2 | #ifndef _BSD_ERRNO_H 3 | #define _BSD_ERRNO_H 4 | 5 | #include_next 6 | #undef EWOULDBLOCK 7 | #define EWOULDBLOCK EAGAIN 8 | 9 | #endif /* _BSD_ERRNO_H */ 10 | -------------------------------------------------------------------------------- /libc/include/bsd/signal.h: -------------------------------------------------------------------------------- 1 | #ifndef _BSD_SIGNAL_H 2 | #define _BSD_SIGNAL_H 3 | 4 | /* make sure we get BSD style signals (that don't need to be reset) */ 5 | 6 | #define __USE_BSD_SIGNAL 7 | #include_next 8 | 9 | /* use rough approximation of sigaction to sigvec, not completely safe! */ 10 | 11 | #define sigvec sigaction 12 | #define sv_mask sa_mask 13 | #define sv_flags sa_flags 14 | #define sv_handler sa_handler 15 | #define sv_onstack sa_mask /* ouch, this one really hurts */ 16 | 17 | /* BSD uses some non-POSIX signals without ifdefs */ 18 | 19 | #define SIGSYS SIGUNUSED 20 | 21 | /* BSD wants this typedef for signal handlers */ 22 | 23 | #define sig_t __sighandler_t 24 | 25 | #endif /* _BSD_SIGNAL_H */ 26 | -------------------------------------------------------------------------------- /libc/include/bsd/stdlib.h: -------------------------------------------------------------------------------- 1 | /* some things shouldn't be macros, get out your barf bag */ 2 | 3 | #ifndef _BSD_STDLIB_H 4 | #define _BSD_STDLIB_H 5 | 6 | #undef __MALLOC_0_RETURNS_NULL 7 | #define __MALLOC_0_RETURNS_NULL 8 | #include_next 9 | #undef atoi 10 | #undef atol 11 | 12 | #endif /* _BSD_STDLIB_H */ 13 | -------------------------------------------------------------------------------- /libc/include/bsd/sys/ttychars.h: -------------------------------------------------------------------------------- 1 | #ifndef _BSD_SYS_TTYCHARS_H 2 | #define _BSD_SYS_TTYCHARS_H 3 | #endif /* _BSD_SYS_TTYCHARS_H */ 4 | -------------------------------------------------------------------------------- /libc/include/bsd/tzfile.h: -------------------------------------------------------------------------------- 1 | #ifndef _BSD_TZFILE_H 2 | #define _BSD_TZFILE_H 3 | 4 | #define SECSPERDAY (60*60*24) 5 | #define DAYSPERNYEAR 365 6 | #define DAYSPERLYEAR 366 7 | 8 | #define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) 9 | 10 | #endif /* _BSD_TZFILE_H */ 11 | -------------------------------------------------------------------------------- /libc/include/bsd/unistd.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | #include 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /libc/include/conio.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CONIO_H 3 | #define __CONIO_H 4 | #include 5 | 6 | int cprintf __P((char *, ...)); 7 | int cputs __P((char *)); 8 | int getch __P((void)); 9 | int getche __P((void)); 10 | int kbhit __P((void)); 11 | int putch __P((int)); 12 | int gotoxy __P((int, int)); 13 | 14 | #if 0 /* Unimplemented as yet */ 15 | char * cgets __P((char *)); 16 | int ungetch __P((int)); 17 | int cscanf __P((char *, ...)); 18 | #endif 19 | 20 | #if 0 /* Hummm */ 21 | unsigned outpw __P((unsigned int, unsigned int)); 22 | unsigned inpw __P((unsigned int)); 23 | int outp __P((unsigned int, int)); 24 | int inp __P((unsigned int)); 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /libc/include/ctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ctype.h Character classification and conversion 3 | */ 4 | 5 | #ifndef __CTYPE_H 6 | #define __CTYPE_H 7 | 8 | extern unsigned char __ctype[]; 9 | 10 | #define __CT_d 0x01 /* numeric digit */ 11 | #define __CT_u 0x02 /* upper case */ 12 | #define __CT_l 0x04 /* lower case */ 13 | #define __CT_c 0x08 /* control character */ 14 | #define __CT_s 0x10 /* whitespace */ 15 | #define __CT_p 0x20 /* punctuation */ 16 | #define __CT_x 0x40 /* hexadecimal */ 17 | 18 | /* Define these as simple old style ascii versions */ 19 | #define toupper(c) (((c)>='a'&&(c)<='z') ? (c)^0x20 : (c)) 20 | #define tolower(c) (((c)>='A'&&(c)<='Z') ? (c)^0x20 : (c)) 21 | #define _toupper(c) ((c)^0x20) 22 | #define _tolower(c) ((c)^0x20) 23 | #define toascii(c) ((c)&0x7F) 24 | 25 | #define __CT(c) (__ctype[1+(unsigned char)c]) 26 | 27 | /* Note the '!!' is a cast to 'bool' and even BCC deletes it in an if() */ 28 | #define isalnum(c) (!!(__CT(c)&(__CT_u|__CT_l|__CT_d))) 29 | #define isalpha(c) (!!(__CT(c)&(__CT_u|__CT_l))) 30 | #define isascii(c) (!((c)&~0x7F)) 31 | #define iscntrl(c) (!!(__CT(c)&__CT_c)) 32 | #define isdigit(c) (!!(__CT(c)&__CT_d)) 33 | #define isgraph(c) (!(__CT(c)&(__CT_c|__CT_s))) 34 | #define islower(c) (!!(__CT(c)&__CT_l)) 35 | #define isprint(c) (!(__CT(c)&__CT_c)) 36 | #define ispunct(c) (!!(__CT(c)&__CT_p)) 37 | #define isspace(c) (!!(__CT(c)&__CT_s)) 38 | #define isupper(c) (!!(__CT(c)&__CT_u)) 39 | #define isxdigit(c) (!!(__CT(c)&__CT_x)) 40 | 41 | #endif /* __CTYPE_H */ 42 | -------------------------------------------------------------------------------- /libc/include/dos.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __DOS_H 3 | #define __DOS_H 4 | #include 5 | #include 6 | 7 | #ifdef __MSDOS__ 8 | extern unsigned int __envseg; 9 | extern unsigned int __psp; 10 | char * __fconv __P((char * fname)); 11 | 12 | unsigned int __segalloc __P((unsigned int paracount)); 13 | void __setvect __P((int i, long j)); 14 | long __getvect __P((int vecno)); 15 | #endif 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /libc/include/errno.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /libc/include/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef __FCNTL__H 2 | #define __FCNTL__H 3 | 4 | #include 5 | #include 6 | #include __SYSINC__(fcntl.h) 7 | 8 | #ifndef FNDELAY 9 | #define FNDELAY O_NDELAY 10 | #endif 11 | 12 | __BEGIN_DECLS 13 | 14 | extern int creat __P ((__const char * __filename, mode_t __mode)); 15 | extern int fcntl __P ((int __fildes,int __cmd, ...)); 16 | extern int open __P ((__const char * __filename, int __flags, ...)); 17 | 18 | __END_DECLS 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /libc/include/features.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __FEATURES_H 3 | #define __FEATURES_H 4 | 5 | #ifdef __STDC__ 6 | 7 | #define __P(x) x 8 | #define __const const 9 | 10 | /* Not really ansi */ 11 | #ifdef __BCC__ 12 | #define const 13 | #define volatile 14 | #endif 15 | 16 | #else /* K&R */ 17 | 18 | #define __P(x) () 19 | #define __const 20 | #define const 21 | #define volatile 22 | 23 | #endif 24 | 25 | /* Pick an OS sysinclude directory */ 26 | /* Use with #include __SYSINC__(errno.h) */ 27 | 28 | #ifdef __ELKS__ 29 | #define __SYSINC__(_h_file_) 30 | #endif 31 | 32 | #ifdef __linux__ 33 | #undef linux /* Eyuk! */ 34 | #define __SYSINC__(_h_file_) 35 | #endif 36 | 37 | #ifdef __MSDOS__ 38 | #define __SYSINC__(_h_file_) 39 | #endif 40 | 41 | #ifndef __SYSINC__ 42 | #define __SYSINC__(_h_file_) 43 | #endif 44 | 45 | /* No C++ */ 46 | #define __BEGIN_DECLS 47 | #define __END_DECLS 48 | 49 | /* GNUish things */ 50 | #define __CONSTVALUE 51 | #define __CONSTVALUE2 52 | 53 | #include 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libc/include/generic/types.h: -------------------------------------------------------------------------------- 1 | 2 | /* arch/i86/include/asm/types.h - Basic Linux/MT data types. */ 3 | 4 | #ifndef __GENERIC_TYPES_H 5 | #define __GENERIC_TYPES_H 6 | 7 | #include 8 | 9 | typedef __u32 off_t; 10 | typedef __u32 time_t; 11 | typedef __u16 mode_t; 12 | typedef __u32 loff_t; 13 | typedef __u32 speed_t; 14 | 15 | typedef __u32 tcflag_t; 16 | typedef __u8 cc_t; 17 | 18 | typedef int ptrdiff_t; 19 | typedef int size_t; 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /libc/include/getopt.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | #ifndef __GETOPT_H 7 | #define __GETOPT_H 8 | 9 | #include 10 | 11 | extern char *optarg; 12 | extern int opterr; 13 | extern int optind; 14 | 15 | extern int getopt __P((int argc, char *const *argv, const char *shortopts)); 16 | 17 | #endif /* __GETOPT_H */ 18 | -------------------------------------------------------------------------------- /libc/include/grp.h: -------------------------------------------------------------------------------- 1 | #ifndef __GRP_H 2 | #define __GRP_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* The group structure */ 9 | struct group 10 | { 11 | char *gr_name; /* Group name. */ 12 | char *gr_passwd; /* Password. */ 13 | gid_t gr_gid; /* Group ID. */ 14 | char **gr_mem; /* Member list. */ 15 | }; 16 | 17 | extern void setgrent __P ((void)); 18 | extern void endgrent __P ((void)); 19 | extern struct group * getgrent __P ((void)); 20 | 21 | extern struct group * getgrgid __P ((__const gid_t gid)); 22 | extern struct group * getgrnam __P ((__const char * name)); 23 | 24 | extern struct group * fgetgrent __P ((FILE * file)); 25 | 26 | extern int setgroups __P ((size_t n, __const gid_t * groups)); 27 | extern int initgroups __P ((__const char * user, gid_t gid)); 28 | 29 | 30 | #ifdef __LIBC__ 31 | extern struct group * __getgrent __P ((int grp_fd)); 32 | #endif 33 | 34 | #endif /* _GRP_H */ 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /libc/include/limits.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | #ifndef __LIMITS_H 7 | #define __LIMITS_H 8 | #include 9 | #endif 10 | -------------------------------------------------------------------------------- /libc/include/linux/ioctl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/libc/include/linux/ioctl.h -------------------------------------------------------------------------------- /libc/include/linux/types.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_TYPES_H 2 | #define __LINUX_TYPES_H 3 | 4 | #include 5 | 6 | typedef __u32 off_t; 7 | typedef __u16 pid_t; 8 | typedef __u16 uid_t; 9 | typedef __u16 gid_t; 10 | typedef __u32 time_t; 11 | typedef __u16 umode_t; 12 | typedef __u16 nlink_t; 13 | typedef __u16 mode_t; 14 | typedef __u32 loff_t; 15 | typedef __u32 speed_t; 16 | 17 | typedef __u32 dev_t; 18 | typedef __u32 ino_t; 19 | typedef __u32 tcflag_t; 20 | typedef __u8 cc_t; 21 | typedef __u32 size_t; 22 | 23 | typedef int ptrdiff_t; 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /libc/include/linux/utsname.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_UTSNAME_H 2 | #define __LINUX_UTSNAME_H 3 | 4 | struct utsname { 5 | char sysname[65]; 6 | char nodename[65]; 7 | char release[65]; 8 | char version[65]; 9 | char machine[65]; 10 | char domainname[65]; 11 | }; 12 | 13 | extern int uname __P ((struct utsname * __utsbuf)); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /libc/include/math.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/libc/include/math.h -------------------------------------------------------------------------------- /libc/include/memory.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /libc/include/msdos/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef __MSDOS_FCNTL_H 2 | #define __MSDOS_FCNTL_H 3 | 4 | /* Definitions taken from Ralf Brown interrupt list and Linux kernel */ 5 | 6 | #define O_ACCMODE 0x03 7 | #define O_RDONLY 0x00 8 | #define O_WRONLY 0x01 9 | #define O_RDWR 0x02 10 | 11 | #define O_DENYMODE 0x70 12 | #define O_DENYALL 0x10 13 | #define O_DENYWRITE 0x20 14 | #define O_DENYREAD 0x30 15 | #define O_DENYNONE 0x40 16 | #define O_SETFD 0x80 /* Close on exec flag for open */ 17 | 18 | #define O_CREAT 0x100 /* Moved on DOS to avoid DENY's */ 19 | #define O_TRUNC 0x200 20 | #define O_APPEND 0x400 21 | #define O_EXCL 0x800 22 | 23 | #define O_BINARY 0x0000 24 | #define O_TEXT 0x8000 /* This right ? Who cares! */ 25 | 26 | #define F_DUPFD 0 /* dup */ 27 | #define F_GETFD 1 /* get f_flags */ 28 | #define F_SETFD 2 /* set f_flags */ 29 | #define F_GETFL 3 /* more flags (cloexec) */ 30 | #define F_SETFL 4 31 | #define F_GETLK 5 32 | #define F_SETLK 6 33 | #define F_SETLKW 7 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libc/include/msdos/types.h: -------------------------------------------------------------------------------- 1 | 2 | /* arch/i86/include/asm/types.h - Basic Linux/MT data types. */ 3 | 4 | #ifndef __MSDOS_TYPES 5 | #define __MSDOS_TYPES 6 | 7 | #include 8 | 9 | typedef __u32 off_t; 10 | typedef __u32 time_t; 11 | typedef __u16 mode_t; 12 | typedef __u32 loff_t; 13 | typedef __u32 speed_t; 14 | 15 | typedef __u32 tcflag_t; 16 | typedef __u8 cc_t; 17 | typedef __u16 size_t; 18 | 19 | typedef int ptrdiff_t; 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /libc/include/paths.h: -------------------------------------------------------------------------------- 1 | /* paths.h */ 2 | 3 | #ifndef ___PATHS_H 4 | #define ___PATHS_H 5 | 6 | 7 | #define _PATH_CONSOLE "/dev/console" 8 | #define _PATH_TTY "/dev/tty" 9 | #define _PATH_NOLOGIN "/etc/nologin" 10 | #define _PATH_LOGIN "/bin/login" 11 | #define _PATH_BSHELL "/bin/sh" 12 | #define _PATH_UTMP "/var/run/utmp" 13 | #define _PATH_WTMP "/var/log/wtmp" 14 | #define _PATH_DEFPATH "/bin:/usr/bin:/usr/local/bin:." 15 | #define _PATH_DEV "/dev/" 16 | #define _PATH_DEVNULL "/dev/null" 17 | #define _PATH_TMP "/tmp/" 18 | #define _PATH_LASTLOG "/var/log/lastlog" 19 | #define _PATH_LOCALE "/usr/lib/locale" 20 | 21 | #endif /* __PATHS_H */ 22 | -------------------------------------------------------------------------------- /libc/include/pwd.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWD_H 2 | #define __PWD_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* The passwd structure. */ 9 | struct passwd 10 | { 11 | char *pw_name; /* Username. */ 12 | char *pw_passwd; /* Password. */ 13 | uid_t pw_uid; /* User ID. */ 14 | gid_t pw_gid; /* Group ID. */ 15 | char *pw_gecos; /* Real name. */ 16 | char *pw_dir; /* Home directory. */ 17 | char *pw_shell; /* Shell program. */ 18 | }; 19 | 20 | 21 | extern void setpwent __P ((void)); 22 | extern void endpwent __P ((void)); 23 | extern struct passwd * getpwent __P ((void)); 24 | 25 | extern int putpwent __P ((__const struct passwd * __p, FILE * __f)); 26 | extern int getpw __P ((uid_t uid, char *buf)); 27 | 28 | extern struct passwd * fgetpwent __P ((FILE * file)); 29 | 30 | extern struct passwd * getpwuid __P ((__const uid_t)); 31 | extern struct passwd * getpwnam __P ((__const char *)); 32 | 33 | #ifdef __LIBC__ 34 | extern struct passwd * __getpwent __P ((__const int passwd_fd)); 35 | #endif 36 | 37 | #endif /* pwd.h */ 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /libc/include/setjmp.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __SETJMP_H 3 | #define __SETJMP_H 4 | 5 | #include 6 | 7 | /* 8 | * I know most systems use an array of ints here, but I prefer this - RDB 9 | */ 10 | 11 | typedef struct 12 | { 13 | unsigned int pc; 14 | unsigned int sp; 15 | unsigned int bp; 16 | unsigned int si; 17 | unsigned int di; 18 | } jmp_buf[1]; 19 | 20 | int _setjmp __P((jmp_buf env)); 21 | void _longjmp __P((jmp_buf env, int rv)); 22 | 23 | /* LATER: Seems GNU beat me to it, must be OK then :-) 24 | * Humm, what's this about setjmp being a macro !? 25 | * Ok, use the BSD names as normal use the ANSI as macros 26 | */ 27 | 28 | #define setjmp(a_env) _setjmp(a_env) 29 | #define longjmp(a_env, a_rv) _longjmp(a_env, a_rv) 30 | #endif 31 | -------------------------------------------------------------------------------- /libc/include/stddef.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | /* We don't care, ignore GCC's __need hackery */ 6 | 7 | #ifndef __STDDEF_H 8 | #define __STDDEF_H 9 | 10 | #include 11 | 12 | #ifndef NULL 13 | #define NULL ((void*)0) 14 | #endif 15 | 16 | #endif /* __STDDEF_H */ 17 | -------------------------------------------------------------------------------- /libc/include/stdlib.h: -------------------------------------------------------------------------------- 1 | /* stdlib.h */ 2 | #include 3 | #include 4 | 5 | #ifndef __STDLIB_H 6 | #define __STDLIB_H 7 | 8 | /* Don't overwrite user definitions of NULL */ 9 | #ifndef NULL 10 | #define NULL ((void *) 0) 11 | #endif 12 | 13 | /* For program termination */ 14 | #define EXIT_FAILURE 1 15 | #define EXIT_SUCCESS 0 16 | 17 | #include 18 | 19 | extern int rand __P ((void)); 20 | extern void srand __P ((unsigned int seed)); 21 | 22 | extern long strtol __P ((const char * nptr, char ** endptr, int base)); 23 | extern unsigned long strtoul __P ((const char * nptr, 24 | char ** endptr, int base)); 25 | #ifndef __HAS_NO_FLOATS__ 26 | extern double strtod __P ((const char * nptr, char ** endptr)); 27 | extern double atof __P ((__const char *__nptr)); 28 | #endif 29 | 30 | extern long int atol __P ((__const char *__nptr)); 31 | extern int atoi __P ((__const char *__nptr)); 32 | 33 | /* Returned by `div'. */ 34 | typedef struct 35 | { 36 | int quot; /* Quotient. */ 37 | int rem; /* Remainder. */ 38 | } div_t; 39 | 40 | /* Returned by `ldiv'. */ 41 | typedef struct 42 | { 43 | long int quot; /* Quotient. */ 44 | long int rem; /* Remainder. */ 45 | } ldiv_t; 46 | 47 | 48 | extern char *getenv __P ((__const char *__name)); 49 | extern char *mktemp __P ((char *__template)); 50 | 51 | #endif /* __STDLIB_H */ 52 | -------------------------------------------------------------------------------- /libc/include/strings.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /libc/include/sys/cdefs.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __SYS_CDEFS_H 3 | #define __SYS_CDEFS_H 4 | #include 5 | 6 | #if __STDC__ 7 | 8 | #define __CONCAT(x,y) x ## y 9 | #define __STRING(x) #x 10 | 11 | /* This is not a typedef so `const __ptr_t' does the right thing. */ 12 | #define __ptr_t void * 13 | #ifndef __HAS_NO_FLOATS__ 14 | typedef long double __long_double_t; 15 | #endif 16 | 17 | #else 18 | 19 | #define __CONCAT(x,y) x/**/y 20 | #define __STRING(x) "x" 21 | 22 | #define __ptr_t char * 23 | 24 | #ifndef __HAS_NO_FLOATS__ 25 | typedef double __long_double_t; 26 | #endif 27 | 28 | #endif 29 | 30 | /* No C++ */ 31 | #define __BEGIN_DECLS 32 | #define __END_DECLS 33 | 34 | /* GNUish things */ 35 | #define __CONSTVALUE 36 | #define __CONSTVALUE2 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libc/include/sys/errno.h: -------------------------------------------------------------------------------- 1 | #ifndef __ERRNO_H 2 | #define __ERRNO_H 3 | 4 | #include 5 | #include __SYSINC__(errno.h) 6 | 7 | #ifdef __USE_BSD 8 | extern int sys_nerr; 9 | extern char *sys_errlist[]; 10 | #endif 11 | #ifdef __USE_GNU 12 | extern int _sys_nerr; 13 | extern char *_sys_errlist[]; 14 | #endif 15 | 16 | extern int errno; 17 | 18 | __BEGIN_DECLS 19 | 20 | extern void perror __P ((__const char* __s)); 21 | extern char* strerror __P ((int __errno)); 22 | 23 | __END_DECLS 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libc/include/sys/fcntl.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /libc/include/sys/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_FILE_H 2 | #define _SYS_FILE_H 3 | 4 | #include 5 | #include 6 | 7 | #ifndef L_SET 8 | 9 | #define L_SET 0 /* absolute offset */ 10 | #define L_INCR 1 /* relative to current offset */ 11 | #define L_XTND 2 /* relative to end of file */ 12 | 13 | #endif 14 | 15 | #ifndef LOCK_SH 16 | 17 | /* Operations for the `flock' call. */ 18 | #define LOCK_SH 1 /* Shared lock. */ 19 | #define LOCK_EX 2 /* Exclusive lock. */ 20 | #define LOCK_UN 8 /* Unlock. */ 21 | 22 | /* Can be OR'd in to one of the above. */ 23 | #define LOCK_NB 4 /* Don't block when locking. */ 24 | 25 | #endif 26 | 27 | __BEGIN_DECLS 28 | 29 | /* Apply or remove an advisory lock, according to OPERATION, 30 | on the file FD refers to. */ 31 | extern int flock __P ((int __fd, int __operation)); 32 | 33 | __END_DECLS 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libc/include/sys/ioctl.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SYS_IOCTL_H 3 | #define _SYS_IOCTL_H 4 | #include 5 | #include __SYSINC__(ioctl.h) 6 | 7 | extern int ioctl __P((int __fildes, int __cmd, ...)); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /libc/include/sys/mman.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __SYS_MMAN_H 3 | #define __SYS_MMAN_H 4 | #include 5 | #include __SYSINC__(mman.h) 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/include/sys/param.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | #ifndef _PARAM_H 7 | #define _PARAM_H 8 | 9 | #include 10 | 11 | #ifndef NR_OPEN 12 | #define NR_OPEN 32 13 | #endif 14 | #ifndef NR_FILE 15 | #define NR_FILE 32 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/include/sys/resource.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __SYS_RESOURCE_H 3 | #define __SYS_RESOURCE_H 4 | #include 5 | #include __SYSINC__(resource.h) 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/include/sys/signal.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /libc/include/sys/socket.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __SYS_SOCKET_H 3 | #define __SYS_SOCKET_H 4 | #include 5 | #include __SYSINC__(socket.h) 6 | #endif 7 | -------------------------------------------------------------------------------- /libc/include/sys/stat.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_STAT_H 2 | #define _SYS_STAT_H 3 | 4 | #include 5 | #include 6 | #include __SYSINC__(stat.h) 7 | 8 | int stat __P((__const char * __path, struct stat * __statbuf)); 9 | int lstat __P((__const char * __path, struct stat * __statbuf)); 10 | int fstat __P((int __fd, struct stat * __statbuf)); 11 | 12 | /* hysterical raisins */ 13 | #define S_IREAD S_IRUSR /* read permission, owner */ 14 | #define S_IWRITE S_IWUSR /* write permission, owner */ 15 | #define S_IEXEC S_IXUSR /* execute/search permission, owner */ 16 | #endif 17 | -------------------------------------------------------------------------------- /libc/include/sys/time.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /libc/include/sys/times.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_TIMES_H 2 | #define _SYS_TIMES_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | struct tms { 9 | clock_t tms_utime; 10 | clock_t tms_stime; 11 | clock_t tms_cutime; 12 | clock_t tms_cstime; 13 | }; 14 | 15 | __BEGIN_DECLS 16 | 17 | extern clock_t times __P ((struct tms * __tp)); 18 | 19 | __END_DECLS 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /libc/include/sys/types.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include __SYSINC__(types.h) 4 | -------------------------------------------------------------------------------- /libc/include/sys/utsname.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYS_UTSNAME_H 2 | #define __SYS_UTSNAME_H 3 | 4 | #include 5 | #include 6 | #include __SYSINC__(utsname.h) 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libc/include/sys/vm86.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYS_VM86_H 2 | #define __SYS_VM86_H 3 | #include 4 | #include __SYSINC__(vm86.h) 5 | #endif 6 | -------------------------------------------------------------------------------- /libc/include/termcap.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TERMCAP_H 3 | #define _TERMCAP_H 4 | 5 | #include 6 | #include 7 | 8 | extern char PC; 9 | extern char *UP; 10 | extern char *BC; 11 | extern int ospeed; 12 | 13 | extern int tgetent __P((char *, const char *)); 14 | extern int tgetflag __P((const char *)); 15 | extern int tgetnum __P((const char *)); 16 | extern char *tgetstr __P((const char *, char **)); 17 | 18 | extern int tputs __P((const char *, int, int (*)(int))); 19 | extern char *tgoto __P((const char *, int, int)); 20 | 21 | #endif /* _TERMCAP_H */ 22 | -------------------------------------------------------------------------------- /libc/include/termio.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /libc/include/termios.h: -------------------------------------------------------------------------------- 1 | #ifndef __TERMIOS_H 2 | #define __TERMIOS_H 3 | 4 | #include 5 | #include 6 | #include __SYSINC__(termios.h) 7 | 8 | extern speed_t cfgetispeed __P ((struct termios *__termios_p)); 9 | extern speed_t cfgetospeed __P ((struct termios *__termios_p)); 10 | extern int cfsetispeed __P ((struct termios *__termios_p, speed_t __speed)); 11 | extern int cfsetospeed __P ((struct termios *__termios_p, speed_t __speed)); 12 | 13 | extern void cfmakeraw __P ((struct termios *__t)); 14 | 15 | extern int tcsetattr __P ((int __fd, int __opt, struct termios *__termios_p)); 16 | extern int tcgetattr __P ((int __fildes, struct termios *__termios_p)); 17 | extern int tcdrain __P ((int __fildes)); 18 | extern int tcflow __P ((int __fildes, int __action)); 19 | extern int tcflush __P ((int __fildes, int __queue_selector)); 20 | extern int tcsendbreak __P ((int __fildes, int __duration)); 21 | extern pid_t tcgetpgrp __P ((int __fildes)); 22 | extern int tcsetpgrp __P ((int __fildes, pid_t __pgrp_id)); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libc/include/unistd.h: -------------------------------------------------------------------------------- 1 | /* unistd.h */ 2 | #include 3 | #include 4 | 5 | #ifndef __UNISTD_H 6 | #define __UNISTD_H 7 | 8 | #define STDIN_FILENO 0 9 | #define STDOUT_FILENO 1 10 | #define STDERR_FILENO 2 11 | 12 | extern int close __P ((int)); 13 | extern size_t read __P ((int __fd, char * __buf, size_t __nbytes)); 14 | extern size_t write __P ((int __fd, __const char * __buf, size_t __n)); 15 | extern off_t lseek __P ((int __fd, off_t __n, int __whence)); 16 | extern int pipe __P ((int __pipedes[2])); 17 | extern unsigned int alarm __P ((unsigned int __seconds)); 18 | extern unsigned int sleep __P ((unsigned int __seconds)); 19 | extern int pause __P ((void)); 20 | extern char* crypt __P((__const char *__key, __const char *__salt)); 21 | 22 | #ifndef SEEK_SET 23 | #define SEEK_SET 0 24 | #define SEEK_CUR 1 25 | #define SEEK_END 2 26 | #endif 27 | 28 | #ifndef R_OK 29 | #define R_OK 4 /* Test for read permission. */ 30 | #define W_OK 2 /* Test for write permission. */ 31 | #define X_OK 1 /* Test for execute permission. */ 32 | #define F_OK 0 /* Test for existence. */ 33 | #endif 34 | 35 | #define _POSIX_VDISABLE '\0' 36 | 37 | #endif /* __UNISTD_H */ 38 | 39 | 40 | -------------------------------------------------------------------------------- /libc/include/utime.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTIME_H 2 | #define __UTIME_H 3 | 4 | #include 5 | #include 6 | 7 | struct utimbuf { 8 | time_t actime; 9 | time_t modtime; 10 | }; 11 | 12 | extern int utime __P ((char *__filename, struct utimbuf *__utimebuf)); 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /libc/include/varargs.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __VARARGS_H 3 | #define __VARARGS_H 4 | 5 | typedef char *va_list; 6 | 7 | #define va_dcl va_list va_alist; 8 | #define va_start(ap) ap = (va_list)&va_alist 9 | #define va_arg(ap,t) ((t *)(ap += sizeof(t)))[-1] 10 | #define va_end(ap) ap = NULL 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /libc/kinclude/Config: -------------------------------------------------------------------------------- 1 | kinc: Example kernel include files and syscall.dat 2 | -------------------------------------------------------------------------------- /libc/kinclude/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1995,1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | all: 6 | @: 7 | 8 | transfer: 9 | -@rm -f ../include/linuxmt ../include/arch 10 | ln -s ../kinclude/linuxmt ../include 11 | ln -s ../kinclude/arch ../include 12 | 13 | clean: 14 | -rm -f ../include/linuxmt ../include/arch 15 | -------------------------------------------------------------------------------- /libc/kinclude/arch/ioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Nothing here yet. 3 | */ 4 | 5 | #ifndef __ARCH_8086_IOCTL_H 6 | #define __ARCH_8086_IOCTL_H 7 | 8 | 9 | #endif /* __ARCH_8086_IOCTL_H */ 10 | -------------------------------------------------------------------------------- /libc/kinclude/arch/stat.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_8086_STAT_H 2 | #define __ARCH_8086_STAT_H 3 | 4 | struct stat { 5 | dev_t st_dev; 6 | ino_t st_ino; 7 | mode_t st_mode; 8 | nlink_t st_nlink; 9 | uid_t st_uid; 10 | gid_t st_gid; 11 | dev_t st_rdev; 12 | off_t st_size; 13 | time_t st_atime; 14 | time_t st_mtime; 15 | time_t st_ctime; 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libc/kinclude/arch/types.h: -------------------------------------------------------------------------------- 1 | /* arch/i86/include/asm/types.h - Basic Linux/MT data types. */ 2 | 3 | #ifndef __ARCH_8086_TYPES 4 | #define __ARCH_8086_TYPES 5 | 6 | #include 7 | 8 | struct _registers { 9 | __u16 ksp, sp, ss, ax, bx, cx, dx, di, si, ds, es, bp, ip, cs, flags; 10 | }; 11 | 12 | typedef struct _registers __registers; 13 | typedef struct _registers * __pregisters; 14 | 15 | typedef __u32 __pptr; 16 | 17 | struct _mminit { 18 | __u16 cs, endcs, ds, endds, ss, endss, lowss; 19 | }; 20 | 21 | typedef struct _mminit __arch_mminit; 22 | typedef struct _mminit * __parch_mminit; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libc/kinclude/linuxmt/errno.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /libc/kinclude/linuxmt/ioctl.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /libc/kinclude/linuxmt/types.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUXMT_TYPES_H 2 | #define __LINUXMT_TYPES_H 3 | 4 | #include 5 | 6 | typedef __u32 off_t; 7 | typedef __u16 pid_t; 8 | typedef __u16 uid_t; 9 | typedef __u16 gid_t; 10 | typedef __u32 time_t; 11 | typedef __u16 umode_t; 12 | typedef __u16 nlink_t; 13 | typedef __u16 mode_t; 14 | typedef __u32 loff_t; 15 | typedef __u32 speed_t; 16 | typedef __u16 size_t; 17 | 18 | typedef __u16 dev_t; 19 | typedef __uint ino_t; 20 | typedef __u32 tcflag_t; 21 | typedef __u8 cc_t; 22 | 23 | typedef int ptrdiff_t; 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /libc/malloc/Config: -------------------------------------------------------------------------------- 1 | malloc: Malloc routines 2 | -------------------------------------------------------------------------------- /libc/malloc/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1995,1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | ASRC=malloc.c 6 | AOBJ=malloc.o alloca.o free.o calloc.o realloc.o 7 | 8 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 9 | 10 | all: $(LIBC)($(AOBJ)) 11 | @$(RM) $(OBJ) 12 | 13 | $(LIBC)($(AOBJ)): $(ASRC) 14 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 15 | $(AR) $(ARFLAGS) $@ $*.o 16 | 17 | clean: 18 | rm -f *.o libc.a ../include/malloc.h 19 | 20 | transfer: 21 | -@rm ../include/malloc.h 22 | cp -p malloc.h ../include/. 23 | -------------------------------------------------------------------------------- /libc/malloc/README: -------------------------------------------------------------------------------- 1 | Copyright (C) 1995,1996 Robert de Bath 2 | This file is part of the Linux-8086 C library and is distributed 3 | under the GNU Library General Public License. 4 | 5 | This is a combined alloca/malloc package. It uses a classic algorithm 6 | and so may be seen to be quite slow compared to more modern routines 7 | with 'nasty' distributions of allocation. 8 | 9 | -Robert 10 | -------------------------------------------------------------------------------- /libc/malloc/malloc.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __MALLOC_H 3 | #define __MALLOC_H 4 | #include 5 | #include 6 | 7 | /* 8 | * Mini malloc allows you to use a less efficient but smaller malloc the 9 | * cost is about 100 bytes of code in free but malloc (700bytes) doesn't 10 | * have to be linked. Unfortunatly memory can only be reused if everything 11 | * above it has been freed 12 | * 13 | */ 14 | 15 | extern void free __P((void *)); 16 | extern void *malloc __P((size_t)); 17 | extern void *realloc __P((void *, size_t)); 18 | extern void *alloca __P((size_t)); 19 | 20 | extern void *(*__alloca_alloc) __P((size_t)); 21 | 22 | #ifdef __LIBC__ 23 | #define __MINI_MALLOC__ 24 | #endif 25 | 26 | #ifdef __MINI_MALLOC__ 27 | #define malloc(x) ((*__alloca_alloc)(x)) 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /libc/misc/Config: -------------------------------------------------------------------------------- 1 | misc: Various unix lib functions 2 | -------------------------------------------------------------------------------- /libc/misc/atof.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | double 7 | #ifdef __STDC__ 8 | atof(const char *p) 9 | #else 10 | atof(p) 11 | char *p; 12 | #endif 13 | { 14 | return strtod(p, (char**)0); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /libc/misc/atoi.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995,1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | int 7 | atoi(number) 8 | register char *number; 9 | { 10 | register int n = 0, neg = 0; 11 | 12 | while (*number <= ' ' && *number > 0) 13 | ++number; 14 | if (*number == '-') 15 | { 16 | neg = 1; 17 | ++number; 18 | } 19 | else if (*number == '+') 20 | ++number; 21 | while (*number>='0' && *number<='9') 22 | n = (n * 10) + ((*number++) - '0'); 23 | return (neg ? -n : n); 24 | } 25 | -------------------------------------------------------------------------------- /libc/misc/atol.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995,1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | long 7 | atol(number) 8 | register char *number; 9 | { 10 | register long n = 0, neg = 0; 11 | 12 | while (*number <= ' ' && *number > 0) 13 | ++number; 14 | if (*number == '-') 15 | { 16 | neg = 1; 17 | ++number; 18 | } 19 | else if (*number == '+') 20 | ++number; 21 | while (*number>='0' && *number<='9') 22 | n = (n * 10) + ((*number++) - '0'); 23 | return (neg ? -n : n); 24 | } 25 | -------------------------------------------------------------------------------- /libc/misc/bsearch.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * This file lifted in toto from 'Dlibs' on the atari ST (RdeBath) 4 | * 5 | * 6 | * Dale Schumacher 399 Beacon Ave. 7 | * (alias: Dalnefre') St. Paul, MN 55104 8 | * dal@syntel.UUCP United States of America 9 | * "It's not reality that's important, but how you perceive things." 10 | */ 11 | #include 12 | 13 | static int _bsearch; /* index of element found, or where to 14 | * insert */ 15 | 16 | char * 17 | bsearch(key, base, num, size, cmp) 18 | register char *key; /* item to search for */ 19 | register char *base; /* base address */ 20 | int num; /* number of elements */ 21 | register int size; /* element size in bytes */ 22 | register int (*cmp) (); /* comparison function */ 23 | { 24 | register int a, b, c, dir; 25 | 26 | a = 0; 27 | b = num - 1; 28 | while (a <= b) 29 | { 30 | c = (a + b) >> 1; /* == ((a + b) / 2) */ 31 | if (dir = (*cmp) ((base + (c * size)), key)) 32 | { 33 | if (dir > 0) 34 | b = c - 1; 35 | else /* (dir < 0) */ 36 | a = c + 1; 37 | } 38 | else 39 | { 40 | _bsearch = c; 41 | return (base + (c * size)); 42 | } 43 | } 44 | _bsearch = b; 45 | return (NULL); 46 | } 47 | -------------------------------------------------------------------------------- /libc/misc/ctypefn.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995,1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | /* 7 | * CTYPE.C Character classification and conversion 8 | */ 9 | 10 | #include 11 | 12 | #undef toupper 13 | #undef tolower 14 | 15 | int toupper(c) 16 | int c; 17 | { 18 | return(islower(c) ? (c ^ 0x20) : (c)); 19 | } 20 | 21 | int tolower(c) 22 | int c; 23 | { 24 | return(isupper(c) ? (c ^ 0x20) : (c)); 25 | } 26 | -------------------------------------------------------------------------------- /libc/misc/getenv.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995,1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | extern char ** environ; 7 | 8 | char * 9 | getenv(name) 10 | char * name; 11 | { 12 | register int l; 13 | register char ** ep = environ; 14 | l = strlen(name); 15 | 16 | if( ep == 0 || l == 0 ) return 0; 17 | 18 | while(*ep) 19 | { 20 | if( **ep == *name && memcmp(name, *ep, l) == 0 && (*ep)[l] == '=' ) 21 | return *ep+l+1; 22 | ep++; 23 | } 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /libc/misc/itoa.c: -------------------------------------------------------------------------------- 1 | /* itoa.c */ 2 | #define __MAX_INT_CHARS 7 3 | 4 | char * 5 | itoa(i) 6 | int i; 7 | { 8 | static char a[__MAX_INT_CHARS]; 9 | char *b = a + sizeof(a) - 1; 10 | int sign = (i < 0); 11 | 12 | if (sign) 13 | i = -i; 14 | *b = 0; 15 | do 16 | { 17 | *--b = '0' + (i % 10); 18 | i /= 10; 19 | } 20 | while (i); 21 | if (sign) 22 | *--b = '-'; 23 | return b; 24 | } 25 | -------------------------------------------------------------------------------- /libc/misc/lsearch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file lifted in toto from 'Dlibs' on the atari ST (RdeBath) 3 | * 4 | * 5 | * Dale Schumacher 399 Beacon Ave. 6 | * (alias: Dalnefre') St. Paul, MN 55104 7 | * dal@syntel.UUCP United States of America 8 | * "It's not reality that's important, but how you perceive things." 9 | */ 10 | 11 | #include 12 | 13 | char * 14 | lfind(key, base, num, size, cmp) 15 | register char *key, *base; 16 | unsigned int *num; 17 | register unsigned int size; 18 | register int (*cmp) (); 19 | { 20 | register int n = *num; 21 | 22 | while (n--) 23 | { 24 | if ((*cmp) (base, key) == 0) 25 | return (base); 26 | base += size; 27 | } 28 | return (NULL); 29 | } 30 | 31 | char * 32 | lsearch(key, base, num, size, cmp) 33 | char *key, *base; 34 | register unsigned int *num; 35 | register unsigned int size; 36 | int (*cmp) (); 37 | { 38 | register char *p; 39 | char *memcpy(); 40 | 41 | if ((p = lfind(key, base, num, size, cmp)) == NULL) 42 | { 43 | p = memcpy((base + (size * (*num))), key, size); 44 | ++(*num); 45 | } 46 | return (p); 47 | } 48 | -------------------------------------------------------------------------------- /libc/misc/ltoa.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995,1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | static char buf[12]; 7 | 8 | extern char * ultoa(); 9 | 10 | char * ltoa(val) 11 | long val; 12 | { 13 | char *p; 14 | int flg = 0; 15 | if( val < 0 ) { flg++; val= -val; } 16 | p = ultoa(val); 17 | if(flg) *--p = '-'; 18 | return p; 19 | } 20 | 21 | char * ultoa(val) 22 | unsigned long val; 23 | { 24 | char *p; 25 | 26 | p = buf+sizeof(buf); 27 | *--p = '\0'; 28 | 29 | do 30 | { 31 | *--p = '0' + val%10; 32 | val/=10; 33 | } 34 | while(val); 35 | return p; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /libc/misc/ltostr.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995,1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | static char buf[34]; 7 | 8 | extern char * ultostr(); 9 | 10 | char * ltostr(val, radix) 11 | long val; 12 | int radix; 13 | { 14 | char *p; 15 | int flg = 0; 16 | if( val < 0 ) { flg++; val= -val; } 17 | p = ultostr(val, radix); 18 | if(p && flg) *--p = '-'; 19 | return p; 20 | } 21 | 22 | char * ultostr(val, radix) 23 | unsigned long val; 24 | int radix; 25 | { 26 | register char *p; 27 | register int c; 28 | 29 | if( radix > 36 || radix < 2 ) return 0; 30 | 31 | p = buf+sizeof(buf); 32 | *--p = '\0'; 33 | 34 | do 35 | { 36 | c = val%radix; 37 | val/=radix; 38 | if( c > 9 ) *--p = 'a'-10+c; else *--p = '0'+c; 39 | } 40 | while(val); 41 | return p; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /libc/misc/popen.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | 5 | FILE * popen(command, rw) 6 | char * command; 7 | char * rw; 8 | { 9 | int pipe_fd[2]; 10 | int pid, reading; 11 | 12 | if( pipe(pipe_fd) < 0 ) return NULL; 13 | reading = (rw[0] == 'r'); 14 | 15 | pid = vfork(); 16 | if( pid < 0 ) { close(pipe_fd[0]); close(pipe_fd[1]); return NULL; } 17 | if( pid == 0 ) 18 | { 19 | close(pipe_fd[!reading]); 20 | close(reading); 21 | if( pipe_fd[reading] != reading ) 22 | { 23 | dup2(pipe_fd[reading], reading); 24 | close(pipe_fd[reading]); 25 | } 26 | 27 | execl("/bin/sh", "sh", "-c", command, (char*)0); 28 | _exit(255); 29 | } 30 | 31 | close(pipe_fd[reading]); 32 | return fdopen(pipe_fd[!reading], rw); 33 | } 34 | 35 | int pclose(fd) 36 | FILE *fd; 37 | { 38 | int waitstat; 39 | if( fclose(fd) != 0 ) return EOF; 40 | wait(&waitstat); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /libc/misc/putenv.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995,1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | #include 6 | #include 7 | #include 8 | 9 | extern char ** environ; 10 | #define ADD_NUM 4 11 | 12 | int 13 | putenv(var) 14 | char * var; 15 | { 16 | static char ** mall_env = 0; 17 | static int extras = 0; 18 | char **p, **d; 19 | char * r; 20 | int len; 21 | 22 | r = strchr(var, '='); 23 | if( r == 0 ) len = strlen(var); 24 | else len = r-var; 25 | 26 | for(p=environ; *p; p++) 27 | { 28 | if( memcmp(var, *p, len) == 0 && (*p)[len] == '=' ) 29 | { 30 | while( p[0] = p[1] ) p++; 31 | extras++; 32 | break; 33 | } 34 | } 35 | if( r == 0 ) return 0; 36 | if( extras <= 0 ) /* Need more space */ 37 | { 38 | d = malloc((p-environ+1+ADD_NUM)*sizeof(char*)); 39 | if( d == 0 ) return -1; 40 | 41 | memcpy((void*) d, (void*) environ, (p-environ+1)*sizeof(char*)); 42 | p = d + (p-environ); 43 | extras=ADD_NUM; 44 | 45 | if( mall_env ) free(mall_env); 46 | environ = d; 47 | mall_env = d; 48 | } 49 | *p++ = var; 50 | *p = '\0'; 51 | extras--; 52 | 53 | return 0; 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /libc/misc/rand.c: -------------------------------------------------------------------------------- 1 | #ifdef ZX81_RNG 2 | /* 3 | * This is my favorite tiny RNG, If you had a ZX81 you may recognise it :-) 4 | * (RdeBath) 5 | */ 6 | 7 | #include 8 | 9 | #define MAXINT (((unsigned)-1)>>1) 10 | 11 | static unsigned int sseed = 0; 12 | 13 | int rand() 14 | { 15 | return ( sseed = (((sseed+1L)*75L)%65537L)-1 ) & MAXINT; 16 | } 17 | 18 | void srand(seed) 19 | unsigned int seed; 20 | { 21 | sseed=seed; 22 | } 23 | 24 | #else 25 | 26 | /* 27 | * This generator is a combination of three linear congruential generators 28 | * with periods or 2^15-405, 2^15-1041 and 2^15-1111. It has a period that 29 | * is the product of these three numbers. 30 | */ 31 | 32 | static int seed1 = 1; 33 | static int seed2 = 1; 34 | static int seed3 = 1; 35 | #define MAXINT (((unsigned)-1)>>1) 36 | 37 | #define CRANK(a,b,c,m,s) \ 38 | q = s/a; \ 39 | s = b*(s-a*q) - c*q; \ 40 | if(s<0) s+=m; 41 | 42 | int rand() 43 | { 44 | register int q, z; 45 | CRANK(206, 157, 31, 32363, seed1); 46 | CRANK(217, 146, 45, 31727, seed2); 47 | CRANK(222, 142, 133, 31657, seed3); 48 | 49 | return seed1^seed2^seed3; 50 | } 51 | 52 | void srand(seed) 53 | unsigned int seed; 54 | { 55 | seed &= MAXINT; 56 | seed1= seed%32362 + 1; 57 | seed2= seed%31726 + 1; 58 | seed3= seed%31656 + 1; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /libc/misc/system.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int 6 | system(command) 7 | char * command; 8 | { 9 | int wait_val, wait_ret, pid; 10 | __sighandler_t save_quit; 11 | __sighandler_t save_int; 12 | 13 | if( command == 0 ) return 1; 14 | 15 | save_quit = signal(SIGQUIT, SIG_IGN); 16 | save_int = signal(SIGINT, SIG_IGN); 17 | 18 | if( (pid=vfork()) < 0 ) 19 | { 20 | signal(SIGQUIT, save_quit); 21 | signal(SIGINT, save_int); 22 | return -1; 23 | } 24 | if( pid == 0 ) 25 | { 26 | signal(SIGQUIT, SIG_DFL); 27 | signal(SIGINT, SIG_DFL); 28 | 29 | execl("/bin/sh", "sh", "-c", command, (char*)0); 30 | _exit(127); 31 | } 32 | /* Signals are not absolutly guarenteed with vfork */ 33 | signal(SIGQUIT, SIG_IGN); 34 | signal(SIGINT, SIG_IGN); 35 | 36 | do 37 | { 38 | if( (wait_ret = wait(&wait_val)) == -1 ) 39 | { 40 | wait_val = -1; 41 | break; 42 | } 43 | } 44 | while( wait_ret != pid ); 45 | 46 | signal(SIGQUIT, save_quit); 47 | signal(SIGINT, save_int); 48 | return wait_val; 49 | } 50 | -------------------------------------------------------------------------------- /libc/misc/tmpnam.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Shane Kerr under terms of LGPL 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #ifndef P_tmpdir 10 | #define P_tmpdir "/tmp" 11 | #endif 12 | 13 | #ifndef L_tmpnam 14 | #define L_tmpnam 20 15 | #endif 16 | 17 | char *tmpnam(s) 18 | char *s; 19 | { 20 | static char ret_val[L_tmpnam]; 21 | static char c1 = 0; 22 | static char c2 = 0; 23 | static char c3 = 0; 24 | static char uniq_ch[] = 25 | "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 26 | struct stat stbuf; 27 | 28 | do { 29 | sprintf(ret_val, "%s/%05d%c%c%c", P_tmpdir, getpid(), 30 | uniq_ch[c1], uniq_ch[c2], uniq_ch[c3]); 31 | if (++c1 >= 62) { 32 | c1 = 0; 33 | if (++c2 >= 62) { 34 | c2 = 0; 35 | if (++c3 >= 62) { 36 | errno = EEXIST; 37 | return 0; 38 | } 39 | } 40 | } 41 | } while (stat(ret_val, &stbuf) == 0); 42 | 43 | if (s != 0) { 44 | strcpy(s, ret_val); 45 | return s; 46 | } else { 47 | return ret_val; 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /libc/msdos/Config: -------------------------------------------------------------------------------- 1 | msdos: Msdos system calls 2 | -------------------------------------------------------------------------------- /libc/msdos/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1995,1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | ASRC=msdos.c 6 | AOBJ= \ 7 | dos_start.o __exterror.o __mkargv.o __mkenvp.o bdos.o \ 8 | dos__fconv.o dos_abort.o dos_close.o dos_getmod.o dos_getvect.o \ 9 | dos_isatty.o dos_lseek.o dos_open.o dos_read.o dos_segalloc.o \ 10 | dos_segfree.o dos_setvect.o dos_stat.o dos_unlink.o dos_write.o 11 | 12 | BSRC=i86.c 13 | BOBJ= __seg_regs.o __peek_es.o __poke_es.o __deek_es.o __doke_es.o \ 14 | __strnget_es.o __strchr_es.o __strlen_es.o int86.o int86x.o segread.o 15 | 16 | ifeq ($(LIB_CPU),i86) 17 | ifeq ($(LIB_OS),DOS) 18 | OBJ=$(AOBJ) $(BOBJ) time.o sound.o 19 | else 20 | OBJ=$(BOBJ) 21 | endif 22 | 23 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 24 | 25 | all: $(LIBC) 26 | @$(RM) $(OBJ) 27 | 28 | $(LIBC): $(LIBC)($(OBJ)) 29 | 30 | $(LIBC)($(AOBJ)): $(ASRC) 31 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 32 | $(AR) $(ARFLAGS) $@ $*.o 33 | 34 | $(LIBC)($(BOBJ)): $(BSRC) 35 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 36 | $(AR) $(ARFLAGS) $@ $*.o 37 | else 38 | all: 39 | @: 40 | endif 41 | 42 | clean: 43 | rm -f *.o libc.a 44 | 45 | -------------------------------------------------------------------------------- /libc/msdos/Notes: -------------------------------------------------------------------------------- 1 | This is currently a very cutdown version of the syslib. 2 | 3 | This also currently does nothing about the difference between 'TEXT' and 4 | 'BINARY' modes but I think that this level of operation should be pure 5 | binary, the 'TEXT' mode is more suited to stdio where an "fopen(f, "rb")" 6 | is more reasonable and probably won't break on other OSs. 7 | 8 | -Robert. 9 | -------------------------------------------------------------------------------- /libc/msdos/TODO: -------------------------------------------------------------------------------- 1 | #define remove(x) unlink(x) 2 | 3 | opendir 4 | 5 | closedir 6 | 7 | readdir 8 | 9 | rewinddir 10 | 11 | See also the other files, many parts are incomplete. 12 | -------------------------------------------------------------------------------- /libc/msdos/dirent.c: -------------------------------------------------------------------------------- 1 | 2 | opendir 3 | 4 | closedir 5 | 6 | readdir 7 | 8 | rewinddir 9 | -------------------------------------------------------------------------------- /libc/msdos/dosound.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | nosound() 4 | { 5 | } 6 | 7 | sound(freq) 8 | int freq 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /libc/msdos/intr.c: -------------------------------------------------------------------------------- 1 | 2 | struct REGPACK 3 | { 4 | unsigned r_ax, r_bx, r_cx, r_dx; 5 | unsigned r_bp, r_si, r_di, r_ds, r_es, r_flags; 6 | }; 7 | 8 | /* DANGER DANGER -- Self modifying code! */ 9 | 10 | #asm 11 | .text 12 | save_sp: 13 | dw 0 14 | #endasm 15 | 16 | intr(intr, regs) 17 | int intr; 18 | struct REGPACK * regs; 19 | { 20 | #asm 21 | mov bx,sp 22 | push bp 23 | push si 24 | push di 25 | push es 26 | push ds 27 | 28 | mov ax,[bx+2] 29 | seg cs 30 | mov [intr_inst+1],al 31 | seg cs 32 | mov [save_sp],sp 33 | 34 | mov bx,[bx+4] 35 | 36 | mov ah,[bx+18] ! Flags low byte 37 | sahf 38 | 39 | mov ax,[bx] 40 | push [bx+2] 41 | mov cx,[bx+4] 42 | mov dx,[bx+6] 43 | mov bp,[bx+8] 44 | mov si,[bx+10] 45 | mov di,[bx+12] 46 | mov es,[bx+16] 47 | mov ds,[bx+14] 48 | pop bx 49 | 50 | intr_inst: 51 | int $FF ! Must be a real int .. consider protected mode. 52 | 53 | seg cs ! Could be SS as DS==SS 54 | mov sp,[save_sp] 55 | seg cs 56 | mov [save_sp],ds 57 | pop ds 58 | push [save_sp] 59 | 60 | push bx 61 | mov bx,sp 62 | mov bx,[bx+12] 63 | 64 | mov [bx],ax 65 | pop [bx+2] 66 | mov [bx+4],cx 67 | mov [bx+6],dx 68 | mov [bx+8],bp 69 | mov [bx+10],si 70 | mov [bx+12],di 71 | pop [bx+14] 72 | mov [bx+16],es 73 | pushf 74 | pop [bx+18] 75 | 76 | pop es 77 | pop di 78 | pop si 79 | pop bp 80 | 81 | #endasm 82 | } 83 | -------------------------------------------------------------------------------- /libc/msdos/new86.c: -------------------------------------------------------------------------------- 1 | 2 | #define disable() _disable() 3 | #define enable() _enable() 4 | 5 | _enable() 6 | { 7 | #asm 8 | sti 9 | #endasm 10 | } 11 | 12 | _disable() 13 | { 14 | #asm 15 | cli 16 | #endasm 17 | } 18 | 19 | geninterrupt(intr) 20 | int intr; 21 | { 22 | } 23 | 24 | inp(portno) 25 | int portno; 26 | { 27 | } 28 | 29 | inpw(portno) 30 | int portno; 31 | { 32 | } 33 | 34 | outp(...) 35 | { 36 | } 37 | 38 | outpw(...) 39 | { 40 | } 41 | 42 | peek(segment, offset) 43 | unsigned segment, offset; 44 | { 45 | } 46 | 47 | peekb(segment, offset) 48 | unsigned segment, offset; 49 | { 50 | } 51 | 52 | poke(segment, offset, value) 53 | unsigned segment, offset, value; 54 | { 55 | } 56 | 57 | pokeb(segment, offset, value) 58 | unsigned segment, offset, value; 59 | { 60 | } 61 | -------------------------------------------------------------------------------- /libc/msdos/sound.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | static int port_val = -1; 5 | 6 | sound(freq) 7 | unsigned freq; /* freq is in hertz */ 8 | { 9 | if(port_val == -1 ) 10 | port_val = inp(0x61); 11 | 12 | freq = 1193180L / freq; 13 | 14 | outp(0x61, port_val|3); 15 | outp(0x43, 0xb6); 16 | outp(0x42, freq&0xFF); 17 | outp(0x42, (freq>>8)&0xFF); 18 | } 19 | 20 | nosound() 21 | { 22 | if( port_val ) 23 | outp(0x61, port_val); 24 | else 25 | outp(0x61, inp(0x61)&~3); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /libc/regexp/Config: -------------------------------------------------------------------------------- 1 | regexp: Regular expression lib 2 | -------------------------------------------------------------------------------- /libc/regexp/Makefile: -------------------------------------------------------------------------------- 1 | 2 | OBJ=regexp.o regsub.o 3 | LSRC=regexp.c regsub.c regerror.c 4 | 5 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 6 | 7 | all: $(LIBC) 8 | @$(RM) $(OBJ) 9 | 10 | $(LIBC): $(LIBC)($(OBJ)) 11 | 12 | transfer: 13 | -@rm -f ../include/regexp.h ../include/regmagic.h 14 | cp -p regexp.h regmagic.h ../include/. 15 | 16 | $(LIBC)(regexp.o): regexp.c regexp.h regmagic.h 17 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 18 | $(AR) $(ARFLAGS) $@ $*.o 19 | 20 | $(LIBC)(regsub.o): regsub.c regexp.h regmagic.h 21 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 22 | $(AR) $(ARFLAGS) $@ $*.o 23 | 24 | clean: 25 | rm -f libc.a *.o core mon.out timer.t.h dMakefile dtr try timer 26 | rm -f ../include/regexp.h ../include/regmagic.h 27 | -------------------------------------------------------------------------------- /libc/regexp/README.rdb: -------------------------------------------------------------------------------- 1 | 2 | I've applied the four bugfix patches I've found and made a couple of 3 | very small changes (added malloc.h) and put in a new Makefile. 4 | Otherwise this is as it was posted on by Henry Spencer to mod.sources. 5 | 6 | -Robert 7 | -------------------------------------------------------------------------------- /libc/regexp/patch.1: -------------------------------------------------------------------------------- 1 | Subject: bug in regexp(3), and fix 2 | Newsgroups: mod.sources 3 | Approved: jpn@panda.UUCP 4 | 5 | Mod.sources: Volume 3, Issue 105 6 | Submitted by: genrad!decvax!utzoo!henry 7 | 8 | Drat! Chris Siebenmann at CSRI just found a bug in my regexp(3) routines. 9 | The problem is that the code for character classes does not check properly 10 | for the possibility that it might be looking at the end of the string. By 11 | simple bad luck none of my test cases hit this. To fix it, make the 12 | following two changes to regexp.c: 13 | 14 | 848c848 15 | < if (strchr(OPERAND(scan), *reginput) == NULL) 16 | --- 17 | > if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL) 18 | 853c853 19 | < if (strchr(OPERAND(scan), *reginput) != NULL) 20 | --- 21 | > if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL) 22 | 23 | and recompile. Also, add the following line to the "tests" file: 24 | 25 | [k] ab n - - 26 | 27 | My thanks to Chris for finding this. 28 | 29 | Henry Spencer @ U of Toronto Zoology 30 | {allegra,ihnp4,linus,decvax}!utzoo!henry 31 | 32 | 33 | -------------------------------------------------------------------------------- /libc/regexp/patch.2: -------------------------------------------------------------------------------- 1 | Subject: 2nd bug fix for regexp(3), in regsub() 2 | Newsgroups: mod.sources 3 | Approved: jpn@panda.UUCP 4 | 5 | Mod.sources: Volume 4, Issue 33 6 | Submitted by: genrad!decvax!utzoo!henry 7 | 8 | I cringe with embarrassment! Another bug in regexp! In regsub.c, the 9 | following line (line 72 in the original distribution): 10 | 11 | if (*(dst-1) == '\0') { /* strncpy hit NUL. */ 12 | 13 | should read 14 | 15 | if (len != 0 && *(dst-1) == '\0') { /* strncpy hit NUL. */ 16 | 17 | This shows up as an occasional spurious complaint from regsub about 18 | "damaged match string"... *if* the program invoking it, and the compiler 19 | compiling it, happen to interact just right. It didn't show in any of 20 | my tests because mine don't. 21 | 22 | My thanks to H}vard Eidnes for finding this. 23 | 24 | Henry Spencer @ U of Toronto Zoology 25 | {allegra,ihnp4,linus,decvax}!utzoo!henry 26 | 27 | 28 | -------------------------------------------------------------------------------- /libc/regexp/regerror.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void 4 | regerror(s) 5 | char *s; 6 | { 7 | #ifdef ERRAVAIL 8 | error("regexp: %s", s); 9 | #else 10 | fprintf(stderr, "regexp(3): %s", s); 11 | exit(1); 12 | #endif 13 | /* NOTREACHED */ 14 | } 15 | -------------------------------------------------------------------------------- /libc/regexp/regexp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions etc. for regexp(3) routines. 3 | * 4 | * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], 5 | * not the System V one. 6 | */ 7 | #define NSUBEXP 10 8 | typedef struct regexp { 9 | char *startp[NSUBEXP]; 10 | char *endp[NSUBEXP]; 11 | char regstart; /* Internal use only. */ 12 | char reganch; /* Internal use only. */ 13 | char *regmust; /* Internal use only. */ 14 | int regmlen; /* Internal use only. */ 15 | char program[1]; /* Unwarranted chumminess with compiler. */ 16 | } regexp; 17 | 18 | extern regexp *regcomp(); 19 | extern int regexec(); 20 | extern void regsub(); 21 | extern void regerror(); 22 | -------------------------------------------------------------------------------- /libc/regexp/regmagic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The first byte of the regexp internal "program" is actually this magic 3 | * number; the start node begins in the second byte. 4 | */ 5 | #define MAGIC 0234 6 | -------------------------------------------------------------------------------- /libc/stdio/Config: -------------------------------------------------------------------------------- 1 | # 2 | 3 | stdio: Stdio package 4 | 5 | -------------------------------------------------------------------------------- /libc/stdio/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1995,1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | ifneq ($(LIB_CPU),i86) 6 | CFLAGS=$(CCFLAGS) $(LIBDEFS) -DFLOATS 7 | endif 8 | 9 | ASRC=stdio.c 10 | AOBJ=_stdio_init.o fputc.o fgetc.o fflush.o fgets.o gets.o fputs.o \ 11 | puts.o fread.o fwrite.o fopen.o fdopen.o freopen.o __fopen.o \ 12 | fclose.o fseek.o rewind.o ftell.o setbuffer.o setvbuf.o ungetc.o 13 | 14 | PSRC=printf.c 15 | POBJ=printf.o sprintf.o fprintf.o vprintf.o vsprintf.o vfprintf.o fp_print.o 16 | 17 | SSRC=scanf.c 18 | SOBJ=scanf.o sscanf.o fscanf.o vscanf.o vsscanf.o vfscanf.o 19 | 20 | OBJ= $(AOBJ) $(POBJ) $(SOBJ) 21 | 22 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 23 | 24 | all: $(LIBC) 25 | @$(RM) $(OBJ) 26 | 27 | $(LIBC): $(LIBC)($(OBJ)) 28 | 29 | $(LIBC)($(AOBJ)): $(ASRC) 30 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 31 | $(AR) $(ARFLAGS) $@ $*.o 32 | 33 | $(LIBC)($(POBJ)): $(PSRC) 34 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 35 | $(AR) $(ARFLAGS) $@ $*.o 36 | 37 | $(LIBC)($(SOBJ)): $(SSRC) 38 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 39 | $(AR) $(ARFLAGS) $@ $*.o 40 | 41 | transfer: 42 | -@rm -f ../include/stdio.h 43 | cp -p stdio.h ../include/. 44 | 45 | clean: 46 | rm -f *.o libc.a ../include/stdio.h 47 | 48 | $(LIBC)($(OBJ)): stdio.h 49 | 50 | -------------------------------------------------------------------------------- /libc/string/Config: -------------------------------------------------------------------------------- 1 | string: String and memory manipulation 2 | -------------------------------------------------------------------------------- /libc/string/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1995,1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | SSRC=string.c 6 | SOBJ=strlen.o strcat.o strcpy.o strcmp.o strncat.o strncpy.o strncmp.o \ 7 | strchr.o strrchr.o strdup.o memcpy.o memccpy.o memchr.o memset.o \ 8 | memcmp.o memmove.o movedata.o 9 | 10 | OBJ=$(SOBJ) strpbrk.o strsep.o strstr.o strtok.o strcspn.o \ 11 | strspn.o strcasecmp.o strncasecmp.o 12 | 13 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 14 | 15 | all: $(LIBC) 16 | @$(RM) $(OBJ) 17 | 18 | $(LIBC): $(LIBC)($(OBJ)) 19 | 20 | $(LIBC)($(SOBJ)): $(SSRC) 21 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 22 | $(AR) $(ARFLAGS) $@ $*.o 23 | 24 | transfer: 25 | -@rm -f ../include/string.h 26 | cp -p string.h ../include/. 27 | 28 | clean: 29 | rm -f *.o ../include/string.h 30 | -------------------------------------------------------------------------------- /libc/string/strcasecmp.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995,1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | int 10 | strcasecmp(s, d) 11 | char *s; 12 | char *d; 13 | { 14 | for(;;) 15 | { 16 | if( *s != *d ) 17 | { 18 | if( tolower(*s) != tolower(*d) ) 19 | return *s - *d; 20 | } 21 | else if( *s == '\0' ) break; 22 | s++; d++; 23 | } 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /libc/string/strcspn.c: -------------------------------------------------------------------------------- 1 | /* strcspn.c */ 2 | 3 | /* from Schumacher's Atari library, improved */ 4 | 5 | #include 6 | 7 | size_t strcspn(string, set) 8 | register char *string; 9 | char *set; 10 | /* 11 | * Return the length of the sub-string of that consists 12 | * entirely of characters not found in . The terminating '\0' 13 | * in is not considered part of the match set. If the first 14 | * character if is in , 0 is returned. 15 | */ 16 | { 17 | register char *setptr; 18 | char *start; 19 | 20 | start = string; 21 | while (*string) 22 | { 23 | setptr = set; 24 | do 25 | if (*setptr == *string) 26 | goto break2; 27 | while (*setptr++); 28 | ++string; 29 | } 30 | break2: 31 | return string - start; 32 | } 33 | -------------------------------------------------------------------------------- /libc/string/strncasecmp.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995,1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | int 10 | strncasecmp(s, d, l) 11 | char *s; 12 | char *d; 13 | size_t l; 14 | { 15 | while(l>0) 16 | { 17 | if( *s != *d ) 18 | { 19 | if( tolower(*s) != tolower(*d) ) 20 | return *s - *d; 21 | } 22 | else 23 | if( *s == '\0' ) return 0; 24 | s++; d++; l--; 25 | } 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /libc/string/strpbrk.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995,1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | #include 7 | 8 | /* This uses strchr, strchr should be in assembler */ 9 | 10 | char *strpbrk(str, set) 11 | register char *str; 12 | char *set; 13 | { 14 | while (*str != '\0') 15 | if (strchr(set, *str) == 0) 16 | ++str; 17 | else 18 | return (char *) str; 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /libc/string/strsep.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1992, 1993 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Library General Public License as 6 | published by the Free Software Foundation; either version 2 of the 7 | License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public 15 | License along with the GNU C Library; see the file COPYING.LIB. If 16 | not, write to the Free Software Foundation, Inc., 675 Mass Ave, 17 | Cambridge, MA 02139, USA. */ 18 | 19 | #include 20 | 21 | char * 22 | strsep(pp, delim) 23 | char **pp; 24 | char *delim; 25 | { 26 | char *p, *q; 27 | 28 | if (!(p = *pp)) 29 | return 0; 30 | if (q = strpbrk (p, delim)) 31 | { 32 | *pp = q + 1; 33 | *q = '\0'; 34 | } 35 | else 36 | *pp = 0; 37 | return p; 38 | } 39 | -------------------------------------------------------------------------------- /libc/string/strspn.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1992, 1993 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Library General Public License as 6 | published by the Free Software Foundation; either version 2 of the 7 | License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public 15 | License along with the GNU C Library; see the file COPYING.LIB. If 16 | not, write to the Free Software Foundation, Inc., 675 Mass Ave, 17 | Cambridge, MA 02139, USA. */ 18 | 19 | #include 20 | 21 | /* Return the length of the maximum initial segment 22 | of S which contains only characters in ACCEPT. */ 23 | size_t 24 | strspn(s, accept) 25 | char *s; 26 | char *accept; 27 | { 28 | register char *p; 29 | register char *a; 30 | register size_t count = 0; 31 | 32 | for (p = s; *p != '\0'; ++p) 33 | { 34 | for (a = accept; *a != '\0'; ++a) 35 | if (*p == *a) 36 | break; 37 | if (*a == '\0') 38 | return count; 39 | else 40 | ++count; 41 | } 42 | 43 | return count; 44 | } 45 | -------------------------------------------------------------------------------- /libc/string/strstr.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995,1996 Robert de Bath 2 | * This file is part of the Linux-8086 C library and is distributed 3 | * under the GNU Library General Public License. 4 | */ 5 | 6 | #include 7 | 8 | #if 1 9 | /* We've now got a nice fast strchr and memcmp use them */ 10 | 11 | char * 12 | strstr(s1, s2) 13 | char *s1; char *s2; 14 | { 15 | register int l = strlen(s2); 16 | register char * p = s1; 17 | 18 | if( l==0 ) return p; 19 | 20 | while (p = strchr(p, *s2)) 21 | { 22 | if( memcmp(p, s2, l) == 0 ) 23 | return p; 24 | p++; 25 | } 26 | return (char *) 0; 27 | } 28 | 29 | #else 30 | /* This is a nice simple self contained strstr, 31 | now go and work out why the GNU one is faster :-) */ 32 | 33 | char *strstr(str1, str2) 34 | char *str1, *str2; 35 | { 36 | register char *Sptr, *Tptr; 37 | int len = strlen(str1) -strlen(str2) + 1; 38 | 39 | if (*str2) 40 | for (; len > 0; len--, str1++){ 41 | if (*str1 != *str2) 42 | continue; 43 | 44 | for (Sptr = str1, Tptr = str2; *Tptr != '\0'; Sptr++, Tptr++) 45 | if (*Sptr != *Tptr) 46 | break; 47 | 48 | if (*Tptr == '\0') 49 | return (char*) str1; 50 | } 51 | 52 | return (char*)0; 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /libc/syscall/Config: -------------------------------------------------------------------------------- 1 | syscall: Linux-8086 system call routines 2 | -------------------------------------------------------------------------------- /libc/syscall/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1995,1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | LSRC=syslib0.c 6 | LOBJ=__cstartup.o lseek.o getpid.o getppid.o getuid.o geteuid.o getgid.o \ 7 | getegid.o dup2.o getpgrp.o times.o 8 | 9 | ESRC=exec.c 10 | EOBJ=execve.o execl.o execv.o execle.o execlp.o execvp.o 11 | 12 | DSRC=dirent.c 13 | DOBJ=opendir.o closedir.o readdir.o 14 | 15 | ifeq ($(LIB_CPU)-$(LIB_OS),i86-ELKS) 16 | OBJ=$(LOBJ) $(DOBJ) $(EOBJ) signal.o setjmp.o 17 | SYSCALLS=call_i86 18 | endif 19 | 20 | ifeq ($(SYSCALLS),) 21 | OBJ=setjmp.o 22 | endif 23 | 24 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 25 | 26 | all: $(SYSCALLS) $(LIBC) 27 | @$(RM) $(OBJ) 28 | 29 | call_i86: syscall.mak 30 | $(MAKE) -f syscall.mak LIBC="$(LIBC)" CFLAGS="$(CFLAGS)" 31 | 32 | syscall.mak: mksyscall syscall.dat 33 | sh mksyscall 34 | 35 | syscall.dat: 36 | @touch syscall.dat 37 | 38 | $(LIBC): $(LIBC)($(OBJ)) 39 | 40 | $(LIBC)($(LOBJ)): $(LSRC) 41 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 42 | $(AR) $(ARFLAGS) $@ $*.o 43 | 44 | $(LIBC)($(DOBJ)): $(DSRC) 45 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 46 | $(AR) $(ARFLAGS) $@ $*.o 47 | 48 | $(LIBC)($(EOBJ)): $(ESRC) 49 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 50 | $(AR) $(ARFLAGS) $@ $*.o 51 | 52 | clean: 53 | rm -f *.o libc.a 54 | rm -f syscall.c syscall.mak syscall.dat 55 | rm -f call_tab.v defn_tab.v 56 | -------------------------------------------------------------------------------- /libc/syscall/dirent.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #ifdef L_opendir 10 | DIR * 11 | opendir(dname) 12 | const char *dname; 13 | { 14 | struct stat st; 15 | int fd; 16 | DIR *p; 17 | 18 | if (stat(dname, &st) < 0) 19 | return 0; 20 | 21 | if (!S_ISDIR(st.st_mode)) 22 | { 23 | errno = ENOTDIR; 24 | return 0; 25 | } 26 | if ((fd = open(dname, O_RDONLY)) < 0) 27 | return 0; 28 | 29 | p = malloc(sizeof(DIR)); 30 | if (p == 0) 31 | { 32 | close(fd); 33 | return 0; 34 | } 35 | 36 | p->dd_buf = malloc(sizeof(struct dirent)); 37 | if (p->dd_buf == 0) 38 | { 39 | free(p); 40 | close(fd); 41 | return 0; 42 | } 43 | p->dd_fd = fd; 44 | p->dd_loc = p->dd_size = 0; 45 | 46 | return p; 47 | } 48 | #endif 49 | 50 | #ifdef L_closedir 51 | int 52 | closedir(dirp) 53 | DIR *dirp; 54 | { 55 | int fd; 56 | fd = dirp->dd_fd; 57 | free(dirp->dd_buf); 58 | free(dirp); 59 | return close(fd); 60 | } 61 | #endif 62 | 63 | #ifdef L_readdir 64 | struct dirent * 65 | readdir(dirp) 66 | DIR *dirp; 67 | { 68 | int cc; 69 | 70 | cc = __readdir(dirp->dd_fd, dirp->dd_buf, 1); 71 | if (cc <= 0) 72 | return 0; 73 | if (cc>1) dirp->dd_buf->d_name[cc] = 0; 74 | 75 | return dirp->dd_buf; 76 | } 77 | #endif 78 | 79 | -------------------------------------------------------------------------------- /libc/syscall/setjmp.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #if __AS386_16__ 5 | 6 | int 7 | setjmp(env) 8 | jmp_buf env; 9 | { 10 | #asm 11 | export __setjmp 12 | __setjmp: 13 | 14 | pop cx ! PC 15 | #if __FIRST_ARG_IN_AX__ 16 | mov bx,ax 17 | #else 18 | mov bx,sp 19 | mov bx,[bx] ! TOS is prt -> env 20 | #endif 21 | mov [bx+0],cx ! PC 22 | mov [bx+2],sp ! This registers are all that may be constant. 23 | mov [bx+4],bp 24 | mov [bx+6],si ! Is saving these the "right thing" ? 25 | mov [bx+8],di 26 | xor ax,ax 27 | jmp cx 28 | #endasm 29 | } 30 | 31 | void 32 | longjmp(env, rv) 33 | jmp_buf env; 34 | int rv; 35 | { 36 | #asm 37 | export __longjmp 38 | __longjmp: 39 | 40 | pop cx ! pc 41 | #if __FIRST_ARG_IN_AX__ 42 | mov bx,ax ! env-> 43 | #else 44 | pop bx ! env-> 45 | #endif 46 | pop ax ! rv 47 | mov cx,[bx+0] ! PC 48 | mov sp,[bx+2] 49 | mov bp,[bx+4] 50 | mov si,[bx+6] 51 | mov di,[bx+8] 52 | jmp cx 53 | #endasm 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /libc/termios/Config: -------------------------------------------------------------------------------- 1 | termios: Termios functions 2 | -------------------------------------------------------------------------------- /libc/termios/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | TSRC=termios.c 6 | TOBJ=tcsetattr.o tcgetattr.o tcdrain.o tcflow.o tcflush.o tcsendbreak.o \ 7 | tcsetpgrp.o tcgetpgrp.o isatty.o \ 8 | cfgetospeed.o cfgetispeed.o cfsetospeed.o cfsetispeed.o cfmakeraw.o 9 | 10 | ifeq ($(LIB_OS),ELKS) 11 | OBJ=$(TOBJ) ttyname.o 12 | 13 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 14 | 15 | all: $(LIBC) 16 | @$(RM) $(OBJ) 17 | 18 | $(LIBC): $(LIBC)($(OBJ)) 19 | 20 | $(LIBC)($(TOBJ)): $(TSRC) 21 | $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o 22 | $(AR) $(ARFLAGS) $@ $*.o 23 | else 24 | all: 25 | @: 26 | endif 27 | 28 | clean: 29 | rm -f *.o libc.a 30 | -------------------------------------------------------------------------------- /libc/termios/README: -------------------------------------------------------------------------------- 1 | Copyright (C) 1996 Robert de Bath 2 | This file is part of the Linux-8086 C library and is distributed 3 | under the GNU Library General Public License. 4 | 5 | There's currently nothing special about termios. 6 | 7 | -Robert 8 | -------------------------------------------------------------------------------- /libc/termios/ttyname.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | char * 7 | ttyname(fd) 8 | int fd; 9 | { 10 | static char dev[] = "/dev"; 11 | struct stat st, dst; 12 | DIR *fp; 13 | struct dirent *d; 14 | static char name[16]; /* should be MAXNAMLEN but that's overkill */ 15 | int noerr = errno; 16 | 17 | if (fstat(fd, &st) < 0) 18 | return 0; 19 | if (!isatty(fd)) 20 | { 21 | errno = ENOTTY; 22 | return 0; 23 | } 24 | 25 | fp = opendir(dev); 26 | if (fp == 0) 27 | return 0; 28 | strcpy(name, dev); 29 | strcat(name, "/"); 30 | 31 | while ((d = readdir(fp)) != 0) 32 | { 33 | if( strlen(d->d_name) > sizeof(name) - sizeof(dev) - 1) 34 | continue; 35 | strcpy(name + sizeof(dev), d->d_name); 36 | if (stat(name, &dst) == 0 37 | && st.st_dev == dst.st_dev && st.st_ino == dst.st_ino) 38 | { 39 | closedir(fp); 40 | errno = noerr; 41 | return name; 42 | } 43 | } 44 | closedir(fp); 45 | errno = noerr; 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /libc/time/Config: -------------------------------------------------------------------------------- 1 | time: Unix time manipulation functions. 2 | -------------------------------------------------------------------------------- /libc/time/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1996 Robert de Bath 2 | # This file is part of the Linux-8086 C library and is distributed 3 | # under the GNU Library General Public License. 4 | 5 | OBJ=localtime.o gmtime.o asctime.o ctime.o asc_conv.o tm_conv.o 6 | 7 | CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) 8 | 9 | all: $(LIBC) 10 | @$(RM) $(OBJ) 11 | 12 | $(LIBC): $(LIBC)($(OBJ)) 13 | 14 | clean: 15 | rm -f *.o libc.a 16 | -------------------------------------------------------------------------------- /libc/time/README: -------------------------------------------------------------------------------- 1 | Copyright (C) 1996 Robert de Bath 2 | This file is part of the Linux-8086 C library and is distributed 3 | under the GNU Library General Public License. 4 | 5 | There are two ways of converting the time_t to a struct tm, I'm not 6 | quite sure which is better. 7 | 8 | -Robert 9 | -------------------------------------------------------------------------------- /libc/time/asc_conv.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | /* 5 | * Internal ascii conversion routine, avoid use of printf, it's a bit big! 6 | */ 7 | 8 | 9 | static void 10 | hit(buf, val) 11 | char * buf; 12 | int val; 13 | { 14 | *buf = '0' + val%10; 15 | } 16 | 17 | void 18 | __asctime(buffer, ptm) 19 | register char * buffer; 20 | struct tm * ptm; 21 | { 22 | static char days[] = "SunMonTueWedThuFriSat"; 23 | static char mons[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; 24 | int year; 25 | 26 | /* 012345678901234567890123456 */ 27 | strcpy(buffer, "Err Err .. ..:..:.. ....\n"); 28 | if( (ptm->tm_wday >= 0) && (ptm->tm_wday <= 6) ) 29 | memcpy(buffer, days+3*(ptm->tm_wday), 3); 30 | 31 | if( (ptm->tm_mon >= 0) && (ptm->tm_mon <= 11) ) 32 | memcpy(buffer+4, mons+3*(ptm->tm_mon), 3); 33 | 34 | 35 | hit(buffer+ 8, ptm->tm_mday/10); 36 | hit(buffer+ 9, ptm->tm_mday ); 37 | hit(buffer+11, ptm->tm_hour/10); 38 | hit(buffer+12, ptm->tm_hour ); 39 | hit(buffer+14, ptm->tm_min/10); 40 | hit(buffer+15, ptm->tm_min ); 41 | hit(buffer+17, ptm->tm_sec/10); 42 | hit(buffer+18, ptm->tm_sec ); 43 | 44 | year = ptm->tm_year + 1900; 45 | hit(buffer+20, year/1000); 46 | hit(buffer+21, year/100); 47 | hit(buffer+22, year/10); 48 | hit(buffer+23, year); 49 | } 50 | -------------------------------------------------------------------------------- /libc/time/asctime.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | extern void __asctime(); 5 | 6 | char * 7 | asctime(timeptr) 8 | __const struct tm * timeptr; 9 | { 10 | static char timebuf[26]; 11 | 12 | if( timeptr == 0 ) return 0; 13 | __asctime(timebuf, timeptr); 14 | return timebuf; 15 | } 16 | -------------------------------------------------------------------------------- /libc/time/ctime.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | extern void __tm_conv(); 5 | extern void __asctime(); 6 | 7 | char * 8 | ctime(timep) 9 | __const time_t * timep; 10 | { 11 | static char cbuf[26]; 12 | struct tm tmb; 13 | struct timezone tz; 14 | time_t offt; 15 | 16 | gettimeofday((void*)0, &tz); 17 | 18 | offt = -tz.tz_minuteswest*60L; 19 | 20 | /* tmb.tm_isdst = ? */ 21 | __tm_conv(&tmb, timep, offt); 22 | 23 | __asctime(cbuf, &tmb); 24 | 25 | return cbuf; 26 | } 27 | -------------------------------------------------------------------------------- /libc/time/gmtime.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | extern void __tm_conv(); 5 | 6 | struct tm * 7 | gmtime(timep) 8 | __const time_t * timep; 9 | { 10 | static struct tm tmb; 11 | 12 | __tm_conv(&tmb, timep, 0L); 13 | 14 | return &tmb; 15 | } 16 | -------------------------------------------------------------------------------- /libc/time/localtime.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | extern void __tm_conv(); 5 | 6 | struct tm * 7 | localtime(timep) 8 | __const time_t * timep; 9 | { 10 | static struct tm tmb; 11 | struct timezone tz; 12 | time_t offt; 13 | 14 | gettimeofday((void*)0, &tz); 15 | 16 | offt = -tz.tz_minuteswest*60L; 17 | 18 | /* tmb.tm_isdst = ? */ 19 | __tm_conv(&tmb, timep, offt); 20 | 21 | return &tmb; 22 | } 23 | -------------------------------------------------------------------------------- /libcompat: -------------------------------------------------------------------------------- 1 | #!/bin/sh - 2 | 3 | FILES="$*" 4 | [ "$FILES" = "" ] && FILES="lib/*.a" 5 | 6 | for i in $FILES 7 | do 8 | ID="`dd bs=8 count=1 < $i 2>/dev/null | cat -v`" 9 | [ "$ID" != "!" ] && { 10 | make ld86r || exit $? 11 | 12 | echo Translating archive $i 13 | rm -rf libconv.d 14 | mkdir libconv.d 15 | cd libconv.d 16 | ar x ../$i 17 | cd .. 18 | 19 | bin/ld86r -o $i libconv.d/* || exit $? 20 | rm -rf libconv.d 21 | } 22 | done 23 | 24 | exit 0 25 | -------------------------------------------------------------------------------- /man/Makefile: -------------------------------------------------------------------------------- 1 | 2 | MANDIR=/usr/man 3 | MAN1PG=as86.1 bcc.1 elks.1 elksemu.1 ld86.1 4 | MAN1DIR=$(MANDIR)/man1 5 | 6 | all: 7 | 8 | install: 9 | install -m 755 -d $(MAN1DIR) 10 | install -m 644 $(MAN1PG) $(MAN1DIR) 11 | 12 | clean: 13 | -------------------------------------------------------------------------------- /man/elks.1: -------------------------------------------------------------------------------- 1 | .so man1/elksemu.1 2 | -------------------------------------------------------------------------------- /man/elksemu.1: -------------------------------------------------------------------------------- 1 | .TH elksemu 1 "Jan, 1997" 2 | .BY Me! 3 | .nh 4 | .SH NAME 5 | elksemu \- Embedded Linux Kernel Subset emulator 6 | .SH SYNOPSIS 7 | .B /lib/elksemu 8 | .B program 9 | .RB [ arguments ] 10 | .SH DESCRIPTION 11 | .B Elksemu 12 | is a program that allows 8086 13 | .B ELKS 14 | programs to be run under Linux-i386. These programs can be compiled using 15 | the 16 | .B bcc(1) 17 | C compiler. 18 | 19 | Yom may use the 20 | .I binfmt-misc 21 | module under Linux 2.1.43 or greater as described in the elksemu README 22 | which will cause the kernel to run 23 | .I elksemu 24 | with the correct arguments whenever the user tries to execute an ELKS 25 | executable directly. 26 | 27 | .SH OPTIONS 28 | There are no flag options to elksemu, the first argument is the name of the 29 | program to run the rest are arguments that are passed to the Elks program. 30 | 31 | .SH SECURITY 32 | The 33 | .B elksemu 34 | program may be installed suid-root and in this event it is able to 35 | run execute only (chmod 111) elks executables and act correctly on the 36 | suid permission bits on any executable. 37 | This should be considered a security hazard so elksemu does 38 | .I not 39 | have to be installed suid-root. 40 | If you consider using this facility you should also be aware that it will 41 | override the 'nosuid' mount(8) option. 42 | 43 | .SH SEE ALSO 44 | bcc(1), as86(1), ld86(1) 45 | .SH BUGS 46 | Elksemu is incomplete. 47 | 48 | The program may still have security bugs! 49 | -------------------------------------------------------------------------------- /tests/README: -------------------------------------------------------------------------------- 1 | Copyright (C) 1996 Robert de Bath 2 | This file is part of the Linux-8086 C library and is distributed 3 | under the GNU Library General Public License. 4 | 5 | These are user level tools, they're being used to test libc routines. 6 | 7 | env.c Prints the environment and arguments (Plus some junk) 8 | compr.c Mini compression program (rather slow but squeezes better than compress) 9 | ucomp.c Mini uncompression program (Very fast) 10 | ft.c Multiple simple file tools. 11 | hd.c Hex dump. 12 | line2.c Print lines from /etc/passwd (stdio) 13 | lines.c Print lines from /etc/passwd 14 | ouch.c Signal test 15 | size.c Size of Linux-i86 executables and object files. 16 | sync.c :-) 17 | wc.c Word,line and character counts. 18 | grab.c Grabs _all_ available memory (3GB+ on Linux-i386) then frees 19 | rand.c Generates random numbers and pipes them to 'hd' 20 | 21 | -Robert 22 | -------------------------------------------------------------------------------- /tests/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lkundrak/dev86/80d485b8014cbb926ce8a00cb87b2ca923c5618c/tests/a.out -------------------------------------------------------------------------------- /tests/hello_world.s: -------------------------------------------------------------------------------- 1 | 2 | .text 3 | entry start 4 | start: 5 | mov ax,#4 6 | mov bx,#1 7 | mov cx,#hello 8 | mov dx,#endhello-hello 9 | int $80 10 | 11 | mov bx,#0 12 | mov ax,#1 13 | int $80 14 | 15 | .data 16 | hello: 17 | .ascii "Hello world!\n" 18 | endhello: 19 | -------------------------------------------------------------------------------- /tests/line2.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | char buf[256]; 5 | 6 | main() 7 | { 8 | FILE * fd; 9 | fd = fopen("/etc/passwd", "r"); 10 | 11 | while(fgets(buf, sizeof(buf), fd) != NULL) 12 | { 13 | printf(">>%s", buf); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/lines.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | char * 6 | readline(fd) 7 | { 8 | static char linebuf[256]; 9 | int cc; 10 | char * p; 11 | 12 | cc = read(fd, linebuf, sizeof(linebuf)-1); 13 | if( cc <= 0 ) return 0; 14 | p = strchr(linebuf, '\n'); 15 | if( p == 0 ) p = linebuf+sizeof(linebuf)-1; 16 | else 17 | { 18 | p++; lseek(fd, (long)(p-linebuf)-cc, 1); 19 | } 20 | *p = 0; 21 | return linebuf; 22 | } 23 | 24 | main() 25 | { 26 | int fd = open("/etc/passwd", O_RDONLY); 27 | char * p; 28 | 29 | if(fd<0) exit(1); 30 | 31 | while( p=readline(fd) ) 32 | { 33 | write(1, ">>", 2); 34 | write(1, p, strlen(p)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/ouch.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | void trap() 7 | { 8 | write(1, "Ouch!!\n", 7); 9 | } 10 | 11 | main() 12 | { 13 | char buf[2]; 14 | int cc; 15 | 16 | signal(SIGINT, trap); 17 | while( (cc=read(0, buf, 1)) > 0 || (cc == -1 && errno == EINTR) ) 18 | { 19 | if( cc < 0 ) 20 | fprintf(stderr, "INTR\n"); 21 | else 22 | fprintf(stderr, "%x\n", buf[0]); 23 | } 24 | 25 | 26 | write(1, "\nExit!\n", 7); 27 | } 28 | -------------------------------------------------------------------------------- /tests/rand.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | FILE * popen(); 4 | 5 | main() 6 | { 7 | FILE * fd = popen("./hd", "w"); 8 | int ch; 9 | 10 | srand(time((void*)0)); 11 | 12 | for(ch=0; ch<256; ch++) 13 | putc(rand(), fd); 14 | 15 | pclose(fd); 16 | } 17 | -------------------------------------------------------------------------------- /tests/sync.c: -------------------------------------------------------------------------------- 1 | int main() { return sync(); } 2 | -------------------------------------------------------------------------------- /unproto/Sharheader: -------------------------------------------------------------------------------- 1 | 2 | # Contents: README unproto.c tok_io.c tok_class.c tok_pool.c vstring.c 3 | # symbol.c error.c hash.c strsave.c error.h token.h vstring.h 4 | # symbol.h Makefile cpp.sh acc.sh stdarg.h stddef.h stdlib.h 5 | # varargs.c example.c example.out unproto.1 6 | # Wrapped by wietse@wzv on Fri Jun 18 22:48:56 1993 7 | -------------------------------------------------------------------------------- /unproto/acc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # @(#) acc.sh 1.1 93/06/18 22:29:42 4 | # 5 | # Script to emulate most of an ANSI C compiler with a traditional UNIX 6 | # C compiler. 7 | 8 | # INCDIR should be the directory with auxiliary include files from the 9 | # unproto source distribution (stdarg.h, stdlib.h, stddef.h, and other 10 | # stuff that is missing from your compilation environment). With Ultrix 11 | # 4.[0-2] you need unproto's stdarg.h even though the system provides 12 | # one. 13 | # 14 | INCDIR=. 15 | 16 | # CPPDIR should be the directory with the unprototypeing cpp filter 17 | # (preferably the version with the PIPE_THROUGH_CPP feature). 18 | # 19 | CPPDIR=. 20 | 21 | # DEFINES: you will want to define volatile and const, and maybe even 22 | # __STDC__. 23 | # 24 | DEFINES="-Dvolatile= -Dconst= -D__STDC__" 25 | 26 | # Possible problem: INCDIR should be listed after the user-specified -I 27 | # command-line options, not before them as we do here. This is a problem 28 | # only if you attempt to redefine system libraries. 29 | # 30 | # Choose one of the commands below that is appropriate for your system. 31 | # 32 | exec cc -Qpath ${CPPDIR} -I${INCDIR} ${DEFINES} "$@" # SunOS 4.x 33 | exec cc -tp -h${CPPDIR} -B -I${INCDIR} ${DEFINES} "$@" # Ultrix 4.2 34 | exec cc -Yp,${CPPDIR} -I${INCDIR} ${DEFINES} "$@" # M88 SysV.3 35 | exec cc -B${CPPDIR}/ -tp -I${INCDIR} ${DEFINES} "$@" # System V.2 36 | -------------------------------------------------------------------------------- /unproto/cpp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # @(#) cpp.sh 1.3 92/01/15 21:53:22 4 | 5 | # Unprototypeing preprocessor for pre-ANSI C compilers. On some systems, 6 | # this script can be as simple as: 7 | # 8 | # /lib/cpp "$@" | unproto 9 | # 10 | # However, some cc(1) drivers specify output file names on the 11 | # preprocessor command line, so this shell script must be prepared to 12 | # intercept them. Depending on the driver program, the cpp options may 13 | # even go before or after the file name argument(s). The script below 14 | # tries to tackle all these cases. 15 | # 16 | # You may want to add -Ipath_to_stdarg.h_file, -Dvoid=, -Dvolatile=, 17 | # and even -D__STDC__. 18 | 19 | cpp_args="" 20 | 21 | while : 22 | do 23 | case $1 in 24 | "") break;; 25 | -*) cpp_args="$cpp_args $1";; 26 | *) cpp_args="$cpp_args $1" 27 | case $2 in 28 | ""|-*) ;; 29 | *) exec 1> $2 || exit 1; shift;; 30 | esac;; 31 | esac 32 | shift 33 | done 34 | 35 | /lib/cpp $cpp_args | unproto 36 | -------------------------------------------------------------------------------- /unproto/error.h: -------------------------------------------------------------------------------- 1 | /* @(#) error.h 1.2 92/01/15 21:53:14 */ 2 | 3 | extern int errcount; /* error counter */ 4 | extern void error(); /* default context */ 5 | extern void error_where(); /* user-specified context */ 6 | extern void fatal(); /* fatal error */ 7 | -------------------------------------------------------------------------------- /unproto/stddef.h: -------------------------------------------------------------------------------- 1 | /* @(#) stddef.h 1.1 92/02/15 17:25:46 */ 2 | 3 | #ifndef _stddef_h_ 4 | #define _stddef_h_ 5 | 6 | /* NULL is also defined in */ 7 | 8 | #ifndef NULL 9 | #define NULL 0 10 | #endif 11 | 12 | /* Structure member offset - some compilers barf on this. */ 13 | 14 | #define offsetof(type, member) ((size_t) &((type *)0)->member) 15 | 16 | /* Some of the following types may already be defined in . */ 17 | 18 | /* #include */ 19 | /* typedef long ptrdiff_t; /* type of pointer difference */ 20 | /* typedef unsigned short wchar_t; /* wide character type */ 21 | /* typedef unsigned size_t; /* type of sizeof */ 22 | 23 | #endif /* _stddef_h_ */ 24 | -------------------------------------------------------------------------------- /unproto/stdlib.h: -------------------------------------------------------------------------------- 1 | /* @(#) stdlib.h 1.1 92/02/15 17:25:45 */ 2 | 3 | #ifndef _stdlib_h_ 4 | #define _stdlib_h_ 5 | 6 | /* NULL is also defined in */ 7 | 8 | #ifndef NULL 9 | #define NULL 0 10 | #endif 11 | 12 | /* 13 | * Some functions in this file will be missing from the typical pre-ANSI 14 | * UNIX library. Some pre-ANSI UNIX library functions have return types 15 | * that differ from what ANSI requires. 16 | */ 17 | 18 | extern double atof(); 19 | extern int atoi(); 20 | extern long atol(); 21 | extern double strtod(); 22 | extern long strtol(); 23 | extern unsigned long strtoul(); 24 | extern int rand(); 25 | extern void srand(); 26 | extern char *calloc(); 27 | extern char *malloc(); 28 | extern char *realloc(); 29 | extern void free(); 30 | extern void abort(); 31 | extern void exit(); 32 | extern int atextit(); 33 | extern int system(); 34 | extern char *getenv(); 35 | extern char *bsearch(); 36 | extern void qsort(); 37 | extern int abs(); 38 | extern long labs(); 39 | 40 | typedef struct { 41 | int quot; 42 | int rem; 43 | } div_t; 44 | 45 | typedef struct { 46 | long quot; 47 | long rem; 48 | } ldiv_t; 49 | 50 | extern div_t div(); 51 | extern ldiv_t ldiv(); 52 | 53 | #endif /* _stdlib_h_ */ 54 | -------------------------------------------------------------------------------- /unproto/symbol.h: -------------------------------------------------------------------------------- 1 | /* @(#) symbol.h 1.1 91/09/22 21:21:42 */ 2 | 3 | struct symbol { 4 | char *name; /* symbol name */ 5 | int type; /* symbol type */ 6 | struct symbol *next; 7 | }; 8 | 9 | extern void sym_enter(); /* add symbol to table */ 10 | extern struct symbol *sym_find(); /* locate symbol */ 11 | extern void sym_init(); /* prime the table */ 12 | -------------------------------------------------------------------------------- /unproto/varargs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#) varargs.c 1.1 91/09/01 23:08:45 3 | * 4 | * This program can be used to verify that the stdarg.h file is set up 5 | * correctly for your system. If it works, it should print one line with the 6 | * text "stdarg.h works". 7 | */ 8 | 9 | #include 10 | #include "stdarg.h" 11 | 12 | main(int argc, char *argv[]) 13 | { 14 | varargs_test("%s %s\n", "stdarg.h", "works"); 15 | } 16 | 17 | varargs_test(char *fmt, ...) 18 | { 19 | va_list ap; 20 | 21 | va_start(ap, fmt); 22 | while (*fmt) { 23 | if (strncmp("%s", fmt, 2) == 0) { 24 | fputs(va_arg(ap, char *), stdout); 25 | fmt += 2; 26 | } else { 27 | putchar(*fmt); 28 | fmt++; 29 | } 30 | } 31 | va_end(ap); 32 | } 33 | -------------------------------------------------------------------------------- /unproto/vstring.h: -------------------------------------------------------------------------------- 1 | /* @(#) vstring.h 1.2 92/01/15 21:53:19 */ 2 | 3 | struct vstring { 4 | char *str; /* string value */ 5 | char *last; /* last position */ 6 | }; 7 | 8 | extern struct vstring *vs_alloc(); /* initial allocation */ 9 | extern char *vs_realloc(); /* string extension */ 10 | extern char *vs_strcpy(); /* copy string */ 11 | 12 | /* macro to add one character to auto-resized string */ 13 | 14 | #define VS_ADDCH(vs,wp,c) \ 15 | ((wp < (vs)->last || (wp = vs_realloc(vs,wp))) ? (*wp++ = c) : 0) 16 | --------------------------------------------------------------------------------