Author SHA1 Message Date
Matt Jenkins 5da189ad36 Changed %2 to %s in string format 2014-04-19 13:37:15 +01:00
Matt Jenkins de9ae5c603 Merge branch 'master' into double_precision 2014-04-19 12:42:19 +01:00
Matt Jenkins 9cf1805a1d Added double precision test programs 2014-04-19 10:31:33 +01:00
Matt Jenkins 4e2777e9fb Added double precision test programs 2014-04-19 10:31:25 +01:00
Matt Jenkins 6316b05ec3 Added gccdump.s to gitignore 2014-04-19 10:26:30 +01:00
Matt Jenkins 738874016f Merge github.com:igor-m/retrobsd-1 into double_precision 2014-04-19 10:04:52 +01:00
igor-m 6ce8e28a85 Fix of 16byte stack alignment, doprnt.c does not require va_arg fix now 2014-04-19 09:50:04 +02:00
igor-m 4783836659 New SPI IOCTL modi - R,W,RB,WB,RWB 2014-04-17 19:49:40 +02:00
igor-m 249b5716bb Original spi.c and spi.h 2014-04-17 01:17:06 +02:00
igor-m 1d1151403b Revert "Added comment to spi.c"
This reverts commit 28aae2c427.
2014-04-17 01:06:49 +02:00
igor-m 54a771c6f0 Revert "Added comment to spi.c"
This reverts commit 28aae2c427.
2014-04-17 00:53:24 +02:00
igor-m eddfd51e51 Fix of vaarg alignment addr calc 2014-04-17 00:14:41 +02:00
igor-m d9033fbf2d target.mk back with -fno-short-double 2014-04-17 00:07:00 +02:00
igor-m 28aae2c427 Added comment to spi.c 2014-04-16 15:24:09 +02:00
igor-m 6d689c335c Added SPI modes R,W,RB,WB,RWB 2014-04-16 15:03:35 +02:00
igor-m bad98ad239 Single -fno-short-double in target.mk 2014-04-14 13:30:22 +02:00
igor-m c04495837f Fix of the vaarg fix 2014-04-13 09:34:13 +02:00
igor-m 297b14aa0c Fixes with aliasing - using ieee.h 2014-04-12 13:39:05 +02:00
igor-m 190aa1e633 Fixes with aliasing 2014-04-12 12:51:40 +02:00
igor-m 0220852a66 Fix of va_arg aliasing in doprnt.c 2014-04-12 01:25:31 +02:00
igor-m 2afff6f8aa Fix to doprnt.c and moded modff, modf etc 2014-04-12 01:14:47 +02:00
igor-m 5b1496e5c3 Fix6 2014-04-11 22:55:29 +02:00
igor-m bcff791a3c Fix5 2014-04-11 22:45:22 +02:00
igor-m 98d034efe1 Fix4 2014-04-11 22:24:56 +02:00
igor-m 0f6e23c2fe Fix 3 2014-04-11 21:55:53 +02:00
igor-m af3db0bcd2 Another attempt to fix isinff.c, grrh 2014-04-11 21:51:23 +02:00
igor-m b73ccfb9dc Attempt to fix isinff.c 2014-04-11 21:23:23 +02:00
igor-m c31e4fa1e8 Was within untracked files ?? 2014-04-11 20:13:51 +02:00
igor-m 16e7b63b48 Fix the Double Precision changes 2014-04-11 19:35:55 +02:00
igor-m 16214d4557 Double Precision Floating Math implementation 2014-04-11 13:36:20 +02:00
2162 changed files with 63216 additions and 303765 deletions
+2 -1
View File
@@ -24,6 +24,7 @@
*.dis *.dis
*.0 *.0
*.img *.img
sdcard.rd
.profile
Makefile.user Makefile.user
TODO
+141 -29
View File
@@ -8,13 +8,39 @@
# The `make' will compile everything, including a kernel, utilities # The `make' will compile everything, including a kernel, utilities
# and a root filesystem image. # and a root filesystem image.
#
# Supported boards
#
MAX32 = sys/pic32/max32/MAX32
UBW32 = sys/pic32/ubw32/UBW32
UBW32UART = sys/pic32/ubw32-uart/UBW32-UART
UBW32UARTSDRAM = sys/pic32/ubw32-uart-sdram/UBW32-UART-SDRAM
MAXIMITE = sys/pic32/maximite/MAXIMITE
MAXCOLOR = sys/pic32/maximite-color/MAXCOLOR
EXPLORER16 = sys/pic32/explorer16/EXPLORER16
STARTERKIT = sys/pic32/starter-kit/STARTER-KIT
DUINOMITE = sys/pic32/duinomite/DUINOMITE
DUINOMITEUART = sys/pic32/duinomite-uart/DUINOMITE-UART
DUINOMITEE = sys/pic32/duinomite-e/DUINOMITE-E
DUINOMITEEUART = sys/pic32/duinomite-e-uart/DUINOMITE-E-UART
PINGUINO = sys/pic32/pinguino-micro/PINGUINO-MICRO
DIP = sys/pic32/dip/DIP
BAREMETAL = sys/pic32/baremetal/BAREMETAL
RETROONE = sys/pic32/retroone/RETROONE
FUBARINO = sys/pic32/fubarino/FUBARINO
FUBARINOBIG = sys/pic32/fubarino/FUBARINO-UART2CONS-UART1-SRAMC
MMBMX7 = sys/pic32/mmb-mx7/MMB-MX7
# Select target board
TARGET ?= $(MAX32)
# Filesystem and swap sizes. # Filesystem and swap sizes.
FS_MBYTES = 100 FS_KBYTES = 102400
U_MBYTES = 100 U_KBYTES = 102400
SWAP_MBYTES = 2 SWAP_KBYTES = 2048
# Set this to the device name for your SD card. With this # Set this to the device name for your SD card. With this
# enabled you can use "make installfs" to copy the sdcard.img # enabled you can use "make installfs" to copy the filesys.img
# to the SD card. # to the SD card.
#SDCARD = /dev/sdb #SDCARD = /dev/sdb
@@ -29,30 +55,111 @@ FSUTIL = tools/fsutil/fsutil
-include Makefile.user -include Makefile.user
TARGETDIR = $(shell dirname $(TARGET))
TARGETNAME = $(shell basename $(TARGET))
TOPSRC = $(shell pwd) TOPSRC = $(shell pwd)
CONFIG = $(TOPSRC)/tools/configsys/config CONFIG = $(TOPSRC)/tools/configsys/config
#
# Filesystem contents.
#
BIN_FILES := $(wildcard bin/*)
SBIN_FILES := $(wildcard sbin/*)
GAMES_FILES := $(shell find games -type f ! -path '*/.*')
LIBEXEC_FILES := $(wildcard libexec/*)
LIB_FILES := lib/crt0.o lib/retroImage $(wildcard lib/*.a)
ETC_FILES = etc/rc etc/rc.local etc/ttys etc/gettytab etc/group \
etc/passwd etc/shadow etc/fstab etc/motd etc/shells \
etc/termcap etc/MAKEDEV etc/phones etc/remote
INC_FILES = $(wildcard include/*.h) \
$(wildcard include/sys/*.h) \
$(wildcard include/machine/*.h) \
$(wildcard include/smallc/*.h) \
$(wildcard include/smallc/sys/*.h) \
$(wildcard include/arpa/*.h)
SHARE_FILES = share/re.help share/example/Makefile \
share/example/ashello.S share/example/chello.c \
share/example/blkjack.bas share/example/hilow.bas \
share/example/stars.bas share/example/prime.scm \
share/example/fact.fth share/example/echo.S \
$(wildcard share/smallc/*)
MANFILES = share/man/ share/man/cat1/ share/man/cat2/ share/man/cat3/ \
share/man/cat4/ share/man/cat5/ share/man/cat6/ share/man/cat7/ \
share/man/cat8/ $(wildcard share/man/cat?/*)
ALLFILES = $(SBIN_FILES) $(ETC_FILES) $(BIN_FILES) $(LIB_FILES) $(LIBEXEC_FILES) \
$(INC_FILES) $(SHARE_FILES) $(GAMES_FILES) \
var/log/messages var/log/wtmp .profile
ALLDIRS = games/ sbin/ bin/ dev/ etc/ tmp/ lib/ libexec/ share/ include/ \
var/ u/ share/example/ share/misc/ share/smallc/ \
var/run/ var/log/ var/lock/ games/ games/lib/ include/sys/ \
include/machine/ include/arpa/ include/smallc/ \
include/smallc/sys/ share/misc/ share/smallc/ include/sys/ \
games/lib/
BDEVS = dev/rd0!b0:0 dev/rd0a!b0:1 dev/rd0b!b0:2 dev/rd0c!b0:3 dev/rd0d!b0:4
BDEVS += dev/rd1!b1:0 dev/rd1a!b1:1 dev/rd1b!b1:2 dev/rd1c!b1:3 dev/rd1d!b1:4
BDEVS += dev/rd2!b2:0 dev/rd2a!b2:1 dev/rd2b!b2:2 dev/rd2c!b2:3 dev/rd2d!b2:4
BDEVS += dev/rd3!b3:0 dev/rd3a!b3:1 dev/rd3b!b3:2 dev/rd3c!b3:3 dev/rd3d!b3:4
BDEVS += dev/swap!b4:64 dev/swap0!b4:0 dev/swap1!b4:1 dev/swap2!b4:2
all: D_CONSOLE = dev/console!c0:0
$(MAKE) -C tools D_MEM = dev/mem!c1:0 dev/kmem!c1:1 dev/null!c1:2 dev/zero!c1:3
$(MAKE) -C src D_TTY = dev/tty!c2:0
$(MAKE) -C lib D_FD = dev/stdin!c3:0 dev/stdout!c3:1 dev/stderr!c3:2
$(MAKE) -C install D_TEMP = dev/temp0!c4:0 dev/temp1!c4:1 dev/temp2!c4:2
$(MAKE) kernel
U_DIRS = $(addsuffix /,$(shell find u -type d ! -path '*/.svn*'))
U_FILES = $(shell find u -type f ! -path '*/.svn/*')
#U_ALL = $(patsubst u/%,%,$(U_DIRS) $(U_FILES))
CDEVS = $(D_CONSOLE) $(D_MEM) $(D_TTY) $(D_FD) $(D_TEMP)
all: tools build kernel
$(MAKE) fs $(MAKE) fs
kernel: $(CONFIG) fs: sdcard.rd
$(MAKE) -C sys/pic32 all
fs: sdcard.img .PHONY: tools
tools:
$(MAKE) -C tools
.PHONY: sdcard.img kernel: $(TARGETDIR)/Makefile
sdcard.img: $(FSUTIL) rootfs.manifest userfs.manifest $(MAKE) -C $(TARGETDIR)
$(TARGETDIR)/Makefile: $(CONFIG) $(TARGETDIR)/$(TARGETNAME)
cd $(TARGETDIR) && ../../../tools/configsys/config $(TARGETNAME)
.PHONY: lib
lib:
$(MAKE) -C lib
build: tools lib
$(MAKE) -C src install
filesys.img: $(FSUTIL) $(ALLFILES)
rm -f $@ rm -f $@
$(FSUTIL) --repartition=fs=$(FS_MBYTES)M:swap=$(SWAP_MBYTES)M:fs=$(U_MBYTES)M $@ $(FSUTIL) -n$(FS_KBYTES) $@
$(FSUTIL) --new --partition=1 --manifest=rootfs.manifest $@ . $(FSUTIL) -a $@ $(ALLDIRS)
# In case you need a separate /u partition, $(FSUTIL) -a $@ $(CDEVS)
# uncomment the following line. $(FSUTIL) -a $@ $(BDEVS)
# $(FSUTIL) --new --partition=3 --manifest=userfs.manifest $@ u $(FSUTIL) -a $@ $(ALLFILES)
$(FSUTIL) -a $@ $(MANFILES)
swap.img:
dd if=/dev/zero of=$@ bs=1k count=$(SWAP_KBYTES)
user.img: $(FSUTIL)
ifneq ($(U_KBYTES), 0)
rm -f $@
$(FSUTIL) -n$(U_KBYTES) $@
(cd u; find . -type d -exec ../$(FSUTIL) -a ../$@ '{}/' \;)
(cd u; find . -type f -exec ../$(FSUTIL) -a ../$@ '{}' \+)
endif
sdcard.rd: filesys.img swap.img user.img
ifneq ($(U_KBYTES), 0)
tools/mkrd/mkrd -out $@ -boot filesys.img -swap swap.img -fs user.img
else
tools/mkrd/mkrd -out $@ -boot filesys.img -swap swap.img
endif
$(FSUTIL): $(FSUTIL):
cd tools/fsutil; $(MAKE) cd tools/fsutil; $(MAKE)
@@ -66,19 +173,21 @@ clean:
cleanall: clean cleanall: clean
$(MAKE) -C lib clean $(MAKE) -C lib clean
rm -f sys/pic32/*/unix.hex bin/* sbin/* libexec/* rm -f sys/pic32/*/unix.hex bin/* sbin/* games/[a-k]* games/[m-z]* libexec/* share/man/cat*/*
rm -f games/[a-k]* games/[m-z]* share/man/cat*/* rm -f games/lib/adventure.dat
rm -f games/lib/adventure.dat games/lib/cfscores rm -f games/lib/cfscores
rm -f share/re.help share/emg.keys share/misc/more.help rm -f share/re.help
rm -f share/misc/more.help
rm -f etc/termcap etc/remote etc/phones rm -f etc/termcap etc/remote etc/phones
rm -rf share/unixbench
rm -f games/lib/adventure.dat games/lib/cfscores share/re.help share/misc/more.help etc/termcap
rm -f tools/configsys/.depend rm -f tools/configsys/.depend
rm -f var/log/aculog sdcard.img rm -f var/log/aculog
rm -rf var/lock share/unixbench rm -rf var/lock
installfs: installfs: filesys.img
ifdef SDCARD ifdef SDCARD
@[ -f sdcard.img ] || $(MAKE) sdcard.img sudo dd bs=32k if=sdcard.rd of=$(SDCARD)
sudo dd bs=32k if=sdcard.img of=$(SDCARD)
else else
@echo "Error: No SDCARD defined." @echo "Error: No SDCARD defined."
endif endif
@@ -90,3 +199,6 @@ installflash:
# TODO: make it relative to Target # TODO: make it relative to Target
installboot: installboot:
sudo pic32prog sys/pic32/fubarino/bootloader.hex sudo pic32prog sys/pic32/fubarino/bootloader.hex
.profile: etc/root/dot.profile
cp etc/root/dot.profile .profile
+47 -24
View File
@@ -15,35 +15,48 @@
## Supported hardware ## Supported hardware
* Fubarino SD board. * chipKIT Max32 board.
* Olimex Duinomite, Duinomite-Mini, Duinomite-Mega and Duinomite-eMega boards. * Sparkfun UBW32 board.
* Olimex Pinguino-Micro board with PIC32MX795F512H microcontroller.
* Maximite and Colour Maximite computers. * Maximite and Colour Maximite computers.
* Majenko SDXL board.
* 4D Systems Picadillo-35T board.
* MikroElektronika MultiMedia Board for PIC32MX7.
* chipKIT Max32 board with SD card shield.
* chipKIT WF32 board with 2.4" LCD TFT display shield.
* Sparkfun UBW32 board with SD card slot.
* Microchip Explorer 16 board, with PIC32 CAN-USB plug-in module and SD & MMC pictail. * Microchip Explorer 16 board, with PIC32 CAN-USB plug-in module and SD & MMC pictail.
* Microchip PIC32 USB or Ethernet Starter Kit, with I/O Expansion board and SD & MMC pictail. * Microchip PIC32 USB or Ethernet Starter Kit, with I/O Expansion board and SD & MMC pictail.
* Olimex Duinomite, Duinomite-Mini and Duinomite-Mega boards.
* Olimex Pinguino-Micro board with PIC32MX795F512H microcontroller.
* eflightworks DIP board.
## Build ## Build
To compile everything from sources, you'll need some packages installed, namely: By default, the system is configured for the Max32 board.
Berkeley YACC, GNU bison, flex, groff, ELF library and FUSE library. To select another target board, edit a top-level user-specific Makefile called "Makefile.user"
Under Ubuntu, for example, you can do it by command: and set a TARGET value:
```shell ```Makefile
$ sudo apt-get install bison byacc flex groff-base libelf-dev TARGET = $(UBW32) # for the UBW32 board with USB console
TARGET = $(UBW32UART) # for the UBW32 board with UART console
TARGET = $(UBW32UARTSDRAM) # for the UBW32 boars with UART console and 8MB SRAM ramdisk
TARGET = $(MAXIMITE) # for the Maximite board
TARGET = $(MAXCOLOR) # for the Colour Maximite board
TARGET = $(EXPLORER16) # for the Explorer 16 board
TARGET = $(STARTERKIT) # for the PIC32 USB or Ethernet Starter Kit
TARGET = $(MAX32) # default
TARGET = $(DUINOMITE) # for the Duinomite board with USB console
TARGET = $(DUINOMITEUART) # for the Duinomite board with UART console
TARGET = $(DUINOMITEE) # for the Duinomite E board with USB console
TARGET = $(DUINOMITEEUART) # for the Duinomite E board with UART console
TARGET = $(PINGUINO) # for the Pinguino-Micro board
TARGET = $(DIP) # for the DIP board
TARGET = $(BAREMETAL) # Bare PIC32 chip on a breakout board
TARGET = $(FUBARINO) # Fubarino SD board
TARGET = $(FUBARINOBIG) # Fubarino SD board with 8MB SRAM RAMDISK
TARGET = $(MMBMX7) # MMB MX7 board
``` ```
You can change a desired filesystem size and swap area size, as required. You can also change a desired filesystem size and swap area size,
Default is: as required. Default is:
```Makefile ```Makefile
FS_MBYTES = 100 FS_KBYTES = 16384
SWAP_MBYTES = 2 SWAP_KBYTES = 2048
``` ```
To compile the kernel and build a filesystem image, run: To compile the kernel and build a filesystem image, run:
@@ -51,7 +64,7 @@ To compile the kernel and build a filesystem image, run:
$ make $ make
``` ```
A resulting root filesystem image is in file `sdcard.img`. A resulting root filesystem image is in file `sdcard.rd`.
A kernel is in file `unix.hex` in your target board subdirectory. A kernel is in file `unix.hex` in your target board subdirectory.
@@ -62,7 +75,7 @@ Win32DiskImager utility (https://launchpad.net/win32-image-writer/+download).
On Linux, run: On Linux, run:
```shell ```shell
$ sudo dd if=sdcard.img of=/dev/XYZ $ sudo dd if=sdcard.rd of=/dev/XYZ
``` ```
Here `XYZ` is a device name of SD card, as recognized by Linux (sdb in my case). Here `XYZ` is a device name of SD card, as recognized by Linux (sdb in my case).
@@ -74,11 +87,11 @@ Kernel image should be written to PIC32 flash memory. The procedure depends
on a board used. on a board used.
#### Max32 board: #### Max32 board:
Use a pic32prog utility (http://code.google.com/p/pic32prog/)
and a USB cable to install a kernel:
```shell ```shell
$ pic32prog -d /dev/ttyUSB0 sys/pic32/max32/unix.hex $ cd sys/pic32/ubw32
$ AVRTOOLS=/Applications/Mpide.app/Contents/Resources/Java/hardware/tools
$AVRTOOLS/bin/avrdude -C$AVRTOOLS/etc/avrdude.conf -c stk500v2 -p pic32 \
-P /dev/tty.usbserial-* -b 115200 -v -U flash:w:unix.hex:i
``` ```
Here you need to change AVRTOOLS path and tty name according to your system. Here you need to change AVRTOOLS path and tty name according to your system.
@@ -140,3 +153,13 @@ $ ./pic32
``` ```
Configuration of simulated board is stored in file `pic32_max32.conf`. Configuration of simulated board is stored in file `pic32_max32.conf`.
## Build packages
For building under Ubuntu you need the following packages installed:
```shell
$ sudo apt-get install byacc libelf-dev
```
Regular → Executable
+4 -8
View File
@@ -1,7 +1,7 @@
DESTDIR = /usr/local/retrobsd DESTDIR = /usr/local/retrobsd
MACHINE = mips MACHINE = mips
CC = gcc -m32 CC = gcc
AS = $(CC) -x assembler-with-cpp AS = $(CC) -x assembler-with-cpp
LD = ld LD = ld
@@ -23,13 +23,9 @@ LDFLAGS =
LIBS = LIBS =
# Add system include path # Add system include path
ifeq (/usr/include/x86_64-linux-gnu,$(wildcard /usr/include/x86_64-linux-gnu)) ifeq (,$(wildcard /usr/include/i386-linux-gnu))
CFLAGS += -I/usr/include/x86_64-linux-gnu
else
ifeq (/usr/include/i386-linux-gnu,$(wildcard /usr/include/i386-linux-gnu))
CFLAGS += -I/usr/include/i386-linux-gnu
else
CFLAGS += -I/usr/include CFLAGS += -I/usr/include
endif else
CFLAGS += -I/usr/include/i386-linux-gnu
endif endif
CFLAGS += -I$(TOPSRC)/include CFLAGS += -I$(TOPSRC)/include
-2
View File
@@ -1,5 +1,3 @@
localtime
phones phones
remote remote
termcap termcap
termcap.full
+33 -1
View File
@@ -4,14 +4,46 @@
# All rights reserved. The Berkeley software License Agreement # All rights reserved. The Berkeley software License Agreement
# specifies the terms and conditions for redistribution. # specifies the terms and conditions for redistribution.
# #
# @(#)MAKEDEV 4.27.6 (2.11BSD) 1999/2/19
#
# Device "make" file. Valid arguments: # Device "make" file. Valid arguments:
# std standard devices # std standard devices
# local configuration specific devices # local configuration specific devices
# fd file descriptor driver # fd file descriptor driver
# Tapes:
# ht* unibus tu77 & te16
# tm* unibus tm11 & te10 emulations (e.g. Emulex tc-11)
# ts* unibus ts11
# tu* tmscp (tk50/tu81)
# Disks: # Disks:
# sd* flash cards SecureDigital # br* unibus Eaton br1538 or br1711
# hk* unibus rk06 and rk07
# ra* unibus uda50 w/ ra??
# rk* unibus rk05
# rl* unibus rl01/rl02
# rx* unibus rx02
# si* unibus cdc 9766 w/ si 9500
# xp* unibus rm02/03/05, rp04/05/06, diva, eagle, cdc9766, fuji 160.
# Terminal multiplexors:
# dl* dl-11 units other than the console
# dz* unibus dz11 and dz32
# dh* unibus dh11 and emulations (e.g. Able dmax, Emulex cs-11)
# dmf* unibus dmf32
# dhu* unibus dhu11
# dmz* unibus dmz32
# dhv* qbus dhv11
# Pseudo terminals: # Pseudo terminals:
# pty* set of 16 master and slave pseudo terminals # pty* set of 16 master and slave pseudo terminals
# Printers:
# lp* unibus lp11 parallel interface
# va* unibus varian parallel interface
# vp* unibus versatec parallel interface
# Call units:
# Special purpose devices:
# dr* unibus dr11
# ram* memory disk
# dn* dn11 dialer
# ingreslock Ingres lock driver.
PATH=/etc:/sbin:/usr/sbin:/bin:/usr/bin PATH=/etc:/sbin:/usr/sbin:/bin:/usr/bin
umask 77 umask 77
+5
View File
@@ -11,6 +11,7 @@ DESTDIR = /foobar
OWN = root OWN = root
GRP = wheel GRP = wheel
SUBDIR = root
FILES = crontab fstab gettytab group motd passwd \ FILES = crontab fstab gettytab group motd passwd \
rc rc.local shells syslog.conf ttys rc rc.local shells syslog.conf ttys
@@ -18,6 +19,8 @@ all install depend lint tags:
clean: clean:
rm -f *~ rm -f *~
-for i in ${SUBDIR}; do \
(cd $$i; make DESTDIR=${DESTDIR} $@); done
distribution: distribution:
-@mkdir -p ${DESTDIR}/dev -@mkdir -p ${DESTDIR}/dev
@@ -72,3 +75,5 @@ distribution:
${DESTDIR}/usr/adm/savacct ${DESTDIR}/usr/adm/savacct
install -c -o uucp -g daemon -m 600 /dev/null \ install -c -o uucp -g daemon -m 600 /dev/null \
${DESTDIR}/usr/adm/aculog ${DESTDIR}/usr/adm/aculog
-for i in ${SUBDIR}; do \
(cd $$i; make DESTDIR=${DESTDIR} distribution); done
+2 -2
View File
@@ -1,2 +1,2 @@
/dev/sd0a / ufs rw,async 1 1 /dev/rd0a / ufs rw,async 1 1
#/dev/sd0c /u ufs rw,async 1 2 #/dev/rd0c /u ufs rw,async 1 2
+6 -5
View File
@@ -1,7 +1,8 @@
root:5:0:1:The Man:/root:/bin/sh root:5:0:1:The Man:/:/bin/sh
daemon:*:1:1:The devil himself:/root:/bin/sh daemon:*:1:1:The devil himself:/:/bin/sh
sys:*:4:2:Operating System:/tmp:nologin sys:*:4:2:Operating System:/tmp:nologin
operator:*:2:5:System &:/u/operator:/bin/sh operator:*:2:5:System &:/usr/guest/operator:/bin/csh
bin:*:3:20:Binaries Commands and Source:/root:/bin/sh bin:*:3:20:Binaries Commands and Source:/:/bin/csh
nobody:*:32767:31:Nobody:/nonexistent:/bin/sh nobody:*:32767:31:Nobody:/nonexistent:/bin/sh
uucp:*:66:1:UNIX-to-UNIX Copy:/spool/uucppublic:/sbin/uucico uucp:*:66:1:UNIX-to-UNIX Copy:/usr/spool/uucppublic:/usr/sbin/uucico
ingres:*:39:74:INGRES Owner:/usr/ingres:/bin/csh
+2
View File
@@ -3,6 +3,8 @@ HOME=/; export HOME
PATH=/bin:/sbin; export PATH PATH=/bin:/sbin; export PATH
exec >/dev/console 2>&1 exec >/dev/console 2>&1
/sbin/devupdate
if test "$1" != "autoboot"; then if test "$1" != "autoboot"; then
# #
# Switch from single-user to multi-user mode. # Switch from single-user to multi-user mode.
+18
View File
@@ -0,0 +1,18 @@
#
# DESTDIR is defined here to be something which does *NOT* exist - it must be
# specified on the command line when doing a "make DESTDIR=/mnt distribution".
# This is aimed at avoiding overwriting the system disk's /etc files.
DESTDIR = /foobar
OWN = root
GRP = wheel
all install depend lint tags:
distribution:
install -c -o ${OWN} -g ${GRP} -m 644 dot.cshrc ${DESTDIR}/.cshrc
install -c -o ${OWN} -g ${GRP} -m 644 dot.login ${DESTDIR}/.login
install -c -o ${OWN} -g ${GRP} -m 644 dot.profile ${DESTDIR}/.profile
clean:
rm -f *~
+14
View File
@@ -0,0 +1,14 @@
set history=30
set path=(/bin /sbin /etc /usr/sbin /usr/ucb /usr/bin /usr/new /usr/local)
if ($?prompt) then
set prompt="\!% "
endif
set filec
set mail=( 0 /usr/spool/mail/$USER )
set cdpath=( ~ /usr/spool/mqueue)
set prompt="\!% root--> "
alias mail /usr/ucb/Mail
alias pwd 'echo $cwd'
alias h history
alias q5 'tail -5 /usr/spool/mqueue/syslog'
+14
View File
@@ -0,0 +1,14 @@
unset noglob
set path=(/bin /etc /sbin /usr/sbin /usr/ucb /usr/bin /usr/local /usr/new)
umask 26
stty dec erase ^H kill ^U eof ^D
set prompt="[\!] root--> "
if ( "$TERM" == dialup || "$TERM" == network) then
setenv TERM vt100
echo -n "Terminal ($TERM)? "
set argv = "$<"
if ( "$argv" != '' ) setenv TERM "$argv"
endif
biff y
+8
View File
@@ -0,0 +1,8 @@
echo 'erase, kill ^U, intr ^C'
stty dec
stty erase
PATH=/bin:/sbin:/usr/sbin:/etc:/usr/ucb:/usr/bin:/usr/new
export PATH
HOME=/
export HOME
export TERM
+6 -5
View File
@@ -1,7 +1,8 @@
root:ro46DZg1ViGBs:0:1:The Man:/root:/bin/sh root:ro46DZg1ViGBs:0:1:The Man:/:/bin/sh
daemon:*:1:1:The devil himself:/root:/bin/sh daemon:*:1:1:The devil himself:/:/bin/sh
sys:*:4:2:Operating System:/tmp:nologin sys:*:4:2:Operating System:/tmp:nologin
operator:*:2:5:System &:/u/operator:/bin/sh operator:*:2:5:System &:/usr/guest/operator:/bin/csh
bin:*:3:20:Binaries Commands and Source:/root:/bin/sh bin:*:3:20:Binaries Commands and Source:/:/bin/csh
nobody:*:32767:31:Nobody:/nonexistent:/bin/sh nobody:*:32767:31:Nobody:/nonexistent:/bin/sh
uucp:*:66:1:UNIX-to-UNIX Copy:/spool/uucppublic:/sbin/uucico uucp:*:66:1:UNIX-to-UNIX Copy:/usr/spool/uucppublic:/usr/sbin/uucico
ingres:*:39:74:INGRES Owner:/usr/ingres:/bin/csh
+8 -8
View File
@@ -1,16 +1,16 @@
# #
# name getty type status comments # name getty type status comments
# #
console "/libexec/getty std.default" xterm on secure #special console "/libexec/getty std.default" vt100 on secure #special
# Enable some of these for additional logins. Do NOT enable the same one as the # Enable some of these for additional logins. Do NOT enable the same one as the
# console port, or strange things will happen. You can turn off the console port # console port, or strange things will happen. You can turn off the console port
# if you would rather use the getty on the real tty - it's up to you. # if you would rather use the getty on the real tty - it's up to you.
tty0 "/libexec/getty std.default" xterm off secure tty0 "/libexec/getty std.default" vt100 off secure
tty1 "/libexec/getty std.default" xterm off secure tty1 "/libexec/getty std.default" vt100 off secure
tty2 "/libexec/getty std.default" xterm off secure tty2 "/libexec/getty std.default" vt100 off secure
tty3 "/libexec/getty std.default" xterm off secure tty3 "/libexec/getty std.default" vt100 off secure
tty4 "/libexec/getty std.default" xterm off secure tty4 "/libexec/getty std.default" vt100 off secure
tty5 "/libexec/getty std.default" xterm off secure tty5 "/libexec/getty std.default" vt100 off secure
ttyUSB0 "/libexec/getty std.default" xterm off secure ttyUSB0 "/libexec/getty std.default" vt100 off secure
-1
View File
@@ -1 +0,0 @@
readline
+23 -1
View File
@@ -33,7 +33,29 @@
#ifndef _AOUT_H_ #ifndef _AOUT_H_
#define _AOUT_H_ #define _AOUT_H_
#include <sys/exec_aout.h> #include <sys/exec.h>
/* Valid magic number check. */
#define N_BADMAG(x) (((x).a_magic) != RMAGIC && \
((x).a_magic) != OMAGIC && \
((x).a_magic) != NMAGIC)
/* Text segment offset. */
#define N_TXTOFF(x) sizeof(struct exec)
/* Data segment offset. */
#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
/* Text relocation table offset. */
#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
/* Data relocation table offset. */
#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_reltext)
/* Symbol table offset. */
#define N_SYMOFF(x) ((x).a_magic == RMAGIC ? \
N_DRELOFF(x) + (x).a_reldata : \
N_DATOFF(x) + (x).a_data)
#define _AOUT_INCLUDE_ #define _AOUT_INCLUDE_
#include <nlist.h> #include <nlist.h>
+2
View File
@@ -1,3 +1,5 @@
/* assert.h 4.2 85/01/21 */
# ifndef NDEBUG # ifndef NDEBUG
# define _assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file \"%s\", line %d\n", __FILE__, __LINE__);exit(1);}} # define _assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file \"%s\", line %d\n", __FILE__, __LINE__);exit(1);}}
# define assert(ex) _assert(ex) # define assert(ex) _assert(ex)
+2
View File
@@ -1,3 +1,5 @@
/* ctype.h 4.2 85/09/04 */
#define _U 01 #define _U 01
#define _L 02 #define _L 02
#define _N 04 #define _N 04
+7 -8
View File
@@ -10,6 +10,7 @@
#include <term.h> #include <term.h>
#define bool int #define bool int
#define reg register
#define TRUE (1) #define TRUE (1)
#define FALSE (0) #define FALSE (0)
@@ -32,6 +33,7 @@ typedef struct sgttyb SGTTY;
/* /*
* Capabilities from termcap * Capabilities from termcap
*/ */
extern bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, extern bool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
XB, XN, XT, XS, XX; XB, XN, XT, XS, XX;
extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
@@ -84,17 +86,17 @@ extern WINDOW *stdscr, *curscr;
int __void__; int __void__;
#define VOID(x) (__void__ = (int) (x)) #define VOID(x) (__void__ = (int) (x))
#else #else
#define VOID(x) ((void)(x)) #define VOID(x) (x)
#endif #endif
/* /*
* psuedo functions for standard screen * psuedo functions for standard screen
*/ */
#define addch(ch) VOID(waddch(stdscr, ch)) #define addch(ch) VOID(waddch(stdscr, ch))
#define getch() wgetch(stdscr) #define getch() VOID(wgetch(stdscr))
#define addstr(str) VOID(waddstr(stdscr, str)) #define addstr(str) VOID(waddstr(stdscr, str))
#define getstr(str) VOID(wgetstr(stdscr, str)) #define getstr(str) VOID(wgetstr(stdscr, str))
#define move(y, x) wmove(stdscr, y, x) #define move(y, x) VOID(wmove(stdscr, y, x))
#define clear() VOID(wclear(stdscr)) #define clear() VOID(wclear(stdscr))
#define erase() VOID(werase(stdscr)) #define erase() VOID(werase(stdscr))
#define clrtobot() VOID(wclrtobot(stdscr)) #define clrtobot() VOID(wclrtobot(stdscr))
@@ -111,7 +113,7 @@ int __void__;
/* /*
* mv functions * mv functions
*/ */
#define mvwaddch(win,y,x,ch) (wmove(win,y,x) == ERR ? ERR : waddch(win,ch)) #define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
#define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win)) #define mvwgetch(win,y,x) VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
#define mvwaddstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str)) #define mvwaddstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
#define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str)) #define mvwgetstr(win,y,x,str) VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
@@ -129,6 +131,7 @@ int __void__;
/* /*
* psuedo functions * psuedo functions
*/ */
#define clearok(win,bf) (win->_clear = bf) #define clearok(win,bf) (win->_clear = bf)
#define leaveok(win,bf) (win->_leave = bf) #define leaveok(win,bf) (win->_leave = bf)
#define scrollok(win,bf) (win->_scroll = bf) #define scrollok(win,bf) (win->_scroll = bf)
@@ -178,10 +181,6 @@ int waddstr (WINDOW *, char *);
int wgetstr (WINDOW *, char *); int wgetstr (WINDOW *, char *);
int wdeleteln (WINDOW *); int wdeleteln (WINDOW *);
void mvcur(int ly, int lx, int y, int x); void mvcur(int ly, int lx, int y, int x);
void overwrite(WINDOW *win1, WINDOW *win2);
void wclrtobot(WINDOW *win);
int mvprintw(int y, int x, char *fmt, ...);
int mvwprintw(WINDOW *win, int y, int x, char *fmt, ...);
/* /*
* Used to be in unctrl.h. * Used to be in unctrl.h.
+28
View File
@@ -0,0 +1,28 @@
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* @(#)dbm.h 5.1 (Berkeley) 3/27/86
*/
#ifndef NULL
/*
* this is lunacy, we no longer use it (and never should have
* unconditionally defined it), but, this whole file is for
* backwards compatability - someone may rely on this.
*/
#define NULL ((char *) 0)
#endif
#include <ndbm.h>
datum fetch();
datum firstkey();
datum nextkey();
#if 0
datum makdatum();
datum firsthash();
long calchash();
long hashinc();
#endif
+3
View File
@@ -47,6 +47,9 @@
* if type is "rq", then use concatenation of fs_file and "quotas" to locate * if type is "rq", then use concatenation of fs_file and "quotas" to locate
* quota file. * quota file.
*/ */
#define _PATH_FSTAB "/etc/fstab"
#define FSTAB "/etc/fstab" /* deprecated */
#define FSTAB_RW "rw" /* read/write device */ #define FSTAB_RW "rw" /* read/write device */
#define FSTAB_RQ "rq" /* read/write with quotas */ #define FSTAB_RQ "rq" /* read/write with quotas */
#define FSTAB_RO "ro" /* read-only device */ #define FSTAB_RO "ro" /* read-only device */
-2
View File
@@ -13,5 +13,3 @@ struct group *getgrgid(gid_t gid);
void setgrent(void); void setgrent(void);
void endgrent(void); void endgrent(void);
int setgroups(size_t size, const gid_t *list); int setgroups(size_t size, const gid_t *list);
int getgrouplist(char *uname, gid_t agroup, gid_t *groups, int *grpcnt);
int initgroups(char *uname, int agroup);
+47
View File
@@ -0,0 +1,47 @@
typedef union // LITTLE ENDIAN
{
double value;
struct
{
unsigned long lsw;
unsigned long msw;
} parts;
} ieee_double_shape_type;
/* Get two 32 bit ints from a double. */
#define EXTRACT_WORDS(ix0,ix1,d) \
do { \
ieee_double_shape_type ew_u; \
ew_u.value = (d); \
(ix0) = ew_u.parts.msw; \
(ix1) = ew_u.parts.lsw; \
} while (0)
/* Get the more significant 32 bit int from a double. */
#define GET_HIGH_WORD(i,d) \
do { \
ieee_double_shape_type gh_u; \
gh_u.value = (d); \
(i) = gh_u.parts.msw; \
} while (0)
/* Set a double from two 32 bit ints. */
#define INSERT_WORDS(d,ix0,ix1) \
do { \
ieee_double_shape_type iw_u; \
iw_u.parts.msw = (ix0); \
iw_u.parts.lsw = (ix1); \
(d) = iw_u.value; \
} while (0)
#define SET_HIGH_WORD(d,v) \
do { \
ieee_double_shape_type sh_u; \
sh_u.value = (d); \
sh_u.parts.msw = (v); \
(d) = sh_u.value; \
} while (0)
-2
View File
@@ -1,2 +0,0 @@
#include <stdint.h>
#include <stddef.h>
+30
View File
@@ -36,6 +36,36 @@
#ifndef _LIMITS_H_ #ifndef _LIMITS_H_
#define _LIMITS_H_ #define _LIMITS_H_
/*
* We don't need this crud at the moment so save on abuse of the C
* preprocessor by not doing the defines.
#define _POSIX_ARG_MAX 4096
#define _POSIX_CHILD_MAX 6
#define _POSIX_LINK_MAX 8
#define _POSIX_MAX_CANON 255
#define _POSIX_MAX_INPUT 255
#define _POSIX_NAME_MAX 14
#define _POSIX_NGROUPS_MAX 0
#define _POSIX_OPEN_MAX 16
#define _POSIX_PATH_MAX 255
#define _POSIX_PIPE_BUF 512
#define _POSIX_SSIZE_MAX 32767
#define _POSIX_STREAM_MAX 8
#define _POSIX_TZNAME_MAX 3
#define _POSIX2_BC_BASE_MAX 99
#define _POSIX2_BC_DIM_MAX 2048
#define _POSIX2_BC_SCALE_MAX 99
#define _POSIX2_BC_STRING_MAX 1000
#define _POSIX2_EQUIV_CLASS_MAX 2
#define _POSIX2_EXPR_NEST_MAX 32
#define _POSIX2_LINE_MAX 2048
#define _POSIX2_RE_DUP_MAX 255
*/
#include <machine/limits.h> #include <machine/limits.h>
/* #include <sys/syslimits.h> */
#endif /* !_LIMITS_H_ */ #endif /* !_LIMITS_H_ */
+10 -27
View File
@@ -4,16 +4,17 @@
* specifies the terms and conditions for redistribution. * specifies the terms and conditions for redistribution.
*/ */
double fabs(double), floor(double), ceil(double); extern double fabs(), floor(), ceil(), fmod(), ldexp();
double sqrt(double), hypot(double, double); extern double sqrt(), hypot(), atof();
double sin(double), cos(double), tan(double); extern double sin(), cos(), tan(), asin(), acos(), atan(), atan2();
double asin(double), acos(double), atan(double), atan2(double, double); extern double exp(), log(), log10(), pow();
double exp(double), log(double), log10(double), pow(double, double); extern double sinh(), cosh(), tanh();
double sinh(double), cosh(double), tanh(double); extern double gamma();
double j0(double), j1(double), jn(int, double); extern double j0(), j1(), jn(), y0(), y1(), yn();
double y0(double), y1(double), yn(int, double);
#define HUGE_VAL 3.40282347e+38 /* TBD??? use infinity? */ // ###PITO #define HUGE 1.701411733192644270e38
#define HUGE 1.79769313486231570000e+308
#define LOGHUGE 307
int isnanf(float x); int isnanf(float x);
int isnan(double x); int isnan(double x);
@@ -31,21 +32,3 @@ float ldexpf(float x, int exp);
double ldexp(double x, int exp); double ldexp(double x, int exp);
double fmod(double x, double y); double fmod(double x, double y);
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
#define M_E 2.7182818284590452354 /* e */
#define M_LOG2E 1.4426950408889634074 /* log 2e */
#define M_LOG10E 0.43429448190325182765 /* log 10e */
#define M_LN2 0.69314718055994530942 /* log e2 */
#define M_LN10 2.30258509299404568402 /* log e10 */
#define M_PI 3.14159265358979323846 /* pi */
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#define M_PI_4 0.78539816339744830962 /* pi/4 */
#define M_1_PI 0.31830988618379067154 /* 1/pi */
#define M_2_PI 0.63661977236758134308 /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
+5 -1
View File
@@ -10,7 +10,11 @@
* Hashed key data base library. * Hashed key data base library.
*/ */
#define PBLKSIZ 1024 #define PBLKSIZ 1024
#define DBLKSIZ 1024 #ifdef pdp11
#define DBLKSIZ 512
#else
#define DBLKSIZ 4096
#endif
typedef struct { typedef struct {
int dbm_dirf; /* open directory file */ int dbm_dirf; /* open directory file */
+1 -1
View File
@@ -39,7 +39,7 @@
*/ */
struct nlist { struct nlist {
char *n_name; /* In memory address of symbol name, char *n_name; /* In memory address of symbol name,
* or string table offset (file) */ or string table offset (file) */
u_short n_len; /* Length of name in bytes */ u_short n_len; /* Length of name in bytes */
u_short n_type; /* Type of symbol - see below */ u_short n_type; /* Type of symbol - see below */
u_int n_value; /* Symbol value */ u_int n_value; /* Symbol value */
-7
View File
@@ -24,25 +24,18 @@
#define _PATH_CORE "/core" #define _PATH_CORE "/core"
#define _PATH_DEV "/dev/" #define _PATH_DEV "/dev/"
#define _PATH_CONSOLE "/dev/console" #define _PATH_CONSOLE "/dev/console"
#define _PATH_LOG "/dev/log"
#define _PATH_DEVNULL "/dev/null" #define _PATH_DEVNULL "/dev/null"
#define _PATH_TTY "/dev/tty" #define _PATH_TTY "/dev/tty"
#define _PATH_MEM "/dev/mem" #define _PATH_MEM "/dev/mem"
#define _PATH_SWAP "/dev/swap" #define _PATH_SWAP "/dev/swap"
#define _PATH_FSTAB "/etc/fstab"
#define _PATH_LOCALTIME "/etc/localtime" #define _PATH_LOCALTIME "/etc/localtime"
#define _PATH_MOTD "/etc/motd" #define _PATH_MOTD "/etc/motd"
#define _PATH_NOLOGIN "/etc/nologin" #define _PATH_NOLOGIN "/etc/nologin"
#define _PATH_PASSWD "/etc/passwd"
#define _PATH_PTMP "/etc/ptmp"
#define _PATH_SHADOW "/etc/shadow"
#define _PATH_TERMCAP "/etc/termcap"
#define _PATH_USRLIB "/lib/" #define _PATH_USRLIB "/lib/"
#define _PATH_CTIMED "/libexec/ctimed" #define _PATH_CTIMED "/libexec/ctimed"
#define _PATH_LOCALLIB "/local/lib/" #define _PATH_LOCALLIB "/local/lib/"
#define _PATH_SBIN "/sbin/" #define _PATH_SBIN "/sbin/"
#define _PATH_USRSBIN "/sbin/" #define _PATH_USRSBIN "/sbin/"
#define _PATH_MKPASSWD "/sbin/mkpasswd"
#define _PATH_SENDMAIL "/sbin/sendmail" #define _PATH_SENDMAIL "/sbin/sendmail"
#define _PATH_SHARE "/share/" #define _PATH_SHARE "/share/"
#define _PATH_ZONEINFO "/share/zoneinfo" /* Time zone object file directory */ #define _PATH_ZONEINFO "/share/zoneinfo" /* Time zone object file directory */
+229
View File
@@ -0,0 +1,229 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* @(#)pcc.h 5.1 (Berkeley) 5/30/85
*/
/*
* This file contains definitions for all the constants and structures
* needed to use the intermediate code files generated and read by
* the Portable C Compiler and related compilers.
*
* Rules for changing this code:
* 1) All op values must be integer constants -- this permits us to run
* a 'sed' script on this file to create %term declarations for yacc.
* 2) Because the PCC uses fancy ASG and UNARY macros, assignment
* operators must have values 1 greater than corresponding normal
* operators, and unary operators must have values 2 greater ditto.
* 3) Ops used only by f1 must have values >= 150 (PCCF_FORTOPS).
* 4) Other language-dependent ops must have values >= 200.
*/
# ifndef PCC_TOKENS
# define PCC_TOKENS 0
# define PCC_ERROR 1 /* an error node */
# define PCC_FREE 2 /* an unused node */
/*
* Constants.
*/
# define PCC_STRING 3 /* a string constant */
# define PCC_ICON 4 /* an integer constant */
# define PCC_FCON 5 /* a floating point constant */
# define PCC_DCON 6 /* a double precision f.p. constant */
/*
* Leaf types.
*/
# define PCC_NAME 7 /* an identifier */
# define PCC_REG 8 /* a register */
# define PCC_OREG 9 /* register and offset */
# define PCC_CCODES 10 /* condition codes */
# define PCC_FLD 11 /* a bit field */
/*
* Arithmetic operators.
*/
# define PCC_PLUS 12 /* + */
# define PCC_PLUSEQ 13 /* += */
# define PCC_UPLUS 14 /* unary + (for completeness) */
# define PCC_MINUS 15 /* - */
# define PCC_MINUSEQ 16 /* -= */
# define PCC_UMINUS 17 /* unary - */
# define PCC_MUL 18 /* * */
# define PCC_MULEQ 19 /* *= */
/* Reserve a slot for 'unary *', which is PCC jargon for PCC_DEREF (yech) */
# define PCC_DIV 21 /* / */
# define PCC_DIVEQ 22 /* /= */
# define PCC_MOD 23 /* % */
# define PCC_MODEQ 24 /* %= */
# define PCC_INCR 25 /* ++ */
# define PCC_DECR 26 /* -- */
# define PCC_ASSIGN 27 /* = (these last 3 are stretching it) */
/*
* Bit operators.
*/
# define PCC_AND 28 /* & */
# define PCC_ANDEQ 29 /* &= */
/* Reserve a slot for 'unary &', jargon for PCC_ADDROF */
# define PCC_OR 31 /* | */
# define PCC_OREQ 32 /* |= */
# define PCC_ER 33 /* ^ */
# define PCC_EREQ 34 /* ^= */
# define PCC_LS 35 /* << */
# define PCC_LSEQ 36 /* <<= */
# define PCC_RS 37 /* >> */
# define PCC_RSEQ 38 /* >>= */
# define PCC_COMPL 39 /* ~ */
/*
* Booleans.
*/
# define PCC_EQ 40 /* == */
# define PCC_NE 41 /* != */
# define PCC_LE 42 /* <= */
# define PCC_LT 43 /* < */
# define PCC_GE 44 /* >= */
# define PCC_GT 45 /* > */
# define PCC_ULE 46 /* unsigned <= */
# define PCC_ULT 47 /* unsigned < */
# define PCC_UGE 48 /* unsigned >= */
# define PCC_UGT 49 /* unsigned > */
# define PCC_QUEST 50 /* ? (for conditional expressions) */
# define PCC_COLON 51 /* : (for conditional expressions) */
# define PCC_ANDAND 52 /* && */
# define PCC_OROR 53 /* || */
# define PCC_NOT 54 /* ! */
/*
* Function calls.
*/
# define PCC_CALL 55 /* call by value */
/* no ASG */
# define PCC_UCALL 57 /* call with no arguments */
# define PCC_FORTCALL 58 /* call by reference? */
/* no ASG */
# define PCC_UFORTCALL 60 /* ??? */
# ifdef INLINE
# define PCC_INLINE 61 /* inline function */
/* no ASG */
# define PCC_UINLINE 63 /* inline with no arguments */
# endif INLINE
/*
* Referencing and dereferencing.
*/
# define PCC_DEREF 20 /* * */
# define PCC_ADDROF 30 /* & */
/*
* Special structure operators.
*/
# define PCC_DOT 64 /* . */
# define PCC_STREF 65 /* -> */
# define PCC_STASG 66 /* structure assignment */
# define PCC_STARG 67 /* an argument of type structure */
# define PCC_STCALL 68 /* a function of type structure */
/* no ASG */
# define PCC_USTCALL 70 /* unary structure function */
/*
* Conversions.
*/
# define PCC_SCONV 71 /* scalar conversion */
# define PCC_PCONV 72 /* pointer conversion */
# define PCC_PMCONV 73 /* pointer multiply conversion */
# define PCC_PVCONV 74 /* pointer divide conversion */
# define PCC_CAST 75 /* redundant? */
/*
* Bracket types.
*/
# define PCC_LB 76 /* [ */
# define PCC_RB 77 /* ] */
/*
* Comma nodes.
*/
# define PCC_COMOP 78 /* , (in expressions) */
# define PCC_CM 79 /* , (in argument lists) */
/*
* Miscellaneous.
*/
# define PCC_FORCE 80 /* result of last expression goes in r0 */
# define PCC_GOTO 81 /* unconditional goto */
# define PCC_CBRANCH 82 /* goto label if !test */
# define PCC_RETURN 83 /* return from function */
# define PCC_INIT 84 /* initialized data */
# define PCC_TYPE 85 /* a type */
# define PCC_CLASS 86 /* a storage class */
# define PCC_MAXOP 86 /* highest numbered PCC op */
/*
* Special codes for interfacing to /lib/f1.
*/
# define PCCF_FORTOPS 150
# define PCCF_FTEXT 150 /* pass literal assembler text */
# define PCCF_FEXPR 151 /* a statement */
# define PCCF_FSWITCH 152 /* not implemented */
# define PCCF_FLBRAC 153 /* beginning of subroutine */
# define PCCF_FRBRAC 154 /* end of subroutine */
# define PCCF_FEOF 155 /* end of file */
# define PCCF_FARIF 156 /* not implemented */
# define PCCF_FLABEL 157 /* an f77 label */
# endif PCC_TOKENS
/*
* Types, as encoded in intermediate file cookies.
*/
# define PCCT_UNDEF 0
# define PCCT_FARG 1 /* function argument */
# define PCCT_CHAR 2
# define PCCT_SHORT 3
# define PCCT_INT 4
# define PCCT_LONG 5
# define PCCT_FLOAT 6
# define PCCT_DOUBLE 7
# define PCCT_STRTY 8
# define PCCT_UNIONTY 9
# define PCCT_ENUMTY 10
# define PCCT_MOETY 11 /* member of enum */
# define PCCT_UCHAR 12
# define PCCT_USHORT 13
# define PCCT_UNSIGNED 14
# define PCCT_ULONG 15
/*
* Type modifiers.
*/
# define PCCTM_PTR 020
# define PCCTM_FTN 040
# define PCCTM_ARY 060
# define PCCTM_BASETYPE 017
# define PCCTM_TYPESHIFT 2
/*
* Useful macros. 'PCCOM' macros apply to ops.
*/
# define PCCOM_ASG 1+
# define PCCOM_UNARY 2+
# define PCCOM_NOASG (-1)+
# define PCCOM_NOUNARY (-2)+
# define PCCM_TRIPLE(op, var, type) \
((op) | ((var) << 8) | (long) (type) << 16)
# define PCCM_TEXT(s) \
PCCM_TRIPLE(PCCF_FTEXT, (strlen(s) + 3) / 4, 0)
# define PCCM_ADDTYPE(t, m) \
((((t) &~ PCCTM_BASETYPE) << PCCTM_TYPESHIFT) | \
(m) | ((t) & PCCTM_BASETYPE))
+1 -1
View File
@@ -34,7 +34,7 @@ struct psout {
time_t o_cstime; /* u_cstime */ time_t o_cstime; /* u_cstime */
short o_pgrp; /* p_pgrp */ short o_pgrp; /* p_pgrp */
int o_sigs; /* sum of SIGINT & SIGQUIT, int o_sigs; /* sum of SIGINT & SIGQUIT,
* if == 2 proc is ignoring both.*/ if == 2 proc is ignoring both.*/
char o_comm[MAXCOMLEN+1]; /* u_comm */ char o_comm[MAXCOMLEN+1]; /* u_comm */
char o_args[64]; /* best guess at args to process */ char o_args[64]; /* best guess at args to process */
}; };
+5
View File
@@ -15,6 +15,11 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/ */
#define _PATH_PASSWD "/etc/passwd"
#define _PATH_SHADOW "/etc/shadow"
#define _PATH_MKPASSWD "/sbin/mkpasswd"
#define _PATH_PTMP "/etc/ptmp"
#define _PW_KEYBYNAME '0' #define _PW_KEYBYNAME '0'
#define _PW_KEYBYUID '1' #define _PW_KEYBYUID '1'
-7
View File
@@ -1,7 +0,0 @@
#ifndef _REGEX_H
#define _REGEX_H
char *re_comp(const char *regex);
int re_exec(const char *string);
#endif
-1
View File
@@ -5,7 +5,6 @@
* not the System V one. * not the System V one.
*/ */
#define NSUBEXP 10 #define NSUBEXP 10
typedef struct regexp { typedef struct regexp {
char *startp[NSUBEXP]; char *startp[NSUBEXP];
char *endp[NSUBEXP]; char *endp[NSUBEXP];
+42
View File
@@ -0,0 +1,42 @@
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* @(#)stab.h 5.1 (Berkeley) 5/30/85
*/
/* IF YOU ADD DEFINITIONS, ADD THEM TO nm.c as well */
/*
* This file gives definitions supplementing <a.out.h>
* for permanent symbol table entries.
* These must have one of the N_STAB bits on,
* and are subject to relocation according to the masks in <a.out.h>.
*/
/*
* for symbolic debugger, sdb(1):
*/
#define N_GSYM 0x20 /* global symbol: name,,0,type,0 */
#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */
#define N_FUN 0x24 /* procedure: name,,0,linenumber,address */
#define N_STSYM 0x26 /* static symbol: name,,0,type,address */
#define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */
#define N_RSYM 0x40 /* register sym: name,,0,type,register */
#define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */
#define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */
#define N_SO 0x64 /* source file name: name,,0,0,address */
#define N_LSYM 0x80 /* local sym: name,,0,type,offset */
#define N_SOL 0x84 /* #included file name: name,,0,0,address */
#define N_PSYM 0xa0 /* parameter: name,,0,type,offset */
#define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */
#define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */
#define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */
#define N_BCOMM 0xe2 /* begin common: name,, */
#define N_ECOMM 0xe4 /* end common: name,, */
#define N_ECOML 0xe8 /* end common (local name): ,,address */
#define N_LENG 0xfe /* second stab entry with length information */
/*
* for the berkeley pascal compiler, pc(1):
*/
#define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */
+22 -39
View File
@@ -4,49 +4,32 @@
#ifndef _STDARG_H #ifndef _STDARG_H
#define _STDARG_H #define _STDARG_H
/* /* Define __gnuc_va_list. */
* Define va_start, va_arg, va_end, va_copy.
*/
#if defined(__GNUC__) /* Gnu C */
# define va_start(ap, last) __builtin_va_start((ap), last)
# define va_arg(ap, type) __builtin_va_arg((ap), type)
# define va_end(ap) __builtin_va_end((ap))
# define va_copy(dest, src) __builtin_va_copy((dest), (src))
#elif defined(__PCC__) /* PCC */
# define va_start(ap, last) __builtin_stdarg_start((ap), last)
# define va_arg(ap, type) __builtin_va_arg((ap), type)
# define va_end(ap) __builtin_va_end((ap))
# define va_copy(dest, src) __builtin_va_copy((dest), (src))
#else /* SmallerC, LCC */ #ifdef __GNUC__
# define va_start(ap, last) (ap = ((char*)&(last) + \ # ifndef __GNUC_VA_LIST
(((sizeof(last) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))))
# define va_arg(ap, type) ((type*)(ap += \
sizeof(type) == sizeof(int) ? sizeof(type) : \
(-(int)(ap) & (sizeof(type) - 1)) + sizeof(type)))[-1]
# define va_end(ap)
# define va_copy(dest, src) (dest = (src))
#endif
/*
* Define va_list.
*/
#ifndef _VA_LIST_T
# define _VA_LIST_T
# if defined(__GNUC__) || defined(__PCC__)
typedef __builtin_va_list va_list;
# else
typedef char *va_list;
# endif
#endif
/*
* Define __gnuc_va_list.
*/
#if defined(__GNUC__) && !defined(__GNUC_VA_LIST)
# define __GNUC_VA_LIST # define __GNUC_VA_LIST
typedef __builtin_va_list __gnuc_va_list; typedef __builtin_va_list __gnuc_va_list;
# endif
# define va_start(ap, last) __builtin_va_start((ap), last)
#endif
#ifdef __PCC__
# define va_start(ap, last) __builtin_stdarg_start((ap), last)
#endif
#define va_arg(ap, type) __builtin_va_arg((ap), type)
#define va_end(ap) __builtin_va_end((ap))
#define va_copy(dest, src) __builtin_va_copy((dest), (src))
#ifndef _VA_LIST
#define _VA_LIST
#ifdef __GNUC__
typedef __builtin_va_list va_list;
#endif
#ifdef __SMALLER_C__
typedef int *va_list;
#endif
#endif #endif
#endif /* not _STDARG_H */ #endif /* not _STDARG_H */
-37
View File
@@ -1,37 +0,0 @@
/*
* Copyright (c) 2000 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
#ifndef __cplusplus
#define false 0
#define true 1
#define bool _Bool
#endif /* !__cplusplus */
#endif /* __bool_true_false_are_defined */
+1 -15
View File
@@ -1,22 +1,8 @@
#ifndef _STDDEF_H_
#define _STDDEF_H_
typedef int ptrdiff_t;
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
#ifndef NULL
#define NULL 0
#endif
/* Offset of member MEMBER in a struct of type TYPE. */ /* Offset of member MEMBER in a struct of type TYPE. */
#if defined(__GNUC__) && __GNUC__ > 3 #if defined(__GNUC__) && __GNUC__ > 3
#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
#else #else
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE*)0)->MEMBER) #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE*)0)->MEMBER)
#endif #endif
#endif /* _STDDEF_H_ */
+1 -16
View File
@@ -5,26 +5,11 @@
typedef signed char int8_t; typedef signed char int8_t;
typedef short int int16_t; typedef short int int16_t;
typedef int int32_t; typedef int int32_t;
typedef long long int64_t;
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
typedef unsigned short int uint16_t; typedef unsigned short int uint16_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
#define INT8_C(x) x
#define UINT8_C(x) x##U
#define INT16_C(x) x
#define UINT16_C(x) x##U
#define INT32_C(x) x
#define UINT32_C(x) x##U
#define INT64_C(x) x##LL
#define UINT64_C(x) x##ULL
#define INTMAX_C(x) x##LL
#define UINTMAX_C(x) x##ULL
#endif #endif
+11 -22
View File
@@ -5,6 +5,8 @@
*/ */
#ifndef FILE #ifndef FILE
#include <sys/types.h>
#define BUFSIZ 1024 #define BUFSIZ 1024
extern struct _iobuf { extern struct _iobuf {
int _cnt; int _cnt;
@@ -38,11 +40,6 @@ extern struct _iobuf {
#define NULL 0 #define NULL 0
#endif #endif
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
#define FILE struct _iobuf #define FILE struct _iobuf
#define EOF (-1) #define EOF (-1)
@@ -65,11 +62,17 @@ typedef unsigned size_t;
_flsbuf((unsigned char)(x), p))) _flsbuf((unsigned char)(x), p)))
#endif /* not lint */ #endif /* not lint */
#define getchar() getc(stdin)
#define putchar(x) putc(x,stdout)
#define feof(p) (((p)->_flag&_IOEOF)!=0)
#define ferror(p) (((p)->_flag&_IOERR)!=0)
#define fileno(p) ((p)->_file)
#define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
FILE *fopen (const char *, const char *); FILE *fopen (const char *, const char *);
FILE *fdopen (int, const char *); FILE *fdopen (int, const char *);
FILE *freopen (const char *, const char *, FILE *); FILE *freopen (const char *, const char *, FILE *);
FILE *popen (const char *, const char *); FILE *popen (const char *, const char *);
int pclose(FILE *stream);
FILE *tmpfile (void); FILE *tmpfile (void);
int fclose (FILE *); int fclose (FILE *);
long ftell (FILE *); long ftell (FILE *);
@@ -77,7 +80,6 @@ int fflush (FILE *);
int fgetc (FILE *); int fgetc (FILE *);
int ungetc (int, FILE *); int ungetc (int, FILE *);
int fputc (int, FILE *); int fputc (int, FILE *);
int putchar (int);
int fputs (const char *, FILE *); int fputs (const char *, FILE *);
int puts (const char *); int puts (const char *);
char *fgets (char *, int, FILE *); char *fgets (char *, int, FILE *);
@@ -90,7 +92,6 @@ void setbuffer (FILE *, char *, size_t);
void setlinebuf (FILE *); void setlinebuf (FILE *);
int setvbuf (FILE *, char *, int, size_t); int setvbuf (FILE *, char *, int, size_t);
int fseek (FILE *, long, int); int fseek (FILE *, long, int);
int rename(const char *, const char *);
void rewind (FILE *); void rewind (FILE *);
int remove (const char *); int remove (const char *);
int getw(FILE *stream); int getw(FILE *stream);
@@ -108,20 +109,8 @@ int fscanf (FILE *, const char *, ...);
int scanf (const char *, ...); int scanf (const char *, ...);
int sscanf (const char *, const char *, ...); int sscanf (const char *, const char *, ...);
#define getchar() getc(stdin)
#define putchar(x) putc(x,stdout)
#define feof(p) (((p)->_flag&_IOEOF)!=0)
#define ferror(p) (((p)->_flag&_IOERR)!=0)
#define fileno(p) ((p)->_file)
#define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
#ifndef _VA_LIST_ #ifndef _VA_LIST_
# ifdef __GNUC__ #define va_list __builtin_va_list /* For GCC */
# define va_list __builtin_va_list /* For Gnu C */
# endif
# ifdef __SMALLER_C__
# define va_list char * /* For Smaller C */
# endif
#endif #endif
int vfprintf (FILE *, const char *, va_list); int vfprintf (FILE *, const char *, va_list);
@@ -137,7 +126,7 @@ int _doprnt (const char *, va_list, FILE *);
int _doscan (FILE *, const char *, va_list); int _doscan (FILE *, const char *, va_list);
#ifndef _VA_LIST_ #ifndef _VA_LIST_
# undef va_list #undef va_list
#endif #endif
void perror (const char *); void perror (const char *);
+38 -41
View File
@@ -43,6 +43,8 @@
#ifndef _STDLIB_H_ #ifndef _STDLIB_H_
#define _STDLIB_H_ #define _STDLIB_H_
#include <sys/types.h>
#ifndef NULL #ifndef NULL
#define NULL 0 #define NULL 0
#endif #endif
@@ -52,54 +54,49 @@
#define RAND_MAX 0x7fff #define RAND_MAX 0x7fff
#ifndef _SIZE_T void abort();
#define _SIZE_T int abs (int);
typedef unsigned size_t; int atexit (void (*)(void));
#endif double atof();
int atoi();
long atol();
void *calloc (size_t, size_t);
void exit (int);
void free (void *);
char *getenv();
long labs (long);
void *malloc (size_t);
char *mktemp (char *);
int mkstemp (char *);
void qsort();
int rand();
void *realloc (void*, size_t);
void srand();
double strtod();
long strtol();
unsigned long strtoul();
int system();
void abort(void); int putenv (char *string);
int abs(int); int setenv (const char *name, const char *value, int overwrite);
int atexit(void (*)(void)); int unsetenv (const char *name);
int atoi(const char *); char *_findenv (const char *name, int *offset);
long atol(const char *);
void *calloc(size_t, size_t);
void exit(int);
void free(void *);
char *getenv(const char *);
long labs(long);
void *malloc(size_t);
char *mktemp(char *);
int mkstemp(char *);
void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
int rand(void);
void *realloc(void*, size_t);
void srand(unsigned);
long strtol(const char *, char **, int);
unsigned long strtoul(const char *, char **, int);
int system(const char *);
int putenv(char *string); void *alloca();
int setenv(const char *name, const char *value, int overwrite);
int unsetenv(const char *name);
char *_findenv(const char *name, int *offset);
void *alloca(size_t size); int daemon();
char *devname();
int daemon(int, int);
char *devname(int dev, int type);
int getloadavg(unsigned loadavg[], int nelem); int getloadavg(unsigned loadavg[], int nelem);
extern char *suboptarg; /* getsubopt(3) external variable */ extern char *suboptarg; /* getsubopt(3) external variable */
int getsubopt(char **, char **, char **); int getsubopt();
long random(void); long random (void);
char *setstate(char *); char *setstate (char *);
void srandom(unsigned); void srandom (unsigned);
double atof(const char *); char *ecvt (double, int, int *, int *);
double strtod(const char *, char **); char *fcvt (double, int, int *, int *);
char *ecvt(double, int, int *, int *); char *gcvt (double, int, char *);
char *fcvt(double, int, int *, int *);
char *gcvt(double, int, char *);
#endif /* _STDLIB_H_ */ #endif /* _STDLIB_H_ */
+2 -5
View File
@@ -3,15 +3,12 @@
* All rights reserved. The Berkeley software License Agreement * All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution. * specifies the terms and conditions for redistribution.
*/ */
#include <sys/types.h>
#ifndef NULL #ifndef NULL
#define NULL 0 #define NULL 0
#endif #endif
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
char *strcat (char *, const char *); char *strcat (char *, const char *);
char *strncat (char *, const char *, size_t); char *strncat (char *, const char *, size_t);
char *strcpy (char *, const char *); char *strcpy (char *, const char *);
+2 -5
View File
@@ -30,14 +30,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#ifndef _SIZE_T #include <sys/types.h>
#define _SIZE_T
typedef unsigned size_t;
#endif
int bcmp(const void *, const void *, size_t); int bcmp(const void *, const void *, size_t);
void bcopy(const void *, void *, size_t); void bcopy(const void *, void *, size_t);
void bzero(void *, unsigned int); void bzero(void *, unsigned long);
int ffs(int); int ffs(int);
char *index(const char *, int); char *index(const char *, int);
char *rindex(const char *, int); char *rindex(const char *, int);
+1 -1
View File
@@ -6,6 +6,6 @@ extern int tgetnum(char *);
extern int tgetflag(char *); extern int tgetflag(char *);
extern char *tgetstr(char *, char **); extern char *tgetstr(char *, char **);
extern char *tgoto(char *, int, int); extern char *tgoto(char *, int, int);
extern int tputs(register char *, int, int (*)(int)); extern int tputs(register char *, int, int (*)());
#endif #endif
+3
View File
@@ -4,6 +4,8 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <stdint.h> #include <stdint.h>
#define E_TERMCAP "/etc/termcap"
typedef unsigned char cc_t; typedef unsigned char cc_t;
typedef unsigned int speed_t; typedef unsigned int speed_t;
typedef unsigned int tcflag_t; typedef unsigned int tcflag_t;
@@ -143,4 +145,5 @@ extern int tcsetattr(int, int, struct termios *);
#define TIOCSETAW _IOW(i, 92, struct termios) #define TIOCSETAW _IOW(i, 92, struct termios)
#define TIOCSETAF _IOW(i, 92, struct termios) #define TIOCSETAF _IOW(i, 92, struct termios)
#endif #endif
+4 -18
View File
@@ -6,19 +6,7 @@
#ifndef _TIME_H #ifndef _TIME_H
#define _TIME_H #define _TIME_H
#ifndef NULL #include <sys/types.h> /* for time_t */
#define NULL 0
#endif
#ifndef _TIME_T
#define _TIME_T
typedef long time_t;
#endif
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
/* /*
* Structure returned by gmtime and localtime calls (see ctime(3)). * Structure returned by gmtime and localtime calls (see ctime(3)).
@@ -37,11 +25,9 @@ struct tm {
char *tm_zone; char *tm_zone;
}; };
struct tm *gmtime(const time_t *); extern struct tm *gmtime(), *localtime();
struct tm *localtime(const time_t *); extern char *asctime(), *ctime();
char *asctime(const struct tm *); extern time_t time();
char *ctime(const time_t *);
time_t time(time_t *);
size_t strftime (char *s, size_t maxsize, const char *format, size_t strftime (char *s, size_t maxsize, const char *format,
const struct tm *timeptr); const struct tm *timeptr);
+3 -1
View File
@@ -5,13 +5,14 @@
/* /*
** Information about time zone files. ** Information about time zone files.
*/ */
/* Time zone object file directory */ /* Time zone object file directory */
#define TZDIR "/usr/share/zoneinfo"
#define TZDEFAULT "/etc/localtime" #define TZDEFAULT "/etc/localtime"
/* /*
** Each file begins with. . . ** Each file begins with. . .
*/ */
struct tzhead { struct tzhead {
char tzh_reserved[32]; /* reserved for future use */ char tzh_reserved[32]; /* reserved for future use */
char tzh_timecnt[4]; /* coded number of transition times */ char tzh_timecnt[4]; /* coded number of transition times */
@@ -95,4 +96,5 @@ struct tzhead {
** Accurate only for the past couple of centuries; ** Accurate only for the past couple of centuries;
** that will probably do. ** that will probably do.
*/ */
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) #define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
+52 -73
View File
@@ -57,16 +57,14 @@
#define X_OK 1 /* Test for execute permission. */ #define X_OK 1 /* Test for execute permission. */
#define F_OK 0 /* Test for existence. */ #define F_OK 0 /* Test for existence. */
void _exit(int); void _exit (int);
int access(); int access();
unsigned int alarm(); unsigned int alarm();
pid_t fork(); pid_t fork();
pid_t setsid(void);
gid_t getegid(); gid_t getegid();
uid_t geteuid(); uid_t geteuid();
gid_t getgid(); gid_t getgid();
char *getlogin(); char *getlogin();
int setlogin(const char *name);
pid_t getpgrp(); pid_t getpgrp();
pid_t getpid(); pid_t getpid();
pid_t getppid(); pid_t getppid();
@@ -75,12 +73,12 @@ off_t lseek();
ssize_t read(); ssize_t read();
unsigned int sleep(); unsigned int sleep();
char *ttyname(); char *ttyname();
ssize_t write(int fd, const void *buf, size_t count); ssize_t write (int fd, const void *buf, size_t count);
int truncate(const char *path, off_t length); int truncate (const char *path, off_t length);
int ftruncate(int fd, off_t length); int ftruncate (int fd, off_t length);
void *brk(const void *addr); void *brk (const void *addr);
int _brk(const void *addr); int _brk (const void *addr);
char *crypt(); char *crypt();
void endusershell(); void endusershell();
long gethostid(); long gethostid();
@@ -90,93 +88,74 @@ char *getwd();
void psignal(); void psignal();
extern char *sys_siglist[]; extern char *sys_siglist[];
char *re_comp(); char *re_comp();
void *sbrk(int incr); void *sbrk (int incr);
int sethostid(); int sethostid();
void setusershell(); void setusershell();
void sync(void); void sync();
unsigned int ualarm(); unsigned int ualarm();
void usleep(); void usleep();
int pause(void); int pause (void);
pid_t vfork(); pid_t vfork();
int pipe(int pipefd[2]); int pipe (int pipefd[2]);
int close(int fd); int close (int fd);
int dup(int oldfd); int dup (int oldfd);
int dup2(int oldfd, int newfd); int dup2 (int oldfd, int newfd);
int unlink(const char *pathname); int unlink (const char *pathname);
int link(const char *oldpath, const char *newpath); int link (const char *oldpath, const char *newpath);
ssize_t readlink(const char *path, char *buf, size_t bufsiz); ssize_t readlink (const char *path, char *buf, size_t bufsiz);
int chown(const char *path, uid_t owner, gid_t group); int chown (const char *path, uid_t owner, gid_t group);
int fchown(int fd, uid_t owner, gid_t group); int nice (int inc);
int nice(int inc); int setuid (uid_t uid);
int setuid(uid_t uid); int setgid (gid_t gid);
int setgid(gid_t gid); int seteuid (uid_t euid);
int seteuid(uid_t euid); int setegid (gid_t egid);
int setegid(gid_t egid); int setreuid (uid_t ruid, uid_t euid);
int setreuid(uid_t ruid, uid_t euid); int setregid (gid_t rgid, gid_t egid);
int setregid(gid_t rgid, gid_t egid); int isatty (int fd);
int setpgrp(void); int chdir (const char *path);
int isatty(int fd); int fchdir (int fd);
int chdir(const char *path); int chflags (const char *path, u_long flags);
int fchdir(int fd); int fchflags (int fd, u_long flags);
int chflags(const char *path, u_long flags); int getgroups (int size, gid_t list[]);
int fchflags(int fd, u_long flags); int getdtablesize (void);
int getgroups(int size, gid_t list[]); int rmdir (const char *pathname);
int getdtablesize(void);
int rmdir(const char *pathname);
struct stat; struct stat;
int stat(const char *path, struct stat *buf); int stat (const char *path, struct stat *buf);
int fstat(int fd, struct stat *buf); int fstat (int fd, struct stat *buf);
int lstat(const char *path, struct stat *buf); int lstat (const char *path, struct stat *buf);
int execl(const char *path, const char *arg0, ... /* NULL */); int execl (const char *path, const char *arg0, ... /* NULL */);
int execle(const char *path, const char *arg0, ... /* NULL, char *envp[] */); int execle (const char *path, const char *arg0, ... /* NULL, char *envp[] */);
int execlp(const char *file, const char *arg0, ... /* NULL */); int execlp (const char *file, const char *arg0, ... /* NULL */);
int execv(const char *path, char *const argv[]); int execv (const char *path, char *const argv[]);
int execve(const char *path, char *const arg0[], char *const envp[]); int execve (const char *path, char *const arg0[], char *const envp[]);
int execvp(const char *file, char *const argv[]); int execvp (const char *file, char *const argv[]);
extern char **environ; /* Environment, from crt0. */ extern char **environ; /* Environment, from crt0. */
extern const char *__progname; /* Program name, from crt0. */ extern const char *__progname; /* Program name, from crt0. */
int getopt(int argc, char * const argv[], const char *optstring); int getopt (int argc, char * const argv[], const char *optstring);
extern char *optarg; /* getopt(3) external variables */ extern char *optarg; /* getopt(3) external variables */
extern int opterr, optind, optopt; extern int opterr, optind, optopt;
int gethostname(char *name, int namelen);
int sethostname(char *name, int namelen);
int chroot(const char *path);
int fsync(int fd);
int getpagesize(void);
int symlink(const char *target, const char *linkpath);
int vhangup(void);
int mknod(const char *, mode_t, dev_t);
int reboot(int howto);
int ttyslot(void);
#ifndef _VA_LIST_ #ifndef _VA_LIST_
# ifdef __GNUC__ #define va_list __builtin_va_list /* For GCC */
# define va_list __builtin_va_list /* For Gnu C */
# endif
# ifdef __SMALLER_C__
# define va_list char * /* For Smaller C */
# endif
#endif #endif
void err(int eval, const char *fmt, ...); void err (int eval, const char *fmt, ...);
void errx(int eval, const char *fmt, ...); void errx (int eval, const char *fmt, ...);
void warn(const char *fmt, ...); void warn (const char *fmt, ...);
void warnx(const char *fmt, ...); void warnx (const char *fmt, ...);
void verr(int eval, const char *fmt, va_list ap); void verr (int eval, const char *fmt, va_list ap);
void verrx(int eval, const char *fmt, va_list ap); void verrx (int eval, const char *fmt, va_list ap);
void vwarn(const char *fmt, va_list ap); void vwarn (const char *fmt, va_list ap);
void vwarnx(const char *fmt, va_list ap); void vwarnx (const char *fmt, va_list ap);
#ifndef _VA_LIST_ #ifndef _VA_LIST_
# undef va_list #undef va_list
#endif #endif
#endif /* !_UNISTD_H_ */ #endif /* !_UNISTD_H_ */
-2
View File
@@ -25,5 +25,3 @@ struct utmp {
char ut_host[UT_HOSTSIZE]; char ut_host[UT_HOSTSIZE];
long ut_time; long ut_time;
}; };
void login(struct utmp *ut);
+13 -12
View File
@@ -11,7 +11,8 @@
* Define segment+offset and modified macros. * Define segment+offset and modified macros.
* Place into the public domain. * Place into the public domain.
* -------------------------------------------------- * --------------------------------------------------
*/ */
#include <sys/types.h> #include <sys/types.h>
#define MAXSEGNO 16384 /* max number of segments in a space */ #define MAXSEGNO 16384 /* max number of segments in a space */
@@ -23,12 +24,12 @@ struct vspace {
int v_fd; /* file for swapping */ int v_fd; /* file for swapping */
off_t v_foffset; /* offset for computing file addresses */ off_t v_foffset; /* offset for computing file addresses */
int v_maxsegno; /* number of segments in this space */ int v_maxsegno; /* number of segments in this space */
}; };
struct dlink { /* general double link structure */ struct dlink { /* general double link structure */
struct dlink *fwd; /* forward link */ struct dlink *fwd; /* forward link */
struct dlink *back; /* back link */ struct dlink *back; /* back link */
}; };
struct vseg { /* structure of a segment in memory */ struct vseg { /* structure of a segment in memory */
struct dlink s_link; /* for linking into lru list */ struct dlink s_link; /* for linking into lru list */
@@ -36,11 +37,12 @@ struct vseg { /* structure of a segment in memory */
struct vspace *s_vspace; /* which virtual space */ struct vspace *s_vspace; /* which virtual space */
int s_lock_count; int s_lock_count;
int s_flags; int s_flags;
union { union
{
int _winfo[WORDSPERSEG]; /* the actual segment */ int _winfo[WORDSPERSEG]; /* the actual segment */
char _cinfo[BYTESPERSEG]; char _cinfo[BYTESPERSEG];
} v_un; } v_un;
}; };
#define s_winfo v_un._winfo #define s_winfo v_un._winfo
#define s_cinfo v_un._cinfo #define s_cinfo v_un._cinfo
@@ -48,16 +50,15 @@ struct vseg { /* structure of a segment in memory */
/* masks for s_flags */ /* masks for s_flags */
#define S_DIRTY 01 /* segment has been modified */ #define S_DIRTY 01 /* segment has been modified */
extern long nswaps; /* number of swaps */ long nswaps; /* number of swaps */
extern long nmapsegs; /* number of mapseg calls */ long nmapsegs; /* number of mapseg calls */
int vminit(), vmopen(); int vminit(), vmopen();
struct vseg *vmmapseg(); struct vseg *vmmapseg();
void vmlock(), vmunlock(), vmclrseg(), vmmodify(); void vmlock(), vmunlock(), vmclrseg(), vmmodify();
void vmflush(), vmclose(); void vmflush(), vmclose();
typedef long VADDR; typedef long VADDR;
#define VMMODIFY(seg) (seg->s_flags |= S_DIRTY) #define VMMODIFY(seg) (seg->s_flags |= S_DIRTY)
#define VSEG(va) ((short)(va >> LOG2BPS)) #define VSEG(va) ((short)(va >> LOG2BPS))
#define VOFF(va) ((u_short)va % BYTESPERSEG) #define VOFF(va) ((u_short)va % BYTESPERSEG)
Regular → Executable
+17 -8
View File
@@ -1,11 +1,21 @@
TOPSRC = $(shell cd ..; pwd) TOPSRC = $(shell cd ..; pwd)
SUBDIR = startup libc libm libcurses libtermlib libwiznet libreadline libgpanel SUBDIR = startup libc libcurses libtermlib libwiznet
PROG = ar as aout ld nm ranlib size strip PROG = ar as aout ld nm ranlib size strip
CFLAGS = -Os -std=gnu89 -fno-builtin -g -Werror -Wall -DCROSS -I. \ # Build a list of the host include directories.
-idirafter $(TOPSRC)/include \ CPP = $(shell gcc -print-prog-name=cc1)
-idirafter $(TOPSRC)/src/cmd/ar \ HOSTINC = $(addprefix -I,$(shell echo | $(CPP) -v 2>&1 | grep '^ /.*include'))
-idirafter $(TOPSRC)/src/cmd/as
# Add system include path
ifeq (,$(wildcard /usr/include/i386-linux-gnu))
HOSTINC += -I/usr/include
else
HOSTINC += -I/usr/include/i386-linux-gnu
endif
CFLAGS += -nostdinc -fno-builtin -g -Werror -Wall -DCROSS -I. $(HOSTINC) \
-I$(TOPSRC)/include -I$(TOPSRC)/src/cmd/ar \
-I$(TOPSRC)/src/cmd/as
LDFLAGS += -g LDFLAGS += -g
AR_OBJS = ar.o append.o archive.o contents.o delete.o extract.o \ AR_OBJS = ar.o append.o archive.o contents.o delete.o extract.o \
@@ -14,9 +24,8 @@ AOUT_OBJS = aout.o mips-dis.o
RANLIB_OBJS = ranlib.o archive.o RANLIB_OBJS = ranlib.o archive.o
HEADERS = a.out.h ar.h nlist.h ranlib.h HEADERS = a.out.h ar.h nlist.h ranlib.h
vpath %.c $(TOPSRC)/src/cmd/aout $(TOPSRC)/src/cmd/ar $(TOPSRC)/src/cmd/as \ vpath %.c $(TOPSRC)/src/cmd/ar $(TOPSRC)/src/cmd/as $(TOPSRC)/src/cmd/ld \
$(TOPSRC)/src/cmd/ld $(TOPSRC)/src/cmd/nm $(TOPSRC)/src/cmd/ranlib \ $(TOPSRC)/src/cmd/nm $(TOPSRC)/src/cmd/ranlib $(TOPSRC)/src/cmd
$(TOPSRC)/src/cmd
all install depend: $(HEADERS) $(SUBDIR) $(PROG) all install depend: $(HEADERS) $(SUBDIR) $(PROG)
-for i in $(SUBDIR); do $(MAKE) -C $$i $(MFLAGS) DESTDIR=$(DESTDIR) $@; done -for i in $(SUBDIR); do $(MAKE) -C $$i $(MFLAGS) DESTDIR=$(DESTDIR) $@; done
+4 -5
View File
@@ -8,7 +8,7 @@ vpath %.c $(LIBCDIR)/mips/sys $(LIBCDIR)/gen $(LIBCDIR)/stdio \
$(LIBCDIR)/stdlib $(LIBCDIR)/string $(LIBCDIR)/inet \ $(LIBCDIR)/stdlib $(LIBCDIR)/string $(LIBCDIR)/inet \
$(LIBCDIR)/compat $(LIBCDIR)/runtime $(LIBCDIR)/compat $(LIBCDIR)/runtime
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
ASFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -I$(LIBCDIR)/mips/sys ASFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -I$(LIBCDIR)/mips/sys
# modules which can not use SYSCALL and must be assembled from sources. The # modules which can not use SYSCALL and must be assembled from sources. The
@@ -87,16 +87,15 @@ OBJS += inet_addr.o inet_network.o inet_netof.o \
inet_ntoa.o inet_lnaof.o inet_maddr.o inet_ntoa.o inet_lnaof.o inet_maddr.o
# libc/compat # libc/compat
OBJS += creat.o ftime.o gethostid.o memccpy.o memchr.o \ OBJS += creat.o ftime.o gethostid.o gtty.o memccpy.o memchr.o \
memcmp.o memcpy.o memset.o nice.o pause.o rand.o \ memcmp.o memcpy.o memset.o nice.o pause.o rand.o \
sethostid.o setregid.o setreuid.o setrgid.o setruid.o \ sethostid.o setregid.o setreuid.o setrgid.o setruid.o \
sigcompat.o strchr.o strrchr.o times.o tmpnam.o \ sigcompat.o strchr.o strrchr.o stty.o times.o tmpnam.o \
utime.o utime.o
# libc/runtime # libc/runtime
OBJS += addsf3.o comparesf2.o divsf3.o fixsfsi.o floatsisf.o \ OBJS += addsf3.o comparesf2.o divsf3.o fixsfsi.o floatsisf.o \
mulsf3.o negsf2.o subsf3.o sc_case.o fixunssfsi.o \ mulsf3.o negsf2.o subsf3.o sc_case.o
floatunsisf.o
all: ../libc.a all: ../libc.a
+1 -1
View File
@@ -3,7 +3,7 @@ include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libcurses vpath %.c $(TOPSRC)/src/libcurses
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = addch.o addstr.o box.o clear.o clrtobot.o clrtoeol.o cr_put.o \ OBJS = addch.o addstr.o box.o clear.o clrtobot.o clrtoeol.o cr_put.o \
cr_tty.o curses.o delch.o deleteln.o delwin.o endwin.o erase.o \ cr_tty.o curses.o delch.o deleteln.o delwin.o endwin.o erase.o \
-18
View File
@@ -1,18 +0,0 @@
TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libgpanel
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = open.o clear.o pixel.o line.o rect.o fill.o fill_triangle.o \
circle.o image.o char.o text.o text_width.o
all: ../libgpanel.a
../libgpanel.a: ../ar ../ranlib $(OBJS)
../ar rc $@ $(OBJS)
../ranlib $@
clean:
rm -f *~ *.o a.out *.a
-18
View File
@@ -1,18 +0,0 @@
TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libm
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = asin.o atan.o exp.o erf.o floor.o fmod.o hypot.o j0.o j1.o \
jn.o log.o pow.o sin.o sinh.o sqrt.o tan.o tanh.o
all: ../libm.a
../libm.a: ../ar ../ranlib $(OBJS)
../ar rc $@ $(OBJS)
../ranlib $@
clean:
rm -f *~ *.o a.out *.a
-17
View File
@@ -1,17 +0,0 @@
TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libreadline
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = readline.o
all: ../libreadline.a
../libreadline.a: ../ar ../ranlib $(OBJS)
../ar rc $@ $(OBJS)
../ranlib $@
clean:
rm -f *~ *.o a.out *.a
+1 -1
View File
@@ -3,7 +3,7 @@ include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libtermlib vpath %.c $(TOPSRC)/src/libtermlib
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = termcap.o tgoto.o tputs.o tcattr.o OBJS = termcap.o tgoto.o tputs.o tcattr.o
+1 -1
View File
@@ -3,7 +3,7 @@ include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libwiznet vpath %.c $(TOPSRC)/src/libwiznet
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = w5100.o socket.o ethernet.o client.o server.o udp.o OBJS = w5100.o socket.o ethernet.o client.o server.o udp.o
+1 -1
View File
@@ -9,7 +9,7 @@ TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/startup-mips vpath %.c $(TOPSRC)/src/startup-mips
CFLAGS = -Os -B$(TOPSRC)/lib/ -fno-integrated-as -Xassembler -x $(DEFS) CFLAGS = -B$(TOPSRC)/lib/ -O -Wa,-x $(DEFS)
OBJS = ../crt0.o OBJS = ../crt0.o
-7
View File
@@ -1,7 +0,0 @@
echo 'erase ^?, kill ^U, intr ^C'
stty dec
PATH=/bin:/sbin:/etc
export PATH
HOME=/
export HOME
export TERM
-2716
View File
File diff suppressed because it is too large Load Diff
+1 -4
View File
@@ -1,6 +1,3 @@
calendar
emg.keys
misc
re.help re.help
misc
unixbench unixbench
zoneinfo
-25486
View File
File diff suppressed because it is too large Load Diff
@@ -4,6 +4,9 @@ all: ashello echo
ashello: ashello.o ashello: ashello.o
$(LD) ashello.o -o $@ $(LD) ashello.o -o $@
chello: chello.o
$(CC) chello.o -o $@
echo: echo.o echo: echo.o
$(LD) $@.o -o $@ $(LD) $@.o -o $@
+30
View File
@@ -0,0 +1,30 @@
TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror
ASFLAGS += -DCROSS
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
all: hello cplus
hello: hello.o
${CC} ${LDFLAGS} -o hello.elf hello.o ${LIBS}
${OBJDUMP} -S hello.elf > hello.dis
${SIZE} hello.elf
${ELF2AOUT} hello.elf $@
cplus: cplus.o
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
${OBJDUMP} -S cplus.elf > cplus.dis
${SIZE} cplus.elf
${ELF2AOUT} cplus.elf $@
echo: echo.o
${LD} ${ASLDFLAGS} -o $@.elf $@.o
${OBJDUMP} -S $@.elf > $@.dis
${SIZE} $@.elf
${ELF2AOUT} $@.elf $@
./aout $@ > $@.dis
clean:
rm -f *.o *.elf ${MAN} hello cplus *.elf *.dis tags *~
+7
View File
@@ -0,0 +1,7 @@
#include <stdio.h>
int main()
{
printf ("Hello, C World!\n");
return 0;
}
-17
View File
@@ -1,17 +0,0 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror
ASFLAGS += -DCROSS
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
all: echo
echo: echo.o
${LD} ${ASLDFLAGS} -o $@.elf $@.o
${OBJDUMP} -S $@.elf > $@.dis
${SIZE} $@.elf
${ELF2AOUT} $@.elf $@
clean:
rm -f *.o *.elf ${MAN} echo *.elf *.dis tags *~
-50
View File
@@ -1,50 +0,0 @@
CC = cc
PROG = hello stdarg skeleton primelist primesum test1 test2 test3 \
gpio adc rain q8 tetris lcd6
all: $(PROG)
hello: hello.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
stdarg: stdarg.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
skeleton: skeleton.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
primelist: primelist.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
primesum: primesum.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
gpio: gpio.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
adc: adc.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
rain: rain.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
q8: q8.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
tetris: tetris.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
lcd6: lcd6.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
test1: test1.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
test2: test2.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
test3: test3.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
clean:
rm -f *.o *~ $(PROG)
-27
View File
@@ -1,27 +0,0 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror -Wall
all: chello stdarg lcd6
chello: chello.o
${CC} ${LDFLAGS} -o chello.elf chello.o ${LIBS}
${OBJDUMP} -S chello.elf > chello.dis
${SIZE} chello.elf
${ELF2AOUT} chello.elf $@
tetris: tetris.o
${CC} ${LDFLAGS} -o tetris.elf tetris.o ${LIBS}
${OBJDUMP} -S tetris.elf > tetris.dis
${SIZE} tetris.elf
${ELF2AOUT} tetris.elf $@
lcd6: lcd6.o
${CC} ${LDFLAGS} -o lcd6.elf lcd6.o ${LIBS}
${OBJDUMP} -S lcd6.elf > lcd6.dis
${SIZE} lcd6.elf
${ELF2AOUT} lcd6.elf $@
clean:
rm -f *.o *.elf ${MAN} chello stdarg lcd6 *.elf *.dis tags *~
-29
View File
@@ -1,29 +0,0 @@
/*
* Example of reading ADC data.
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
char buf[100];
int main(void)
{
int i, fd, value;
for (i=0; i<16; i++) {
sprintf(buf, "/dev/adc%d", i);
fd = open(buf, O_RDWR);
if (fd < 0) {
printf("Error: unable to open %s\n", buf);
} else {
if (read(fd, buf, 20) > 0) {
value = strtol (buf, 0, 0);
printf("adc%-2d = %d\n", i, value);
}
close(fd);
}
}
return 0;
}
-26
View File
@@ -1,26 +0,0 @@
/*
* Example of polling general purpose i/o pins.
*/
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/gpio.h>
int main(void)
{
int fd, pnum, value;
fd = open ("/dev/porta", O_RDWR);
if (fd < 0) {
perror ("/dev/porta");
return -1;
}
for (pnum=0; pnum<7; pnum++) {
value = ioctl (fd, GPIO_POLL | GPIO_PORT (pnum), 0);
if (value < 0)
perror ("GPIO_POLL");
printf ("port%c = 0x%04x\n", pnum + 'A', value);
}
return 0;
}
-7
View File
@@ -1,7 +0,0 @@
#include <stdio.h>
int main()
{
printf ("Hello, C World!\n");
return 0;
}
-287
View File
@@ -1,287 +0,0 @@
/*
* Demo for 6 digit LCD module based on HT1261 controller.
* Based on example sources from http://www.canton-electronics.com
*
* Copyright (C) 2015 Serge Vakulenko
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for any purpose and without fee is hereby
* granted, provided that the above copyright notice appear in all
* copies and that both that the copyright notice and this
* permission notice and warranty disclaimer appear in supporting
* documentation, and that the name of the author not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
*
* The author disclaim all warranties with regard to this
* software, including all implied warranties of merchantability
* and fitness. In no event shall the author be liable for any
* special, indirect or consequential damages or any damages
* whatsoever resulting from loss of use, data or profits, whether
* in an action of contract, negligence or other tortious action,
* arising out of or in connection with the use or performance of
* this software.
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/gpio.h>
/*
* Digits, decimal dots and battery levels:
* A B C D E F
* -- -- -- -- -- -- z
* | | | | | | | | | | | | y
* -- -- -- -- -- -- x
* | | | | | | | | | | | |
* -- -- -- c -- d -- e --
*
* Memory map:
* Byte 0, bits 0-6 - segments of digit 'F'
* Byte 0, bit 7 - decimal dot 'e'
* Byte 1, bits 0-6 - segments of digit 'E'
* Byte 1, bit 7 - decimal dot 'd'
* Byte 2, bits 0-6 - segments of digit 'D'
* Byte 2, bit 7 - decimal dot 'c'
* Byte 3, bits 0-6 - segments of digit 'C'
* Byte 3, bit 7 - battery level 'x'
* Byte 4, bits 0-6 - segments of digit 'B'
* Byte 4, bit 7 - battery level 'y'
* Byte 5, bits 0-6 - segments of digit 'A'
* Byte 5, bit 7 - battery level 'z'
*
* Segments are mapped to bits 0-6:
* --4--
* 0---5
* --1--
* 2---6
* --3--
*/
/*
* Signal assignment.
* LED modulee is connected to pins 16,17,18 of Fubarino SD board.
*
* Fubarino PIC32 LED module
* --------------------------
* 16 RE0 CS
* 17 RE1 WR
* 18 RE2 DATA
*/
#define gpio_cs_clear() ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 0)
#define gpio_cs_set() ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 0)
#define gpio_wr_clear() ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 1)
#define gpio_wr_set() ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 1)
#define gpio_data_clear() ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 2)
#define gpio_data_set() ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 2)
/*
* HT1621 commands
*/
#define HT_SYS_DIS 0x00 /* Turn off system osc and bias generator */
#define HT_SYS_EN 0x01 /* Turn on system oscillator */
#define HT_LCD_OFF 0x02 /* Turn off LCD bias generator */
#define HT_LCD_ON 0x03 /* Turn on LCD bias generator */
#define HT_CLOCK_XTAL 0x14 /* Crystal 32kHz */
#define HT_CLOCK_RC 0x18 /* On-chip RC oscillator 256kHz */
#define HT_CLOCK_EXT 0x1c /* External clock */
#define HT_BIAS_1_3 0x21 /* LCD 1/3 bias option, 2 commons default */
#define HT_COMMONS_3 0x04 /* 3 commons option */
#define HT_COMMONS_4 0x08 /* 4 commons option */
/*
* Mapping of symbols to segments.
* 0, 1, 2, 3, 4, 5, 6, 7,
* 8, 9, A, b, C, c, d, E,
* F, H, h, L, n, N, o, P,
* r, t, U, -, ,
*/
const char char_to_segm[] = {
0x7D, 0x60, 0x3E, 0x7A, 0x63, 0x5B, 0x5F, 0x70,
0x7F, 0x7B, 0x77, 0x4F, 0x1D, 0x0E, 0x6E, 0x1F,
0x17, 0x67, 0x47, 0x0D, 0x46, 0x75, 0x37, 0x06,
0x0F, 0x6D, 0x02, 0x00,
};
/*
* File descriptor for GPIO driver.
*/
int gpio;
/*
* Suspend the process for some amount of milliseconds.
*/
void mdelay(unsigned msec)
{
usleep(msec * 1000);
}
/*
* Send a series of bits to HT1621.
* Up to 8 bits, high bit first.
* Max clock rate is 150kHz.
*/
void ht_send(int nbits, int data)
{
data <<= (8 - nbits);
gpio_wr_clear();
while (nbits-- > 0) {
if (data & 0x80)
gpio_data_set();
else
gpio_data_clear();
gpio_wr_set();
gpio_wr_clear();
data <<= 1;
}
}
/*
* Send command to HT1621.
*/
void ht_cmd(int command)
{
gpio_cs_clear();
ht_send(3, 0x4); /* Mode "100" */
ht_send(8, command);
gpio_cs_set();
}
/*
* Send data and command.
*/
void ht_write(int addr, int data)
{
gpio_cs_clear();
ht_send(3, 0x5); /* Mode "101" */
ht_send(6, addr << 1); /* Half-byte address 6 bits */
ht_send(8, data); /* Data 8 bits */
gpio_cs_set();
}
/*
* Initialize LCD controller.
*/
void lcd_init()
{
/* Open GPIO driver. */
gpio = open("/dev/porta", 1);
if (gpio < 0) {
perror("/dev/porta");
exit(-1);
}
/* Configure pins RE0-RE2 as outputs. */
ioctl(gpio, GPIO_PORTE | GPIO_CONFOUT, 0x07);
gpio_cs_set();
gpio_wr_clear();
/* Setup appropriate HT1621 mode. */
ht_cmd(HT_SYS_EN);
ht_cmd(HT_CLOCK_RC);
ht_cmd(HT_BIAS_1_3 | HT_COMMONS_4);
ht_cmd(HT_LCD_ON);
}
/*
* Set display memory to given value.
*/
void lcd_clear(int value)
{
int i;
for (i=0; i<6; i++) {
ht_write(i, value);
}
}
/*
* LCD on/off.
*/
void lcd_enable(int on)
{
if (on)
ht_cmd(HT_LCD_ON);
else
ht_cmd(HT_LCD_OFF);
}
/*
* Display data.
* val - Data to be displayed, 0-999999
* dot - Display decimal dot, 0-3
* bat - Battery level, 0-3
*/
void lcd_display(unsigned val, int dot, int bat)
{
int i, byte[6];
/* Set numeric value. */
byte[5] = char_to_segm[val / 100000];
byte[4] = char_to_segm[(val / 10000) % 10];
byte[3] = char_to_segm[(val / 1000) % 10];
byte[2] = char_to_segm[(val / 100) % 10];
byte[1] = char_to_segm[(val / 10) % 10];
byte[0] = char_to_segm[val % 10];
/* Enable decimal dot/ */
switch (dot) {
case 1:
byte[0] |= 1 << 7;
break;
case 2:
byte[1] |= 1 << 7;
break;
case 3:
byte[2] |= 1 << 7;
break;
default:
break;
}
if (bat > 0)
byte[3] |= 1 << 7;
if (bat > 1)
byte[4] |= 1 << 7;
if (bat > 2)
byte[5] |= 1 << 7;
for (i=0; i<6; i++) {
ht_write(i, byte[i]);
}
}
int main()
{
int i;
/* Initialize hardware. */
lcd_init();
/* Blink all segments twice. */
lcd_clear(0xff);
mdelay(1000);
lcd_clear(0);
mdelay(1000);
lcd_clear(0xff);
mdelay(1000);
lcd_clear(0);
mdelay(1000);
/* Show all characters on all segments. */
for (i=0; i<sizeof(char_to_segm); i++) {
lcd_clear(char_to_segm[i]);
mdelay(200);
}
lcd_clear(0);
/* Display counter 0 to 999999. */
for (;;) {
for (i=0; i<999999; i++) {
lcd_display(i, i/10%4, i/10%4);
mdelay(100);
}
}
return 0;
}
-35
View File
@@ -1,35 +0,0 @@
/*
* Print the list of prime numbers up to 100.
*/
#include <stdio.h>
int isprime(int);
int main(void)
{
int n;
for (n=2; n<100; ++n) {
if (isprime(n)) {
printf("%d ", n);
}
}
printf("\n");
}
int isprime(int n)
{
int j;
if (n == 2)
return 1;
if (n % 2 == 0)
return 0;
for (j=3; j*j<=n; j+=2)
if (n % j == 0)
return 0;
return 1;
}
-35
View File
@@ -1,35 +0,0 @@
/*
* Compute the sum of prime numbers up to 10000.
*/
#include <stdio.h>
int isprime(int);
int main(void)
{
int sum, n;
sum = 0;
for (n=2; n<10000; ++n) {
if (isprime(n)) {
sum += n;
}
}
printf("Sum of primes less than 10000: %d\n", sum);
}
int isprime(int n)
{
int j;
if (n == 2)
return 1;
if (n % 2 == 0)
return 0;
for (j=3; j*j<=n; j+=2)
if (n % j == 0)
return 0;
return 1;
}
-209
View File
@@ -1,209 +0,0 @@
/*
* Eight Queens puzzle
*
* (C) 2010 by Mark Sproul
* Open source as per standard Arduino code
* Modified by Pito 12/2012 for SmallC and then by Alexey Frunze for Smaller C
*/
#include <stdio.h>
#define TRUE 1
#define FALSE 0
unsigned int gChessBoard[8];
unsigned int gLoopCounter;
int gValidCount;
int CheckCurrentBoard(void)
{
int ii;
int jj;
int theRow;
int theLongRow;
int theLongColumns;
int bitCount;
//* we know we have 1 in each row,
//* Check for 1 in each column
theRow = 0;
for (ii=0; ii<8; ii++) {
theRow |= gChessBoard[ii];
}
if (theRow != 0x0ff) {
return FALSE;
}
//* we have 1 in each column, now check the diagonals
theLongColumns = 0;
for (ii=0; ii<8; ii++) {
theLongRow = gChessBoard[ii] & 0x0ff;
theLongRow = theLongRow << ii;
theLongColumns |= theLongRow;
}
//* now count the bits
bitCount = 0;
for (ii=0; ii<16; ii++) {
if ((theLongColumns & 0x01) == 0x01) {
bitCount++;
}
theLongColumns = theLongColumns >> 1;
}
if (bitCount != 8) {
return FALSE;
}
//* we now have to check the other diagonal
theLongColumns = 0;
for (ii=0; ii<8; ii++) {
theLongRow = gChessBoard[ii] & 0x0ff;
theLongRow = theLongRow << 8;
theLongRow = theLongRow >> ii;
theLongColumns |= theLongRow;
}
//* now count the bits
bitCount = 0;
for (ii=0; ii<16; ii++) {
if ((theLongColumns & 0x01) == 0x01) {
bitCount++;
}
theLongColumns = theLongColumns >> 1;
}
if (bitCount != 8) {
return FALSE;
}
return TRUE;
}
int CheckForDone(void)
{
int ii;
int weAreDone;
int theRow;
weAreDone = FALSE;
//* we know we have 1 in each row,
//* Check for 1 in each column
theRow = 0;
for (ii=0; ii<8; ii++) {
theRow |= gChessBoard[ii];
}
if (theRow == 0x01) {
weAreDone = TRUE;
}
return weAreDone;
}
void RotateQueens(void)
{
int ii;
int keepGoing;
int theRow;
ii = 0;
keepGoing = TRUE;
while (keepGoing && (ii < 8)) {
theRow = gChessBoard[ii] & 0x0ff;
theRow = (theRow >> 1) & 0x0ff;
if (theRow != 0) {
gChessBoard[ii] = theRow;
keepGoing = FALSE;
} else {
gChessBoard[ii] = 0x080;
}
ii++;
}
}
void PrintChessBoard(void)
{
int ii;
int jj;
int theRow;
char textString[32];
printf("\nLoop= %d\n", gLoopCounter);
printf("Solution count= %d\n", gValidCount);
printf("+----------------+\n");
for (ii=0; ii<8; ii++) {
theRow = gChessBoard[ii];
printf("|");
for (jj=0; jj<8; jj++) {
if (theRow & 0x080) {
printf("Q ");
} else {
printf(". ");
}
theRow = theRow << 1;
}
printf("|\n");
}
printf("+----------------+\n");
}
int main(void)
{
int ii;
printf("\nEight Queens brute force");
printf("\n************************\n");
//* put the 8 queens on the board, 1 in each row
for (ii=0; ii<8; ii++) {
gChessBoard[ii] = 0x080;
}
PrintChessBoard();
gLoopCounter = 0;
gValidCount = 0;
while (1) {
gLoopCounter++;
if (CheckCurrentBoard()) {
gValidCount++;
PrintChessBoard();
} else if ((gLoopCounter % 1000) == 0) {
//PrintChessBoard();
}
RotateQueens();
if (CheckForDone()) {
//int elapsedSeconds;
//int elapsedMinutes;
//int elapsedHours;
//elapsedSeconds = millis() / 1000;
//elapsedMinutes = elapsedSeconds / 60;
//elapsedHours = elapsedMinutes / 60;
printf("----------------------------------\n");
printf("All done\n");
PrintChessBoard();
printf("----------------------------------\n");
//Serial.print("total seconds=");
//Serial.println(elapsedSeconds);
//Serial.print("hours=");
//Serial.println(elapsedHours);
//Serial.print("minutes=");
//Serial.println(elapsedMinutes % 60);
//Serial.print("seconds=");
//Serial.println(elapsedSeconds % 60);
return (1);
}
}
}
-129
View File
@@ -1,129 +0,0 @@
/*
* Example of using termcap library for SmallC.
* 11/3/1980 EPS/CITHEP
*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#define CO 80 /* number of columns */
#define LI 24 /* number of lines */
#define CL "\33[H\33[J" /* clear the screen */
#define CM "\33[%u;%uH" /* move the cursor to row, column */
#define BC "\b" /* move cursor left */
#define DN "\33[B" /* move cursor down */
#define ND " " /* move cursor right */
int xpos[5], ypos[5];
char outbuf[BUFSIZ];
void moveto(int col, int row)
{
printf(CM, row, col);
}
void onsig(int n)
{
moveto(0, LI - 1);
fflush(stdout);
_exit(0);
}
int main(void)
{
int x, y, j;
setbuf(stdout, outbuf);
for (j = SIGHUP; j <= SIGTERM; j++)
if (signal(j, SIG_IGN) != SIG_IGN)
signal(j, onsig);
fputs(CL, stdout);
fflush(stdout);
for (j = 5; --j >= 0; ) {
xpos[j] = 2 + rand() % (CO - 4);
ypos[j] = 2 + rand() % (LI - 4);
}
for (j = 0; ; ) {
x = 2 + rand() % (CO - 4);
y = 2 + rand() % (LI - 4);
moveto(x, y);
putchar('.');
moveto(xpos[j], ypos[j]);
putchar('o');
if (j == 0)
j = 4;
else
--j;
moveto(xpos[j], ypos[j]);
putchar('O');
if (j == 0)
j = 4;
else
--j;
moveto(xpos[j], ypos[j]-1);
putchar('-');
fputs(DN, stdout);
fputs(BC, stdout);
fputs(BC, stdout);
fputs("|.|", stdout);
fputs(DN, stdout);
fputs(BC, stdout);
fputs(BC, stdout);
putchar('-');
if (j == 0)
j = 4;
else
--j;
moveto(xpos[j], ypos[j]-2);
putchar('-');
fputs(DN, stdout);
fputs(BC, stdout);
fputs(BC, stdout);
fputs("/ \\", stdout);
moveto(xpos[j]-2, ypos[j]);
fputs("| O |", stdout);
moveto(xpos[j]-1, ypos[j]+1);
fputs("\\ /", stdout);
fputs(DN, stdout);
fputs(BC, stdout);
fputs(BC, stdout);
putchar('-');
if (j == 0)
j = 4;
else
--j;
moveto(xpos[j], ypos[j]-2);
putchar(' ');
fputs(DN, stdout);
fputs(BC, stdout);
fputs(BC, stdout);
putchar(' ');
fputs(ND, stdout);
putchar(' ');
moveto(xpos[j]-2, ypos[j]);
putchar(' ');
fputs(ND, stdout);
putchar(' ');
fputs(ND, stdout);
putchar(' ');
moveto(xpos[j]-1, ypos[j]+1);
putchar(' ');
fputs(ND, stdout);
putchar(' ');
fputs(DN, stdout);
fputs(BC, stdout);
fputs(BC, stdout);
putchar(' ');
xpos[j] = x;
ypos[j] = y;
fflush(stdout);
usleep(100000);
}
}
-92
View File
@@ -1,92 +0,0 @@
/*
* Generic skeleton for a C program.
* When you create your own program based on this skeleton,
* you can replace the author's name and copyright with
* whatever your want. When you redistribute this skeleton or
* enhance it, please leave my name and copyright on it.
*
* Copyright (C) 1993-2014 Serge Vakulenko, <vak@cronyx.ru>
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for any purpose and without fee is hereby
* granted, provided that the above copyright notice appear in all
* copies and that both that the copyright notice and this
* permission notice and warranty disclaimer appear in supporting
* documentation, and that the name of the author not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
*
* The author disclaim all warranties with regard to this
* software, including all implied warranties of merchantability
* and fitness. In no event shall the author be liable for any
* special, indirect or consequential damages or any damages
* whatsoever resulting from loss of use, data or profits, whether
* in an action of contract, negligence or other tortious action,
* arising out of or in connection with the use or performance of
* this software.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
const char version[] = "1.0";
const char copyright[] = "Copyright (C) 1993-2014 Serge Vakulenko";
char *progname; /* Name of the current program (argv[0]) */
int verbose; /* Option -v */
int trace; /* Option -t */
int debug; /* Option -d */
void usage ()
{
fprintf (stderr, "Generic C skeleton, Version %s, %s\n", version, copyright);
fprintf (stderr, "Usage:\n\t%s [-vtd] [-r count] file...\n", progname);
fprintf (stderr, "Options:\n");
fprintf (stderr, "\t-v\tverbose mode\n");
fprintf (stderr, "\t-t\ttrace mode\n");
fprintf (stderr, "\t-d\tdebug\n");
fprintf (stderr, "\t-r #\trepeat count\n");
exit (-1);
}
int main (int argc, char **argv)
{
int count = 1; /* Option -r # */
progname = *argv;
for (;;) {
switch (getopt (argc, argv, "vtdr:")) {
case EOF:
break;
case 'v':
++verbose;
continue;
case 't':
++trace;
continue;
case 'd':
++debug;
continue;
case 'r':
count = strtol (optarg, 0, 0);
continue;
default:
usage ();
}
break;
}
argc -= optind;
argv += optind;
if (argc < 1)
usage ();
while (count-- > 0) {
int i;
for (i=0; i<argc; ++i)
printf ("%s ", argv[i]);
printf ("\n");
}
return (0);
}
-34
View File
@@ -1,34 +0,0 @@
#include <stdio.h>
#include <stdarg.h>
void print(char *fmt, ...)
{
va_list ap;
int d;
char c, *s;
va_start(ap, fmt);
while (*fmt) {
switch (*fmt++) {
case 's': /* string */
s = va_arg(ap, char*);
printf("string %s\n", s);
break;
case 'd': /* int */
d = va_arg(ap, int);
printf("int %d\n", d);
break;
case 'c': /* char */
c = va_arg(ap, int);
printf("char %c\n", c);
break;
}
}
va_end(ap);
}
int main()
{
print("sdcsdc", "abracadabra", 12345, 'Z', "foo", 365, '%');
return 0;
}
-214
View File
@@ -1,214 +0,0 @@
#include <stdio.h>
int ga[5];
int main(void)
{
int a, b, c, d;
int arr[5];
int *pi;
char arrc[5];
char *pic;
int s1, s2;
int z;
int t;
int *pip;
int *picp;
int e1, e2;
ga[0] = 10;
ga[1] = 20;
ga[2] = 30;
ga[3] = 40;
ga[4] = 50;
a = 21;
b = 31;
c = 71;
d = 82;
arr[0] = 10;
arr[1] = 20;
arr[2] = 30;
arr[3] = 40;
arr[4] = 50;
pi = &arr[0];
arrc[0] = 13;
arrc[1] = 23;
arrc[2] = 33;
arrc[3] = 43;
arrc[4] = 53;
pic = &arrc[0];
printf(" 21 + 31 = %d (52)\n", a + b);
printf(" 21 - 31 = %d (-10)\n", a - b);
printf(" 21 & 71 = %d (5)\n", a & c);
printf(" 21 | 82 = %d (87)\n", a | d);
printf(" 21 ^ 82 = %d (71)\n", a ^ d);
printf(" 21 * 82 = %d (1722)\n", a * d);
printf(" 82 %% 21 = %d (19)\n", d % a);
printf(" 82 / 21 = %d (3)\n", d / a);
printf(" *pi = %d (10)\n", *pi);
printf(" *pi + 1 = %d (11)\n", *pi + 1);
printf(" *(pi + 1) = %d (20)\n", *(pi + 1));
printf("&arr[3] - &arr[0] = %d (3)\n", &arr[3] - &arr[0]);
printf(" arr[3]-arr[0] = %d (30)\n", arr[3] - arr[0]);
printf(" arr[3]+arr[0] = %d (50)\n", arr[3] + arr[0]);
printf(" &ga[3] - &ga[0] = %d (3)\n", &ga[3] - &ga[0]);
printf(" ga[3]-ga[0] = %d (30)\n", ga[3] - ga[0]);
printf(" ga[3]+ga[0] = %d (50)\n", ga[3] + ga[0]);
printf("\n");
printf(" *pic = %d (13)\n", *pic);
printf(" *pic + 1 = %d (14)\n", *pic+1);
printf(" *(pic + 1) = %d (23)\n", *(pic+1));
printf("&arrc[3] - &arrc[0] = %d (3)\n", &arrc[3]-&arrc[0]);
printf("\n");
s1 = 3;
s2 = -200;
printf(" 82 << 3 = %d (656)\n", d << s1);
printf(" 82 >> 3 = %d (10)\n", d >> s1);
printf("-200 >> 3 = %d (-25)\n", s2 >> s1);
printf("-200 << 3 = %d (-1600)\n", s2 << s1);
printf("\n");
printf("-s1 = %d (-3)\n", -s1);
printf("-s2 = %d (200)\n", -s2);
printf("\n");
printf("~82 = %d (-83)\n", ~d);
printf("\n");
z = 0;
printf("!82 = %d (0)\n", !d);
printf(" !0 = %d (1)\n", !z);
printf("\n");
printf(" 0 && 0 = %d (0)\n", z && z);
printf(" 0 && 21 = %d (0)\n", z && a);
printf(" 3 && 21 = %d (1)\n", s1 && a);
printf("21 && 3 = %d (1)\n", a && s1);
printf("\n");
printf(" 0 || 0 = %d (0)\n", z || z);
printf(" 0 || 21 = %d (1)\n", z || a);
printf(" 3 || 21 = %d (1)\n", s1 || a);
printf("21 || 3 = %d (1)\n", a || s1);
printf("\n");
pi = 4;
printf("pi++ = %d (4)\n", pi++);
printf(" pi = %d (8)\n", pi);
printf("++pi = %d (12)\n", ++pi);
printf("pi-- = %d (12)\n", pi--);
printf(" pi = %d (8)\n", pi);
printf("--pi = %d (4)\n", --pi);
printf("\n");
pic = 4;
printf("pic++ = %d (4)\n", pic++);
printf(" pic = %d (5)\n", pic);
printf("++pic = %d (6)\n", ++pic);
printf("pic-- = %d (6)\n", pic--);
printf(" pic = %d (5)\n", pic);
printf("--pic = %d (4)\n", --pic);
printf("\n");
t = 4;
printf("t++ = %d (4)\n", t++);
printf(" t = %d (5)\n", t);
printf("++t = %d (6)\n", ++t);
printf("t-- = %d (6)\n", t--);
printf(" t = %d (5)\n", t);
printf("--t = %d (4)\n", --t);
printf("\n");
t = 4;
printf(" t==4 = %d (1)\n", t == 4);
printf(" t==3 = %d (0)\n", t == 3);
printf(" t==5 = %d (0)\n", t == 5);
t = -4;
printf("t==-4 = %d (1)\n", t == -4);
printf("t==-3 = %d (0)\n", t == -3);
printf("t==-5 = %d (0)\n", t == -5);
printf(" t==4 = %d (0)\n", t == 4);
printf(" t==3 = %d (0)\n", t == 3);
printf(" t==5 = %d (0)\n", t == 5);
printf("\n");
t = 4;
printf(" t!=4 = %d (0)\n", t != 4);
printf(" t!=3 = %d (1)\n", t != 3);
printf(" t!=5 = %d (1)\n", t != 5);
t = -4;
printf("t!=-4 = %d (0)\n", t != -4);
printf("t!=-3 = %d (1)\n", t != -3);
printf("t!=-5 = %d (1)\n", t != -5);
printf(" t!=4 = %d (1)\n", t != 4);
printf(" t!=3 = %d (1)\n", t != 3);
printf(" t!=5 = %d (1)\n", t != 5);
printf("\n");
t = 4;
printf(" t<4 = %d (0)\n", t < 4);
printf(" t<3 = %d (0)\n", t < 3);
printf(" t<5 = %d (1)\n", t < 5);
printf("t<-1 = %d (0)\n", t < -1);
printf("\n");
printf(" t<=4 = %d (1)\n", t <= 4);
printf(" t<=3 = %d (0)\n", t <= 3);
printf(" t<=5 = %d (1)\n", t <= 5);
printf("t<=-1 = %d (0)\n", t <= -1);
printf("\n");
t = 4;
printf(" t>4 = %d (0)\n", t > 4);
printf(" t>3 = %d (1)\n", t > 3);
printf(" t>5 = %d (0)\n", t > 5);
printf("t>-1 = %d (1)\n", t > -1);
printf("\n");
printf(" t>=4 = %d (1)\n", t >= 4);
printf(" t>=3 = %d (1)\n", t >= 3);
printf(" t>=5 = %d (0)\n", t >= 5);
printf("t>=-1 = %d (1)\n", t >= -1);
printf("\n");
pi = -100;
printf(" pi<4 = %d (0)\n", pi < (int*)4);
printf(" pi<3 = %d (0)\n", pi < (int*)3);
printf("pi<-100 = %d (0)\n", pi < (int*)-100);
printf(" pi<-1 = %d (1)\n", pi < (int*)-1);
printf("\n");
printf(" pi<=4 = %d (0)\n", pi <= (int*)4);
printf(" pi<=3 = %d (0)\n", pi <= (int*)3);
printf("pi<=-100 = %d (1)\n", pi <= (int*)-100);
printf(" pi<=-1 = %d (1)\n", pi <= (int*)-1);
printf("\n");
pi = -100;
printf(" pi>4 = %d (1)\n", pi > (int*)4);
printf(" pi>3 = %d (1)\n", pi > (int*)3);
printf("pi>-100 = %d (0)\n", pi > (int*)-100);
printf(" pi>-1 = %d (0)\n", pi > (int*)-1);
printf("\n");
printf(" pi>=4 = %d (1)\n", pi >= (int*)4);
printf(" pi>=3 = %d (1)\n", pi >= (int*)3);
printf("pi>=-100 = %d (1)\n", pi >= (int*)-100);
printf(" pi>=-1 = %d (0)\n", pi >= (int*)-1);
printf("\n");
pi = &arr[0];
pip = &arr[3];
printf(" *pip - *pi: %d (30)\n", *pip - *pi);
printf(" pip - pi: %d (3)\n", pip - pi);
printf(" *pip: %d (40)\n", *pip);
printf(" *(pip - 3): %d (10)\n", *(pip - 3));
printf(" *&arr[3]: %d (40)\n", *&arr[3]);
printf("*(&arr[3] - 3): %d (10)\n", *(&arr[3]-3));
}
-128
View File
@@ -1,128 +0,0 @@
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
int aaa;
int bbb;
int ccc;
char gc;
char gbuffer[3];
int gibuffer[4];
int main(void)
{
char b;
int la;
unsigned int u1, u2;
int s1, s2;
unsigned char uc1, uc2;
char sc1, sc2;
int fd;
char buffer[6];
int ibuffer[7];
printf(" sizeof(uc1): %d 1\n", sizeof(uc1));
printf(" sizeof(sc1): %d 1\n", sizeof(sc1));
printf(" sizeof(u1): %d 4\n", sizeof(u1));
printf(" sizeof(s1): %d 4\n", sizeof(s1));
printf(" sizeof(aaa): %d 4\n", sizeof(aaa));
printf(" sizeof(bbb): %d 4\n", sizeof(bbb));
printf(" sizeof(gc): %d 1\n", sizeof(gc));
printf(" sizeof(buffer): %d 6\n", sizeof(buffer));
printf(" sizeof(ibuffer): %d 28\n", sizeof(ibuffer));
printf(" sizeof(char): %d 1\n", sizeof(char));
printf(" sizeof(int): %d 4\n", sizeof(int));
printf(" sizeof(gbuffer): %d 3\n", sizeof(gbuffer));
printf(" sizeof(gibuffer): %d 16\n", sizeof(gibuffer));
// sizeof(ibuffer[0]) is not supported, so the following can be used...
printf("sizeof(ibuffer)/sizeof(int): %d 7\n", sizeof(ibuffer)/sizeof(int));
aaa = 1;
bbb = 2;
la = 4;
printf("%d 1\n", aaa);
printf("%d 2\n", bbb);
printf("%d 4\n", la);
uc1 = 0x80;
sc1 = 0x80;
s1 = uc1;
s2 = sc1;
printf("unsigned char (0x80) -> int: %d 128\n", s1);
printf(" signed char (0x80) -> int: %d -128\n", s2);
u1 = uc1;
u2 = sc1;
printf("unsigned char (0x80) -> unsigned: %d 128\n", u1);
printf(" signed char (0x80) -> unsigned: %d -128\n", u2);
la = errno;
printf("errno: %d 0\n", la);
write(1, "abcd ", 5);
la = errno;
printf("errno after good write call: %d 0\n", la);
write(10, "abcde", 5);
la = errno;
printf("errno after bad write call: %d 9\n", la);
write(1, "abcd ", 5);
la = errno;
printf("good write after failed should not overwrite errno: %d 9\n", la);
errno = 0;
write(1, "abcd ", 5);
la = errno;
printf("good write after errno set to zero: %d 0\n", la);
la = write(1, "abcd ", 5);
printf("write() return: %d 5\n", la);
la = write(10, "abcd ", 5);
printf("write(bad fd) return: %d -1\n", la);
fd = open("/a.txt", O_WRONLY | O_CREAT, 0666);
if (fd != -1) {
printf("open success\n");
la = write(fd, "abcd\n", 5);
if (la == 5) printf("write success\n"); else printf("write failed\n");
la = close(fd);
if (la != -1) printf("close success\n"); else printf("close failed\n");
} else {
printf("open failed\n");
}
buffer[0] = 0;
buffer[1] = 0;
buffer[2] = 0;
buffer[3] = 0;
buffer[4] = 0;
buffer[5] = 0;
fd = open("/a.txt", O_RDONLY, 0666);
if (fd != -1) {
printf("open success\n");
la = read(fd, buffer, 5);
printf(buffer);
if (la == 5) printf("read success\n"); else printf("read failed\n");
la = close(fd);
if (la != -1) printf("close success\n"); else printf("close failed\n");
} else {
printf("open failed\n");
}
if (buffer[0] != 'a') printf("data0 readback from file MISMATCH\n");
if (buffer[1] != 'b') printf("data1 readback from file MISMATCH\n");
if (buffer[2] != 'c') printf("data2 readback from file MISMATCH\n");
if (buffer[3] != 'd') printf("data3 readback from file MISMATCH\n");
if (buffer[4] != '\n') printf("data4 readback from file MISMATCH\n");
if (buffer[0] != 'a' || buffer[1] != 'b' || buffer[2] != 'c' ||
buffer[3] != 'd' || buffer[4] != '\n') {
printf("data readback from file MISMATCH\n");
} else {
printf("data readback from file OK\n");
}
}
-51
View File
@@ -1,51 +0,0 @@
#include <stdio.h>
void printt(int t, char* str);
int main(void)
{
int t;
t = 0;
if (t) printt(t, "failure"); else printt(t, "success");
t = 1;
if (t) printt(t, "success"); else printt(t, "failure");
t = 8;
if (t) printt(t, "success"); else printt(t, "failure");
t = -2;
if (t) printt(t, "success"); else printt(t, "failure");
printf("\n");
t = 4;
printf("switch test: ");
switch (t) {
case 3:
printf("failure");
break;
case 4:
printf("success");
break;
case 5:
printf("failure");
break;
}
printf("\n");
printf("switch fallthrough test: ");
switch (t) {
case 3:
printf("failure");
break;
case 4:
printf("OKSOFAR: ");
case 5:
printf("success if oksofar printed before this in caps");
break;
}
printf("\n");
}
void printt(int t, char* str)
{
printf("bool test on value %d %s\n", t, str);
}
-666
View File
@@ -1,666 +0,0 @@
/*
* Tetris (C) Copyright 1995, Vadim Antonov
* Port to RetroBSD (C) 2015, Serge Vakulenko
*
* This program is designed to run on Olimex Duinomite board
* with SainSmart Graphic LCD4884 shield, modified for 3.3V.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for any purpose and without fee is hereby
* granted, provided that the above copyright notice appear in all
* copies and that both that the copyright notice and this
* permission notice and warranty disclaimer appear in supporting
* documentation, and that the name of the author not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
*
* The author disclaim all warranties with regard to this
* software, including all implied warranties of merchantability
* and fitness. In no event shall the author be liable for any
* special, indirect or consequential damages or any damages
* whatsoever resulting from loss of use, data or profits, whether
* in an action of contract, negligence or other tortious action,
* arising out of or in connection with the use or performance of
* this software.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/gpio.h>
#define PITWIDTH 12
#define PITDEPTH 21
#define NSHAPES 7
#define NBLOCKS 5
#define FIN 999
typedef struct {
int x, y;
} coord_t;
typedef struct {
int dx, dy;
coord_t p[NBLOCKS];
} shape_t;
const shape_t shape [NSHAPES] = {
/* OOOO */ { 0, 3, { {0,0}, {0,1}, {0,2}, {0,3}, {FIN,FIN} } },
/* O */ { 1, 2, { {0,0}, {1,0}, {1,1}, {1,2}, {FIN,FIN} } },
/* OOO */
/* O */ { 1, 2, { {0,1}, {1,0}, {1,1}, {1,2}, {FIN,FIN} } },
/* OOO */
/* O */ { 1, 2, { {0,2}, {1,0}, {1,1}, {1,2}, {FIN,FIN} } },
/* OOO */
/* OO */ { 1, 2, { {0,0}, {0,1}, {1,1}, {1,2}, {FIN,FIN} } },
/* OO */
/* OO */ { 1, 2, { {0,1}, {0,2}, {1,0}, {1,1}, {FIN,FIN} } },
/* OO */
/* OO */ { 1, 1, { {0,0}, {0,1}, {1,0}, {1,1}, {FIN,FIN} } },
/* OO */
};
int pit [PITDEPTH+1] [PITWIDTH];
int pitcnt [PITDEPTH];
coord_t old [NBLOCKS], new [NBLOCKS], chk [NBLOCKS];
int gpio; /* File descriptor of GPIO driver. */
int adc3; /* File descriptor of ADC3 driver. */
/*-------------------------------------------------------------
* Definitions for a "digital" joystick at A0 analog input.
* Button values are determined by resistors on a board.
*/
enum {
JOYSTICK_LEFT,
JOYSTICK_SELECT,
JOYSTICK_DOWN,
JOYSTICK_RIGHT,
JOYSTICK_UP,
JOYSTICK_IDLE = -1,
};
/*
* Initialize ADC for a joystick.
*/
void joystick_init()
{
/* Open ADC driver. */
adc3 = open("/dev/adc3", 0);
if (adc3 < 0) {
perror("/dev/adc3");
exit(-1);
}
}
/*
* Get a state of joystick.
* Convert ADC value to key number.
* Input buttons are connected to a series network of resistors:
* GND - 3.3k - 1k - 620 - 330 - 2k - +3.3V
* Expected values are:
* 0 - 144 - 329 - 506 - 741 - 1023
*/
int joystick_get()
{
static const unsigned level[5] = { 72, 236, 417, 623, 882 };
unsigned input, k;
char buf[16];
if (read(adc3, buf, sizeof(buf)) <= 0) {
perror("adc");
exit(-1);
}
input = strtol(buf, 0, 10);
for (k=0; k<5; k++) {
if (input < level[k]) {
return k;
}
}
return JOYSTICK_IDLE;
}
/*-------------------------------------------------------------
* Routines for Nokia 5110 display.
* See Philips PCD8544 datasheet.
*/
#define NROW 48
#define NCOL 84
/*
* Pinout for SainSmart Graphic LCD4884 Shield.
*/
#define MASKE_LCD_SCK (1 << 2) /* signal D2, pin RE2 */
#define MASKE_LCD_MOSI (1 << 3) /* signal D3, pin RE3 */
#define MASKE_LCD_DC (1 << 4) /* signal D4, pin RE4 */
#define MASKE_LCD_CS (1 << 5) /* signal D5, pin RE5 */
#define MASKE_LCD_RST (1 << 6) /* signal D6, pin RE6 */
#define MASKE_LCD_BL (1 << 7) /* signal D7, pin RE7 */
static unsigned char gpanel_screen [NROW*NCOL/8];
int gpanel_row, gpanel_col;
static void lcd_cs(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_CS);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_CS);
}
}
static void lcd_rst(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_RST);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_RST);
}
}
static void lcd_dc(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_DC);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_DC);
}
}
static void lcd_bl(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_BL);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_BL);
}
}
static void lcd_mosi(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_MOSI);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_MOSI);
}
}
static void lcd_sck(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_SCK);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_SCK);
}
}
static void lcd_write(unsigned byte, unsigned data_flag)
{
unsigned i;
lcd_cs(0);
lcd_dc(data_flag);
for (i=0; i<8; i++, byte<<=1) {
lcd_mosi(byte & 0x80); /* SDIN = bit[i] */
lcd_sck(0); /* SCLK = 0 */
lcd_sck(1); /* SCLK = 1 */
}
lcd_cs(1);
}
/*
* Set up hardware for communication to Nokia 5110 LCD Display.
* Do not clear the display.
* Leave backlight turned off.
*/
void gpanel_init()
{
gpanel_row = 0;
gpanel_col = 0;
/* Open GPIO driver. */
gpio = open("/dev/porta", 0);
if (gpio < 0) {
perror("/dev/porta");
exit(-1);
}
/*
* Set pins as outputs.
*/
ioctl(gpio, GPIO_PORTE | GPIO_CONFOUT, MASKE_LCD_SCK |
MASKE_LCD_MOSI | MASKE_LCD_DC | MASKE_LCD_CS |
MASKE_LCD_RST | MASKE_LCD_BL);
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_RST | MASKE_LCD_CS);
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_SCK |
MASKE_LCD_MOSI | MASKE_LCD_DC | MASKE_LCD_BL);
/* Turn off backlight. */
lcd_bl(0);
/* Reset the display. */
lcd_rst(0);
usleep(10000); // need 1 usec
lcd_rst(1);
usleep(10000); // need 1 usec
lcd_write(0x21, 0); // Enable extended instruction set
lcd_write(0xbf, 0); // Set Vop - contrast level
lcd_write(0x04, 0); // Set temperature coefficient to 0
lcd_write(0x14, 0); // Set bias to 4
lcd_write(0x20, 0); // Back to normal instruction set
lcd_write(0x0c, 0); // Set normal mode
/* Enable backlight. */
lcd_bl(1);
}
/*
* Clear the the LCD screen.
*/
void gpanel_clear()
{
unsigned i;
/* Clear data */
lcd_write(0x40, 0);
lcd_write(0x80, 0);
for (i=0; i<NROW*NCOL/8; i++) {
gpanel_screen[i] = 0;
lcd_write(0, 1);
}
gpanel_row = 0;
gpanel_col = 0;
}
/*
* Lights a single pixel in the specified color
* at the specified x and y addresses
*/
void gpanel_pixel(int x, int y, int color)
{
unsigned char *data;
if (x >= NCOL || y >= NROW)
return;
data = &gpanel_screen [(y >> 3) * NCOL + x];
if (color)
*data |= 1 << (y & 7);
else
*data &= ~(1 << (y & 7));
lcd_write(0x40 | (y >> 3), 0);
lcd_write(0x80 | x, 0);
lcd_write(*data, 1);
}
/*
* Draw a filled rectangle in the specified color from (x1,y1) to (x2,y2).
*
* The best way to fill a rectangle is to take advantage of the "wrap-around" featute
* built into the Philips PCF8833 controller. By defining a drawing box, the memory can
* be simply filled by successive memory writes until all pixels have been illuminated.
*/
void gpanel_rect_filled(int x0, int y0, int x1, int y1, int color)
{
/* Temporary solution */
int xmin, xmax, ymin, ymax, x, y;
/* calculate the min and max for x and y directions */
if (x0 <= x1) {
xmin = x0;
xmax = x1;
} else {
xmin = x1;
xmax = x0;
}
if (y0 <= y1) {
ymin = y0;
ymax = y1;
} else {
ymin = y1;
ymax = y0;
}
for (y=ymin; y<=ymax; y++)
for (x=xmin; x<=xmax; x++)
gpanel_pixel(x, y, color);
}
/*-------------------------------------------------------------
* Output piece coordinates given its center and angle
*/
void translate(const shape_t *t, const coord_t *c, int a, coord_t *res)
{
coord_t org, tmp;
int yw, xw, i;
if (a & 1) { /* 90 deg */
xw = t->dy;
yw = t->dx;
} else {
xw = t->dx;
yw = t->dy;
}
org = *c;
org.x -= (xw + 1) / 2;
org.y -= yw / 2;
if (org.y < 0)
org.y = 0;
if (org.y + yw >= PITWIDTH && c->y <= PITWIDTH)
org.y = PITWIDTH-1 - yw;
for (i=0; t->p[i].x!=FIN; i++) {
switch (a) {
case 0:
res[i].x = t->p[i].x;
res[i].y = t->p[i].y;
break;
case 3:
res[i].x = xw - t->p[i].y;
res[i].y = t->p[i].x;
break;
case 2:
res[i].x = xw - t->p[i].x;
res[i].y = yw - t->p[i].y;
break;
case 1:
res[i].x = t->p[i].y;
res[i].y = yw - t->p[i].x;
}
res[i].x += org.x;
res[i].y += org.y;
}
res[i].x = res[i].y = FIN;
do {
xw = 0;
for (i=0; res[i+1].x!=FIN; i++) {
if (res[i].x < res[i+1].x)
continue;
if (res[i].x == res[i+1].x && res[i].y <= res[i+1].y)
continue;
xw++;
tmp = res[i];
res[i] = res[i+1];
res[i+1] = tmp;
}
} while (xw);
}
/*
* Draw the block
*/
void draw_block(int h, int w, int visible)
{
h *= 4;
w *= 4;
if (visible) {
gpanel_rect_filled(NCOL-1 - h, w, NCOL-1 - (h + 3), w + 3, 1);
} else {
gpanel_rect_filled(NCOL-1 - h, w, NCOL-1 - (h + 3), w + 3, 0);
if (h == (PITDEPTH-1)*5)
gpanel_pixel(NCOL-1 - (h + 3), w + 2, 1);
if (w == 0)
gpanel_pixel(NCOL-1 - (h + 2), w, 1);
else if (w % 16 == 12)
gpanel_pixel(NCOL-1 - (h + 2), w + 3, 1);
}
}
/*
* Move the piece
*/
void move(coord_t *old, coord_t *new)
{
for (;;) {
if (old->x == FIN) {
draw: if (new->x == FIN)
break;
if (new->x >= 0)
draw_block(new->x, new->y, 1);
new++;
continue;
}
if (new->x == FIN) {
clear: if (old->x >= 0)
draw_block(old->x, old->y, 0);
old++;
continue;
}
if (old->x > new->x)
goto draw;
if (old->x < new->x)
goto clear;
if (old->y > new->y)
goto draw;
if (old->y != new->y)
goto clear;
/* old & new at the same place */
old++;
new++;
}
}
/*
* Draw the pit
*/
void clear()
{
int h, w;
for (h=0; h<PITDEPTH; h++) {
for (w=0; w<PITWIDTH; w++) {
draw_block(h, w, 0);
pit[h][w] = 0;
}
pitcnt[h] = 0;
}
for (w=0; w<PITWIDTH; w++)
pit[PITDEPTH][w] = 1;
}
/*
* The piece reached the bottom
*/
void stopped(coord_t *c)
{
int h, nfull, w, k;
/* Count the full lines */
nfull = 0;
for (; c->x!=FIN; c++) {
if (c->x <= 0) {
/* Game over. */
clear();
return;
}
pit[c->x][c->y] = 1;
++pitcnt[c->x];
if (pitcnt[c->x] == PITWIDTH)
nfull++;
}
if (! nfull)
return;
/* Clear upper nfull lines */
for (h=0; h<nfull; h++) {
for (w=0; w<PITWIDTH; w++) {
if (pit[h][w]) {
draw_block(h, w, 0);
}
}
}
/* Move lines down */
k = nfull;
for (h=nfull; h<PITDEPTH && k>0; h++) {
if (pitcnt[h-k] == PITWIDTH) {
k--;
h--;
continue;
}
for (w=0; w<PITWIDTH; w++) {
if (pit[h][w] != pit[h-k][w]) {
draw_block(h, w, pit[h-k][w]);
}
}
}
/* Now fix the pit contents */
for (h=PITDEPTH-1; h>0; h--) {
if (pitcnt[h] != PITWIDTH)
continue;
memmove(pit[0]+PITWIDTH, pit[0], h * sizeof(pit[0]));
memset(pit[0], 0, sizeof(pit[0]));
memmove(pitcnt+1, pitcnt, h * sizeof(pitcnt[0]));
pitcnt[0] = 0;
h++;
}
}
int main()
{
int ptype; /* Piece type */
int angle, anew; /* Angle */
int msec; /* Timeout */
coord_t c, cnew, *cp;
unsigned up_pressed = 0, left_pressed = 0;
unsigned right_pressed = 0, down_pressed = 0;
joystick_init();
gpanel_init();
gpanel_clear();
/* Draw the pit */
clear();
newpiece:
ptype = rand() % NSHAPES;
angle = rand() % 3;
c.y = PITWIDTH/2 - 1;
for (c.x= -2; ; c.x++) {
translate(&shape[ptype], &c, angle, new);
for (cp=new; cp->x!=FIN; cp++) {
if (cp->x >= 0)
goto ok;
}
}
ok:
/* Draw new piece */
for (cp=new; cp->x!=FIN; cp++) {
if (cp->x >= 0) {
draw_block(cp->x, cp->y, 1);
}
}
memcpy(old, new, sizeof old);
msec = 500;
for (;;) {
cnew = c;
anew = angle;
if (msec <= 0) {
/* Timeout: move down */
msec = 500;
cnew.x++;
translate(&shape[ptype], &cnew, anew, chk);
for (cp=chk; cp->x!=FIN; cp++) {
if (cp->x >= 0 && pit[cp->x][cp->y]) {
stopped(new);
goto newpiece;
}
}
goto check;
}
int key = joystick_get();
if (key != JOYSTICK_RIGHT)
right_pressed = 0;
else if (! right_pressed) {
right_pressed = 1;
/* Right: rotate */
if (--anew < 0)
anew = 3;
translate(&shape[ptype], &cnew, anew, chk);
goto check;
}
if (key != JOYSTICK_UP)
up_pressed = 0;
else if (! up_pressed) {
up_pressed = 1;
/* Up: move left. */
if (cnew.y <= 0)
continue;
cnew.y--;
translate(&shape[ptype], &cnew, anew, chk);
goto check;
}
if (key != JOYSTICK_DOWN)
down_pressed = 0;
else if (! down_pressed) {
down_pressed = 1;
/* Down: move right */
if (cnew.y >= PITWIDTH-1)
continue;
cnew.y++;
translate(&shape[ptype], &cnew, anew, chk);
goto check;
}
if (key != JOYSTICK_LEFT)
left_pressed = 0;
else if (! left_pressed) {
left_pressed = 1;
/* Right: drop */
for (;;) {
cnew.x++;
translate(&shape[ptype], &cnew, anew, chk);
for (cp=chk; cp->x!=FIN; cp++) {
if (cp->x >= 0 && pit[cp->x][cp->y]) {
cnew.x--;
translate(&shape[ptype], &cnew, anew, chk);
move(new, chk);
stopped(chk);
goto newpiece;
}
}
}
}
usleep(10000);
msec -= 10;
continue;
check:
for (cp=chk; cp->x!=FIN; cp++) {
if (cp->y < 0 || cp->y >= PITWIDTH)
goto done;
}
for (cp=chk; cp->x!=FIN; cp++) {
if (cp->x >= 0 && pit[cp->x][cp->y])
goto done;
}
c = cnew;
angle = anew;
memcpy(old, new, sizeof old);
memcpy(new, chk, sizeof new);
move(old, new);
done: ;
}
}
-15
View File
@@ -1,15 +0,0 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror
all: cplus
cplus: cplus.o
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
${OBJDUMP} -S cplus.elf > cplus.dis
${SIZE} cplus.elf
${ELF2AOUT} cplus.elf $@
clean:
rm -f *.o *.elf ${MAN} cplus *.elf *.dis tags *~
-24
View File
@@ -1,24 +0,0 @@
PROG = all backlight cube demo
# Duinomite board
#OBJS = duinomite.o
# Fubarino board
OBJS = fubarino.o
all: $(PROG)
all: all.c $(OBJS)
cc $@.c $(OBJS) -o $@
backlight: backlight.c $(OBJS)
cc $@.c $(OBJS) -o $@
cube: cube.c $(OBJS)
cc $@.c $(OBJS) -o $@
demo: demo.c $(OBJS)
cc $@.c $(OBJS) -o $@
clean:
rm -f *.o *~ $(PROG)
-16
View File
@@ -1,16 +0,0 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror
LIBS += -lm
#all: demo
demo: demo.o fubarino.o
${CC} ${LDFLAGS} -o demo.elf demo.o fubarino.o ${LIBS}
${OBJDUMP} -S demo.elf > demo.dis
${SIZE} demo.elf
${ELF2AOUT} demo.elf $@
clean:
rm -f *.o *.elf ${MAN} demo *.elf *.dis tags *~
-1
View File
@@ -1 +0,0 @@
Examples for LED cube 8x8x8.
-25
View File
@@ -1,25 +0,0 @@
/*
* Demo for LED cube 8x8x8.
* Turn on all LEDs.
*/
#include <stdio.h>
#include "cube.h"
int main()
{
static unsigned char data[8] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
int i;
gpio_init();
gpio_le(0);
gpio_plane(data);
gpio_ext(1);
for (;;) {
for (i=0; i<8; i++) {
gpio_layer(i);
}
}
return 0;
}
-20
View File
@@ -1,20 +0,0 @@
/*
* Demo for LED cube 8x8x8.
* Test backlight LEDs.
*/
#include <stdio.h>
#include "cube.h"
int main()
{
gpio_init();
for (;;) {
gpio_backlight_upper(1);
usleep(500000);
gpio_backlight_upper(0);
gpio_backlight_lower(1);
usleep(500000);
gpio_backlight_lower(0);
}
return 0;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Some files were not shown because too many files have changed in this diff Show More