├── .gitignore ├── Kbuild ├── Makefile ├── README ├── contrib └── klibc.m4 ├── defconfig ├── git-rm-for-kernel.sh ├── klcc ├── .gitignore ├── Kbuild ├── klcc.1 ├── klcc.in └── makeklcc.pl ├── klibc.spec.in ├── makerpm.sh ├── maketar.sh ├── scripts ├── Kbuild.include ├── Kbuild.install ├── Kbuild.klibc ├── Makefile.clean ├── Makefile.host └── basic │ ├── .gitignore │ ├── Kbuild │ └── fixdep.c └── usr ├── .gitignore ├── Kbuild ├── dash ├── .gitignore ├── Kbuild ├── README.dash ├── TOUR ├── alias.c ├── alias.h ├── arith_yacc.c ├── arith_yacc.h ├── arith_yylex.c ├── bltin │ ├── bltin.h │ ├── echo.1 │ ├── printf.1 │ ├── printf.c │ ├── test.1 │ └── test.c ├── builtins.def.in ├── cd.c ├── cd.h ├── config.h ├── error.c ├── error.h ├── eval.c ├── eval.h ├── exec.c ├── exec.h ├── expand.c ├── expand.h ├── funcs │ ├── cmv │ ├── dirs │ ├── kill │ ├── login │ ├── newgrp │ ├── popd │ ├── pushd │ └── suspend ├── gendeps.pl ├── hetio.c ├── hetio.h ├── histedit.c ├── init.h ├── input.c ├── input.h ├── jobs.c ├── jobs.h ├── machdep.h ├── mail.c ├── mail.h ├── main.c ├── main.h ├── memalloc.c ├── memalloc.h ├── miscbltin.c ├── miscbltin.h ├── mkbuiltins ├── mkinit.c ├── mknodes.c ├── mksyntax.c ├── mktokens ├── myhistedit.h ├── mystring.c ├── mystring.h ├── nodes.c.pat ├── nodetypes ├── options.c ├── options.h ├── output.c ├── output.h ├── parser.c ├── parser.h ├── redir.c ├── redir.h ├── sh.1 ├── shell.h ├── show.c ├── show.h ├── system.c ├── system.h ├── trap.c ├── trap.h ├── var.c └── var.h ├── gzip ├── .gitignore ├── COPYING ├── Kbuild ├── README ├── bits.c ├── deflate.c ├── gzip.c ├── gzip.h ├── inflate.c ├── revision.h ├── tailor.h ├── trees.c ├── unzip.c ├── util.c └── zip.c ├── include ├── Kbuild ├── alloca.h ├── arch │ ├── alpha │ │ ├── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ └── archstat.h │ │ └── machine │ │ │ └── asm.h │ ├── arm │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ ├── archstat.h │ │ │ └── asmmacros.h │ ├── cris │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ └── archstat.h │ ├── i386 │ │ ├── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ ├── archstat.h │ │ │ └── diverr.h │ │ └── sys │ │ │ ├── io.h │ │ │ └── vm86.h │ ├── ia64 │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ ├── archstat.h │ │ │ └── archsys.h │ ├── m32r │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ └── archstat.h │ ├── m68k │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ └── archstat.h │ ├── mips │ │ ├── klibc │ │ │ ├── archconfig.h │ │ │ ├── archfcntl.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ ├── archsocket.h │ │ │ └── archstat.h │ │ ├── machine │ │ │ └── asm.h │ │ ├── sgidefs.h │ │ └── spaces.h │ ├── mips64 │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsignal.h │ │ │ ├── archsocket.h │ │ │ └── archstat.h │ ├── parisc │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ └── archstat.h │ ├── ppc │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ └── archstat.h │ ├── ppc64 │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ └── archstat.h │ ├── s390 │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ └── archstat.h │ ├── sh │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ └── archstat.h │ ├── sparc │ │ ├── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ └── archstat.h │ │ └── machine │ │ │ ├── asm.h │ │ │ ├── frame.h │ │ │ └── trap.h │ ├── sparc64 │ │ └── klibc │ │ │ ├── archconfig.h │ │ │ ├── archsetjmp.h │ │ │ ├── archsignal.h │ │ │ └── archstat.h │ └── x86_64 │ │ ├── klibc │ │ ├── archconfig.h │ │ ├── archsetjmp.h │ │ ├── archsignal.h │ │ └── archstat.h │ │ └── sys │ │ └── io.h ├── arpa │ └── inet.h ├── assert.h ├── bits32 │ ├── bitsize.h │ └── bitsize │ │ ├── limits.h │ │ ├── stddef.h │ │ ├── stdint.h │ │ ├── stdintconst.h │ │ └── stdintlimits.h ├── bits64 │ ├── bitsize.h │ └── bitsize │ │ ├── limits.h │ │ ├── stddef.h │ │ ├── stdint.h │ │ ├── stdintconst.h │ │ └── stdintlimits.h ├── byteswap.h ├── ctype.h ├── dirent.h ├── elf.h ├── endian.h ├── errno.h ├── fcntl.h ├── fnmatch.h ├── getopt.h ├── grp.h ├── inttypes.h ├── klibc │ ├── compiler.h │ ├── diverr.h │ ├── endian.h │ ├── extern.h │ ├── stathelp.h │ └── sysconfig.h ├── limits.h ├── malloc.h ├── mntent.h ├── net │ ├── if.h │ ├── if_arp.h │ ├── if_packet.h │ └── route.h ├── netinet │ ├── if_ether.h │ ├── in.h │ ├── in6.h │ ├── ip.h │ ├── tcp.h │ └── udp.h ├── netpacket │ └── packet.h ├── paths.h ├── poll.h ├── pwd.h ├── sched.h ├── setjmp.h ├── signal.h ├── stdarg.h ├── stddef.h ├── stdint.h ├── stdio.h ├── stdlib.h ├── string.h ├── sys │ ├── capability.h │ ├── dirent.h │ ├── elf32.h │ ├── elf64.h │ ├── elfcommon.h │ ├── file.h │ ├── fsuid.h │ ├── inotify.h │ ├── ioctl.h │ ├── klog.h │ ├── md.h │ ├── mman.h │ ├── mount.h │ ├── param.h │ ├── poll.h │ ├── prctl.h │ ├── reboot.h │ ├── resource.h │ ├── select.h │ ├── sendfile.h │ ├── socket.h │ ├── socketcalls.h │ ├── splice.h │ ├── stat.h │ ├── statfs.h │ ├── syscall.h │ ├── sysinfo.h │ ├── sysmacros.h │ ├── time.h │ ├── times.h │ ├── types.h │ ├── uio.h │ ├── un.h │ ├── utime.h │ ├── utsname.h │ ├── vfs.h │ └── wait.h ├── sysexits.h ├── syslog.h ├── termios.h ├── time.h ├── unistd.h ├── utime.h ├── zconf.h └── zlib.h ├── kinit ├── .gitignore ├── Kbuild ├── README ├── capabilities.c ├── devname.c ├── do_mounts.c ├── do_mounts.h ├── do_mounts_md.c ├── do_mounts_mtd.c ├── fstype │ ├── Kbuild │ ├── btrfs.h │ ├── cramfs_fs.h │ ├── ext2_fs.h │ ├── ext3_fs.h │ ├── fstype.c │ ├── fstype.h │ ├── gfs2_fs.h │ ├── iso9660_sb.h │ ├── jfs_superblock.h │ ├── luks_fs.h │ ├── lvm2_sb.h │ ├── main.c │ ├── minix_fs.h │ ├── nilfs_fs.h │ ├── ocfs2_fs.h │ ├── reiser4_fs.h │ ├── reiserfs_fs.h │ ├── romfs_fs.h │ ├── squashfs_fs.h │ ├── swap_fs.h │ └── xfs_sb.h ├── getarg.c ├── getintfile.c ├── initrd.c ├── ipconfig │ ├── Kbuild │ ├── README.ipconfig │ ├── bootp_packet.h │ ├── bootp_proto.c │ ├── bootp_proto.h │ ├── dhcp_proto.c │ ├── dhcp_proto.h │ ├── ipconfig.h │ ├── main.c │ ├── netdev.c │ ├── netdev.h │ ├── packet.c │ └── packet.h ├── kinit.c ├── kinit.h ├── name_to_dev.c ├── nfsmount │ ├── Kbuild │ ├── README.locking │ ├── dummypmap.c │ ├── dummypmap.h │ ├── dummypmap_test.c │ ├── main.c │ ├── mount.c │ ├── nfsmount.h │ ├── portmap.c │ ├── sunrpc.c │ └── sunrpc.h ├── nfsroot.c ├── ramdisk_load.c ├── readfile.c ├── resume │ ├── Kbuild │ ├── resume.c │ ├── resume.h │ └── resumelib.c ├── run-init │ ├── Kbuild │ ├── run-init.c │ ├── run-init.h │ └── runinitlib.c ├── xpio.c └── xpio.h ├── klibc ├── .gitignore ├── CAVEATS ├── Kbuild ├── LICENSE ├── README.klibc ├── SOCKETCALLS.def ├── SYSCALLS.def ├── __put_env.c ├── __shared_init.c ├── __signal.c ├── __static_init.c ├── abort.c ├── alarm.c ├── alphasort.c ├── arch │ ├── README.klibc.arch │ ├── alpha │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── README-gcc │ │ ├── crt0.S │ │ ├── divide.c │ │ ├── pipe.S │ │ ├── setjmp.S │ │ ├── syscall.S │ │ ├── sysdual.S │ │ └── sysstub.ph │ ├── arm │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── __muldi3.c │ │ ├── aeabi_nonsense.S │ │ ├── crt0.S │ │ ├── setjmp.S │ │ ├── syscall.S │ │ ├── sysstub.ph │ │ └── vfork.S │ ├── cris │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── __negdi2.S │ │ ├── crt0.S │ │ ├── divide.c │ │ ├── setjmp.S │ │ ├── syscall.S │ │ ├── sysstub.ph │ │ └── vfork.S │ ├── i386 │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── libgcc │ │ │ ├── __ashldi3.S │ │ │ ├── __ashrdi3.S │ │ │ ├── __lshrdi3.S │ │ │ ├── __muldi3.S │ │ │ └── __negdi2.S │ │ ├── open.S │ │ ├── openat.S │ │ ├── setjmp.S │ │ ├── socketcall.S │ │ ├── syscall.S │ │ ├── sysstub.ph │ │ ├── varsyscall.S │ │ └── vfork.S │ ├── ia64 │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── pipe.c │ │ ├── setjmp.S │ │ ├── syscall.S │ │ ├── sysstub.ph │ │ └── vfork.S │ ├── m32r │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── setjmp.S │ │ ├── syscall.S │ │ └── sysstub.ph │ ├── m68k │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── setjmp.S │ │ ├── syscall.S │ │ ├── sysstub.ph │ │ └── vfork.S │ ├── mips │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── klibc.ld │ │ ├── pipe.S │ │ ├── setjmp.S │ │ ├── syscall.S │ │ ├── sysstub.ph │ │ └── vfork.S │ ├── mips64 │ │ ├── Kbuild │ │ └── MCONFIG │ ├── parisc │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── setjmp.S │ │ ├── syscall.S │ │ ├── sysstub.ph │ │ └── vfork.S │ ├── ppc │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── setjmp.S │ │ ├── syscall.S │ │ └── sysstub.ph │ ├── ppc64 │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── setjmp.S │ │ ├── syscall.c │ │ └── sysstub.ph │ ├── s390 │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── mmap.c │ │ ├── setjmp.S │ │ ├── syscall.c │ │ └── sysstub.ph │ ├── sh │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── pipe.S │ │ ├── setjmp.S │ │ ├── syscall.S │ │ └── sysstub.ph │ ├── sparc │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── __muldi3.S │ │ ├── crt0.S │ │ ├── crt0i.S │ │ ├── divrem.m4 │ │ ├── pipe.S │ │ ├── setjmp.S │ │ ├── smul.S │ │ ├── syscall.S │ │ ├── sysfork.S │ │ ├── sysstub.ph │ │ └── umul.S │ ├── sparc64 │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── pipe.S │ │ ├── setjmp.S │ │ ├── syscall.S │ │ ├── sysfork.S │ │ └── sysstub.ph │ └── x86_64 │ │ ├── Kbuild │ │ ├── MCONFIG │ │ ├── crt0.S │ │ ├── setjmp.S │ │ ├── sigreturn.S │ │ ├── syscall.S │ │ ├── sysstub.ph │ │ └── vfork.S ├── asprintf.c ├── assert.c ├── atexit.c ├── atexit.h ├── atoi.c ├── atol.c ├── atoll.c ├── atox.c ├── brk.c ├── bsd_signal.c ├── bsearch.c ├── bzero.c ├── calloc.c ├── clearenv.c ├── closelog.c ├── creat.c ├── ctype │ ├── ctypefunc.h │ ├── isalnum.c │ ├── isalpha.c │ ├── isascii.c │ ├── isblank.c │ ├── iscntrl.c │ ├── isdigit.c │ ├── isgraph.c │ ├── islower.c │ ├── isprint.c │ ├── ispunct.c │ ├── isspace.c │ ├── isupper.c │ ├── isxdigit.c │ ├── tolower.c │ └── toupper.c ├── ctypes.c ├── daemon.c ├── endmntent.c ├── env.h ├── exec_l.c ├── execl.c ├── execle.c ├── execlp.c ├── execlpe.c ├── execv.c ├── execvp.c ├── execvpe.c ├── exit.c ├── fgetc.c ├── fgets.c ├── fnmatch.c ├── fork.c ├── fprintf.c ├── fputc.c ├── fputs.c ├── fread2.c ├── fstatfs.c ├── fwrite2.c ├── getcwd.c ├── getdomainname.c ├── getenv.c ├── gethostname.c ├── getmntent.c ├── getopt.c ├── getopt_long.c ├── getpgrp.c ├── getpriority.c ├── getpt.c ├── globals.c ├── inet │ ├── bindresvport.c │ ├── inet_addr.c │ ├── inet_aton.c │ ├── inet_ntoa.c │ ├── inet_ntop.c │ └── inet_pton.c ├── interp.S ├── isatty.c ├── jrand48.c ├── libc_init.c ├── libgcc │ ├── __ashldi3.c │ ├── __ashrdi3.c │ ├── __clzsi2.c │ ├── __divdi3.c │ ├── __divsi3.c │ ├── __lshrdi3.c │ ├── __moddi3.c │ ├── __modsi3.c │ ├── __udivdi3.c │ ├── __udivmoddi4.c │ ├── __udivmodsi4.c │ ├── __udivsi3.c │ ├── __umoddi3.c │ └── __umodsi3.c ├── llseek.c ├── lrand48.c ├── makeerrlist.pl ├── malloc.c ├── malloc.h ├── memccpy.c ├── memchr.c ├── memcmp.c ├── memcpy.c ├── memmem.c ├── memmove.c ├── memrchr.c ├── memset.c ├── memswap.c ├── mmap.c ├── mrand48.c ├── nice.c ├── nrand48.c ├── nullenv.c ├── onexit.c ├── open.c ├── open_cloexec.c ├── openat.c ├── pause.c ├── perror.c ├── posix_openpt.c ├── ppoll.c ├── printf.c ├── pselect.c ├── pty.c ├── putchar.c ├── putenv.c ├── puts.c ├── qsort.c ├── raise.c ├── readdir.c ├── realloc.c ├── reboot.c ├── recv.c ├── remove.c ├── sbrk.c ├── scandir.c ├── seed48.c ├── send.c ├── setegid.c ├── setenv.c ├── seteuid.c ├── setmntent.c ├── setpgrp.c ├── sha1hash.c ├── shm_open.c ├── shm_unlink.c ├── sigabbrev.c ├── sigaction.c ├── siglist.c ├── siglongjmp.c ├── sigpending.c ├── sigprocmask.c ├── sigsuspend.c ├── sleep.c ├── snprintf.c ├── socketcalls.pl ├── socketcalls │ ├── .gitignore │ ├── Kbuild │ └── socketcommon.h ├── sprintf.c ├── srand48.c ├── sscanf.c ├── statfs.c ├── stdio │ ├── fclose.c │ ├── fdopen.c │ ├── feof.c │ ├── ferror.c │ ├── fflush.c │ ├── fopen.c │ ├── fputc.c │ ├── fread.c │ ├── fseek.c │ ├── fwrite.c │ ├── fxopen.c │ ├── stdioint.h │ └── ungetc.c ├── strcasecmp.c ├── strcat.c ├── strchr.c ├── strcmp.c ├── strcpy.c ├── strcspn.c ├── strdup.c ├── strerror.c ├── strlcat.c ├── strlcpy.c ├── strlen.c ├── strncasecmp.c ├── strncat.c ├── strncmp.c ├── strncpy.c ├── strndup.c ├── strnlen.c ├── strntoimax.c ├── strntoumax.c ├── strpbrk.c ├── strrchr.c ├── strsep.c ├── strsignal.c ├── strspn.c ├── strstr.c ├── strtoimax.c ├── strtok.c ├── strtok_r.c ├── strtol.c ├── strtoll.c ├── strtotimespec.c ├── strtotimeval.c ├── strtotimex.c ├── strtoul.c ├── strtoull.c ├── strtoumax.c ├── strtox.c ├── strxspn.c ├── strxspn.h ├── syscalls.pl ├── syscalls │ ├── .gitignore │ ├── Kbuild │ └── syscommon.h ├── syslog.c ├── system.c ├── sysv_signal.c ├── tests │ ├── Kbuild │ ├── environ.c │ ├── fcntl.c │ ├── fnmatch.c │ ├── getoptlong.c │ ├── getopttest.c │ ├── getpagesize.c │ ├── hello.c │ ├── idtest.c │ ├── malloctest.c │ ├── malloctest2.c │ ├── memstrtest.c │ ├── microhello.c │ ├── minihello.c │ ├── mmaptest.c │ ├── opentest.c │ ├── pipetest.c │ ├── rtsig.c │ ├── select.c │ ├── setenvtest.c │ ├── setjmptest.c │ ├── sig-nodefer.c │ ├── sigint.c │ ├── socket.c │ ├── stat.c │ ├── statfs.c │ ├── strlcpycat.c │ ├── strtoimax.c │ ├── strtotime.c │ ├── testrand48.c │ ├── testvsnp.c │ └── vfork.c ├── time.c ├── umount.c ├── unsetenv.c ├── userdb │ ├── getgrgid.c │ ├── getgrnam.c │ ├── getpwnam.c │ ├── getpwuid.c │ ├── root_group.c │ ├── root_user.c │ └── userdb.h ├── usleep.c ├── utime.c ├── vasprintf.c ├── version ├── vfork.c ├── vfprintf.c ├── vprintf.c ├── vsnprintf.c ├── vsprintf.c ├── vsscanf.c ├── wait.c ├── wait3.c ├── waitpid.c └── zlib │ ├── FAQ │ ├── INDEX │ ├── Kbuild │ ├── README │ ├── adler32.c │ ├── algorithm.txt │ ├── compress.c │ ├── crc32.c │ ├── crc32.h │ ├── deflate.c │ ├── deflate.h │ ├── gzio.c │ ├── infback.c │ ├── inffast.c │ ├── inffast.h │ ├── inffixed.h │ ├── inflate.c │ ├── inflate.h │ ├── inftrees.c │ ├── inftrees.h │ ├── trees.c │ ├── trees.h │ ├── uncompr.c │ ├── zconf.in.h │ ├── zlib.3 │ ├── zutil.c │ └── zutil.h └── utils ├── Kbuild ├── cat.c ├── chroot.c ├── cpio.c ├── dd.c ├── dmesg.c ├── false.c ├── file_mode.c ├── file_mode.h ├── halt.c ├── kill.c ├── ln.c ├── loop.h ├── losetup.c ├── ls.c ├── minips.c ├── mkdir.c ├── mkfifo.c ├── mknod.c ├── mount_main.c ├── mount_opts.c ├── mount_opts.h ├── mv.c ├── nuke.c ├── pivot_root.c ├── readlink.c ├── sleep.c ├── sync.c ├── true.c ├── umount.c └── uname.c /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE! Don't add files that are generated in specific 3 | # subdirectories here. Add them in the ".gitignore" file 4 | # in that subdirectory instead. 5 | # 6 | # Normal rules 7 | # 8 | *.o 9 | *.o.cmd 10 | .*.cmd 11 | *.g 12 | \#* 13 | .\#* 14 | *~ 15 | 16 | # Top-level ignorables 17 | /linux 18 | /.config 19 | 20 | # Common generated subdirectores 21 | shared 22 | static 23 | -------------------------------------------------------------------------------- /Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # Kbuild file for klibc 3 | # 4 | .PHONY: $(obj)/all 5 | always := all 6 | 7 | $(obj)/all: 8 | $(Q)$(MAKE) $(klibc)=scripts/basic 9 | $(Q)$(MAKE) $(klibc)=usr/klibc 10 | $(Q)$(MAKE) $(klibc)=usr/kinit 11 | $(Q)$(MAKE) $(klibc)=usr/dash 12 | $(Q)$(MAKE) $(klibc)=usr/utils 13 | $(Q)$(MAKE) $(klibc)=usr/gzip 14 | 15 | 16 | # Directories to visit during clean and install 17 | subdir- := scripts/basic klcc usr/klibc usr/dash usr/utils usr/gzip \ 18 | usr/kinit usr/klibc/tests 19 | -------------------------------------------------------------------------------- /defconfig: -------------------------------------------------------------------------------- 1 | CONFIG_KLIBC=y 2 | CONFIG_KLIBC_ERRLIST=y 3 | CONFIG_KLIBC_ZLIB=y 4 | # i386 option 5 | CONFIG_REGPARM=y 6 | # ARM options 7 | # CONFIG_KLIBC_THUMB is not set 8 | # CONFIG_AEABI is not set 9 | -------------------------------------------------------------------------------- /git-rm-for-kernel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ -z "$RM" ]; then 3 | export RM='git rm -rf' 4 | fi 5 | 6 | nuke () { 7 | find "$@" -print | sort -r | xargs -rt $RM 8 | } 9 | 10 | nuke README Kbuild Makefile defconfig klibc.spec.in *.sh 11 | nuke contrib klcc 12 | 13 | # These files are either not needed or provided from the 14 | # kernel tree 15 | nuke scripts/Kbuild.include scripts/Kbuild.install 16 | nuke scripts/Makefile.* 17 | nuke scripts/basic 18 | -------------------------------------------------------------------------------- /klcc/.gitignore: -------------------------------------------------------------------------------- 1 | klcc 2 | klibc.config 3 | -------------------------------------------------------------------------------- /makerpm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -xe 2 | # 3 | # Make an rpm from the current git repository 4 | # 5 | 6 | [ -z "$tmpdir" ] && export tmpdir=/var/tmp 7 | 8 | ./maketar.sh 9 | rpmbuild -ta $tmpdir/klibc-`cat usr/klibc/version`.tar.gz 10 | -------------------------------------------------------------------------------- /maketar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -xe 2 | # 3 | # Make a tarball from the current git repository 4 | # 5 | 6 | [ -z "$tmpdir" ] && tmpdir=/var/tmp 7 | 8 | tmp=$tmpdir/klibc.$$ 9 | rm -rf $tmp 10 | cg-export $tmp 11 | cd $tmp 12 | make release 13 | version=`cat usr/klibc/version` 14 | rm -rf $tmpdir/klibc-$version 15 | mv $tmp $tmpdir/klibc-$version 16 | cd .. 17 | rm -f klibc-$version.tar* 18 | tar cvvf klibc-$version.tar klibc-$version 19 | gzip -9 klibc-$version.tar 20 | rm -rf klibc-$version 21 | -------------------------------------------------------------------------------- /scripts/basic/.gitignore: -------------------------------------------------------------------------------- 1 | fixdep 2 | -------------------------------------------------------------------------------- /scripts/basic/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # Kbuild file to build basic kbuild programs 3 | # 4 | 5 | hostprogs-y := fixdep 6 | always := $(hostprogs-y) 7 | -------------------------------------------------------------------------------- /usr/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated headers (we don't want a .gitignore in the include directory!) 2 | /include/klibc/havesyscall.h 3 | -------------------------------------------------------------------------------- /usr/dash/.gitignore: -------------------------------------------------------------------------------- 1 | arith.[ch] 2 | .builtins.def.d 3 | builtins.[ch] 4 | builtins.def 5 | init.c 6 | mkinit 7 | mknodes 8 | mksyntax 9 | nodes.[ch] 10 | sh 11 | sh.shared 12 | syntax.[ch] 13 | token.h 14 | -------------------------------------------------------------------------------- /usr/gzip/.gitignore: -------------------------------------------------------------------------------- 1 | gunzip 2 | gzip 3 | zcat 4 | -------------------------------------------------------------------------------- /usr/gzip/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # Kbuild file for gzip 3 | # 4 | 5 | # The gzip executable 6 | static-y := gzip 7 | gzip-y := gzip.o util.o unzip.o inflate.o 8 | 9 | # Additional targets 10 | always := gunzip zcat 11 | 12 | # Optional ZIP support 13 | gzip-$(CONFIG_KLIB_ZIP) += zip.o deflate.o trees.o bits.o 14 | cflags-$(CONFIG_KLIB_ZIP) += -DSUPPORT_ZIP 15 | EXTRA_KLIBCCFLAGS := $(cflags-y) 16 | 17 | # Additionally linked targets 18 | $(obj)/gunzip $(obj)/zcat: $(obj)/gzip 19 | $(call cmd,ln) 20 | 21 | # Cleaning 22 | targets := gzip gzip.g gunzip zcat 23 | 24 | # Targets to install 25 | install-y := gzip gunzip zcat 26 | -------------------------------------------------------------------------------- /usr/gzip/revision.h: -------------------------------------------------------------------------------- 1 | /* revision.h -- define the version number 2 | * Copyright (C) 1992-1993 Jean-loup Gailly. 3 | * This is free software; you can redistribute it and/or modify it under the 4 | * terms of the GNU General Public License, see the file COPYING. 5 | */ 6 | 7 | #define VERSION "1.2.4" 8 | #define PATCHLEVEL 0 9 | #define REVDATE "18 Aug 93" 10 | 11 | /* $Id: revision.h,v 1.1 2002/08/18 00:59:21 hpa Exp $ */ 12 | -------------------------------------------------------------------------------- /usr/include/Kbuild: -------------------------------------------------------------------------------- 1 | always := asm 2 | 3 | $(obj)/asm: 4 | @echo ' SYMLINK $@ -> include/asm-$(KLIBCASMARCH)' 5 | $(Q)if [ '$(KLIBCKERNELSRC)/.' -ef '$(obj)/../..' ]; then \ 6 | ln -fsn ../../include/asm-$(KLIBCASMARCH) $@; \ 7 | else \ 8 | ln -fsn $(KLIBCKERNELSRC)/include/asm-$(KLIBCASMARCH) $@; \ 9 | fi 10 | 11 | clean-files := asm 12 | -------------------------------------------------------------------------------- /usr/include/alloca.h: -------------------------------------------------------------------------------- 1 | /* 2 | * alloca.h 3 | * 4 | * Just call the builtin alloca() function 5 | */ 6 | 7 | #ifndef _ALLOCA_H 8 | #define _ALLOCA_H 9 | 10 | #define alloca(size) __builtin_alloca(size) 11 | 12 | #endif /* _ALLOCA_H */ 13 | -------------------------------------------------------------------------------- /usr/include/arch/alpha/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/alpha/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | #define _KLIBC_USE_RT_SIG 1 13 | #define _KLIBC_STATFS_F_TYPE_64 0 14 | 15 | #endif /* _KLIBC_ARCHCONFIG_H */ 16 | -------------------------------------------------------------------------------- /usr/include/arch/alpha/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/alpha/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | /* No special stuff for this architecture */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/arch/alpha/klibc/archstat.h: -------------------------------------------------------------------------------- 1 | #ifndef _KLIBC_ARCHSTAT_H 2 | #define _KLIBC_ARCHSTAT_H 3 | 4 | #include 5 | 6 | #define _STATBUF_ST_NSEC 7 | 8 | struct stat { 9 | __stdev64 (st_dev); 10 | unsigned long st_ino; 11 | __stdev64 (st_rdev); 12 | long st_size; 13 | unsigned long st_blocks; 14 | 15 | unsigned int st_mode; 16 | unsigned int st_uid; 17 | unsigned int st_gid; 18 | unsigned int st_blksize; 19 | unsigned int st_nlink; 20 | unsigned int __pad0; 21 | 22 | struct timespec st_atim; 23 | struct timespec st_mtim; 24 | struct timespec st_ctim; 25 | long __unused[3]; 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /usr/include/arch/arm/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/arm/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* newer arm arch support bx instruction */ 13 | #if (!defined(__ARM_ARCH_2__) && !defined(__ARM_ARCH_3__) \ 14 | && !defined(__ARM_ARCH_3M__) && !defined(__ARM_ARCH_4__)) 15 | # define _KLIBC_ARM_USE_BX 1 16 | #endif 17 | 18 | #endif /* _KLIBC_ARCHCONFIG_H */ 19 | -------------------------------------------------------------------------------- /usr/include/arch/arm/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/include/klibc/archsetjmp.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSETJMP_H 6 | #define _KLIBC_ARCHSETJMP_H 7 | 8 | struct __jmp_buf { 9 | unsigned int regs[10]; 10 | }; 11 | 12 | typedef struct __jmp_buf jmp_buf[1]; 13 | 14 | #endif /* _SETJMP_H */ 15 | -------------------------------------------------------------------------------- /usr/include/arch/arm/klibc/asmmacros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * usr/include/arch/arm/klibc/asmmacros.h 3 | * 4 | * Assembly macros used by ARM system call stubs 5 | */ 6 | 7 | #ifndef _KLIBC_ASMMACROS_H 8 | #define _KLIBC_ASMMACROS_H 9 | 10 | #if _KLIBC_ARM_USE_BX 11 | # define BX(x) bx x 12 | #else 13 | # define BX(x) mov pc, x 14 | #endif 15 | 16 | #endif /* _KLIBC_ASMMACROS_H */ 17 | -------------------------------------------------------------------------------- /usr/include/arch/cris/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/cris/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* cris uses 13 as the page shift factor for sys_mmap2 */ 13 | #define _KLIBC_MMAP2_SHIFT 13 14 | 15 | #endif /* _KLIBC_ARCHCONFIG_H */ 16 | -------------------------------------------------------------------------------- /usr/include/arch/cris/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/cris/include/klibc/archsetjmp.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSETJMP_H 6 | #define _KLIBC_ARCHSETJMP_H 7 | 8 | struct __jmp_buf { 9 | unsigned long __r0; 10 | unsigned long __r1; 11 | unsigned long __r2; 12 | unsigned long __r3; 13 | unsigned long __r4; 14 | unsigned long __r5; 15 | unsigned long __r6; 16 | unsigned long __r7; 17 | unsigned long __r8; 18 | unsigned long __sp; 19 | unsigned long __srp; 20 | }; 21 | 22 | typedef struct __jmp_buf jmp_buf[1]; 23 | 24 | #endif /* _KLIBC_ARCHSETJMP_H */ 25 | -------------------------------------------------------------------------------- /usr/include/arch/cris/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/cris/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | /* No special stuff for this architecture */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/arch/i386/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/i386/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* The i386 is still not clean enough for this... */ 13 | #define _KLIBC_USE_RT_SIG 0 14 | 15 | #endif /* _KLIBC_ARCHCONFIG_H */ 16 | -------------------------------------------------------------------------------- /usr/include/arch/i386/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/include/klibc/archsetjmp.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSETJMP_H 6 | #define _KLIBC_ARCHSETJMP_H 7 | 8 | struct __jmp_buf { 9 | unsigned int __ebx; 10 | unsigned int __esp; 11 | unsigned int __ebp; 12 | unsigned int __esi; 13 | unsigned int __edi; 14 | unsigned int __eip; 15 | }; 16 | 17 | typedef struct __jmp_buf jmp_buf[1]; 18 | 19 | #endif /* _SETJMP_H */ 20 | -------------------------------------------------------------------------------- /usr/include/arch/i386/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Architecture-specific signal definitions 4 | * 5 | */ 6 | 7 | #ifndef _KLIBC_ARCHSIGNAL_H 8 | #define _KLIBC_ARCHSIGNAL_H 9 | 10 | /* The in-kernel headers for i386 got clean up, use them. */ 11 | 12 | #include 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/arch/i386/klibc/diverr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/include/klibc/diverr.h 3 | */ 4 | 5 | #ifndef _KLIBC_DIVERR_H 6 | #define _KLIBC_DIVERR_H 7 | 8 | #include 9 | 10 | static __inline__ void __divide_error(void) 11 | { 12 | asm volatile ("int $0"); 13 | } 14 | 15 | #endif /* _KLIBC_DIVERR_H */ 16 | -------------------------------------------------------------------------------- /usr/include/arch/ia64/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/ia64/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* IA64 doesn't have sys_fork, but it does have an MMU */ 13 | #define _KLIBC_NO_MMU 0 14 | /* IA64 doesn't have sys_vfork, it has architecture-specific code */ 15 | #define _KLIBC_REAL_VFORK 1 16 | 17 | #endif /* _KLIBC_ARCHCONFIG_H */ 18 | -------------------------------------------------------------------------------- /usr/include/arch/ia64/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/ia64/include/klibc/archsetjmp.h 3 | * 4 | * Code borrowed from the FreeBSD kernel. 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSETJMP_H 9 | #define _KLIBC_ARCHSETJMP_H 10 | 11 | /* User code must not depend on the internal representation of jmp_buf. */ 12 | #define _JBLEN 0x200 13 | 14 | /* guaranteed 128-bit alignment! */ 15 | typedef char jmp_buf[_JBLEN] __attribute__ ((aligned(16))); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /usr/include/arch/ia64/klibc/archstat.h: -------------------------------------------------------------------------------- 1 | #ifndef _KLIBC_ARCHSTAT_H 2 | #define _KLIBC_ARCHSTAT_H 3 | 4 | #include 5 | 6 | #define _STATBUF_ST_NSEC 7 | 8 | struct stat { 9 | __stdev64 (st_dev); 10 | unsigned long st_ino; 11 | unsigned long st_nlink; 12 | unsigned int st_mode; 13 | unsigned int st_uid; 14 | unsigned int st_gid; 15 | unsigned int __pad0; 16 | __stdev64 (st_rdev); 17 | unsigned long st_size; 18 | struct timespec st_atim; 19 | struct timespec st_mtim; 20 | struct timespec st_ctim; 21 | unsigned long st_blksize; 22 | long st_blocks; 23 | unsigned long __unused[3]; 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /usr/include/arch/m32r/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/m32r/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* All defaults */ 13 | 14 | #endif /* _KLIBC_ARCHCONFIG_H */ 15 | -------------------------------------------------------------------------------- /usr/include/arch/m32r/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/m32r/include/klibc/archsetjmp.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSETJMP_H 6 | #define _KLIBC_ARCHSETJMP_H 7 | 8 | struct __jmp_buf { 9 | unsigned long __r8; 10 | unsigned long __r9; 11 | unsigned long __r10; 12 | unsigned long __r11; 13 | unsigned long __r12; 14 | unsigned long __r13; 15 | unsigned long __r14; 16 | unsigned long __r15; 17 | }; 18 | 19 | typedef struct __jmp_buf jmp_buf[1]; 20 | 21 | #endif /* _KLIBC_ARCHSETJMP_H */ 22 | -------------------------------------------------------------------------------- /usr/include/arch/m32r/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/m32r/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | /* No special stuff for this architecture */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/arch/m68k/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/m68k/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* On m68k, sys_mmap2 uses the current page size as the shift factor */ 13 | #define _KLIBC_MMAP2_SHIFT __getpageshift() 14 | 15 | #endif /* _KLIBC_ARCHCONFIG_H */ 16 | -------------------------------------------------------------------------------- /usr/include/arch/m68k/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * usr/include/arch/m68k/klibc/archsetjmp.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSETJMP_H 6 | #define _KLIBC_ARCHSETJMP_H 7 | 8 | struct __jmp_buf { 9 | unsigned int __d2; 10 | unsigned int __d3; 11 | unsigned int __d4; 12 | unsigned int __d5; 13 | unsigned int __d6; 14 | unsigned int __d7; 15 | unsigned int __a2; 16 | unsigned int __a3; 17 | unsigned int __a4; 18 | unsigned int __a5; 19 | unsigned int __fp; /* a6 */ 20 | unsigned int __sp; /* a7 */ 21 | unsigned int __retaddr; 22 | }; 23 | 24 | typedef struct __jmp_buf jmp_buf[1]; 25 | 26 | #endif /* _KLBIC_ARCHSETJMP_H */ 27 | -------------------------------------------------------------------------------- /usr/include/arch/m68k/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/m68k/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | /* No special stuff for this architecture */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/arch/mips/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/mips/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* MIPS has architecture-specific code for vfork() */ 13 | #define _KLIBC_REAL_VFORK 1 14 | 15 | /* MIPS defines it's own statfs */ 16 | #define _KLIBC_STATFS_F_TYPE_32B 1 17 | 18 | /* MIPS has nonstandard socket definitions */ 19 | #define _KLIBC_HAS_ARCHSOCKET_H 1 20 | 21 | #endif /* _KLIBC_ARCHCONFIG_H */ 22 | -------------------------------------------------------------------------------- /usr/include/arch/mips/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/mips/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | /* No special stuff for this architecture */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/arch/mips/klibc/archsocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/mips/klibc/archsocket.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSOCKET_H 6 | #define _KLIBC_ARCHSOCKET_H 7 | 8 | #ifndef SOCK_STREAM 9 | # define SOCK_DGRAM 1 10 | # define SOCK_STREAM 2 11 | # define SOCK_RAW 3 12 | # define SOCK_RDM 4 13 | # define SOCK_SEQPACKET 5 14 | # define SOCK_PACKET 10 15 | #endif 16 | 17 | #endif /* _KLIBC_ARCHSOCKET_H */ 18 | -------------------------------------------------------------------------------- /usr/include/arch/mips/sgidefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/mips/include/sgidefs.h 3 | */ 4 | 5 | /* Some ABI constants */ 6 | 7 | #ifndef _SGIDEFS_H 8 | #define _SGIDEFS_H 9 | 10 | #define _MIPS_ISA_MIPS1 1 11 | #define _MIPS_ISA_MIPS2 2 12 | #define _MIPS_ISA_MIPS3 3 13 | #define _MIPS_ISA_MIPS4 4 14 | #define _MIPS_ISA_MIPS5 5 15 | 16 | #define _MIPS_SIM_ABI32 1 17 | #define _MIPS_SIM_NABI32 2 18 | #define _MIPS_SIM_ABI64 3 19 | 20 | #endif /* _SGIDEFS_H */ 21 | -------------------------------------------------------------------------------- /usr/include/arch/mips/spaces.h: -------------------------------------------------------------------------------- 1 | /* Included by but not actually needed */ 2 | -------------------------------------------------------------------------------- /usr/include/arch/mips64/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/mips64/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* MIPS has nonstandard socket definitions */ 13 | #define _KLIBC_HAS_ARCHSOCKET_H 1 14 | 15 | #endif /* _KLIBC_ARCHCONFIG_H */ 16 | -------------------------------------------------------------------------------- /usr/include/arch/mips64/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/mips64/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | /* No special stuff for this architecture */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/arch/mips64/klibc/archsocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/mips64/klibc/archsocket.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSOCKET_H 6 | #define _KLIBC_ARCHSOCKET_H 7 | 8 | #ifndef SOCK_STREAM 9 | # define SOCK_DGRAM 1 10 | # define SOCK_STREAM 2 11 | # define SOCK_RAW 3 12 | # define SOCK_RDM 4 13 | # define SOCK_SEQPACKET 5 14 | # define SOCK_PACKET 10 15 | #endif 16 | 17 | #endif /* _KLIBC_ARCHSOCKET_H */ 18 | -------------------------------------------------------------------------------- /usr/include/arch/parisc/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/parisc/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* All defaults */ 13 | 14 | #endif /* _KLIBC_ARCHCONFIG_H */ 15 | -------------------------------------------------------------------------------- /usr/include/arch/parisc/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/parisc/include/klibc/archsetjmp.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSETJMP_H 6 | #define _KLIBC_ARCHSETJMP_H 7 | 8 | struct __jmp_buf { 9 | double regs[21]; 10 | }; 11 | 12 | typedef struct __jmp_buf jmp_buf[1]; 13 | 14 | #endif /* _SETJMP_H */ 15 | -------------------------------------------------------------------------------- /usr/include/arch/parisc/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/parisc/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | #define _NSIG 64 13 | #define _NSIG_SZ (_NSIG / LONG_BIT) 14 | 15 | typedef struct { 16 | unsigned long sig[_NSIG_SZ]; 17 | } sigset_t; 18 | 19 | struct sigaction { 20 | __sighandler_t sa_handler; 21 | unsigned long sa_flags; 22 | sigset_t sa_mask; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /usr/include/arch/ppc/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/ppc/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* All defaults */ 13 | 14 | #endif /* _KLIBC_ARCHCONFIG_H */ 15 | -------------------------------------------------------------------------------- /usr/include/arch/ppc/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/ppc/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | /* No special stuff for this architecture */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/arch/ppc64/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/ppc64/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in this file. 5 | */ 6 | 7 | #ifndef _KLIBC_ARCHCONFIG_H 8 | #define _KLIBC_ARCHCONFIG_H 9 | 10 | #define _KLIBC_USE_RT_SIG 1 11 | 12 | #endif /* _KLIBC_ARCHCONFIG_H */ 13 | -------------------------------------------------------------------------------- /usr/include/arch/ppc64/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/ppc64/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | /* No special stuff for this architecture */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/arch/s390/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/s390/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* Both s390 and s390x use the "32-bit" version of this structure */ 13 | #define _KLIBC_STATFS_F_TYPE_64 0 14 | 15 | #endif /* _KLIBC_ARCHCONFIG_H */ 16 | -------------------------------------------------------------------------------- /usr/include/arch/s390/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/s390/include/klibc/archsetjmp.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSETJMP_H 6 | #define _KLIBC_ARCHSETJMP_H 7 | 8 | #ifndef __s390x__ 9 | 10 | struct __jmp_buf { 11 | uint32_t __gregs[10]; /* general registers r6-r15 */ 12 | uint64_t __fpregs[2]; /* fp registers f4 and f6 */ 13 | }; 14 | 15 | #else /* __s390x__ */ 16 | 17 | struct __jmp_buf { 18 | uint64_t __gregs[10]; /* general registers r6-r15 */ 19 | uint64_t __fpregs[4]; /* fp registers f1, f3, f5, f7 */ 20 | }; 21 | 22 | #endif /* __s390x__ */ 23 | 24 | typedef struct __jmp_buf jmp_buf[1]; 25 | 26 | #endif /* _SETJMP_H */ 27 | -------------------------------------------------------------------------------- /usr/include/arch/s390/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/s390/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | /* No special stuff for this architecture */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/arch/sh/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/sh/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* All defaults */ 13 | 14 | #endif /* _KLIBC_ARCHCONFIG_H */ 15 | -------------------------------------------------------------------------------- /usr/include/arch/sh/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sh/include/klibc/archsetjmp.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSETJMP_H 6 | #define _KLIBC_ARCHSETJMP_H 7 | 8 | struct __jmp_buf { 9 | unsigned long __r8; 10 | unsigned long __r9; 11 | unsigned long __r10; 12 | unsigned long __r11; 13 | unsigned long __r12; 14 | unsigned long __r13; 15 | unsigned long __r14; 16 | unsigned long __r15; 17 | unsigned long __pr; 18 | }; 19 | 20 | typedef struct __jmp_buf jmp_buf[1]; 21 | 22 | #endif /* _KLIBC_ARCHSETJMP_H */ 23 | -------------------------------------------------------------------------------- /usr/include/arch/sh/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sh/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | /* No special stuff for this architecture */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/arch/sparc/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/sparc/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | #define _KLIBC_USE_RT_SIG 1 /* Use rt_* signals */ 13 | #define _KLIBC_SYS_SOCKETCALL 1 /* Use sys_socketcall unconditionally */ 14 | 15 | #endif /* _KLIBC_ARCHCONFIG_H */ 16 | -------------------------------------------------------------------------------- /usr/include/arch/sparc/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sparc/include/klibc/archsetjmp.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSETJMP_H 6 | #define _KLIBC_ARCHSETJMP_H 7 | 8 | struct __jmp_buf { 9 | unsigned long __sp; 10 | unsigned long __fp; 11 | unsigned long __pc; 12 | }; 13 | 14 | typedef struct __jmp_buf jmp_buf[1]; 15 | 16 | #endif /* _SETJMP_H */ 17 | -------------------------------------------------------------------------------- /usr/include/arch/sparc/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Architecture-specific signal definitions 4 | * 5 | */ 6 | 7 | #ifndef _KLIBC_ARCHSIGNAL_H 8 | #define _KLIBC_ARCHSIGNAL_H 9 | 10 | #define __WANT_POSIX1B_SIGNALS__ 11 | 12 | #include 13 | 14 | /* Not actually used by the kernel... */ 15 | #define SA_RESTORER 0x80000000 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /usr/include/arch/sparc64/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/sparc64/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | #define _KLIBC_USE_RT_SIG 1 /* Use rt_* signals */ 13 | #define _KLIBC_NEEDS_SA_RESTORER 1 /* Need a restorer function */ 14 | #define _KLIBC_SYS_SOCKETCALL 1 /* Use sys_socketcall unconditionally */ 15 | 16 | #endif /* _KLIBC_ARCHCONFIG_H */ 17 | -------------------------------------------------------------------------------- /usr/include/arch/sparc64/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sparc64/include/klibc/archsetjmp.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSETJMP_H 6 | #define _KLIBC_ARCHSETJMP_H 7 | 8 | struct __jmp_buf { 9 | unsigned long __sp; 10 | unsigned long __fp; 11 | unsigned long __pc; 12 | }; 13 | 14 | typedef struct __jmp_buf jmp_buf[1]; 15 | 16 | #endif /* _SETJMP_H */ 17 | -------------------------------------------------------------------------------- /usr/include/arch/sparc64/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sparc64/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #define __WANT_POSIX1B_SIGNALS__ 12 | #include 13 | 14 | /* Not actually used by the kernel... */ 15 | #define SA_RESTORER 0x80000000 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /usr/include/arch/sparc64/klibc/archstat.h: -------------------------------------------------------------------------------- 1 | #ifndef _KLIBC_ARCHSTAT_H 2 | #define _KLIBC_ARCHSTAT_H 3 | 4 | #include 5 | 6 | #define _STATBUF_ST_NSEC 7 | 8 | struct stat { 9 | __stdev64 (st_dev); 10 | unsigned long st_ino; 11 | unsigned long st_nlink; 12 | 13 | unsigned int st_mode; 14 | unsigned int st_uid; 15 | unsigned int st_gid; 16 | unsigned int __pad0; 17 | 18 | __stdev64 (st_rdev); 19 | long st_size; 20 | long st_blksize; 21 | long st_blocks; 22 | 23 | struct timespec st_atim; 24 | struct timespec st_mtim; 25 | struct timespec st_ctim; 26 | 27 | unsigned long __unused[3]; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /usr/include/arch/x86_64/klibc/archconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/arch/x86_64/klibc/archconfig.h 3 | * 4 | * See include/klibc/sysconfig.h for the options that can be set in 5 | * this file. 6 | * 7 | */ 8 | 9 | #ifndef _KLIBC_ARCHCONFIG_H 10 | #define _KLIBC_ARCHCONFIG_H 11 | 12 | /* x86-64 doesn't provide a default sigreturn. */ 13 | #define _KLIBC_NEEDS_SA_RESTORER 1 14 | 15 | #endif /* _KLIBC_ARCHCONFIG_H */ 16 | -------------------------------------------------------------------------------- /usr/include/arch/x86_64/klibc/archsetjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/x86_64/include/klibc/archsetjmp.h 3 | */ 4 | 5 | #ifndef _KLIBC_ARCHSETJMP_H 6 | #define _KLIBC_ARCHSETJMP_H 7 | 8 | struct __jmp_buf { 9 | unsigned long __rbx; 10 | unsigned long __rsp; 11 | unsigned long __rbp; 12 | unsigned long __r12; 13 | unsigned long __r13; 14 | unsigned long __r14; 15 | unsigned long __r15; 16 | unsigned long __rip; 17 | }; 18 | 19 | typedef struct __jmp_buf jmp_buf[1]; 20 | 21 | #endif /* _SETJMP_H */ 22 | -------------------------------------------------------------------------------- /usr/include/arch/x86_64/klibc/archsignal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/x86_64/include/klibc/archsignal.h 3 | * 4 | * Architecture-specific signal definitions 5 | * 6 | */ 7 | 8 | #ifndef _KLIBC_ARCHSIGNAL_H 9 | #define _KLIBC_ARCHSIGNAL_H 10 | 11 | #include 12 | /* The x86-64 headers defines NSIG 32, but it's actually 64 */ 13 | #undef _NSIG 14 | #undef NSIG 15 | #define _NSIG 64 16 | #define NSIG _NSIG 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /usr/include/arch/x86_64/klibc/archstat.h: -------------------------------------------------------------------------------- 1 | #ifndef _KLIBC_ARCHSTAT_H 2 | #define _KLIBC_ARCHSTAT_H 3 | 4 | #include 5 | 6 | #define _STATBUF_ST_NSEC 7 | 8 | struct stat { 9 | __stdev64 (st_dev); 10 | unsigned long st_ino; 11 | unsigned long st_nlink; 12 | 13 | unsigned int st_mode; 14 | unsigned int st_uid; 15 | unsigned int st_gid; 16 | unsigned int __pad0; 17 | __stdev64 (st_rdev); 18 | long st_size; 19 | long st_blksize; 20 | long st_blocks; /* Number 512-byte blocks allocated. */ 21 | 22 | struct timespec st_atim; 23 | struct timespec st_mtim; 24 | struct timespec st_ctim; 25 | long __unused[3]; 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /usr/include/bits32/bitsize.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITSIZE 2 | #define _BITSIZE 32 3 | #endif 4 | -------------------------------------------------------------------------------- /usr/include/bits32/bitsize/limits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bits32/limits.h 3 | */ 4 | 5 | #ifndef _BITSIZE_LIMITS_H 6 | #define _BITSIZE_LIMITS_H 7 | 8 | #define LONG_BIT 32 9 | 10 | #define LONG_MIN (-2147483647L-1) 11 | #define LONG_MAX 2147483647L 12 | #define ULONG_MAX 4294967295UL 13 | 14 | #endif /* _BITSIZE_LIMITS_H */ 15 | -------------------------------------------------------------------------------- /usr/include/bits32/bitsize/stddef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bits32/stddef.h 3 | */ 4 | 5 | #ifndef _BITSIZE_STDDEF_H 6 | #define _BITSIZE_STDDEF_H 7 | 8 | #define _SIZE_T 9 | #if defined(__s390__) || defined(__cris__) 10 | typedef unsigned long size_t; 11 | #else 12 | typedef unsigned int size_t; 13 | #endif 14 | 15 | #define _PTRDIFF_T 16 | typedef signed int ptrdiff_t; 17 | 18 | #endif /* _BITSIZE_STDDEF_H */ 19 | -------------------------------------------------------------------------------- /usr/include/bits32/bitsize/stdintconst.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bits32/stdintconst.h 3 | */ 4 | 5 | #ifndef _BITSIZE_STDINTCONST_H 6 | #define _BITSIZE_STDINTCONST_H 7 | 8 | #define INT_FAST16_C(c) INT32_C(c) 9 | #define INT_FAST32_C(c) INT32_C(c) 10 | 11 | #define UINT_FAST16_C(c) UINT32_C(c) 12 | #define UINT_FAST32_C(c) UINT32_C(c) 13 | 14 | #define INTPTR_C(c) INT32_C(c) 15 | #define UINTPTR_C(c) UINT32_C(c) 16 | #define PTRDIFF_C(c) INT32_C(c) 17 | 18 | #endif /* _BITSIZE_STDINTCONST_H */ 19 | -------------------------------------------------------------------------------- /usr/include/bits32/bitsize/stdintlimits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bits32/stdintlimits.h 3 | */ 4 | 5 | #ifndef _BITSIZE_STDINTLIMITS_H 6 | #define _BITSIZE_STDINTLIMITS_H 7 | 8 | #define INT_FAST16_MIN INT32_MIN 9 | #define INT_FAST32_MIN INT32_MIN 10 | #define INT_FAST16_MAX INT32_MAX 11 | #define INT_FAST32_MAX INT32_MAX 12 | #define UINT_FAST16_MAX UINT32_MAX 13 | #define UINT_FAST32_MAX UINT32_MAX 14 | 15 | #define INTPTR_MIN INT32_MIN 16 | #define INTPTR_MAX INT32_MAX 17 | #define UINTPTR_MAX UINT32_MAX 18 | 19 | #define PTRDIFF_MIN INT32_MIN 20 | #define PTRDIFF_MAX INT32_MAX 21 | 22 | #endif /* _BITSIZE_STDINTLIMITS_H */ 23 | -------------------------------------------------------------------------------- /usr/include/bits64/bitsize.h: -------------------------------------------------------------------------------- 1 | #ifndef _BITSIZE 2 | #define _BITSIZE 64 3 | #endif 4 | -------------------------------------------------------------------------------- /usr/include/bits64/bitsize/limits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bits64/limits.h 3 | */ 4 | 5 | #ifndef _BITSIZE_LIMITS_H 6 | #define _BITSIZE_LIMITS_H 7 | 8 | #define LONG_BIT 64 9 | 10 | #define LONG_MIN (-9223372036854775807L-1) 11 | #define LONG_MAX 9223372036854775807L 12 | #define ULONG_MAX 18446744073709551615UL 13 | 14 | #endif /* _BITSIZE_LIMITS_H */ 15 | -------------------------------------------------------------------------------- /usr/include/bits64/bitsize/stddef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bits64/stddef.h 3 | */ 4 | 5 | #ifndef _BITSIZE_STDDEF_H 6 | #define _BITSIZE_STDDEF_H 7 | 8 | #define _SIZE_T 9 | typedef unsigned long size_t; 10 | #define _PTRDIFF_T 11 | typedef signed long ptrdiff_t; 12 | 13 | #endif /* _BITSIZE_STDDEF_H */ 14 | -------------------------------------------------------------------------------- /usr/include/bits64/bitsize/stdintconst.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bits64/stdintconst.h 3 | */ 4 | 5 | #ifndef _BITSIZE_STDINTCONST_H 6 | #define _BITSIZE_STDINTCONST_H 7 | 8 | #define INT_FAST16_C(c) INT64_C(c) 9 | #define INT_FAST32_C(c) INT64_C(c) 10 | 11 | #define UINT_FAST16_C(c) UINT64_C(c) 12 | #define UINT_FAST32_C(c) UINT64_C(c) 13 | 14 | #define INTPTR_C(c) INT64_C(c) 15 | #define UINTPTR_C(c) UINT64_C(c) 16 | #define PTRDIFF_C(c) INT64_C(c) 17 | 18 | #endif /* _BITSIZE_STDINTCONST_H */ 19 | -------------------------------------------------------------------------------- /usr/include/bits64/bitsize/stdintlimits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bits64/stdintlimits.h 3 | */ 4 | 5 | #ifndef _BITSIZE_STDINTLIMITS_H 6 | #define _BITSIZE_STDINTLIMITS_H 7 | 8 | #define INT_FAST16_MIN INT64_MIN 9 | #define INT_FAST32_MIN INT64_MIN 10 | #define INT_FAST16_MAX INT64_MAX 11 | #define INT_FAST32_MAX INT64_MAX 12 | #define UINT_FAST16_MAX UINT64_MAX 13 | #define UINT_FAST32_MAX UINT64_MAX 14 | 15 | #define INTPTR_MIN INT64_MIN 16 | #define INTPTR_MAX INT64_MAX 17 | #define UINTPTR_MAX UINT64_MAX 18 | 19 | #define PTRDIFF_MIN INT64_MIN 20 | #define PTRDIFF_MAX INT64_MAX 21 | 22 | #endif /* _BITSIZE_STDINTLIMITS_H */ 23 | -------------------------------------------------------------------------------- /usr/include/byteswap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * byteswap.h 3 | */ 4 | 5 | #ifndef _BYTESWAP_H 6 | #define _BYTESWAP_H 7 | 8 | #include 9 | #include 10 | 11 | #define bswap_16(x) __swab16(x) 12 | #define bswap_32(x) __swab32(x) 13 | #define bswap_64(x) __swab64(x) 14 | 15 | #endif /* _BYTESWAP_H */ 16 | -------------------------------------------------------------------------------- /usr/include/elf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * elf.h 3 | */ 4 | 5 | #ifndef _ELF_H 6 | #define _ELF_H 7 | 8 | #include 9 | #include 10 | 11 | #endif /* _ELF_H */ 12 | -------------------------------------------------------------------------------- /usr/include/endian.h: -------------------------------------------------------------------------------- 1 | /* 2 | * endian.h 3 | */ 4 | 5 | #ifndef _ENDIAN_H 6 | #define _ENDIAN_H 7 | 8 | #include 9 | 10 | #define LITTLE_ENDIAN __LITTLE_ENDIAN 11 | #define BIG_ENDIAN __BIG_ENDIAN 12 | #define PDP_ENDIAN __PDP_ENDIAN 13 | #define BYTE_ORDER __BYTE_ORDER 14 | 15 | #endif /* _ENDIAN_H */ 16 | -------------------------------------------------------------------------------- /usr/include/errno.h: -------------------------------------------------------------------------------- 1 | /* 2 | * errno.h 3 | */ 4 | 5 | #ifndef _ERRNO_H 6 | #define _ERRNO_H 7 | 8 | #include 9 | #include 10 | 11 | __extern int errno; 12 | 13 | #endif /* _ERRNO_H */ 14 | -------------------------------------------------------------------------------- /usr/include/fnmatch.h: -------------------------------------------------------------------------------- 1 | #ifndef _FNMATCH_H 2 | #define _FNMATCH_H 3 | 4 | #include 5 | 6 | #define FNM_NOMATCH 1 7 | 8 | #define FNM_PATHNAME 1 9 | #define FNM_FILE_NAME FNM_PATHNAME 10 | #define FNM_NOESCAPE 2 11 | #define FNM_PERIOD 4 12 | 13 | __extern int fnmatch(const char *, const char *, int); 14 | 15 | #endif /* _FNMATCH_H */ 16 | -------------------------------------------------------------------------------- /usr/include/getopt.h: -------------------------------------------------------------------------------- 1 | #ifndef _GETOPT_H 2 | #define _GETOPT_H 3 | 4 | #include 5 | 6 | struct option { 7 | const char *name; 8 | int has_arg; 9 | int *flag; 10 | int val; 11 | }; 12 | 13 | enum { 14 | no_argument = 0, 15 | required_argument = 1, 16 | optional_argument = 2, 17 | }; 18 | 19 | __extern int getopt_long(int, char *const *, const char *, 20 | const struct option *, int *); 21 | 22 | #endif /* _GETOPT_H */ 23 | -------------------------------------------------------------------------------- /usr/include/grp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * grp.h 3 | */ 4 | 5 | #ifndef _GRP_H 6 | #define _GRP_H 7 | 8 | #include 9 | #include 10 | 11 | struct group { 12 | char *gr_name; 13 | char *gr_passwd; 14 | gid_t gr_gid; 15 | char **gr_mem; 16 | }; 17 | 18 | __extern int setgroups(size_t, const gid_t *); 19 | __extern struct group *getgrgid(gid_t); 20 | __extern struct group *getgrnam(const char *); 21 | 22 | #endif /* _GRP_H */ 23 | -------------------------------------------------------------------------------- /usr/include/klibc/diverr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * klibc/diverr.h 3 | */ 4 | 5 | #ifndef _KLIBC_DIVERR_H 6 | #define _KLIBC_DIVERR_H 7 | 8 | #include 9 | 10 | static __inline__ void __divide_error(void) 11 | { 12 | raise(SIGFPE); 13 | } 14 | 15 | #endif /* _KLIBC_DIVERR_H */ 16 | -------------------------------------------------------------------------------- /usr/include/klibc/extern.h: -------------------------------------------------------------------------------- 1 | /* 2 | * klibc/extern.h 3 | */ 4 | 5 | #ifndef _KLIBC_EXTERN_H 6 | #define _KLIBC_EXTERN_H 7 | 8 | #ifdef __cplusplus 9 | #define __extern extern "C" 10 | #else 11 | #define __extern extern 12 | #endif 13 | 14 | #define __alias(x) __attribute__((weak, alias(x))) 15 | 16 | #endif /* _KLIBC_EXTERN_H */ 17 | -------------------------------------------------------------------------------- /usr/include/klibc/stathelp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stathelp.h 3 | * 4 | * Helper macros for 5 | */ 6 | 7 | #ifndef _KLIBC_STATHELP_H 8 | #define _KLIBC_STATHELP_H 9 | 10 | #include 11 | 12 | /* 13 | * Most architectures have a 64-bit field for st_dev and st_rdev, 14 | * but dev_t is 32 bits (uint32_t == unsigned int), so make a 15 | * macro we can use across all architectures. 16 | */ 17 | 18 | #if __BYTE_ORDER == __BIG_ENDIAN 19 | # define __stdev64(x) unsigned int __##x, x; 20 | #else 21 | # define __stdev64(x) unsigned int x, __##x; 22 | #endif 23 | 24 | #endif /* _KLIBC_STATHELP_H */ 25 | -------------------------------------------------------------------------------- /usr/include/malloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * malloc.h 3 | * 4 | * Apparently people haven't caught on to use , which is the 5 | * standard place for this crap since the 1980's... 6 | */ 7 | 8 | #ifndef _MALLOC_H 9 | #define _MALLOC_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | __extern void free(void *); 16 | 17 | __extern __mallocfunc void *malloc(size_t); 18 | __extern __mallocfunc void *calloc(size_t, size_t); 19 | __extern __mallocfunc void *realloc(void *, size_t); 20 | 21 | #endif /* _MALLOC_H */ 22 | -------------------------------------------------------------------------------- /usr/include/mntent.h: -------------------------------------------------------------------------------- 1 | #ifndef _MNTENT_H 2 | #define _MNTENT_H 1 3 | 4 | #define MNTTYPE_SWAP "swap" 5 | 6 | struct mntent { 7 | char *mnt_fsname; /* name of mounted file system */ 8 | char *mnt_dir; /* file system path prefix */ 9 | char *mnt_type; /* mount type (see mntent.h) */ 10 | char *mnt_opts; /* mount options (see mntent.h) */ 11 | int mnt_freq; /* dump frequency in days */ 12 | int mnt_passno; /* pass number on parallel fsck */ 13 | }; 14 | 15 | extern FILE *setmntent(const char *, const char *); 16 | 17 | extern struct mntent *getmntent(FILE *); 18 | 19 | extern int endmntent(FILE *fp); 20 | 21 | #endif /* mntent.h */ 22 | -------------------------------------------------------------------------------- /usr/include/net/if.h: -------------------------------------------------------------------------------- 1 | #ifndef _NET_IF_H 2 | #define _NET_IF_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #endif /* _NET_IF_H */ 9 | -------------------------------------------------------------------------------- /usr/include/net/if_arp.h: -------------------------------------------------------------------------------- 1 | /* if_arp.h needs sockaddr */ 2 | #include 3 | #include 4 | -------------------------------------------------------------------------------- /usr/include/net/if_packet.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /usr/include/net/route.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /usr/include/netinet/if_ether.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /usr/include/netinet/in6.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netinet/in6.h 3 | */ 4 | 5 | #ifndef _NETINET_IN6_H 6 | #define _NETINET_IN6_H 7 | 8 | #include 9 | 10 | #endif /* _NETINET_IN6_H */ 11 | -------------------------------------------------------------------------------- /usr/include/netinet/ip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netinet/ip.h 3 | */ 4 | 5 | #ifndef _NETINET_IP_H 6 | #define _NETINET_IP_H 7 | 8 | #include 9 | #include 10 | 11 | #define IP_DF 0x4000 /* Flag: "Don't Fragment" */ 12 | 13 | #endif /* _NETINET_IP_H */ 14 | -------------------------------------------------------------------------------- /usr/include/netinet/tcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netinet/tcp.h 3 | */ 4 | 5 | #ifndef _NETINET_TCP_H 6 | #define _NETINET_TCP_H 7 | 8 | #include /* Include *before* linux/tcp.h */ 9 | #include 10 | 11 | #endif /* _NETINET_TCP_H */ 12 | -------------------------------------------------------------------------------- /usr/include/netinet/udp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netinet/udp.h 3 | */ 4 | 5 | #ifndef _NETINET_UDP_H 6 | #define _NETINET_UDP_H 7 | 8 | /* 9 | * We would include linux/udp.h, but it brings in too much other stuff 10 | */ 11 | 12 | struct udphdr { 13 | __u16 source; 14 | __u16 dest; 15 | __u16 len; 16 | __u16 check; 17 | }; 18 | 19 | #endif /* _NETINET_UDP_H */ 20 | -------------------------------------------------------------------------------- /usr/include/netpacket/packet.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /usr/include/poll.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /usr/include/pwd.h: -------------------------------------------------------------------------------- 1 | #ifndef _PWD_H 2 | #define _PWD_H 3 | 4 | #include 5 | #include 6 | 7 | struct passwd { 8 | char *pw_name; 9 | char *pw_passwd; 10 | uid_t pw_uid; 11 | gid_t pw_gid; 12 | char *pw_gecos; 13 | char *pw_dir; 14 | char *pw_shell; 15 | }; 16 | 17 | __extern struct passwd *getpwuid(uid_t uid); 18 | 19 | __extern struct passwd *getpwnam(const char *name); 20 | 21 | #endif /* _PWD_H */ 22 | -------------------------------------------------------------------------------- /usr/include/stdarg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stdarg.h 3 | * 4 | * This is just a wrapper for the gcc one, but defines va_copy() 5 | * even if gcc doesn't. 6 | */ 7 | 8 | /* Note: the _STDARG_H macro belongs to the gcc header... */ 9 | #include_next 10 | 11 | /* Older gcc considers this an extension, so it's double underbar only */ 12 | #ifndef va_copy 13 | #define va_copy(d,s) __va_copy(d,s) 14 | #endif 15 | -------------------------------------------------------------------------------- /usr/include/stddef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stddef.h 3 | */ 4 | 5 | #ifndef _STDDEF_H 6 | #define _STDDEF_H 7 | 8 | #ifndef __KLIBC__ 9 | # error "__KLIBC__ not defined, compiler invocation error!" 10 | #endif 11 | 12 | #include 13 | 14 | #undef NULL 15 | #ifdef __cplusplus 16 | # define NULL 0 17 | #else 18 | # define NULL ((void *)0) 19 | #endif 20 | 21 | #undef offsetof 22 | #define offsetof(t,m) ((size_t)&((t *)0)->m) 23 | 24 | #endif /* _STDDEF_H */ 25 | -------------------------------------------------------------------------------- /usr/include/sys/capability.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_CAPABILITY_H 2 | #define _SYS_CAPABILITY_H 3 | 4 | #include 5 | #include 6 | 7 | __extern int capget(cap_user_header_t, cap_user_data_t); 8 | __extern int capset(cap_user_header_t, const cap_user_data_t); 9 | 10 | #endif /* _SYS_CAPABILITY_H */ 11 | -------------------------------------------------------------------------------- /usr/include/sys/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_FILE_H 2 | #define _SYS_FILE_H 3 | 4 | /* LOCK_ definitions */ 5 | #include 6 | 7 | __extern int flock(int, int); 8 | 9 | #endif /* _SYS_FILE_H */ 10 | -------------------------------------------------------------------------------- /usr/include/sys/fsuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/fsuid.h 3 | */ 4 | 5 | #ifndef _SYS_FSUID_H 6 | #define _SYS_FSUID_H 7 | 8 | #include 9 | #include 10 | 11 | __extern int setfsuid(uid_t); 12 | __extern int setfsgid(gid_t); 13 | 14 | #endif /* _SYS_FSUID_H */ 15 | -------------------------------------------------------------------------------- /usr/include/sys/inotify.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/inotify.h 3 | */ 4 | 5 | #ifndef _SYS_INOTIFY_H 6 | #define _SYS_INOTIFY_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | __extern int inotify_init(void); 13 | __extern int inotify_add_watch(int, const char *, __u32); 14 | __extern int inotify_rm_watch(int, __u32); 15 | 16 | #endif /* _SYS_INOTIFY_H */ 17 | -------------------------------------------------------------------------------- /usr/include/sys/ioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/ioctl.h 3 | */ 4 | 5 | #ifndef _SYS_IOCTL_H 6 | #define _SYS_IOCTL_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | /* the SIOCxxx I/O are hidden */ 13 | #include 14 | 15 | __extern int ioctl(int, int, void *); 16 | 17 | #endif /* _SYS_IOCTL_H */ 18 | -------------------------------------------------------------------------------- /usr/include/sys/klog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/klog.h 3 | */ 4 | 5 | #ifndef _SYS_KLOG_H 6 | #define _SYS_KLOG_H 7 | 8 | #include 9 | 10 | #define KLOG_CLOSE 0 11 | #define KLOG_OPEN 1 12 | #define KLOG_READ 2 13 | #define KLOG_READ_ALL 3 14 | #define KLOG_READ_CLEAR 4 15 | #define KLOG_CLEAR 5 16 | #define KLOG_DISABLE 6 17 | #define KLOG_ENABLE 7 18 | #define KLOG_SETLEVEL 8 19 | #define KLOG_UNREADSIZE 9 20 | #define KLOG_WRITE 10 21 | 22 | __extern int klogctl(int, char *, int); 23 | 24 | #endif /* _SYS_KLOG_H */ 25 | -------------------------------------------------------------------------------- /usr/include/sys/param.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/param.h 3 | */ 4 | 5 | #ifndef _SYS_PARAM_H 6 | #define _SYS_PARAM_H 7 | 8 | #include 9 | #include 10 | 11 | #endif /* _SYS_PARAM_H */ 12 | -------------------------------------------------------------------------------- /usr/include/sys/poll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * poll.h 3 | */ 4 | 5 | #ifndef _POLL_H 6 | #define _POLL_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /* POSIX specifies "int" for the timeout, Linux seems to use long... */ 14 | 15 | typedef unsigned int nfds_t; 16 | __extern int poll(struct pollfd *, nfds_t, long); 17 | __extern int ppoll(struct pollfd *, nfds_t, struct timespec *, 18 | const sigset_t *); 19 | 20 | #endif /* _POLL_H */ 21 | -------------------------------------------------------------------------------- /usr/include/sys/prctl.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_PRCTL_H 2 | #define _SYS_PRCTL_H 3 | 4 | #include 5 | #include 6 | 7 | /* glibc has this as a varadic function, so join the club... */ 8 | __extern int prctl(int, ...); 9 | 10 | #endif /* _SYS_PRCTL_H */ 11 | -------------------------------------------------------------------------------- /usr/include/sys/resource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/resource.h 3 | */ 4 | 5 | #ifndef _SYS_RESOURCE_H 6 | #define _SYS_RESOURCE_H 7 | 8 | #include 9 | #include /* MUST be included before linux/resource.h */ 10 | #include 11 | 12 | __extern int getpriority(int, int); 13 | __extern int setpriority(int, int, int); 14 | 15 | __extern int getrusage(int, struct rusage *); 16 | 17 | #endif /* _SYS_RESOURCE_H */ 18 | -------------------------------------------------------------------------------- /usr/include/sys/select.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/select.h 3 | */ 4 | 5 | #ifndef _SYS_SELECT_H 6 | #define _SYS_SELECT_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | __extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); 14 | __extern int pselect(int, fd_set *, fd_set *, fd_set *, 15 | const struct timespec *, const sigset_t *); 16 | 17 | #endif /* _SYS_SELECT_H */ 18 | -------------------------------------------------------------------------------- /usr/include/sys/sendfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/sendfile.h 3 | */ 4 | 5 | #ifndef _SYS_SENDFILE_H 6 | #define _SYS_SENDFILE_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | __extern ssize_t sendfile(int, int, off_t *, size_t, off_t); 13 | 14 | #endif /* _SYS_SENDFILE_H */ 15 | -------------------------------------------------------------------------------- /usr/include/sys/splice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/splice.h 3 | */ 4 | 5 | #ifndef _SYS_SPLICE_H 6 | #define _SYS_SPLICE_H 7 | 8 | /* move pages instead of copying */ 9 | #define SPLICE_F_MOVE 1 10 | /* don't block on the pipe splicing (but we may still block on the fd 11 | we splice from/to, of course */ 12 | #define SPLICE_F_NONBLOCK 2 13 | /* expect more data */ 14 | #define SPLICE_F_MORE 4 15 | 16 | __extern int splice(int, off_t *, int, off_t *, size_t, unsigned int); 17 | __extern int tee(int, int, size_t, unsigned int); 18 | 19 | #endif /* _SYS_SPLICE_H */ 20 | -------------------------------------------------------------------------------- /usr/include/sys/statfs.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /usr/include/sys/syscall.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/syscall.h 3 | * 4 | * Generic system call interface macros 5 | */ 6 | #ifndef _SYS_SYSCALL_H 7 | #define _SYS_SYSCALL_H 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #endif /* _SYS_SYSCALL_H */ 14 | -------------------------------------------------------------------------------- /usr/include/sys/sysinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/sysinfo.h 3 | */ 4 | 5 | #ifndef _SYS_SYSINFO_H 6 | #define _SYS_SYSINFO_H 7 | 8 | #include 9 | 10 | extern int sysinfo(struct sysinfo *info); 11 | 12 | #endif /* _SYS_SYSINFO_H */ 13 | -------------------------------------------------------------------------------- /usr/include/sys/times.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/times.h 3 | */ 4 | 5 | #ifndef _SYS_TIMES_H 6 | #define _SYS_TIMES_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | __extern clock_t times(struct tms *); 13 | 14 | #endif /* _SYS_TIMES_H */ 15 | -------------------------------------------------------------------------------- /usr/include/sys/uio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/uio.h 3 | */ 4 | 5 | #ifndef _SYS_UIO_H 6 | #define _SYS_UIO_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | __extern int readv(int, const struct iovec *, int); 13 | __extern int writev(int, const struct iovec *, int); 14 | 15 | #endif /* _SYS_UIO_H */ 16 | -------------------------------------------------------------------------------- /usr/include/sys/un.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | 5 | #ifndef _SYS_UN_H 6 | #define _SYS_UN_H 7 | 8 | #include 9 | #include 10 | 11 | #endif /* _SYS_UN_H */ 12 | -------------------------------------------------------------------------------- /usr/include/sys/utime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/utime.h 3 | */ 4 | 5 | #ifndef _SYS_UTIME_H 6 | #define _SYS_UTIME_H 7 | 8 | #include 9 | 10 | #endif /* _SYS_UTIME_H */ 11 | -------------------------------------------------------------------------------- /usr/include/sys/utsname.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sys/utsname.h 3 | */ 4 | 5 | #ifndef _SYS_UTSNAME_H 6 | #define _SYS_UTSNAME_H 7 | 8 | #include 9 | 10 | #define SYS_NMLN 65 11 | 12 | struct utsname { 13 | char sysname[SYS_NMLN]; 14 | char nodename[SYS_NMLN]; 15 | char release[SYS_NMLN]; 16 | char version[SYS_NMLN]; 17 | char machine[SYS_NMLN]; 18 | char domainname[SYS_NMLN]; 19 | }; 20 | 21 | __extern int uname(struct utsname *); 22 | 23 | #endif /* _SYS_UTSNAME_H */ 24 | -------------------------------------------------------------------------------- /usr/include/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * time.h 3 | */ 4 | 5 | #ifndef _TIME_H 6 | #define _TIME_H 7 | 8 | #include 9 | #include 10 | 11 | __extern time_t time(time_t *); 12 | __extern int nanosleep(const struct timespec *, struct timespec *); 13 | 14 | /* klibc-specific but useful since we don't have floating point */ 15 | __extern char *strtotimeval(const char *str, struct timeval *tv); 16 | __extern char *strtotimespec(const char *str, struct timespec *tv); 17 | 18 | #endif /* _TIME_H */ 19 | -------------------------------------------------------------------------------- /usr/include/utime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * utime.h 3 | */ 4 | 5 | #ifndef _UTIME_H 6 | #define _UTIME_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | __extern int utime(const char *, const struct utimbuf *); 13 | 14 | #endif /* _UTIME_H */ 15 | -------------------------------------------------------------------------------- /usr/kinit/.gitignore: -------------------------------------------------------------------------------- 1 | lib.a 2 | kinit 3 | kinit.shared 4 | -------------------------------------------------------------------------------- /usr/kinit/README: -------------------------------------------------------------------------------- 1 | kinit - tiny init program 2 | ------------------------- 3 | 4 | This program is intended for use as /sbin/init in an initramfs 5 | environment. It currently replaces the kernel's ipconfig and nfsroot 6 | code. 7 | 8 | -- 9 | Bryan O'Sullivan (2003/05/05) 10 | -------------------------------------------------------------------------------- /usr/kinit/fstype/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # Kbuild file for fstype 3 | # 4 | 5 | static-y := static/fstype 6 | shared-y := shared/fstype 7 | 8 | # common .o files 9 | objs := main.o fstype.o 10 | 11 | # TODO - do we want a stripped version 12 | # TODO - do we want the static.g + shared.g directories? 13 | 14 | # Create built-in.o with all object files (used by kinit) 15 | lib-y := $(objs) 16 | 17 | # .o files used to built executables 18 | static/fstype-y := $(objs) 19 | shared/fstype-y := $(objs) 20 | 21 | # Cleaning 22 | clean-dirs := static shared 23 | 24 | # install binary 25 | install-y := $(shared-y) 26 | -------------------------------------------------------------------------------- /usr/kinit/fstype/fstype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * by rmk 3 | * 4 | * Detect filesystem type (on stdin) and output strings for two 5 | * environment variables: 6 | * FSTYPE - filesystem type 7 | * FSSIZE - filesystem size (if known) 8 | * 9 | * We currently detect the fs listed in struct imagetype. 10 | */ 11 | 12 | #ifndef FSTYPE_H 13 | #define FSTYPE_H 14 | 15 | #include 16 | 17 | int identify_fs(int fd, const char **fstype, 18 | unsigned long long *bytes, off_t offset); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /usr/kinit/fstype/iso9660_sb.h: -------------------------------------------------------------------------------- 1 | #ifndef __ISO9660_SB_H 2 | #define __ISO9660_SB_H 3 | 4 | #define ISO_MAGIC_L 5 5 | #define ISO_MAGIC "CD001" 6 | #define ISO_HS_MAGIC_L 5 7 | #define ISO_HS_MAGIC "CDROM" 8 | 9 | /* ISO9660 Volume Descriptor */ 10 | struct iso_volume_descriptor { 11 | __u8 type; 12 | char id[ISO_MAGIC_L]; 13 | __u8 version; 14 | }; 15 | 16 | /* High Sierra Volume Descriptor */ 17 | struct iso_hs_volume_descriptor { 18 | char foo[8]; 19 | __u8 type; 20 | char id[ISO_HS_MAGIC_L]; 21 | __u8 version; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /usr/kinit/fstype/lvm2_sb.h: -------------------------------------------------------------------------------- 1 | #ifndef __LVM2_SB_H 2 | #define __LVM2_SB_H 3 | 4 | /* LVM2 super block definitions */ 5 | #define LVM2_MAGIC_L 8 6 | #define LVM2_MAGIC "LABELONE" 7 | #define LVM2_TYPE_L 8 8 | #define LVM2_TYPE "LVM2 001" 9 | 10 | struct lvm2_super_block { 11 | char magic[LVM2_MAGIC_L]; 12 | __be64 sector; 13 | __be32 crc; 14 | __be32 offset; 15 | char type[LVM2_TYPE_L]; 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /usr/kinit/fstype/xfs_sb.h: -------------------------------------------------------------------------------- 1 | #ifndef __XFS_SB_H 2 | #define __XFS_SB_H 3 | 4 | /* 5 | * Super block 6 | * Fits into a sector-sized buffer at address 0 of each allocation group. 7 | * Only the first of these is ever updated except during growfs. 8 | */ 9 | 10 | struct xfs_buf; 11 | struct xfs_mount; 12 | 13 | #define XFS_SB_MAGIC 0x58465342 /* 'XFSB' */ 14 | 15 | typedef struct xfs_sb { 16 | __u32 sb_magicnum; /* magic number == XFS_SB_MAGIC */ 17 | __u32 sb_blocksize; /* logical block size, bytes */ 18 | __u64 sb_dblocks; /* number of data blocks */ 19 | } xfs_sb_t; 20 | 21 | #endif /* __XFS_SB_H */ 22 | -------------------------------------------------------------------------------- /usr/kinit/getintfile.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Open a file and read it, assuming it contains a single long value. 3 | * Return 0 if we read a valid value, otherwise -1. 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | #include "kinit.h" 10 | 11 | int getintfile(const char *path, long *val) 12 | { 13 | char buffer[64]; 14 | char *ep; 15 | FILE *f; 16 | 17 | f = fopen(path, "r"); 18 | if (!f) 19 | return -1; 20 | 21 | ep = buffer + fread(buffer, 1, sizeof buffer - 1, f); 22 | fclose(f); 23 | *ep = '\0'; 24 | 25 | *val = strtol(buffer, &ep, 0); 26 | if (*ep && *ep != '\n') 27 | return -1; 28 | else 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /usr/kinit/ipconfig/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # Kbuild file for ipconfig 3 | # 4 | 5 | static-y := static/ipconfig 6 | shared-y := shared/ipconfig 7 | 8 | # common .o files 9 | objs := main.o netdev.o packet.o 10 | # dhcp 11 | objs += dhcp_proto.o 12 | # bootp 13 | objs += bootp_proto.o 14 | 15 | 16 | # TODO - do we want a stripped version 17 | # TODO - do we want the static.g + shared.g directories? 18 | 19 | 20 | # Create built-in.o with all object files (used by kinit) 21 | lib-y := $(objs) 22 | 23 | # .o files used to built executables 24 | static/ipconfig-y := $(objs) 25 | shared/ipconfig-y := $(objs) 26 | 27 | # Cleaning 28 | clean-dirs := static shared 29 | 30 | # install binary 31 | install-y := $(shared-y) 32 | -------------------------------------------------------------------------------- /usr/kinit/ipconfig/bootp_packet.h: -------------------------------------------------------------------------------- 1 | #ifndef BOOTP_PACKET_H 2 | #define BOOTP_PACKET_H 3 | 4 | #include 5 | 6 | struct netdev; 7 | 8 | /* packet ops */ 9 | #define BOOTP_REQUEST 1 10 | #define BOOTP_REPLY 2 11 | 12 | /* your basic bootp packet */ 13 | struct bootp_hdr { 14 | uint8_t op; 15 | uint8_t htype; 16 | uint8_t hlen; 17 | uint8_t hops; 18 | uint32_t xid; 19 | uint16_t secs; 20 | uint16_t flags; 21 | uint32_t ciaddr; 22 | uint32_t yiaddr; 23 | uint32_t siaddr; 24 | uint32_t giaddr; 25 | uint8_t chaddr[16]; 26 | char server_name[64]; 27 | char boot_file[128]; 28 | /* 312 bytes of extensions */ 29 | }; 30 | 31 | #endif /* BOOTP_PACKET_H */ 32 | -------------------------------------------------------------------------------- /usr/kinit/ipconfig/bootp_proto.h: -------------------------------------------------------------------------------- 1 | #ifndef IPCONFIG_BOOTP_PROTO_H 2 | #define IPCONFIG_BOOTP_PROTO_H 3 | 4 | int bootp_send_request(struct netdev *dev); 5 | int bootp_recv_reply(struct netdev *dev); 6 | int bootp_parse(struct netdev *dev, struct bootp_hdr *hdr, uint8_t * exts, 7 | int extlen); 8 | int bootp_init_if(struct netdev *dev); 9 | 10 | #endif /* IPCONFIG_BOOTP_PROTO_H */ 11 | -------------------------------------------------------------------------------- /usr/kinit/ipconfig/dhcp_proto.h: -------------------------------------------------------------------------------- 1 | #ifndef IPCONFIG_DHCP_PROTO_H 2 | #define IPCONFIG_DHCP_PROTO_H 3 | 4 | /* DHCP message types */ 5 | #define DHCPDISCOVER 1 6 | #define DHCPOFFER 2 7 | #define DHCPREQUEST 3 8 | #define DHCPDECLINE 4 9 | #define DHCPACK 5 10 | #define DHCPNAK 6 11 | #define DHCPRELEASE 7 12 | #define DHCPINFORM 8 13 | 14 | int dhcp_send_discover(struct netdev *dev); 15 | int dhcp_recv_offer(struct netdev *dev); 16 | int dhcp_send_request(struct netdev *dev); 17 | int dhcp_recv_ack(struct netdev *dev); 18 | 19 | #endif /* IPCONFIG_DHCP_PROTO_H */ 20 | -------------------------------------------------------------------------------- /usr/kinit/ipconfig/ipconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef IPCONFIG_IPCONFIG_H 2 | #define IPCONFIG_IPCONFIG_H 3 | 4 | #include 5 | #include 6 | 7 | #define LOCAL_PORT 68 8 | #define REMOTE_PORT (LOCAL_PORT - 1) 9 | 10 | extern uint16_t cfg_local_port; 11 | extern uint16_t cfg_remote_port; 12 | 13 | extern char vendor_class_identifier[]; 14 | extern int vendor_class_identifier_len; 15 | 16 | int ipconfig_main(int argc, char *argv[]); 17 | uint32_t ipconfig_server_address(void *next); 18 | 19 | #ifdef DEBUG 20 | # define dprintf printf 21 | #else 22 | # define dprintf(...) ((void)0) 23 | #endif 24 | 25 | #endif /* IPCONFIG_IPCONFIG_H */ 26 | -------------------------------------------------------------------------------- /usr/kinit/ipconfig/packet.h: -------------------------------------------------------------------------------- 1 | #ifndef IPCONFIG_PACKET_H 2 | #define IPCONFIG_PACKET_H 3 | 4 | struct iovec; 5 | 6 | int packet_open(void); 7 | void packet_close(void); 8 | int packet_send(struct netdev *dev, struct iovec *iov, int iov_len); 9 | void packet_discard(struct netdev *dev); 10 | int packet_recv(struct netdev *dev, struct iovec *iov, int iov_len); 11 | 12 | #endif /* IPCONFIG_PACKET_H */ 13 | -------------------------------------------------------------------------------- /usr/kinit/nfsmount/dummypmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Functions for the portmap spoofer 3 | */ 4 | 5 | #ifndef NFSMOUNT_DUMMYPORTMAP_H 6 | #define NFSMOUNT_DUMMYPORTMAP_H 7 | 8 | #include 9 | pid_t start_dummy_portmap(const char *file); 10 | 11 | #endif /* NFSMOUNT_DUMMYPORTMAP_H */ 12 | -------------------------------------------------------------------------------- /usr/kinit/nfsmount/dummypmap_test.c: -------------------------------------------------------------------------------- 1 | #define TEST 2 | #include "dummypmap.c" 3 | -------------------------------------------------------------------------------- /usr/kinit/resume/resume.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Handle resume from suspend-to-disk 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | #include "resume.h" 9 | 10 | char *progname; 11 | 12 | static __noreturn usage(void) 13 | { 14 | fprintf(stderr, "Usage: %s /dev/ [offset]\n", progname); 15 | exit(1); 16 | } 17 | 18 | int main(int argc, char *argv[]) 19 | { 20 | progname = argv[0]; 21 | if (argc < 2 || argc > 3) 22 | usage(); 23 | 24 | return resume(argv[1], (argc > 2) ? strtoull(argv[2], NULL, 0) : 0ULL); 25 | } 26 | -------------------------------------------------------------------------------- /usr/kinit/resume/resume.h: -------------------------------------------------------------------------------- 1 | #ifndef RESUME_H 2 | #define RESUME_H 3 | 4 | int do_resume(int argc, char *argv[]); 5 | int resume(const char *resume_file, unsigned long long resume_offset); 6 | 7 | #endif /* RESUME_H */ 8 | -------------------------------------------------------------------------------- /usr/kinit/xpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * kinit/xpio.h 3 | */ 4 | 5 | #ifndef KINIT_XPIO_H 6 | #define KINIT_XPIO_H 7 | 8 | ssize_t xpread(int fd, void *buf, size_t count, off_t offset); 9 | ssize_t xpwrite(int fd, void *buf, size_t count, off_t offset); 10 | 11 | #endif /* KINIT_XPIO_H */ 12 | -------------------------------------------------------------------------------- /usr/klibc/.gitignore: -------------------------------------------------------------------------------- 1 | errlist.c 2 | .interp.o.d 3 | klibc*.so 4 | klib.list 5 | .klib.list.cmd 6 | libc.a 7 | libc.so 8 | libc.so.hash 9 | sha1hash 10 | tests/* 11 | !tests/Kbuild 12 | !tests/*.c 13 | -------------------------------------------------------------------------------- /usr/klibc/__shared_init.c: -------------------------------------------------------------------------------- 1 | #define SHARED 1 2 | #include "libc_init.c" 3 | -------------------------------------------------------------------------------- /usr/klibc/__signal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * __signal.c 3 | */ 4 | 5 | #include 6 | 7 | __sighandler_t __signal(int signum, __sighandler_t handler, int flags) 8 | { 9 | struct sigaction sa; 10 | 11 | sa.sa_handler = handler; 12 | sa.sa_flags = flags; 13 | sigemptyset(&sa.sa_mask); 14 | 15 | if (sigaction(signum, &sa, &sa)) { 16 | return (__sighandler_t) SIG_ERR; 17 | } else { 18 | return (__sighandler_t) sa.sa_handler; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /usr/klibc/__static_init.c: -------------------------------------------------------------------------------- 1 | #define SHARED 0 2 | #include "libc_init.c" 3 | -------------------------------------------------------------------------------- /usr/klibc/abort.c: -------------------------------------------------------------------------------- 1 | /* 2 | * abort.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | void abort(void) 10 | { 11 | sigset_t set; 12 | 13 | sigemptyset(&set); 14 | sigaddset(&set, SIGABRT); 15 | sigprocmask(SIG_UNBLOCK, &set, NULL); 16 | raise(SIGABRT); 17 | _exit(255); /* raise() should have killed us */ 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/alarm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * alarm.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | #ifndef __NR_alarm 9 | 10 | /* Emulate alarm() via setitimer() */ 11 | 12 | unsigned int alarm(unsigned int seconds) 13 | { 14 | struct itimerval iv; 15 | 16 | iv.it_interval.tv_sec = iv.it_interval.tv_usec = 0; 17 | iv.it_value.tv_sec = seconds; 18 | iv.it_value.tv_usec = 0; 19 | 20 | setitimer(ITIMER_REAL, &iv, &iv); 21 | 22 | return iv.it_value.tv_sec + (iv.it_value.tv_usec ? 1 : 0); 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /usr/klibc/alphasort.c: -------------------------------------------------------------------------------- 1 | /* 2 | * alphasort.c: alphasort 3 | */ 4 | 5 | #include 6 | 7 | #include 8 | 9 | int alphasort(const struct dirent **a, const struct dirent **b) 10 | { 11 | return strcmp((*a)->d_name, (*b)->d_name); 12 | } 13 | -------------------------------------------------------------------------------- /usr/klibc/arch/alpha/MCONFIG: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | # 3 | # arch/alpha/MCONFIG 4 | # 5 | # Build configuration for this architecture 6 | # 7 | 8 | KLIBCOPTFLAGS += -Os 9 | KLIBCBITSIZE = 64 10 | 11 | # Extra linkflags when building the shared version of the library 12 | # This address needs to be reachable using normal inter-module 13 | # calls, and work on the memory models for this architecture 14 | # 7 GB - normal binaries start at 4.5 GB, and the stack is below 15 | # the binary. 16 | KLIBCSHAREDFLAGS = -Ttext 0x1c0000200 17 | -------------------------------------------------------------------------------- /usr/klibc/arch/alpha/crt0.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/alpha/crt0.S 3 | # 4 | 5 | .text 6 | .type _start,@function 7 | .ent _start, 0 8 | .globl _start 9 | _start: 10 | .frame $30, 0, $26, 0 11 | mov $31, $15 12 | br $29, 1f 13 | 1: ldgp $29, 0($29) 14 | .prologue 0 15 | 16 | lda $16, 0($30) # ELF data structure 17 | lda $17, 0($0) # atexit pointer 18 | 19 | jsr $26, __libc_init 20 | 21 | .size _start,.-_start 22 | .end _start 23 | -------------------------------------------------------------------------------- /usr/klibc/arch/alpha/syscall.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/alpha/syscall.S 3 | # 4 | 5 | #include 6 | 7 | .text 8 | .align 3 9 | .type __syscall_common,@function 10 | .ent __syscall_common, 0 11 | .globl __syscall_common 12 | __syscall_common: 13 | .frame sp,0,ra,0 14 | callsys 15 | beq a3, 1f 16 | br pv, 2f # pv <- pc 17 | 2: 18 | ldgp gp, 0(pv) 19 | lda a1, errno 20 | stl v0, 0(a1) 21 | lda v0, -1(zero) 22 | 1: 23 | ret zero,(ra),1 24 | 25 | .size __syscall_common,.-__syscall_common 26 | .end __syscall_common 27 | -------------------------------------------------------------------------------- /usr/klibc/arch/alpha/sysdual.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/alpha/sysdual.S 3 | # 4 | 5 | # 6 | # Some system calls have an alternate return value in r20 (a4). 7 | # This system call stub is for system calls where that is 8 | # the "real" return value. 9 | # 10 | 11 | #include 12 | 13 | .text 14 | .align 3 15 | .type __syscall_dual1,@function 16 | .ent __syscall_dual1, 0 17 | .globl __syscall_dual1 18 | __syscall_dual1: 19 | .frame sp,0,ra,0 20 | callsys 21 | mov v0, a4 22 | beq a3, 1f 23 | br pv, 2f # pv <- pc 24 | 2: 25 | ldgp gp, 0(pv) 26 | lda a1, errno 27 | lda v0, -1(zero) 28 | stl a3, 0(a1) 29 | 1: 30 | ret zero,(ra),1 31 | 32 | .size __syscall_dual1,.-__syscall_dual1 33 | .end __syscall_dual1 34 | -------------------------------------------------------------------------------- /usr/klibc/arch/arm/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for arm 3 | # 4 | 5 | klib-y := setjmp.o syscall.o vfork.o aeabi_nonsense.o 6 | 7 | klib-y += ../../libgcc/__udivmodsi4.o ../../libgcc/__divdi3.o 8 | klib-y += ../../libgcc/__moddi3.o ../../libgcc/__udivdi3.o 9 | klib-y += ../../libgcc/__umoddi3.o ../../libgcc/__udivmoddi4.o 10 | klib-y += ../../libgcc/__clzsi2.o 11 | 12 | always := crt0.o 13 | targets := crt0.o 14 | -------------------------------------------------------------------------------- /usr/klibc/arch/arm/__muldi3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | uint64_t __muldi3(uint64_t a, uint64_t b) 4 | { 5 | uint32_t al = (uint32_t)a; 6 | uint32_t ah = (uint32_t)(a >> 32); 7 | uint32_t bl = (uint32_t)b; 8 | uint32_t bh = (uint32_t)(b >> 32); 9 | uint64_t v; 10 | 11 | v = (uint64_t)al * bl; 12 | v += (uint64_t)(al*bh+ah*bl) << 32; 13 | 14 | return v; 15 | } 16 | -------------------------------------------------------------------------------- /usr/klibc/arch/arm/aeabi_nonsense.S: -------------------------------------------------------------------------------- 1 | .text 2 | .globl __aeabi_unwind_cpp_pr0 3 | __aeabi_unwind_cpp_pr0: 4 | .globl __aeabi_unwind_cpp_pr1 5 | __aeabi_unwind_cpp_pr1: 6 | .globl __aeabi_unwind_cpp_pr2 7 | __aeabi_unwind_cpp_pr2: 8 | .globl __aeabi_unwind_cpp_pr3 9 | __aeabi_unwind_cpp_pr3: 10 | -------------------------------------------------------------------------------- /usr/klibc/arch/arm/crt0.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/arm/crt0.S 3 | # 4 | # void _start(void) 5 | # { 6 | # __libc_init(elf_structure, atexit_ptr); 7 | # } 8 | # 9 | 10 | .text 11 | .balign 4 12 | .type _start,#function 13 | .globl _start 14 | 15 | #ifdef __thumb__ 16 | .thumb_func 17 | #endif 18 | 19 | _start: mov r0, sp 20 | mov r1, #0 21 | bl __libc_init 22 | 23 | .size _start,.-_start 24 | -------------------------------------------------------------------------------- /usr/klibc/arch/cris/__negdi2.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/cris/__negdi2.c 3 | */ 4 | 5 | /* 6 | * In 2's complement arithmetric, -x == (~x + 1), so 7 | * -{h,l} = (~{h,l} + {0,1) 8 | * -{h,l} = {~h,~l} + {0,1} 9 | * -{h,l} = {~h + cy, ~l + 1} 10 | * ... where cy = (l == 0) 11 | * -{h,l} = {~h + cy, -l} 12 | */ 13 | 14 | .text 15 | .balign 4 16 | .type __negdi2,@function 17 | .globl __negdi2 18 | __negdi2: 19 | neg.d $r10,$r10 20 | seq $r12 21 | not $r11 22 | ret 23 | add.d $r12,$r11 24 | 25 | .size __negdi2, .-__negdi2 26 | -------------------------------------------------------------------------------- /usr/klibc/arch/cris/crt0.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/cris/crt0.S 3 | # 4 | # Does arch-specific initialization and invokes __libc_init 5 | # with the appropriate arguments. 6 | # 7 | # See __static_init.c or __shared_init.c for the expected 8 | # arguments. 9 | # 10 | 11 | .text 12 | .balign 4 13 | .type _start,@function 14 | .globl _start 15 | _start: 16 | /* Save the address of the ELF argument array */ 17 | move.d $sp,$r10 /* Address of ELF arguments */ 18 | 19 | /* atexit() function (assume null) */ 20 | moveq 0,$r11 21 | 22 | /* Set up a dummy stack frame to keep gcc from getting confused */ 23 | push $r11 24 | push $r11 25 | jump __libc_init 26 | 27 | .size _start, .-_start 28 | -------------------------------------------------------------------------------- /usr/klibc/arch/cris/vfork.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/cris/vfork.S 3 | * 4 | * On cris, r9 contains the syscall number (set by generated stub); 5 | * r10..r13 contain arguments 0-3 per the standard calling convention. 6 | * The return address is in $srp; so we just need to avoid the stack 7 | * usage of the normal syscall stubs. 8 | */ 9 | 10 | #include 11 | 12 | .section ".text","ax" 13 | .balign 4 14 | .globl vfork 15 | .type vfork,@function 16 | vfork: 17 | move.d __NR_vfork, $r9 18 | break 13 19 | 20 | cmps.w -4096,$r10 21 | blo 1f 22 | neg.d $r10,$r11 23 | move.d $r11,[errno] 24 | moveq -1,$r10 25 | 1: 26 | ret 27 | nop 28 | 29 | .size vfork,.-vfork 30 | -------------------------------------------------------------------------------- /usr/klibc/arch/i386/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc .o files for i386 3 | # 4 | 5 | klib-y := socketcall.o setjmp.o syscall.o varsyscall.o 6 | klib-y += open.o openat.o vfork.o 7 | klib-y += libgcc/__ashldi3.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o 8 | klib-y += libgcc/__muldi3.o libgcc/__negdi2.o 9 | 10 | klib-y += ../../libgcc/__divdi3.o 11 | klib-y += ../../libgcc/__moddi3.o 12 | klib-y += ../../libgcc/__udivdi3.o 13 | klib-y += ../../libgcc/__umoddi3.o 14 | klib-y += ../../libgcc/__udivmoddi4.o 15 | 16 | always := crt0.o 17 | targets := crt0.o 18 | -------------------------------------------------------------------------------- /usr/klibc/arch/i386/libgcc/__ashldi3.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__ashldi3.S 3 | * 4 | * 64-bit shl 5 | */ 6 | .text 7 | .align 4 8 | .globl __ashldi3 9 | .type __ashldi3,@function 10 | __ashldi3: 11 | #ifndef _REGPARM 12 | movl 4(%esp),%eax 13 | movl 8(%esp),%edx 14 | movb 12(%esp),%cl 15 | #endif 16 | cmpb $32,%cl 17 | jae 1f 18 | 19 | shldl %cl,%eax,%edx 20 | shl %cl,%eax 21 | ret 22 | 23 | 1: 24 | xorl %edx,%edx 25 | shl %cl,%eax 26 | xchgl %edx,%eax 27 | ret 28 | 29 | .size __ashldi3,.-__ashldi3 30 | -------------------------------------------------------------------------------- /usr/klibc/arch/i386/libgcc/__ashrdi3.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__ashrdi3.S 3 | * 4 | * 64-bit sar 5 | */ 6 | .text 7 | .align 4 8 | .globl __ashrdi3 9 | .type __ashrdi3,@function 10 | __ashrdi3: 11 | #ifndef _REGPARM 12 | movl 4(%esp),%eax 13 | movl 8(%esp),%edx 14 | movb 12(%esp),%cl 15 | #endif 16 | cmpb $32,%cl 17 | jae 1f 18 | 19 | shrdl %cl,%edx,%eax 20 | sarl %cl,%edx 21 | ret 22 | 23 | 1: 24 | sarl %cl,%edx 25 | movl %edx,%eax 26 | cdq 27 | ret 28 | 29 | .size __ashrdi3,.-__ashrdi3 30 | -------------------------------------------------------------------------------- /usr/klibc/arch/i386/libgcc/__lshrdi3.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__lshrdi3.S 3 | * 4 | * 64-bit shr 5 | */ 6 | .text 7 | .align 4 8 | .globl __lshrdi3 9 | .type __lshrdi3,@function 10 | __lshrdi3: 11 | #ifndef _REGPARM 12 | movl 4(%esp),%eax 13 | movl 8(%esp),%edx 14 | movb 12(%esp),%cl 15 | #endif 16 | cmpb $32,%cl 17 | jae 1f 18 | 19 | shrdl %cl,%edx,%eax 20 | shrl %cl,%edx 21 | ret 22 | 23 | 1: 24 | shrl %cl,%edx 25 | xorl %eax,%eax 26 | xchgl %edx,%eax 27 | ret 28 | 29 | .size __lshrdi3,.-__lshrdi3 30 | -------------------------------------------------------------------------------- /usr/klibc/arch/i386/libgcc/__muldi3.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__muldi3.S 3 | * 4 | * 64*64 = 64 bit unsigned multiplication 5 | */ 6 | 7 | .text 8 | .align 4 9 | .globl __muldi3 10 | .type __muldi3,@function 11 | __muldi3: 12 | push %esi 13 | #ifndef _REGPARM 14 | movl 8(%esp),%eax 15 | movl %eax,%esi 16 | movl 16(%esp),%ecx 17 | mull %ecx 18 | imull 12(%esp),%ecx 19 | imull 20(%esp),%esi 20 | addl %ecx,%edx 21 | addl %esi,%edx 22 | #else 23 | movl %eax,%esi 24 | push %edx 25 | mull %ecx 26 | imull 8(%esp),%esi 27 | addl %esi,%edx 28 | pop %esi 29 | imull %esi,%ecx 30 | addl %ecx,%edx 31 | #endif 32 | pop %esi 33 | ret 34 | .size __muldi3,.-__muldi3 35 | -------------------------------------------------------------------------------- /usr/klibc/arch/i386/libgcc/__negdi2.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__negdi2.S 3 | * 4 | * 64-bit negation 5 | */ 6 | 7 | .text 8 | .align 4 9 | .globl __negdi2 10 | .type __negdi2,@function 11 | __negdi2: 12 | #ifndef _REGPARM 13 | movl 4(%esp),%eax 14 | movl 8(%esp),%edx 15 | #endif 16 | negl %edx 17 | negl %eax 18 | sbbl $0,%edx 19 | ret 20 | 21 | .size __negdi2,.-__negdi2 22 | -------------------------------------------------------------------------------- /usr/klibc/arch/i386/open.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/open.S 3 | * 4 | * Handle the open() system call - oddball due to the varadic 5 | * prototype, which forces the use of the cdecl calling convention, 6 | * and the need for O_LARGEFILE. 7 | */ 8 | 9 | #include 10 | 11 | /* , despite the name, isn't assembly-safe */ 12 | #define O_LARGEFILE 0100000 13 | 14 | .globl open 15 | .type open,@function 16 | 17 | open: 18 | #ifdef _REGPARM 19 | movl 4(%esp),%eax 20 | movl 8(%esp),%edx 21 | movl 12(%esp),%ecx 22 | orl $O_LARGEFILE,%edx 23 | #else 24 | orl $O_LARGEFILE,8(%esp) 25 | #endif 26 | pushl $__NR_open 27 | jmp __syscall_common 28 | 29 | .size open,.-open 30 | -------------------------------------------------------------------------------- /usr/klibc/arch/i386/openat.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/openat.S 3 | * 4 | * Handle the openat() system call - oddball due to the varadic 5 | * prototype, which forces the use of the cdecl calling convention, 6 | * and the need for O_LARGEFILE. 7 | */ 8 | 9 | #include 10 | 11 | /* , despite the name, isn't assembly-safe */ 12 | #define O_LARGEFILE 0100000 13 | 14 | #ifdef __NR_openat /* Don't build if kernel headers too old */ 15 | 16 | .globl openat 17 | .type openat,@function 18 | 19 | openat: 20 | orl $O_LARGEFILE,12(%esp) 21 | pushl $__NR_openat 22 | jmp __syscall_varadic 23 | 24 | .size openat,.-openat 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /usr/klibc/arch/i386/vfork.S: -------------------------------------------------------------------------------- 1 | # 2 | # usr/klibc/arch/i386/vfork.S 3 | # 4 | # vfork is nasty - there must be nothing at all on the stack above 5 | # the stack frame of the enclosing function. 6 | # 7 | 8 | #include 9 | 10 | .text 11 | .align 4 12 | .globl vfork 13 | .type vfork, @function 14 | vfork: 15 | popl %edx /* Return address */ 16 | movl $__NR_vfork, %eax 17 | int $0x80 18 | pushl %edx 19 | cmpl $-4095, %eax 20 | jae 1f 21 | ret 22 | 1: 23 | negl %eax 24 | movl %eax, errno 25 | orl $-1, %eax 26 | ret 27 | -------------------------------------------------------------------------------- /usr/klibc/arch/ia64/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for ia64 3 | # 4 | 5 | klib-y := vfork.o setjmp.o pipe.o syscall.o 6 | 7 | klib-y += ../../libgcc/__divdi3.o ../../libgcc/__divsi3.o 8 | klib-y += ../../libgcc/__udivdi3.o ../../libgcc/__udivsi3.o 9 | klib-y += ../../libgcc/__umodsi3.o ../../libgcc/__umoddi3.o 10 | klib-y += ../../libgcc/__udivmodsi4.o ../../libgcc/__udivmoddi4.o 11 | 12 | always := crt0.o 13 | targets := crt0.o 14 | -------------------------------------------------------------------------------- /usr/klibc/arch/ia64/MCONFIG: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | # 3 | # arch/ia64/MCONFIG 4 | # 5 | # Special rules for this architecture. Note that this is actually 6 | # included from the main Makefile, and that pathnames should be 7 | # accordingly. 8 | # 9 | 10 | KLIBCOPTFLAGS += -Os 11 | KLIBCBITSIZE = 64 12 | -------------------------------------------------------------------------------- /usr/klibc/arch/ia64/crt0.S: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | .align 32 5 | .global _start 6 | 7 | .proc _start 8 | .type _start,@function 9 | _start: 10 | .prologue 11 | .save rp, r0 12 | 13 | alloc r2 = ar.pfs,0,0,2,0 14 | movl r3 = FPSR_DEFAULT 15 | ;; 16 | adds out0= 16,sp /* argc pointer */ 17 | movl gp = @gprel(0f) 18 | 0: mov r9 = ip 19 | ;; 20 | sub gp = r9, gp /* back-compute gp value */ 21 | 22 | .body 23 | br.call.sptk.few rp = __libc_init 24 | ;; 25 | break 0 /* break miserably if we ever return */ 26 | 27 | .endp _start 28 | -------------------------------------------------------------------------------- /usr/klibc/arch/ia64/syscall.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/ia64/syscall.S 3 | # 4 | 5 | #include 6 | 7 | .text 8 | .align 32 9 | .proc __syscall_error 10 | .globl __syscall_error 11 | __syscall_error: 12 | addl r2 = @ltoffx(errno),gp 13 | ;; 14 | ld8.mov r3 = [r2],errno 15 | ;; 16 | st4 [r3] = r8 17 | mov r8 = -1 18 | br.ret.sptk.many b0 19 | .size __syscall_error, .-__syscall_error 20 | .endp __syscall_error 21 | -------------------------------------------------------------------------------- /usr/klibc/arch/m32r/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for m32r 3 | # 4 | 5 | 6 | klib-y := setjmp.o syscall.o 7 | 8 | klib-y += ../../libgcc/__divdi3.o ../../libgcc/__moddi3.o 9 | klib-y += ../../libgcc/__udivdi3.o ../../libgcc/__umoddi3.o 10 | klib-y += ../../libgcc/__udivmoddi4.o 11 | 12 | always := crt0.o 13 | targets := crt0.o 14 | -------------------------------------------------------------------------------- /usr/klibc/arch/m32r/MCONFIG: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | # 3 | # arch/m32r/MCONFIG 4 | # 5 | # Special rules for this architecture. Note that this is actually 6 | # included from the main Makefile, and that pathnames should be 7 | # accordingly. 8 | # 9 | 10 | KLIBCOPTFLAGS += -Os 11 | KLIBCBITSIZE = 32 12 | 13 | # Extra linkflags when building the shared version of the library 14 | # This address needs to be reachable using normal inter-module 15 | # calls, and work on the memory models for this architecture 16 | # 224 MB - normal binaries start at 0 (?) 17 | # (lib?)gcc on cris seems to insist on producing .init and .fini sections 18 | KLIBCSHAREDFLAGS = --section-start .init=0x0e000100 19 | -------------------------------------------------------------------------------- /usr/klibc/arch/m32r/crt0.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/m32r/crt0.S 3 | # 4 | # Does arch-specific initialization and invokes __libc_init 5 | # with the appropriate arguments. 6 | # 7 | # See __static_init.c or __shared_init.c for the expected 8 | # arguments. 9 | # 10 | 11 | .text 12 | .balign 4 13 | .type _start,@function 14 | .globl _start 15 | _start: 16 | /* Save the address of the ELF argument array */ 17 | mv r0, sp 18 | 19 | /* atexit() function (assume null) */ 20 | xor r1, r1 21 | 22 | bl __libc_init 23 | 24 | .size _start, .-_start 25 | -------------------------------------------------------------------------------- /usr/klibc/arch/m32r/syscall.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/m32r/syscall.S 3 | * 4 | * r7 contains the syscall number (set by stub); 5 | * r0..r3 contains arguments 0-3 per standard calling convention; 6 | * r4..r5 contains arguments 4-5, but we have to get those from 7 | * the stack. 8 | */ 9 | 10 | .section ".text","ax" 11 | .balign 4 12 | .globl __syscall_common 13 | .type __syscall_common,@function 14 | __syscall_common: 15 | ld r4,@sp 16 | ld r5,@(4,sp) 17 | trap #2 18 | cmpi r0, #-4096 19 | bnc 1f 20 | jmp r14 21 | 1: 22 | seth r2,#high(errno) 23 | or3 r2,r2,#low(errno) 24 | neg r1,r0 25 | st r1,@r7 26 | ldi r0,#-1 27 | jmp r14 28 | 29 | .size __syscall_common,.-__syscall_common 30 | -------------------------------------------------------------------------------- /usr/klibc/arch/m68k/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for m68k 3 | # 4 | 5 | klib-y := setjmp.o syscall.o vfork.o 6 | 7 | always := crt0.o 8 | targets := crt0.o 9 | -------------------------------------------------------------------------------- /usr/klibc/arch/m68k/crt0.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/m68k/crt0.S 3 | # 4 | # Does arch-specific initialization and invokes __libc_init 5 | # with the appropriate arguments. 6 | # 7 | # See __static_init.c or __shared_init.c for the expected 8 | # arguments. 9 | # 10 | 11 | .text 12 | .align 4 13 | .type _start,@function 14 | .globl _start 15 | _start: 16 | # Zero out the frame pointer to be nice to the debugger 17 | movea.l #0,%a6 18 | # Save the address of the ELF argument array 19 | move.l %a7, %d0 20 | # Push a zero on the stack in lieu of atexit pointer 21 | clr.l -(%sp) 22 | # Push ELF argument pointer on the stack 23 | move.l %d0, -(%a7) 24 | 25 | jbsr __libc_init 26 | 27 | .size _start, .-_start 28 | -------------------------------------------------------------------------------- /usr/klibc/arch/m68k/syscall.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/m68k/syscall.S 3 | * 4 | * Common tail-handling code for system calls. 5 | * 6 | * The arguments are on the stack; the system call number in %d0. 7 | */ 8 | 9 | .text 10 | .align 2 11 | .globl __syscall_common 12 | .type __syscall_common, @function 13 | __syscall_common: 14 | movem.l %d2-%d6, -(%sp) /* 5 registers saved */ 15 | movem.l 24(%sp), %d1-%d6 16 | trap #0 17 | cmpi.l #-4095, %d0 18 | blt.l 1f 19 | neg.l %d0 20 | move.l %d0, (errno) 21 | moveq #-1, %d0 22 | 1: 23 | movea.l %d0, %a0 /* Redundant return */ 24 | movem.l (%sp)+, %d2-%d6 /* Restore registers */ 25 | rts 26 | 27 | .size __syscall_common,.-__syscall_common 28 | -------------------------------------------------------------------------------- /usr/klibc/arch/m68k/vfork.S: -------------------------------------------------------------------------------- 1 | # 2 | # usr/klibc/arch/m68k/vfork.S 3 | # 4 | # vfork is nasty - there must be nothing at all on the stack above 5 | # the stack frame of the enclosing function. 6 | # 7 | 8 | #include 9 | 10 | .text 11 | .align 2 12 | .globl vfork 13 | .type vfork, @function 14 | vfork: 15 | move.l (%sp)+, %d1 /* Return address */ 16 | move.l # __NR_vfork, %d0 17 | trap #0 18 | move.l %d1, -(%sp) 19 | cmpi.l #-4095, %d0 20 | blt.l 1f 21 | neg.l %d0 22 | move.l %d0, (errno) 23 | moveq #-1, %d0 24 | 1: 25 | movea.l %d0, %a0 26 | rts 27 | 28 | .size vfork, .-vfork 29 | -------------------------------------------------------------------------------- /usr/klibc/arch/mips/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for mips 3 | # 4 | 5 | klib-y := pipe.o vfork.o setjmp.o syscall.o 6 | 7 | klib-y += ../../libgcc/__clzsi2.o ../../libgcc/__ashldi3.o 8 | klib-y += ../../libgcc/__ashrdi3.o ../../libgcc/__lshrdi3.o 9 | klib-y += ../../libgcc/__divdi3.o ../../libgcc/__moddi3.o 10 | klib-y += ../../libgcc/__udivdi3.o ../../libgcc/__umoddi3.o 11 | klib-y += ../../libgcc/__udivmoddi4.o 12 | 13 | always := crt0.o 14 | targets := crt0.o 15 | -------------------------------------------------------------------------------- /usr/klibc/arch/mips/MCONFIG: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | # 3 | # arch/mips/MCONFIG 4 | # 5 | # Special rules for this architecture. Note that this is actually 6 | # included from the main Makefile, and that pathnames should be 7 | # accordingly. 8 | # 9 | 10 | KLIBCARCHREQFLAGS = -fno-pic -mno-abicalls -G 0 11 | KLIBCOPTFLAGS += -Os 12 | KLIBCBITSIZE = 32 13 | 14 | # Extra linkflags when building the shared version of the library 15 | KLIBCSHAREDFLAGS = -T $(src)/arch/$(KLIBCARCH)/klibc.ld 16 | -------------------------------------------------------------------------------- /usr/klibc/arch/mips/crt0.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/mips/crt0.S 3 | # 4 | # Does arch-specific initialization and invokes __libc_init 5 | # with the appropriate arguments. 6 | # 7 | # See __static_init.c or __shared_init.c for the expected 8 | # arguments. 9 | # 10 | 11 | #include 12 | 13 | NESTED(__start, 32, sp) 14 | subu sp, 32 15 | sw zero, 16(sp) 16 | 17 | lui gp, %hi(_gp) # Initialize gp 18 | addiu gp, gp, _gp 19 | 20 | addiu a0, sp, 32 # Pointer to ELF entry structure 21 | move a1, v0 # Kernel-provided atexit() pointer 22 | 23 | jal __libc_init 24 | 25 | END(__start) 26 | -------------------------------------------------------------------------------- /usr/klibc/arch/mips/pipe.S: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | LEAF(pipe) 5 | li v0, __NR_pipe 6 | syscall 7 | bnez a3, 1f 8 | sw v0, (a0) 9 | sw v1, 4(a0) 10 | li v0, 0 11 | b 2f 12 | 1: sw v0, errno 13 | li v0, -1 14 | 2: jr ra 15 | END(pipe) 16 | -------------------------------------------------------------------------------- /usr/klibc/arch/mips/syscall.S: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | .set noreorder 5 | 6 | LEAF(__syscall_common) 7 | syscall 8 | beqz a3, 1f 9 | # sw is actually two instructions; the first one goes 10 | # in the branch delay slot 11 | # XXX: Break this up manually; as it is now it generates warnings. 12 | sw v0, errno 13 | li v0, -1 14 | 1: jr ra 15 | END(__syscall_common) 16 | -------------------------------------------------------------------------------- /usr/klibc/arch/mips/vfork.S: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define CLONE_VM 0x00000100 5 | #define CLONE_VFORK 0x00004000 6 | #define SIGCHLD 18 7 | 8 | .set noreorder 9 | 10 | LEAF(vfork) 11 | li a0, CLONE_VFORK | CLONE_VM | SIGCHLD 12 | li a1, 0 13 | j __syscall_common 14 | li v0, __NR_clone 15 | END(vfork) 16 | -------------------------------------------------------------------------------- /usr/klibc/arch/mips64/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for mips64 3 | # 4 | -------------------------------------------------------------------------------- /usr/klibc/arch/mips64/MCONFIG: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | # 3 | # arch/mips64/MCONFIG 4 | # 5 | # Special rules for this architecture. Note that this is actually 6 | # included from the main Makefile, and that pathnames should be 7 | # accordingly. 8 | # 9 | 10 | KLIBCOPTFLAGS += -Os 11 | KLIBCBITSIZE = 64 12 | -------------------------------------------------------------------------------- /usr/klibc/arch/parisc/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for parisc 3 | # 4 | 5 | klib-y := setjmp.o syscall.o vfork.o 6 | 7 | always := crt0.o 8 | targets := crt0.o 9 | -------------------------------------------------------------------------------- /usr/klibc/arch/parisc/MCONFIG: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | # 3 | # arch/parisc/MCONFIG 4 | # 5 | # Special rules for this architecture. Note that this is actually 6 | # included from the main Makefile, and that pathnames should be 7 | # accordingly. 8 | # 9 | 10 | KLIBCOPTFLAGS += -Os -fomit-frame-pointer 11 | KLIBCBITSIZE = 32 12 | KLIBCSHAREDFLAGS = -Ttext 0x40001000 13 | -------------------------------------------------------------------------------- /usr/klibc/arch/ppc/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for ppc 3 | # 4 | 5 | klib-y := setjmp.o syscall.o 6 | 7 | klib-y += ../../libgcc/__divdi3.o ../../libgcc/__moddi3.o 8 | klib-y += ../../libgcc/__udivdi3.o ../../libgcc/__umoddi3.o 9 | klib-y += ../../libgcc/__udivmoddi4.o 10 | 11 | always := crt0.o 12 | targets := crt0.o 13 | -------------------------------------------------------------------------------- /usr/klibc/arch/ppc/crt0.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/ppc/crt0.S 3 | # 4 | 5 | .text 6 | .align 4 7 | .type _start,@function 8 | .globl _start 9 | _start: 10 | stwu 1,-16(1) 11 | addi 3,1,16 12 | /* 13 | * the SVR4abippc.pdf specifies r7 as a pointer to 14 | * a termination function point 15 | * However, Section 8.4.1 of the LSB API docs say that 16 | * The value to be placed into register r7, the termination 17 | * function pointer, is not passed to the process. 18 | * So we stub it out, instead. 19 | */ 20 | li 4,0 21 | bl __libc_init 22 | 23 | .size _start,.-_start 24 | -------------------------------------------------------------------------------- /usr/klibc/arch/ppc/syscall.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/ppc/syscall.S 3 | * 4 | * Common error-handling path for system calls. 5 | */ 6 | 7 | .text 8 | .align 2 9 | .globl __syscall_error 10 | .type __syscall_error,@function 11 | __syscall_error: 12 | lis 9,errno@ha 13 | stw 3,errno@l(9) 14 | li 3,-1 15 | blr 16 | .size __syscall_error,.-__syscall_error 17 | -------------------------------------------------------------------------------- /usr/klibc/arch/ppc64/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for ppc64 3 | # 4 | 5 | klib-y := setjmp.o syscall.o 6 | 7 | always := crt0.o 8 | targets := crt0.o 9 | -------------------------------------------------------------------------------- /usr/klibc/arch/ppc64/crt0.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/ppc64/crt0.S 3 | # 4 | # void _start(void) 5 | # { 6 | # /* Divine up argc, argv, and envp */ 7 | # environ = envp; 8 | # exit(main(argc, argv, envp)); 9 | # } 10 | # 11 | 12 | .section ".toc","aw" 13 | .LC0: .tc environ[TC],environ 14 | 15 | .text 16 | .align 4 17 | 18 | .section ".opd","aw" 19 | _start: 20 | .quad ._start, .TOC.@tocbase, 0 21 | .previous 22 | .size _start, 24 23 | .type ._start,@function 24 | .globl _start 25 | .globl ._start 26 | ._start: 27 | stdu %r1,-32(%r1) 28 | addi %r3,%r1,32 29 | li %r4,0 /* fini (unused) */ 30 | b .__libc_init 31 | nop 32 | 33 | .size ._start,.-._start 34 | -------------------------------------------------------------------------------- /usr/klibc/arch/ppc64/syscall.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/ppc64/syscall.c 3 | * 4 | * Common error-handling path for system calls. 5 | * The return value from __syscall_error becomes the 6 | * return value from the system call. 7 | */ 8 | #include 9 | 10 | long int __syscall_error(long int err) 11 | { 12 | errno = err; 13 | return -1; 14 | } 15 | -------------------------------------------------------------------------------- /usr/klibc/arch/s390/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for s390 3 | # 4 | 5 | always := crt0.o 6 | targets := crt0.o 7 | 8 | ifneq ("$(KLIBCARCH)", "s390x") 9 | 10 | klib-y := setjmp.o mmap.o syscall.o 11 | 12 | klib-y += ../../libgcc/__clzsi2.o ../../libgcc/__ashldi3.o 13 | klib-y += ../../libgcc/__ashrdi3.o ../../libgcc/__lshrdi3.o 14 | klib-y += ../../libgcc/__divdi3.o ../../libgcc/__moddi3.o 15 | klib-y += ../../libgcc/__udivdi3.o ../../libgcc/__umoddi3.o 16 | klib-y += ../../libgcc/__udivmoddi4.o 17 | 18 | else 19 | 20 | klib-y := setjmp.o mmap.o syscall.o 21 | 22 | endif 23 | -------------------------------------------------------------------------------- /usr/klibc/arch/s390/MCONFIG: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | # 3 | # arch/s390/MCONFIG 4 | # 5 | # Special rules for this architecture. Note that this is actually 6 | # included from the main Makefile, and that pathnames should be 7 | # accordingly. 8 | # 9 | 10 | KLIBCOPTFLAGS += -Os 11 | 12 | ifneq ("$(KLIBCARCH)", "s390x") 13 | KLIBCBITSIZE = 32 14 | KLIBCCFLAGS += -m31 15 | KLIBCLDFLAGS += -m elf_s390 16 | else 17 | KLIBCBITSIZE = 64 18 | KLIBCCFLAGS += -m64 19 | KLIBCLDFLAGS += -m elf64_s390 20 | endif 21 | 22 | KLIBCASMARCH = s390 23 | KLIBCSHAREDFLAGS = -Ttext 0x40000200 24 | -------------------------------------------------------------------------------- /usr/klibc/arch/s390/crt0.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/s390/crt0.S 3 | # 4 | # Does arch-specific initialization and invokes __libc_init 5 | # with the appropriate arguments. 6 | # 7 | # See __static_init.c or __shared_init.c for the expected 8 | # arguments. 9 | # 10 | .text 11 | .align 4 12 | .type _start,@function 13 | .globl _start 14 | 15 | #ifndef __s390x__ 16 | 17 | _start: 18 | lr %r2,%r15 19 | lhi %r3,0 20 | ahi %r15,-96 21 | bras %r1,.L0 22 | .L0: 23 | l %r1,.L1-.L0(%r1) 24 | br %r1 25 | .L1: 26 | .long __libc_init 27 | #else 28 | 29 | _start: 30 | lgr %r2,%r15 31 | lghi %r3,0 32 | aghi %r15,-160 33 | jg __libc_init 34 | #endif 35 | .size _start,.-_start 36 | -------------------------------------------------------------------------------- /usr/klibc/arch/s390/syscall.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/s390/syscall.c 3 | * 4 | * Common error-handling path for system calls. 5 | * The return value from __syscall_common becomes the 6 | * return value from the system call. 7 | */ 8 | #include 9 | 10 | unsigned long __syscall_common(unsigned long err) 11 | { 12 | if (err < -4095UL) 13 | return err; 14 | errno = -err; 15 | return -1; 16 | } 17 | -------------------------------------------------------------------------------- /usr/klibc/arch/sh/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for sh 3 | # 4 | 5 | klib-y := pipe.o setjmp.o syscall.o 6 | 7 | always := crt0.o 8 | targets := crt0.o 9 | -------------------------------------------------------------------------------- /usr/klibc/arch/sh/MCONFIG: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | # 3 | # arch/sh/MCONFIG 4 | # 5 | # Special rules for this architecture. Note that this is actually 6 | # included from the main Makefile, and that pathnames should be 7 | # accordingly. 8 | # 9 | 10 | ARCHREGFLAGS = -m4 -mno-implicit-fp 11 | KLIBCOPTFLAGS += -Os -fomit-frame-pointer 12 | KLIBCBITSIZE = 32 13 | 14 | # Extra linkflags when building the shared version of the library 15 | # This address needs to be reachable using normal inter-module 16 | # calls, and work on the memory models for this architecture 17 | # 2 MB -- the normal starting point for text is 4 MB. 18 | KLIBCSHAREDFLAGS = -Ttext 0x00200200 19 | -------------------------------------------------------------------------------- /usr/klibc/arch/sh/crt0.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/sh/crt0.S 3 | # 4 | # Does arch-specific initialization and invokes __libc_init 5 | # with the appropriate arguments. 6 | # 7 | # See __static_init.c or __shared_init.c for the expected 8 | # arguments. 9 | # 10 | 11 | .text 12 | .align 2 13 | .type _start,#function 14 | .globl _start 15 | 16 | _start: 17 | mov r15, r4 18 | mov #0, r5 19 | mov.l 1f, r0 20 | 21 | jsr @r0 22 | nop 23 | 24 | .align 2 25 | 1: .long __libc_init 26 | 27 | .size _start,.-_start 28 | -------------------------------------------------------------------------------- /usr/klibc/arch/sh/pipe.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sh/pipe.S 3 | * 4 | * The pipe system call is special on sh: it returns 5 | * the two file descriptors in r0 and r1. 6 | */ 7 | 8 | #include 9 | 10 | .section ".text.syscall","ax" 11 | .align 2 12 | .globl pipe 13 | .type pipe,@function 14 | pipe: 15 | mov #__NR_pipe, r3 16 | trapa #0x10 17 | mov.l 1f,r2 18 | cmp/hs r0,r2 19 | bt/s 3f 20 | neg r0,r2 21 | mov.l 2f,r3 22 | mov.l r2,@r3 23 | rts 24 | mov #-1,r0 25 | 3: 26 | mov.l r0, @r4 27 | mov.l r1, @(4, r4) 28 | rts 29 | mov #0,r0 30 | 31 | .align 2 32 | 1: .long -4096 /* Errno limit */ 33 | 2: .long errno 34 | 35 | .size pipe,.-pipe 36 | -------------------------------------------------------------------------------- /usr/klibc/arch/sparc/__muldi3.S: -------------------------------------------------------------------------------- 1 | .global .umul 2 | .section ".text" 3 | .align 4 4 | .global __muldi3 5 | .type __muldi3, #function 6 | .proc 017 7 | __muldi3: 8 | save %sp, -104, %sp 9 | mov %i1, %o0 10 | call .umul, 0 11 | mov %i3, %o1 12 | mov %o0, %l2 13 | mov %o1, %l3 14 | mov %i1, %o0 15 | call .umul, 0 16 | mov %i2, %o1 17 | mov %i0, %o1 18 | mov %o0, %l0 19 | call .umul, 0 20 | mov %i3, %o0 21 | mov 0, %l1 22 | add %l0, %o0, %l0 23 | addcc %l3, %l1, %i1 24 | addx %l2, %l0, %i0 25 | jmp %i7+8 26 | restore 27 | .size __muldi3, .-__muldi3 28 | -------------------------------------------------------------------------------- /usr/klibc/arch/sparc/crt0.S: -------------------------------------------------------------------------------- 1 | #define TARGET_PTR_SIZE 32 2 | #include "crt0i.S" 3 | -------------------------------------------------------------------------------- /usr/klibc/arch/sparc/pipe.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sparc/pipe.S 3 | * 4 | * The pipe system call are special on sparc[64]: 5 | * they return the two file descriptors in %o0 and %o1. 6 | */ 7 | 8 | #include 9 | 10 | .globl pipe 11 | .type pipe,#function 12 | .align 4 13 | pipe: 14 | mov __NR_pipe, %g1 15 | or %o0, 0, %g4 16 | t 0x10 17 | bcc 1f 18 | nop 19 | sethi %hi(errno), %g4 20 | or %g4, %lo(errno), %g4 21 | st %o0,[%g4] 22 | retl 23 | mov -1, %o0 24 | 1: 25 | st %o0,[%g4] 26 | st %o1,[%g4+4] 27 | retl 28 | mov 0, %o0 29 | 30 | .size pipe,.-pipe 31 | -------------------------------------------------------------------------------- /usr/klibc/arch/sparc/syscall.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sparc/syscall.S 3 | * 4 | * Common system-call stub; %g1 already set to syscall number 5 | */ 6 | 7 | .globl __syscall_common 8 | .type __syscall_common,#function 9 | .align 4 10 | __syscall_common: 11 | t 0x10 12 | bcc 1f 13 | sethi %hi(errno), %g4 14 | or %g4, %lo(errno), %g4 15 | st %o0,[%g4] 16 | mov -1, %o0 17 | 1: 18 | retl 19 | nop 20 | -------------------------------------------------------------------------------- /usr/klibc/arch/sparc/sysfork.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sparc/sysfork.S 3 | * 4 | * The fork and vfork system calls are special on sparc[64]: 5 | * they return the "other process" pid in %o0 and the 6 | * "is child" flag in %o1 7 | * 8 | * Common system-call stub; %g1 already set to syscall number 9 | */ 10 | 11 | .globl __syscall_forkish 12 | .type __syscall_forkish,#function 13 | .align 4 14 | __syscall_forkish: 15 | t 0x10 16 | sub %o1, 1, %o1 17 | bcc,a 1f 18 | and %o0, %o1, %o0 19 | sethi %hi(errno), %g4 20 | or %g4, %lo(errno), %g4 21 | st %o0,[%g4] 22 | mov -1, %o0 23 | 1: 24 | retl 25 | nop 26 | -------------------------------------------------------------------------------- /usr/klibc/arch/sparc64/Kbuild: -------------------------------------------------------------------------------- 1 | # 2 | # klibc files for sparc64 3 | # 4 | 5 | klib-y := pipe.o setjmp.o syscall.o sysfork.o 6 | 7 | always := crt0.o 8 | targets := crt0.o 9 | -------------------------------------------------------------------------------- /usr/klibc/arch/sparc64/crt0.S: -------------------------------------------------------------------------------- 1 | #define TARGET_PTR_SIZE 64 2 | #include "../sparc/crt0i.S" 3 | -------------------------------------------------------------------------------- /usr/klibc/arch/sparc64/pipe.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sparc64/pipe.S 3 | * 4 | * The pipe system call are special on sparc[64]: 5 | * they return the two file descriptors in %o0 and %o1. 6 | */ 7 | 8 | #include 9 | 10 | .globl pipe 11 | .type pipe,#function 12 | .align 4 13 | pipe: 14 | mov __NR_pipe, %g1 15 | or %o0, 0, %g4 16 | t 0x6d 17 | bcc %xcc, 1f 18 | nop 19 | sethi %hi(errno), %g4 20 | or %g4, %lo(errno), %g4 21 | st %o0,[%g4] 22 | retl 23 | mov -1, %o0 24 | 1: 25 | st %o0,[%g4] 26 | st %o1,[%g4+4] 27 | retl 28 | mov 0, %o0 29 | 30 | .size pipe,.-pipe 31 | -------------------------------------------------------------------------------- /usr/klibc/arch/sparc64/syscall.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sparc64/syscall.S 3 | * 4 | * Common system-call stub; %g1 already set to syscall number 5 | */ 6 | 7 | .globl __syscall_common 8 | .type __syscall_common,#function 9 | .align 4 10 | __syscall_common: 11 | t 0x6d 12 | bcc %xcc, 1f 13 | sethi %hi(errno), %g4 14 | or %g4, %lo(errno), %g4 15 | st %o0,[%g4] 16 | 1: 17 | retl 18 | movcs %xcc, -1, %o0 19 | -------------------------------------------------------------------------------- /usr/klibc/arch/sparc64/sysfork.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/sparc64/sysfork.S 3 | * 4 | * The fork and vfork system calls are special on sparc[64]: 5 | * they return the "other process" pid in %o0 and the 6 | * "is child" flag in %o1 7 | * 8 | * Common system-call stub; %g1 already set to syscall number 9 | */ 10 | 11 | .globl __syscall_forkish 12 | .type __syscall_forkish,#function 13 | .align 4 14 | __syscall_forkish: 15 | t 0x6d 16 | sub %o1, 1, %o1 17 | bcc,a %xcc, 1f 18 | and %o0, %o1, %o0 19 | sethi %hi(errno), %g4 20 | or %g4, %lo(errno), %g4 21 | st %o0, [%g4] 22 | retl 23 | mov -1, %o0 24 | 1: 25 | retl 26 | nop 27 | -------------------------------------------------------------------------------- /usr/klibc/arch/x86_64/Kbuild: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | # 3 | # klibc files for x86_64 4 | 5 | always := crt0.o 6 | targets := crt0.o 7 | 8 | klib-y := setjmp.o syscall.o sigreturn.o vfork.o 9 | -------------------------------------------------------------------------------- /usr/klibc/arch/x86_64/crt0.S: -------------------------------------------------------------------------------- 1 | # 2 | # arch/x86_64/crt0.S 3 | # 4 | # Does arch-specific initialization and invokes __libc_init 5 | # with the appropriate arguments. 6 | # 7 | # See __static_init.c or __shared_init.c for the expected 8 | # arguments. 9 | # 10 | 11 | .text 12 | .align 4 13 | .type _start,@function 14 | .globl _start 15 | _start: 16 | movq %rsp,%rdi # Offset of the ELF data structure 17 | movq %rdx,%rsi # The atexit() pointer (if any) 18 | call __libc_init 19 | # We should never get here... 20 | hlt 21 | 22 | .size _start,.-_start 23 | -------------------------------------------------------------------------------- /usr/klibc/arch/x86_64/sigreturn.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/x86_64/sigreturn.S 3 | */ 4 | 5 | #include 6 | 7 | .text 8 | .align 4 9 | .globl __sigreturn 10 | .type __sigreturn,@function 11 | __sigreturn: 12 | movl $__NR_rt_sigreturn,%eax 13 | syscall 14 | 15 | .size __sigreturn,.-__sigreturn 16 | -------------------------------------------------------------------------------- /usr/klibc/arch/x86_64/syscall.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/x86-64/syscall.S 3 | * 4 | * Common tail-handling code for system calls. 5 | * 6 | * The arguments are in the standard argument registers; the system 7 | * call number in %eax. 8 | */ 9 | .text 10 | .align 4 11 | .globl __syscall_common 12 | .type __syscall_common,@function 13 | __syscall_common: 14 | movq %rcx,%r10 # The kernel uses %r10 istf %rcx 15 | syscall 16 | 17 | cmpq $-4095,%rax 18 | jnb 1f 19 | ret 20 | 21 | # Error return, must set errno 22 | 1: 23 | negl %eax 24 | movl %eax,errno(%rip) # errno is type int, so 32 bits 25 | orq $-1,%rax # orq $-1 smaller than movq $-1 26 | ret 27 | 28 | .size __syscall_common,.-__syscall_common 29 | -------------------------------------------------------------------------------- /usr/klibc/arch/x86_64/sysstub.ph: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | # 3 | # arch/x86_64/sysstub.ph 4 | # 5 | # Script to generate system call stubs 6 | # 7 | 8 | sub make_sysstub($$$$$@) { 9 | my($outputdir, $fname, $type, $sname, $stype, @args) = @_; 10 | 11 | open(OUT, '>', "${outputdir}/${fname}.S"); 12 | print OUT "#include \n"; 13 | print OUT "\n"; 14 | print OUT "\t.type ${fname},\@function\n"; 15 | print OUT "\t.globl ${fname}\n"; 16 | print OUT "${fname}:\n"; 17 | print OUT "\tmovl \$__NR_${sname},%eax\n"; # Zero-extends to 64 bits 18 | print OUT "\tjmp __syscall_common\n"; 19 | print OUT "\t.size ${fname},.-${fname}\n"; 20 | close(OUT); 21 | } 22 | 23 | 1; 24 | -------------------------------------------------------------------------------- /usr/klibc/arch/x86_64/vfork.S: -------------------------------------------------------------------------------- 1 | # 2 | # usr/klibc/arch/x86_64/vfork.S 3 | # 4 | # vfork is nasty - there must be nothing at all on the stack above 5 | # the stack frame of the enclosing function. 6 | # 7 | 8 | #include 9 | 10 | .text 11 | .align 4 12 | .globl vfork 13 | .type vfork, @function 14 | vfork: 15 | pop %rdx /* Return address */ 16 | movl $__NR_vfork, %eax 17 | syscall 18 | push %rdx 19 | cmpq $-4095, %rax 20 | jae 1f 21 | ret 22 | 1: 23 | negl %eax 24 | movl %eax, errno(%rip) 25 | orq $-1, %rax 26 | ret 27 | -------------------------------------------------------------------------------- /usr/klibc/asprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * asprintf.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int asprintf(char **bufp, const char *format, ...) 10 | { 11 | va_list ap, ap1; 12 | int rv; 13 | int bytes; 14 | char *p; 15 | 16 | va_start(ap, format); 17 | va_copy(ap1, ap); 18 | 19 | bytes = vsnprintf(NULL, 0, format, ap1) + 1; 20 | va_end(ap1); 21 | 22 | *bufp = p = malloc(bytes); 23 | if (!p) 24 | return -1; 25 | 26 | rv = vsnprintf(p, bytes, format, ap); 27 | va_end(ap); 28 | 29 | return rv; 30 | } 31 | -------------------------------------------------------------------------------- /usr/klibc/assert.c: -------------------------------------------------------------------------------- 1 | /* 2 | * assert.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | __noreturn __assert_fail(const char *expr, const char *file, unsigned int line) 11 | { 12 | printf("Assertion %s failed, file %s, line %u\n", expr, file, line); 13 | abort(); 14 | } 15 | -------------------------------------------------------------------------------- /usr/klibc/atexit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * atexit.c 3 | */ 4 | 5 | #include 6 | 7 | int atexit(void (*fctn) (void)) 8 | { 9 | return on_exit((void (*)(int, void *))fctn, NULL); 10 | } 11 | -------------------------------------------------------------------------------- /usr/klibc/atexit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * atexit.h 3 | * 4 | * atexit()/on_exit() internal definitions 5 | */ 6 | 7 | #ifndef ATEXIT_H 8 | #define ATEXIT_H 9 | 10 | struct atexit { 11 | void (*fctn) (int, void *); 12 | void *arg; /* on_exit() parameter */ 13 | struct atexit *next; 14 | }; 15 | 16 | extern struct atexit *__atexit_list; 17 | 18 | #endif /* ATEXIT_H */ 19 | -------------------------------------------------------------------------------- /usr/klibc/atoi.c: -------------------------------------------------------------------------------- 1 | #define TYPE int 2 | #define NAME atoi 3 | #include "atox.c" 4 | -------------------------------------------------------------------------------- /usr/klibc/atol.c: -------------------------------------------------------------------------------- 1 | #define TYPE long 2 | #define NAME atol 3 | #include "atox.c" 4 | -------------------------------------------------------------------------------- /usr/klibc/atoll.c: -------------------------------------------------------------------------------- 1 | #define TYPE long long 2 | #define NAME atoll 3 | #include "atox.c" 4 | -------------------------------------------------------------------------------- /usr/klibc/atox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * atox.c 3 | * 4 | * atoi(), atol(), atoll() 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | TYPE NAME(const char *nptr) 12 | { 13 | return (TYPE) strntoumax(nptr, (char **)NULL, 10, ~(size_t) 0); 14 | } 15 | -------------------------------------------------------------------------------- /usr/klibc/brk.c: -------------------------------------------------------------------------------- 1 | /* brk.c - Change data segment size */ 2 | 3 | /* Written 2000 by Werner Almesberger */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include "malloc.h" 9 | 10 | #if !_KLIBC_NO_MMU /* uClinux doesn't have brk() */ 11 | 12 | char *__current_brk; 13 | 14 | /* 15 | * The Linux brk() isn't what most people expect, so we call the 16 | * system call __brk() and provide a wrapper. 17 | */ 18 | int brk(void *end_data_segment) 19 | { 20 | char *new_brk; 21 | 22 | new_brk = __brk(end_data_segment); 23 | if (new_brk != end_data_segment) 24 | return -1; 25 | __current_brk = new_brk; 26 | return 0; 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /usr/klibc/bsd_signal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * bsd_signal.c 3 | */ 4 | 5 | #include 6 | 7 | __sighandler_t bsd_signal(int signum, __sighandler_t handler) 8 | { 9 | /* BSD signal() semantics */ 10 | return __signal(signum, handler, SA_RESTART); 11 | } 12 | 13 | __sighandler_t signal(int signum, __sighandler_t handler) 14 | __alias("bsd_signal"); 15 | -------------------------------------------------------------------------------- /usr/klibc/bsearch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * bsearch.c 3 | */ 4 | 5 | #include 6 | 7 | void *bsearch(const void *key, const void *base, size_t nmemb, 8 | size_t size, int (*cmp) (const void *, const void *)) 9 | { 10 | while (nmemb) { 11 | size_t mididx = nmemb / 2; 12 | const void *midobj = base + mididx * size; 13 | int diff = cmp(key, midobj); 14 | 15 | if (diff == 0) 16 | return (void *)midobj; 17 | 18 | if (diff > 0) { 19 | base = midobj + size; 20 | nmemb -= mididx + 1; 21 | } else 22 | nmemb = mididx; 23 | } 24 | 25 | return NULL; 26 | } 27 | -------------------------------------------------------------------------------- /usr/klibc/bzero.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void bzero(void *dst, size_t n) 4 | { 5 | memset(dst, 0, n); 6 | } 7 | -------------------------------------------------------------------------------- /usr/klibc/calloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * calloc.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | /* FIXME: This should look for multiplication overflow */ 9 | 10 | void *calloc(size_t nmemb, size_t size) 11 | { 12 | void *ptr; 13 | 14 | size *= nmemb; 15 | ptr = malloc(size); 16 | if (ptr) 17 | memset(ptr, 0, size); 18 | 19 | return ptr; 20 | } 21 | -------------------------------------------------------------------------------- /usr/klibc/clearenv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * clearenv.c 3 | * 4 | * Empty the environment 5 | */ 6 | 7 | #include 8 | #include 9 | #include "env.h" 10 | 11 | /* Note: if environ has been malloc'd, it will be freed on the next 12 | setenv() or putenv() */ 13 | int clearenv(void) 14 | { 15 | environ = (char **)__null_environ; 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /usr/klibc/closelog.c: -------------------------------------------------------------------------------- 1 | /* 2 | * closelog.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | extern int __syslog_fd; 9 | 10 | void closelog(void) 11 | { 12 | int logfd = __syslog_fd; 13 | 14 | if (logfd != -1) { 15 | close(logfd); 16 | __syslog_fd = -1; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/creat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * creat.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int creat(const char *pathname, mode_t mode) 10 | { 11 | return open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode); 12 | } 13 | -------------------------------------------------------------------------------- /usr/klibc/ctype/ctypefunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ctype/ctype.h 3 | * 4 | * Common header for out-of-line ctype functions 5 | */ 6 | 7 | #define __CTYPE_NO_INLINE 8 | #include 9 | 10 | #define CTYPEFUNC(X) \ 11 | int X(int c) { \ 12 | return __ctype_##X(c); \ 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/ctype/isalnum.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(isalnum) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/isalpha.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(isalpha) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/isascii.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(isascii) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/isblank.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(isblank) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/iscntrl.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(iscntrl) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/isdigit.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(isdigit) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/isgraph.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(isgraph) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/islower.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(islower) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/isprint.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(isprint) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/ispunct.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(ispunct) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/isspace.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(isspace) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/isupper.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(isupper) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/isxdigit.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(isxdigit) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/tolower.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(tolower) 3 | -------------------------------------------------------------------------------- /usr/klibc/ctype/toupper.c: -------------------------------------------------------------------------------- 1 | #include "ctypefunc.h" 2 | CTYPEFUNC(toupper) 3 | -------------------------------------------------------------------------------- /usr/klibc/daemon.c: -------------------------------------------------------------------------------- 1 | /* 2 | * daemon.c - "daemonize" a process 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int daemon(int nochdir, int noclose) 10 | { 11 | int nullfd; 12 | pid_t f; 13 | 14 | if (!nochdir) { 15 | if (chdir("/")) 16 | return -1; 17 | } 18 | 19 | if (!noclose) { 20 | if ((nullfd = open("/dev/null", O_RDWR)) < 0 || 21 | dup2(nullfd, 0) < 0 || 22 | dup2(nullfd, 1) < 0 || 23 | dup2(nullfd, 2) < 0) 24 | return -1; 25 | close(nullfd); 26 | } 27 | 28 | f = fork(); 29 | if (f < 0) 30 | return -1; 31 | else if (f > 0) 32 | _exit(0); 33 | 34 | return setsid(); 35 | } 36 | -------------------------------------------------------------------------------- /usr/klibc/endmntent.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int endmntent(FILE *fp) 5 | { 6 | if (fp) 7 | fclose(fp); 8 | return 1; 9 | } 10 | -------------------------------------------------------------------------------- /usr/klibc/env.h: -------------------------------------------------------------------------------- 1 | #ifndef ENV_H 2 | #define ENV_H 3 | 4 | /* str should be a duplicated version of the input string; 5 | len is the length of the key including the = sign */ 6 | int __put_env(char *str, size_t len, int overwrite); 7 | 8 | extern char *const __null_environ[]; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /usr/klibc/execl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * execl.c 3 | */ 4 | 5 | #define NAME execl 6 | #define EXEC_P 0 7 | #define EXEC_E 0 8 | #include "exec_l.c" 9 | -------------------------------------------------------------------------------- /usr/klibc/execle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * execle.c 3 | */ 4 | 5 | #define NAME execle 6 | #define EXEC_P 0 7 | #define EXEC_E 1 8 | #include "exec_l.c" 9 | -------------------------------------------------------------------------------- /usr/klibc/execlp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * execlp.c 3 | */ 4 | 5 | #define NAME execlp 6 | #define EXEC_P 1 7 | #define EXEC_E 0 8 | #include "exec_l.c" 9 | -------------------------------------------------------------------------------- /usr/klibc/execlpe.c: -------------------------------------------------------------------------------- 1 | /* 2 | * execlpe.c 3 | */ 4 | 5 | #define NAME execlpe 6 | #define EXEC_P 1 7 | #define EXEC_E 1 8 | #include "exec_l.c" 9 | -------------------------------------------------------------------------------- /usr/klibc/execv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * execv.c 3 | */ 4 | 5 | #include 6 | 7 | int execv(const char *path, char *const *argv) 8 | { 9 | return execve(path, argv, environ); 10 | } 11 | -------------------------------------------------------------------------------- /usr/klibc/execvp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * execvp.c 3 | */ 4 | 5 | #include 6 | 7 | int execvp(const char *path, char *const *argv) 8 | { 9 | return execvpe(path, argv, environ); 10 | } 11 | -------------------------------------------------------------------------------- /usr/klibc/fgetc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fgetc.c 3 | * 4 | * Extremely slow fgetc implementation, using _fread(). If people 5 | * actually need character-oriented input to be fast, we may actually 6 | * have to implement buffering. Sigh. 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | int fgetc(FILE *f) 14 | { 15 | unsigned char ch; 16 | 17 | return (_fread(&ch, 1, f) == 1) ? (int)ch : EOF; 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/fgets.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fgets.c 3 | * 4 | * This will be very slow due to the implementation of getc(), 5 | * but we don't have anywhere to put characters we don't need from 6 | * the input. 7 | */ 8 | 9 | #include 10 | 11 | char *fgets(char *s, int n, FILE *f) 12 | { 13 | int ch; 14 | char *p = s; 15 | 16 | while (n > 1) { 17 | ch = getc(f); 18 | if (ch == EOF) { 19 | *p = '\0'; 20 | return NULL; 21 | } 22 | *p++ = ch; 23 | n--; 24 | if (ch == '\n') 25 | break; 26 | } 27 | if (n) 28 | *p = '\0'; 29 | 30 | return s; 31 | } 32 | -------------------------------------------------------------------------------- /usr/klibc/fork.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fork.c 3 | * 4 | * This is normally just a syscall stub, but at least one system 5 | * doesn't have sys_fork, only sys_clone... 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #if !_KLIBC_NO_MMU && !defined(__NR_fork) 15 | 16 | pid_t fork(void) 17 | { 18 | return __clone(SIGCHLD, 0); 19 | } 20 | 21 | #endif /* __NR_fork */ 22 | -------------------------------------------------------------------------------- /usr/klibc/fprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fprintf.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | #define BUFFER_SIZE 16384 9 | 10 | int fprintf(FILE * file, const char *format, ...) 11 | { 12 | va_list ap; 13 | int rv; 14 | 15 | va_start(ap, format); 16 | rv = vfprintf(file, format, ap); 17 | va_end(ap); 18 | return rv; 19 | } 20 | -------------------------------------------------------------------------------- /usr/klibc/fputc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fputc.c 3 | * 4 | * gcc "printf decompilation" expects this to exist... 5 | */ 6 | 7 | #include 8 | 9 | int fputc(int c, FILE *f) 10 | { 11 | unsigned char ch = c; 12 | 13 | return _fwrite(&ch, 1, f) == 1 ? ch : EOF; 14 | } 15 | -------------------------------------------------------------------------------- /usr/klibc/fputs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fputs.c 3 | * 4 | * This isn't quite fputs() in the stdio sense, since we don't 5 | * have stdio, but it takes a file descriptor argument instead 6 | * of the FILE *. 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | int fputs(const char *s, FILE *file) 13 | { 14 | return _fwrite(s, strlen(s), file); 15 | } 16 | -------------------------------------------------------------------------------- /usr/klibc/fread2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fread2.c 3 | * 4 | * The actual fread() function as a non-inline 5 | */ 6 | 7 | #define __NO_FREAD_FWRITE_INLINES 8 | #include 9 | 10 | size_t fread(void *ptr, size_t size, size_t nmemb, FILE * f) 11 | { 12 | return _fread(ptr, size * nmemb, f) / size; 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/fstatfs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fstatfs.c 3 | * 4 | * On architectures which do fstatfs64, wrap the system call 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #ifdef __NR_fstatfs64 11 | 12 | extern int __fstatfs64(int, size_t, struct statfs *); 13 | 14 | int fstatfs(int fd, struct statfs *buf) 15 | { 16 | return __fstatfs64(fd, sizeof *buf, buf); 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /usr/klibc/fwrite2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fwrite2.c 3 | * 4 | * The actual fwrite() function as a non-inline 5 | */ 6 | 7 | #define __NO_FREAD_FWRITE_INLINES 8 | #include 9 | 10 | size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE * f) 11 | { 12 | return _fwrite(ptr, size * nmemb, f) / size; 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/getcwd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getcwd.c 3 | * 4 | * The system call behaves differently than the library function. 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | extern int __getcwd(char *buf, size_t size); 11 | 12 | char *getcwd(char *buf, size_t size) 13 | { 14 | return (__getcwd(buf, size) < 0) ? NULL : buf; 15 | } 16 | -------------------------------------------------------------------------------- /usr/klibc/getdomainname.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getdomainname.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int getdomainname(char *name, size_t len) 11 | { 12 | struct utsname un; 13 | 14 | if (!uname(&un)) 15 | return -1; 16 | 17 | if (len < strlen(un.domainname) + 1) { 18 | errno = EINVAL; 19 | return -1; 20 | } 21 | 22 | strcpy(name, un.domainname); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /usr/klibc/getenv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getenv.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | char *getenv(const char *name) 10 | { 11 | char **p, *q; 12 | int len = strlen(name); 13 | 14 | if (!environ) 15 | return NULL; 16 | 17 | for (p = environ; (q = *p); p++) { 18 | if (!strncmp(name, q, len) && q[len] == '=') { 19 | return q + (len + 1); 20 | } 21 | } 22 | 23 | return NULL; 24 | } 25 | -------------------------------------------------------------------------------- /usr/klibc/gethostname.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gethostname.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int gethostname(char *name, size_t len) 11 | { 12 | struct utsname un; 13 | 14 | if (!uname(&un)) 15 | return -1; 16 | 17 | if (len < strlen(un.nodename) + 1) { 18 | errno = EINVAL; 19 | return -1; 20 | } 21 | 22 | strcpy(name, un.nodename); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /usr/klibc/getpgrp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getpgrp.c 3 | */ 4 | 5 | #include 6 | 7 | pid_t getpgrp(void) 8 | { 9 | return getpgid(0); 10 | } 11 | -------------------------------------------------------------------------------- /usr/klibc/getpriority.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getpriority.c 3 | * 4 | * Needs to do some post-syscall mangling to distinguish error returns... 5 | * but only on some platforms. Sigh. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #if !defined(__alpha__) && !defined(__ia64__) 14 | 15 | extern int __getpriority(int, int); 16 | 17 | int getpriority(int which, int who) 18 | { 19 | int rv = __getpriority(which, who); 20 | return (rv < 0) ? rv : 20-rv; 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /usr/klibc/getpt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getpt.c 3 | * 4 | * GNU extension to the standard Unix98 pty suite 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int getpt(void) 14 | { 15 | return open("/dev/ptmx", O_RDWR | O_NOCTTY); 16 | } 17 | -------------------------------------------------------------------------------- /usr/klibc/globals.c: -------------------------------------------------------------------------------- 1 | /* 2 | * globals.c 3 | * 4 | * These have to be defined somewhere... 5 | */ 6 | #include 7 | #include 8 | 9 | int errno; 10 | char **environ; 11 | -------------------------------------------------------------------------------- /usr/klibc/inet/inet_addr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * inet/inet_addr.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | uint32_t inet_addr(const char *str) 9 | { 10 | struct in_addr a; 11 | int rv = inet_aton(str, &a); 12 | 13 | return rv ? a.s_addr : INADDR_NONE; 14 | } 15 | -------------------------------------------------------------------------------- /usr/klibc/inet/inet_aton.c: -------------------------------------------------------------------------------- 1 | /* 2 | * inet/inet_aton.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int inet_aton(const char *str, struct in_addr *addr) 9 | { 10 | union { 11 | uint8_t b[4]; 12 | uint32_t l; 13 | } a; 14 | 15 | if (sscanf(str, "%hhu.%hhu.%hhu.%hhu", 16 | &a.b[0], &a.b[1], &a.b[2], &a.b[3]) == 4) { 17 | addr->s_addr = a.l; /* Always in network byte order */ 18 | return 1; 19 | } else { 20 | return 0; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /usr/klibc/inet/inet_ntoa.c: -------------------------------------------------------------------------------- 1 | /* 2 | * inet/inet_ntoa.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | char *inet_ntoa(struct in_addr addr) 10 | { 11 | static char name[16]; 12 | const uint8_t *cp = (const uint8_t *) &addr.s_addr; 13 | 14 | sprintf(name, "%u.%u.%u.%u", cp[0], cp[1], cp[2], cp[3]); 15 | return name; 16 | } 17 | -------------------------------------------------------------------------------- /usr/klibc/interp.S: -------------------------------------------------------------------------------- 1 | # 2 | # This is a hack to generate the .intrp section, which then 3 | # ld turns into an PT_INTERP header. 4 | # 5 | # NOTE: The .interp section needs to be "a", or it doesnt work... 6 | # 7 | 8 | .section ".interp","a" 9 | .ascii LIBDIR 10 | .ascii "/klibc-" 11 | .ascii SOHASH 12 | .ascii ".so" 13 | .byte 0 14 | -------------------------------------------------------------------------------- /usr/klibc/isatty.c: -------------------------------------------------------------------------------- 1 | /* 2 | * isatty.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int isatty(int fd) 10 | { 11 | int old_errno = errno; 12 | int istty; 13 | pid_t dummy; 14 | 15 | /* All ttys support TIOCGPGRP */ 16 | istty = !ioctl(fd, TIOCGPGRP, &dummy); 17 | errno = old_errno; 18 | 19 | return istty; 20 | } 21 | -------------------------------------------------------------------------------- /usr/klibc/jrand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jrand48.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | long jrand48(unsigned short xsubi[3]) 9 | { 10 | uint64_t x; 11 | 12 | /* The xsubi[] array is littleendian by spec */ 13 | x = (uint64_t) (uint16_t) xsubi[0] + 14 | ((uint64_t) (uint16_t) xsubi[1] << 16) + 15 | ((uint64_t) (uint16_t) xsubi[2] << 32); 16 | 17 | x = (0x5deece66dULL * x) + 0xb; 18 | 19 | xsubi[0] = (unsigned short)(uint16_t) x; 20 | xsubi[1] = (unsigned short)(uint16_t) (x >> 16); 21 | xsubi[2] = (unsigned short)(uint16_t) (x >> 32); 22 | 23 | return (long)(int32_t) (x >> 16); 24 | } 25 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__ashldi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libgcc/__ashldi3.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | uint64_t __ashldi3(uint64_t v, int cnt) 9 | { 10 | int c = cnt & 31; 11 | uint32_t vl = (uint32_t) v; 12 | uint32_t vh = (uint32_t) (v >> 32); 13 | 14 | if (cnt & 32) { 15 | vh = (vl << c); 16 | vl = 0; 17 | } else { 18 | vh = (vh << c) + (vl >> (32 - c)); 19 | vl = (vl << c); 20 | } 21 | 22 | return ((uint64_t) vh << 32) + vl; 23 | } 24 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__ashrdi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libgcc/__ashrdi3.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | uint64_t __ashrdi3(uint64_t v, int cnt) 9 | { 10 | int c = cnt & 31; 11 | uint32_t vl = (uint32_t) v; 12 | uint32_t vh = (uint32_t) (v >> 32); 13 | 14 | if (cnt & 32) { 15 | vl = ((int32_t) vh >> c); 16 | vh = (int32_t) vh >> 31; 17 | } else { 18 | vl = (vl >> c) + (vh << (32 - c)); 19 | vh = ((int32_t) vh >> c); 20 | } 21 | 22 | return ((uint64_t) vh << 32) + vl; 23 | } 24 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__clzsi2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libgcc/__clzsi2.c 3 | * 4 | * Returns the leading number of 0 bits in the argument 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | uint32_t __clzsi2(uint32_t v) 11 | { 12 | int p = 31; 13 | 14 | if (v & 0xffff0000) { 15 | p -= 16; 16 | v >>= 16; 17 | } 18 | if (v & 0xff00) { 19 | p -= 8; 20 | v >>= 8; 21 | } 22 | if (v & 0xf0) { 23 | p -= 4; 24 | v >>= 4; 25 | } 26 | if (v & 0xc) { 27 | p -= 2; 28 | v >>= 2; 29 | } 30 | if (v & 0x2) { 31 | p -= 1; 32 | v >>= 1; 33 | } 34 | 35 | return p; 36 | } 37 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__divdi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__divdi3.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem); 9 | 10 | int64_t __divdi3(int64_t num, int64_t den) 11 | { 12 | int minus = 0; 13 | int64_t v; 14 | 15 | if (num < 0) { 16 | num = -num; 17 | minus = 1; 18 | } 19 | if (den < 0) { 20 | den = -den; 21 | minus ^= 1; 22 | } 23 | 24 | v = __udivmoddi4(num, den, NULL); 25 | if (minus) 26 | v = -v; 27 | 28 | return v; 29 | } 30 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__divsi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libgcc/__divsi3.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem); 9 | 10 | int32_t __divsi3(int32_t num, int32_t den) 11 | { 12 | int minus = 0; 13 | int32_t v; 14 | 15 | if (num < 0) { 16 | num = -num; 17 | minus = 1; 18 | } 19 | if (den < 0) { 20 | den = -den; 21 | minus ^= 1; 22 | } 23 | 24 | v = __udivmodsi4(num, den, NULL); 25 | if (minus) 26 | v = -v; 27 | 28 | return v; 29 | } 30 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__lshrdi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libgcc/__lshrdi3.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | uint64_t __lshrdi3(uint64_t v, int cnt) 9 | { 10 | int c = cnt & 31; 11 | uint32_t vl = (uint32_t) v; 12 | uint32_t vh = (uint32_t) (v >> 32); 13 | 14 | if (cnt & 32) { 15 | vl = (vh >> c); 16 | vh = 0; 17 | } else { 18 | vl = (vl >> c) + (vh << (32 - c)); 19 | vh = (vh >> c); 20 | } 21 | 22 | return ((uint64_t) vh << 32) + vl; 23 | } 24 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__moddi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__moddi3.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem); 9 | 10 | int64_t __moddi3(int64_t num, int64_t den) 11 | { 12 | int minus = 0; 13 | int64_t v; 14 | 15 | if (num < 0) { 16 | num = -num; 17 | minus = 1; 18 | } 19 | if (den < 0) { 20 | den = -den; 21 | minus ^= 1; 22 | } 23 | 24 | (void)__udivmoddi4(num, den, (uint64_t *) & v); 25 | if (minus) 26 | v = -v; 27 | 28 | return v; 29 | } 30 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__modsi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libgcc/__modsi3.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem); 9 | 10 | int32_t __modsi3(int32_t num, int32_t den) 11 | { 12 | int minus = 0; 13 | int32_t v; 14 | 15 | if (num < 0) { 16 | num = -num; 17 | minus = 1; 18 | } 19 | if (den < 0) { 20 | den = -den; 21 | minus ^= 1; 22 | } 23 | 24 | (void)__udivmodsi4(num, den, (uint32_t *) & v); 25 | if (minus) 26 | v = -v; 27 | 28 | return v; 29 | } 30 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__udivdi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__divdi3.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem); 9 | 10 | uint64_t __udivdi3(uint64_t num, uint64_t den) 11 | { 12 | return __udivmoddi4(num, den, NULL); 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__udivmoddi4.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem_p) 5 | { 6 | uint64_t quot = 0, qbit = 1; 7 | 8 | if (den == 0) { 9 | __divide_error(); 10 | return 0; /* If trap returns... */ 11 | } 12 | 13 | /* Left-justify denominator and count shift */ 14 | while ((int64_t) den >= 0) { 15 | den <<= 1; 16 | qbit <<= 1; 17 | } 18 | 19 | while (qbit) { 20 | if (den <= num) { 21 | num -= den; 22 | quot += qbit; 23 | } 24 | den >>= 1; 25 | qbit >>= 1; 26 | } 27 | 28 | if (rem_p) 29 | *rem_p = num; 30 | 31 | return quot; 32 | } 33 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__udivmodsi4.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem_p) 5 | { 6 | uint32_t quot = 0, qbit = 1; 7 | 8 | if (den == 0) { 9 | __divide_error(); 10 | return 0; /* If trap returns... */ 11 | } 12 | 13 | /* Left-justify denominator and count shift */ 14 | while ((int32_t) den >= 0) { 15 | den <<= 1; 16 | qbit <<= 1; 17 | } 18 | 19 | while (qbit) { 20 | if (den <= num) { 21 | num -= den; 22 | quot += qbit; 23 | } 24 | den >>= 1; 25 | qbit >>= 1; 26 | } 27 | 28 | if (rem_p) 29 | *rem_p = num; 30 | 31 | return quot; 32 | } 33 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__udivsi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libgcc/__divsi3.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem); 9 | 10 | uint32_t __udivsi3(uint32_t num, uint32_t den) 11 | { 12 | return __udivmodsi4(num, den, NULL); 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__umoddi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__umoddi3.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem); 9 | 10 | uint64_t __umoddi3(uint64_t num, uint64_t den) 11 | { 12 | uint64_t v; 13 | 14 | (void)__udivmoddi4(num, den, &v); 15 | return v; 16 | } 17 | -------------------------------------------------------------------------------- /usr/klibc/libgcc/__umodsi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libgcc/__umodsi3.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem); 9 | 10 | uint32_t __umodsi3(uint32_t num, uint32_t den) 11 | { 12 | uint32_t v; 13 | 14 | (void)__udivmodsi4(num, den, &v); 15 | return v; 16 | } 17 | -------------------------------------------------------------------------------- /usr/klibc/lrand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lrand48.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | unsigned short __rand48_seed[3]; /* Common with mrand48.c, srand48.c */ 9 | 10 | long lrand48(void) 11 | { 12 | return (uint32_t) jrand48(__rand48_seed) >> 1; 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/memccpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memccpy.c 3 | * 4 | * memccpy() 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | void *memccpy(void *dst, const void *src, int c, size_t n) 11 | { 12 | char *q = dst; 13 | const char *p = src; 14 | char ch; 15 | 16 | while (n--) { 17 | *q++ = ch = *p++; 18 | if (ch == (char)c) 19 | return q; 20 | } 21 | 22 | return NULL; /* No instance of "c" found */ 23 | } 24 | -------------------------------------------------------------------------------- /usr/klibc/memchr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memchr.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | void *memchr(const void *s, int c, size_t n) 9 | { 10 | const unsigned char *sp = s; 11 | 12 | while (n--) { 13 | if (*sp == (unsigned char)c) 14 | return (void *)sp; 15 | sp++; 16 | } 17 | 18 | return NULL; 19 | } 20 | -------------------------------------------------------------------------------- /usr/klibc/memcmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memcmp.c 3 | */ 4 | 5 | #include 6 | 7 | int memcmp(const void *s1, const void *s2, size_t n) 8 | { 9 | const unsigned char *c1 = s1, *c2 = s2; 10 | int d = 0; 11 | 12 | while (n--) { 13 | d = (int)*c1++ - (int)*c2++; 14 | if (d) 15 | break; 16 | } 17 | 18 | return d; 19 | } 20 | -------------------------------------------------------------------------------- /usr/klibc/memcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memcpy.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | void *memcpy(void *dst, const void *src, size_t n) 9 | { 10 | const char *p = src; 11 | char *q = dst; 12 | #if defined(__i386__) 13 | size_t nl = n >> 2; 14 | asm volatile ("cld ; rep ; movsl ; movl %3,%0 ; rep ; movsb":"+c" (nl), 15 | "+S"(p), "+D"(q) 16 | :"r"(n & 3)); 17 | #elif defined(__x86_64__) 18 | size_t nq = n >> 3; 19 | asm volatile ("cld ; rep ; movsq ; movl %3,%%ecx ; rep ; movsb":"+c" 20 | (nq), "+S"(p), "+D"(q) 21 | :"r"((uint32_t) (n & 7))); 22 | #else 23 | while (n--) { 24 | *q++ = *p++; 25 | } 26 | #endif 27 | 28 | return dst; 29 | } 30 | -------------------------------------------------------------------------------- /usr/klibc/memmove.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memmove.c 3 | */ 4 | 5 | #include 6 | 7 | void *memmove(void *dst, const void *src, size_t n) 8 | { 9 | const char *p = src; 10 | char *q = dst; 11 | #if defined(__i386__) || defined(__x86_64__) 12 | if (q < p) { 13 | asm volatile("cld; rep; movsb" 14 | : "+c" (n), "+S"(p), "+D"(q)); 15 | } else { 16 | p += (n - 1); 17 | q += (n - 1); 18 | asm volatile("std; rep; movsb; cld" 19 | : "+c" (n), "+S"(p), "+D"(q)); 20 | } 21 | #else 22 | if (q < p) { 23 | while (n--) { 24 | *q++ = *p++; 25 | } 26 | } else { 27 | p += n; 28 | q += n; 29 | while (n--) { 30 | *--q = *--p; 31 | } 32 | } 33 | #endif 34 | 35 | return dst; 36 | } 37 | -------------------------------------------------------------------------------- /usr/klibc/memrchr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memrchr.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | void *memrchr(const void *s, int c, size_t n) 9 | { 10 | const unsigned char *sp = (const unsigned char *)s + n - 1; 11 | 12 | while (n--) { 13 | if (*sp == (unsigned char)c) 14 | return (void *)sp; 15 | sp--; 16 | } 17 | 18 | return NULL; 19 | } 20 | -------------------------------------------------------------------------------- /usr/klibc/memswap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memswap() 3 | * 4 | * Swaps the contents of two nonoverlapping memory areas. 5 | * This really could be done faster... 6 | */ 7 | 8 | #include 9 | 10 | void memswap(void *m1, void *m2, size_t n) 11 | { 12 | char *p = m1; 13 | char *q = m2; 14 | char tmp; 15 | 16 | while (n--) { 17 | tmp = *p; 18 | *p = *q; 19 | *q = tmp; 20 | 21 | p++; 22 | q++; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /usr/klibc/mrand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mrand48.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | unsigned short __rand48_seed[3]; /* Common with lrand48.c, srand48.c */ 9 | 10 | long mrand48(void) 11 | { 12 | return jrand48(__rand48_seed); 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/nice.c: -------------------------------------------------------------------------------- 1 | /* 2 | * nice.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #ifndef __NR_nice 11 | 12 | int nice(int inc) 13 | { 14 | pid_t me = getpid(); 15 | return setpriority(me, PRIO_PROCESS, 16 | getpriority(me, PRIO_PROCESS) + inc); 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /usr/klibc/nrand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * nrand48.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | long nrand48(unsigned short xsubi[3]) 9 | { 10 | return (long)((uint32_t) jrand48(xsubi) >> 1); 11 | } 12 | -------------------------------------------------------------------------------- /usr/klibc/nullenv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * nullenv.c 3 | */ 4 | 5 | #include 6 | #include "env.h" 7 | 8 | char * const __null_environ[] = { NULL }; 9 | -------------------------------------------------------------------------------- /usr/klibc/onexit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * onexit.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include "atexit.h" 8 | 9 | int on_exit(void (*fctn) (int, void *), void *arg) 10 | { 11 | struct atexit *as = malloc(sizeof(struct atexit)); 12 | 13 | if (!as) 14 | return -1; 15 | 16 | as->fctn = fctn; 17 | as->arg = arg; 18 | 19 | as->next = __atexit_list; 20 | __atexit_list = as; 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /usr/klibc/open.c: -------------------------------------------------------------------------------- 1 | /* 2 | * open.c 3 | * 4 | * On 32-bit platforms we need to pass O_LARGEFILE to the open() 5 | * system call, to indicate that we're 64-bit safe. 6 | */ 7 | 8 | #define _KLIBC_IN_OPEN_C 9 | #include 10 | #include 11 | #include 12 | 13 | #if _BITSIZE == 32 && !defined(__i386__) 14 | 15 | extern int __open(const char *, int, mode_t); 16 | 17 | int open(const char *pathname, int flags, mode_t mode) 18 | { 19 | return __open(pathname, flags | O_LARGEFILE, mode); 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /usr/klibc/open_cloexec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * open_cloexec.c 3 | * 4 | * A quick hack to do an open() and set the cloexec flag 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | int open_cloexec(const char *path, int flags, mode_t mode) 11 | { 12 | int fd = open(path, flags, mode); 13 | 14 | if (fd >= 0) 15 | fcntl(fd, F_SETFD, FD_CLOEXEC); 16 | 17 | return fd; 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/openat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * openat.c 3 | * 4 | * On 32-bit platforms we need to pass O_LARGEFILE to the openat() 5 | * system call, to indicate that we're 64-bit safe. 6 | */ 7 | 8 | #define _KLIBC_IN_OPEN_C 9 | #include 10 | #include 11 | #include 12 | 13 | #if _BITSIZE == 32 && !defined(__i386__) && defined(__NR_openat) 14 | 15 | extern int __openat(int, const char *, int, mode_t); 16 | 17 | int openat(int dirfd, const char *pathname, int flags, mode_t mode) 18 | { 19 | return __openat(dirfd, pathname, flags | O_LARGEFILE, mode); 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /usr/klibc/pause.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pause.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #ifndef __NR_pause 11 | 12 | int pause(void) 13 | { 14 | return select(0, NULL, NULL, NULL, NULL); 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /usr/klibc/perror.c: -------------------------------------------------------------------------------- 1 | /* 2 | * perror.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | void perror(const char *s) 10 | { 11 | int e = errno; 12 | fprintf(stderr, "%s: %s\n", s, strerror(e)); 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/posix_openpt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * posix_openpt.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | int posix_openpt(int oflag) 12 | { 13 | return open("/dev/ptmx", oflag); 14 | } 15 | -------------------------------------------------------------------------------- /usr/klibc/ppoll.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ppoll.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | #ifdef __NR_ppoll 9 | 10 | __extern int __ppoll(struct pollfd *, nfds_t, struct timespec *, 11 | const sigset_t *, size_t); 12 | 13 | int ppoll(struct pollfd *ufds, nfds_t nfds, struct timespec *timeout, 14 | const sigset_t * sigmask) 15 | { 16 | return __ppoll(ufds, nfds, timeout, sigmask, sizeof *sigmask); 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /usr/klibc/printf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * printf.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | #define BUFFER_SIZE 16384 9 | 10 | int printf(const char *format, ...) 11 | { 12 | va_list ap; 13 | int rv; 14 | 15 | va_start(ap, format); 16 | rv = vfprintf(stdout, format, ap); 17 | va_end(ap); 18 | return rv; 19 | } 20 | -------------------------------------------------------------------------------- /usr/klibc/pty.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pty.c 3 | * 4 | * Basic Unix98 PTY functionality; assumes devpts mounted on /dev/pts 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | char *ptsname(int fd) 14 | { 15 | static char buffer[32]; /* Big enough to hold even a 64-bit pts no */ 16 | unsigned int ptyno; 17 | 18 | if (ioctl(fd, TIOCGPTN, &ptyno)) 19 | return NULL; 20 | 21 | snprintf(buffer, sizeof buffer, "/dev/pts/%u", ptyno); 22 | 23 | return buffer; 24 | } 25 | 26 | int unlockpt(int fd) 27 | { 28 | int unlock = 0; 29 | 30 | return ioctl(fd, TIOCSPTLCK, &unlock); 31 | } 32 | -------------------------------------------------------------------------------- /usr/klibc/putchar.c: -------------------------------------------------------------------------------- 1 | /* 2 | * putchar.c 3 | * 4 | * - gcc wants this 5 | */ 6 | 7 | #include 8 | 9 | #undef putchar /* Defined as a macro */ 10 | int putchar(int); 11 | 12 | int putchar(int c) 13 | { 14 | return fputc(c, stdout); 15 | } 16 | -------------------------------------------------------------------------------- /usr/klibc/putenv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * putenv.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "env.h" 10 | 11 | int putenv(const char *str) 12 | { 13 | char *s; 14 | const char *e, *z; 15 | 16 | if (!str) { 17 | errno = EINVAL; 18 | return -1; 19 | } 20 | 21 | e = NULL; 22 | for (z = str; *z; z++) { 23 | if (*z == '=') 24 | e = z; 25 | } 26 | 27 | if (!e) { 28 | errno = EINVAL; 29 | return -1; 30 | } 31 | 32 | s = strdup(str); 33 | if (!s) 34 | return -1; 35 | 36 | return __put_env(s, e - str, 1); 37 | } 38 | -------------------------------------------------------------------------------- /usr/klibc/puts.c: -------------------------------------------------------------------------------- 1 | /* 2 | * puts.c 3 | */ 4 | 5 | #include 6 | 7 | int puts(const char *s) 8 | { 9 | if (fputs(s, stdout) < 0) 10 | return -1; 11 | 12 | return _fwrite("\n", 1, stdout); 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/raise.c: -------------------------------------------------------------------------------- 1 | /* 2 | * raise.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int raise(int signal) 9 | { 10 | return kill(getpid(), signal); 11 | } 12 | -------------------------------------------------------------------------------- /usr/klibc/reboot.c: -------------------------------------------------------------------------------- 1 | /* 2 | * reboot.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* This provides the one-argument glibc-ish version of reboot. 10 | The full four-argument system call is available as __reboot(). */ 11 | 12 | int reboot(int flag) 13 | { 14 | return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, flag, NULL); 15 | } 16 | -------------------------------------------------------------------------------- /usr/klibc/recv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * recv.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int recv(int s, void *buf, size_t len, unsigned int flags) 9 | { 10 | return recvfrom(s, buf, len, flags, NULL, 0); 11 | } 12 | -------------------------------------------------------------------------------- /usr/klibc/remove.c: -------------------------------------------------------------------------------- 1 | /* 2 | * remove.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int remove(const char *pathname) 10 | { 11 | int rv; 12 | 13 | rv = unlink(pathname); 14 | if (rv == -1 && errno == EISDIR) 15 | return rmdir(pathname); 16 | 17 | return rv; 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/seed48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * seed48.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | unsigned short __rand48_seed[3]; 10 | 11 | unsigned short *seed48(const unsigned short xsubi[3]) 12 | { 13 | static unsigned short oldseed[3]; 14 | memcpy(oldseed, __rand48_seed, sizeof __rand48_seed); 15 | memcpy(__rand48_seed, xsubi, sizeof __rand48_seed); 16 | 17 | return oldseed; 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/send.c: -------------------------------------------------------------------------------- 1 | /* 2 | * send.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int send(int s, const void *buf, size_t len, unsigned int flags) 9 | { 10 | return sendto(s, buf, len, flags, NULL, 0); 11 | } 12 | -------------------------------------------------------------------------------- /usr/klibc/setegid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * setegid.c 3 | */ 4 | 5 | #include 6 | 7 | int setegid(gid_t egid) 8 | { 9 | return setregid(-1, egid); 10 | } 11 | -------------------------------------------------------------------------------- /usr/klibc/seteuid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * seteuid.c 3 | */ 4 | 5 | #include 6 | 7 | int seteuid(uid_t euid) 8 | { 9 | return setreuid(-1, euid); 10 | } 11 | -------------------------------------------------------------------------------- /usr/klibc/setmntent.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | FILE *setmntent(const char *filename, const char *type) 5 | { 6 | return fopen(filename, type); 7 | } 8 | -------------------------------------------------------------------------------- /usr/klibc/setpgrp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * setpgrp.c 3 | */ 4 | 5 | #include 6 | 7 | int setpgrp(void) 8 | { 9 | return setpgid(0, 0); 10 | } 11 | -------------------------------------------------------------------------------- /usr/klibc/shm_open.c: -------------------------------------------------------------------------------- 1 | /* 2 | * shm_open.c 3 | * 4 | * POSIX shared memory support 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | int shm_open(const char *path, int oflag, mode_t mode) 15 | { 16 | int len = strlen(path); 17 | char *pathbuf = alloca(len+10); 18 | 19 | memcpy(pathbuf, "/dev/shm/", 9); 20 | memcpy(pathbuf+9, path, len+1); 21 | 22 | return open_cloexec(path, oflag, mode); 23 | } 24 | -------------------------------------------------------------------------------- /usr/klibc/shm_unlink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * shm_unlink.c 3 | * 4 | * POSIX shared memory support 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | int shm_unlink(const char *path) 15 | { 16 | int len = strlen(path); 17 | char *pathbuf = alloca(len+10); 18 | 19 | memcpy(pathbuf, "/dev/shm/", 9); 20 | memcpy(pathbuf+9, path, len+1); 21 | 22 | return unlink(path); 23 | } 24 | -------------------------------------------------------------------------------- /usr/klibc/siglongjmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * siglongjmp.c 3 | * 4 | * sigsetjmp() is a macro, by necessity (it's either that or write 5 | * it in assembly), but siglongjmp() is a normal function. 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | __noreturn siglongjmp(sigjmp_buf buf, int retval) 12 | { 13 | sigprocmask(SIG_SETMASK, &buf->__sigs, NULL); 14 | longjmp(buf->__jmpbuf, retval); 15 | } 16 | -------------------------------------------------------------------------------- /usr/klibc/sigpending.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sigpending.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #if _KLIBC_USE_RT_SIG 10 | 11 | __extern int __rt_sigpending(sigset_t *, size_t); 12 | 13 | int sigpending(sigset_t * set) 14 | { 15 | return __rt_sigpending(set, sizeof(sigset_t)); 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /usr/klibc/sigprocmask.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sigprocmask.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #if _KLIBC_USE_RT_SIG 10 | 11 | __extern int __rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t); 12 | 13 | int sigprocmask(int how, const sigset_t * set, sigset_t * oset) 14 | { 15 | return __rt_sigprocmask(how, set, oset, sizeof(sigset_t)); 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /usr/klibc/sigsuspend.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sigsuspend.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #if _KLIBC_USE_RT_SIG 10 | 11 | __extern int __rt_sigsuspend(const sigset_t *, size_t); 12 | 13 | int sigsuspend(const sigset_t * mask) 14 | { 15 | return __rt_sigsuspend(mask, sizeof *mask); 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /usr/klibc/sleep.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sleep.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | unsigned int sleep(unsigned int seconds) 11 | { 12 | struct timespec ts; 13 | 14 | ts.tv_sec = seconds; 15 | ts.tv_nsec = 0; 16 | if (!nanosleep(&ts, &ts)) 17 | return 0; 18 | else if (errno == EINTR) 19 | return ts.tv_sec; 20 | else 21 | return -1; 22 | } 23 | -------------------------------------------------------------------------------- /usr/klibc/snprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * snprintf.c 3 | */ 4 | 5 | #include 6 | 7 | int snprintf(char *buffer, size_t n, const char *format, ...) 8 | { 9 | va_list ap; 10 | int rv; 11 | 12 | va_start(ap, format); 13 | rv = vsnprintf(buffer, n, format, ap); 14 | va_end(ap); 15 | return rv; 16 | } 17 | -------------------------------------------------------------------------------- /usr/klibc/socketcalls/.gitignore: -------------------------------------------------------------------------------- 1 | *.S 2 | *.c 3 | SOCKETCALLS.i 4 | socketcalls.mk 5 | -------------------------------------------------------------------------------- /usr/klibc/socketcalls/socketcommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * socketcommon.h 3 | * 4 | * Common header file for socketcall stubs 5 | */ 6 | 7 | #define __IN_SYS_COMMON 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | -------------------------------------------------------------------------------- /usr/klibc/sprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sprintf.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int sprintf(char *buffer, const char *format, ...) 9 | { 10 | va_list ap; 11 | int rv; 12 | 13 | va_start(ap, format); 14 | rv = vsnprintf(buffer, ~(size_t) 0, format, ap); 15 | va_end(ap); 16 | 17 | return rv; 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/srand48.c: -------------------------------------------------------------------------------- 1 | /* 2 | * srand48.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | unsigned short __rand48_seed[3]; /* Common with mrand48.c, lrand48.c */ 9 | 10 | void srand48(long seedval) 11 | { 12 | __rand48_seed[0] = 0x330e; 13 | __rand48_seed[1] = (unsigned short)seedval; 14 | __rand48_seed[2] = (unsigned short)((uint32_t) seedval >> 16); 15 | } 16 | -------------------------------------------------------------------------------- /usr/klibc/sscanf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sscanf() 3 | */ 4 | 5 | #include 6 | 7 | int sscanf(const char *str, const char *format, ...) 8 | { 9 | va_list ap; 10 | int rv; 11 | 12 | va_start(ap, format); 13 | rv = vsscanf(str, format, ap); 14 | va_end(ap); 15 | 16 | return rv; 17 | } 18 | -------------------------------------------------------------------------------- /usr/klibc/statfs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * statfs.c 3 | * 4 | * On architectures which do statfs64, wrap the system call 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #ifdef __NR_statfs64 11 | 12 | extern int __statfs64(const char *, size_t, struct statfs *); 13 | 14 | int statfs(const char *path, struct statfs *buf) 15 | { 16 | return __statfs64(path, sizeof *buf, buf); 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /usr/klibc/stdio/fclose.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fclose.c 3 | */ 4 | 5 | #include "stdioint.h" 6 | 7 | int fclose(FILE *f) 8 | { 9 | int rv; 10 | 11 | fflush(f); 12 | 13 | rv = close(f->fd); 14 | 15 | /* Remove from linked list */ 16 | f->next->prev = f->prev; 17 | f->prev->next = f->next; 18 | 19 | free(f->buf); 20 | free(f); 21 | 22 | return rv; 23 | } 24 | -------------------------------------------------------------------------------- /usr/klibc/stdio/fdopen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fdopen.c 3 | */ 4 | 5 | #include "stdioint.h" 6 | 7 | FILE *fdopen(int fd, const char *mode) 8 | { 9 | int flags = __parse_open_mode(mode); 10 | int oldflags; 11 | 12 | if (fcntl(fd, F_GETFL, &oldflags)) 13 | return NULL; 14 | 15 | oldflags = (oldflags & ~O_APPEND) | (flags & O_APPEND); 16 | if (fcntl(fd, F_SETFL, &oldflags)) 17 | return NULL; 18 | 19 | return __fxopen(fd, flags, 0); 20 | } 21 | -------------------------------------------------------------------------------- /usr/klibc/stdio/feof.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int feof(FILE *f) 4 | { 5 | return f->flags & _IO_FILE_FLAG_EOF; 6 | } 7 | -------------------------------------------------------------------------------- /usr/klibc/stdio/ferror.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int ferror(FILE *f) 4 | { 5 | return f->flags & _IO_FILE_FLAG_ERR; 6 | } 7 | -------------------------------------------------------------------------------- /usr/klibc/stdio/fopen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fopen.c 3 | */ 4 | 5 | #include "stdioint.h" 6 | 7 | extern int __parse_open_mode(const char *); 8 | 9 | FILE *fopen(const char *file, const char *mode) 10 | { 11 | int flags = __parse_open_mode(mode); 12 | int fd; 13 | 14 | fd = open(file, flags, 0666); 15 | if (fd < 0) 16 | return NULL; 17 | 18 | return __fxopen(fd, flags, 1); 19 | } 20 | -------------------------------------------------------------------------------- /usr/klibc/stdio/fputc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fputc.c 3 | */ 4 | 5 | #include "stdioint.h" 6 | 7 | int __fputc(int c, FILE *f) 8 | { 9 | if (f->bytes >= f->bufsiz) 10 | fflush(f); 11 | 12 | *f->buf++ = c; 13 | f->flags |= _IO_FILE_FLAG_WRITE; 14 | 15 | if (f->flags & _IO_FILE_LINE_BUF && c == '\n') 16 | fflush(f); 17 | } 18 | 19 | int fputc(int c, FILE *f) 20 | { 21 | __fputc(c, f); 22 | if (f->flags & _IO_FILE_UNBUF) 23 | fflush(f); 24 | } 25 | -------------------------------------------------------------------------------- /usr/klibc/stdio/fseek.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fseek.c 3 | */ 4 | 5 | #include "stdioint.h" 6 | 7 | __extern int fseek(FILE *f, off_t where, int whence) 8 | { 9 | off_t rv; 10 | 11 | fflush(f); 12 | 13 | rv = lseek(f->fd, where, whence); 14 | if (rv != -1) { 15 | f->filepos = rv; 16 | f->bytes = 0; 17 | f->flags &= ~_IO_FILE_FLAG_READ; 18 | return 0; 19 | } else { 20 | return -1; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /usr/klibc/stdio/stdioint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stdioint.h 3 | * 4 | * stdio internals 5 | */ 6 | 7 | #ifndef USR_KLIBC_STDIO_STDIOINT_H 8 | #define USR_KLIBC_STDIO_STDIOINT_H 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | /* Assign this much extra to the input buffer in case of ungetc() */ 17 | #define _IO_UNGET_SLOP 32 18 | 19 | __extern int __parse_open_mode(const char *mode); 20 | __extern FILE *__fxopen(int fd, int flags, int close_on_err); 21 | __extern int __fputc(int c, FILE *f); 22 | 23 | __extern struct _IO_file __stdio_headnode; 24 | 25 | #endif /* USR_KLIBC_STDIO_STDIOINT_H */ 26 | -------------------------------------------------------------------------------- /usr/klibc/stdio/ungetc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ungetc.c 3 | */ 4 | 5 | #include "stdioint.h" 6 | 7 | int ungetc(int c, FILE *f) 8 | { 9 | if (f->flags & _IO_FILE_FLAG_WRITE || f->offset <= 0) 10 | return EOF; 11 | 12 | f->buf[--f->offset] = c; 13 | f->bytes++; 14 | f->flags |= _IO_FILE_FLAG_READ; 15 | return c; 16 | } 17 | -------------------------------------------------------------------------------- /usr/klibc/strcasecmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strcasecmp.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int strcasecmp(const char *s1, const char *s2) 9 | { 10 | const unsigned char *c1 = (const unsigned char *)s1; 11 | const unsigned char *c2 = (const unsigned char *)s2; 12 | unsigned char ch; 13 | int d = 0; 14 | 15 | while (1) { 16 | /* toupper() expects an unsigned char (implicitly cast to int) 17 | as input, and returns an int, which is exactly what we want. */ 18 | d = toupper(ch = *c1++) - toupper(*c2++); 19 | if (d || !ch) 20 | break; 21 | } 22 | 23 | return d; 24 | } 25 | -------------------------------------------------------------------------------- /usr/klibc/strcat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strcat.c 3 | */ 4 | 5 | #include 6 | 7 | char *strcat(char *dst, const char *src) 8 | { 9 | strcpy(strchr(dst, '\0'), src); 10 | return dst; 11 | } 12 | -------------------------------------------------------------------------------- /usr/klibc/strchr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strchr.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | char *strchr(const char *s, int c) 9 | { 10 | while (*s != (char)c) { 11 | if (!*s) 12 | return NULL; 13 | s++; 14 | } 15 | 16 | return (char *)s; 17 | } 18 | 19 | __ALIAS(char *, index, (const char *, int), strchr) 20 | -------------------------------------------------------------------------------- /usr/klibc/strcmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strcmp.c 3 | */ 4 | 5 | #include 6 | 7 | int strcmp(const char *s1, const char *s2) 8 | { 9 | const unsigned char *c1 = (const unsigned char *)s1; 10 | const unsigned char *c2 = (const unsigned char *)s2; 11 | unsigned char ch; 12 | int d = 0; 13 | 14 | while (1) { 15 | d = (int)(ch = *c1++) - (int)*c2++; 16 | if (d || !ch) 17 | break; 18 | } 19 | 20 | return d; 21 | } 22 | -------------------------------------------------------------------------------- /usr/klibc/strcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strcpy.c 3 | * 4 | * strcpy() 5 | */ 6 | 7 | #include 8 | 9 | char *strcpy(char *dst, const char *src) 10 | { 11 | char *q = dst; 12 | const char *p = src; 13 | char ch; 14 | 15 | do { 16 | *q++ = ch = *p++; 17 | } while (ch); 18 | 19 | return dst; 20 | } 21 | -------------------------------------------------------------------------------- /usr/klibc/strcspn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strcspn 3 | */ 4 | 5 | #include 6 | 7 | #include "strxspn.h" 8 | 9 | size_t strcspn(const char *s, const char *reject) 10 | { 11 | return __strxspn(s, reject, 1); 12 | } 13 | -------------------------------------------------------------------------------- /usr/klibc/strdup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strdup.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | char *strdup(const char *s) 9 | { 10 | int l = strlen(s) + 1; 11 | char *d = malloc(l); 12 | 13 | if (d) 14 | memcpy(d, s, l); 15 | 16 | return d; 17 | } 18 | -------------------------------------------------------------------------------- /usr/klibc/strlcat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strlcat.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | size_t strlcat(char *dst, const char *src, size_t size) 9 | { 10 | size_t bytes = 0; 11 | char *q = dst; 12 | const char *p = src; 13 | char ch; 14 | 15 | while (bytes < size && *q) { 16 | q++; 17 | bytes++; 18 | } 19 | if (bytes == size) 20 | return (bytes + strlen(src)); 21 | 22 | while ((ch = *p++)) { 23 | if (bytes + 1 < size) 24 | *q++ = ch; 25 | 26 | bytes++; 27 | } 28 | 29 | *q = '\0'; 30 | return bytes; 31 | } 32 | -------------------------------------------------------------------------------- /usr/klibc/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strlcpy.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | size_t strlcpy(char *dst, const char *src, size_t size) 9 | { 10 | size_t bytes = 0; 11 | char *q = dst; 12 | const char *p = src; 13 | char ch; 14 | 15 | while ((ch = *p++)) { 16 | if (bytes + 1 < size) 17 | *q++ = ch; 18 | 19 | bytes++; 20 | } 21 | 22 | /* If size == 0 there is no space for a final null... */ 23 | if (size) 24 | *q = '\0'; 25 | 26 | return bytes; 27 | } 28 | -------------------------------------------------------------------------------- /usr/klibc/strlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strlen() 3 | */ 4 | 5 | #include 6 | 7 | size_t strlen(const char *s) 8 | { 9 | const char *ss = s; 10 | while (*ss) 11 | ss++; 12 | return ss - s; 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/strncasecmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strncasecmp.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int strncasecmp(const char *s1, const char *s2, size_t n) 9 | { 10 | const unsigned char *c1 = (const unsigned char *)s1; 11 | const unsigned char *c2 = (const unsigned char *)s2; 12 | unsigned char ch; 13 | int d = 0; 14 | 15 | while (n--) { 16 | /* toupper() expects an unsigned char (implicitly cast to int) 17 | as input, and returns an int, which is exactly what we want. */ 18 | d = toupper(ch = *c1++) - toupper(*c2++); 19 | if (d || !ch) 20 | break; 21 | } 22 | 23 | return d; 24 | } 25 | -------------------------------------------------------------------------------- /usr/klibc/strncat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strncat.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | char *strncat(char *dst, const char *src, size_t n) 9 | { 10 | char *q = strchr(dst, '\0'); 11 | const char *p = src; 12 | char ch; 13 | 14 | while (n--) { 15 | *q++ = ch = *p++; 16 | if (!ch) 17 | return dst; 18 | } 19 | *q = '\0'; 20 | 21 | return dst; 22 | } 23 | -------------------------------------------------------------------------------- /usr/klibc/strncmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strncmp.c 3 | */ 4 | 5 | #include 6 | 7 | int strncmp(const char *s1, const char *s2, size_t n) 8 | { 9 | const unsigned char *c1 = (const unsigned char *)s1; 10 | const unsigned char *c2 = (const unsigned char *)s2; 11 | unsigned char ch; 12 | int d = 0; 13 | 14 | while (n--) { 15 | d = (int)(ch = *c1++) - (int)*c2++; 16 | if (d || !ch) 17 | break; 18 | } 19 | 20 | return d; 21 | } 22 | -------------------------------------------------------------------------------- /usr/klibc/strncpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strncpy.c 3 | */ 4 | 5 | #include 6 | 7 | char *strncpy(char *dst, const char *src, size_t n) 8 | { 9 | char *q = dst; 10 | const char *p = src; 11 | char ch; 12 | 13 | while (n) { 14 | n--; 15 | *q++ = ch = *p++; 16 | if (!ch) 17 | break; 18 | } 19 | 20 | /* The specs say strncpy() fills the entire buffer with NUL. Sigh. */ 21 | memset(q, 0, n); 22 | 23 | return dst; 24 | } 25 | -------------------------------------------------------------------------------- /usr/klibc/strndup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strndup.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | char *strndup(const char *s, size_t n) 9 | { 10 | size_t l = strnlen(s, n); 11 | char *d = malloc(l + 1); 12 | if (!d) 13 | return NULL; 14 | 15 | memcpy(d, s, l); 16 | d[l] = '\0'; 17 | return d; 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/strnlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strnlen() 3 | */ 4 | 5 | #include 6 | 7 | size_t strnlen(const char *s, size_t maxlen) 8 | { 9 | const char *ss = s; 10 | 11 | /* Important: the maxlen test must precede the reference through ss; 12 | since the byte beyond the maximum may segfault */ 13 | while ((maxlen > 0) && *ss) { 14 | ss++; 15 | maxlen--; 16 | } 17 | return ss - s; 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/strntoimax.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strntoimax.c 3 | * 4 | * strntoimax() 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | intmax_t strntoimax(const char *nptr, char **endptr, int base, size_t n) 11 | { 12 | return (intmax_t) strntoumax(nptr, endptr, base, n); 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/strpbrk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strpbrk 3 | */ 4 | 5 | #include 6 | 7 | #include "strxspn.h" 8 | 9 | char *strpbrk(const char *s, const char *accept) 10 | { 11 | const char *ss = s + __strxspn(s, accept, 1); 12 | 13 | return *ss ? (char *)ss : NULL; 14 | } 15 | -------------------------------------------------------------------------------- /usr/klibc/strrchr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strrchr.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | char *strrchr(const char *s, int c) 9 | { 10 | const char *found = NULL; 11 | 12 | while (*s) { 13 | if (*s == (char)c) 14 | found = s; 15 | s++; 16 | } 17 | 18 | return (char *)found; 19 | } 20 | 21 | __ALIAS(char *, rindex, (const char *, int), strrchr) 22 | -------------------------------------------------------------------------------- /usr/klibc/strsep.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strsep.c 3 | */ 4 | 5 | #include 6 | 7 | char *strsep(char **stringp, const char *delim) 8 | { 9 | char *s = *stringp; 10 | char *e; 11 | 12 | if (!s) 13 | return NULL; 14 | 15 | e = strpbrk(s, delim); 16 | if (e) 17 | *e++ = '\0'; 18 | 19 | *stringp = e; 20 | return s; 21 | } 22 | -------------------------------------------------------------------------------- /usr/klibc/strsignal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strsignal.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | char *strsignal(int sig) 10 | { 11 | static char buf[64]; 12 | 13 | if ((unsigned)sig < _NSIG && sys_siglist[sig]) 14 | return (char *)sys_siglist[sig]; 15 | 16 | #ifdef SIGRTMIN 17 | if (sig >= SIGRTMIN && sig <= SIGRTMAX) { 18 | snprintf(buf, sizeof buf, "Real-time signal %d", 19 | sig - SIGRTMIN); 20 | return buf; 21 | } 22 | #endif 23 | 24 | snprintf(buf, sizeof buf, "Signal %d", sig); 25 | return buf; 26 | } 27 | -------------------------------------------------------------------------------- /usr/klibc/strspn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strspn 3 | */ 4 | 5 | #include 6 | 7 | #include "strxspn.h" 8 | 9 | size_t strspn(const char *s, const char *accept) 10 | { 11 | return __strxspn(s, accept, 0); 12 | } 13 | -------------------------------------------------------------------------------- /usr/klibc/strstr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strstr.c 3 | */ 4 | 5 | #include 6 | 7 | char *strstr(const char *haystack, const char *needle) 8 | { 9 | return (char *)memmem(haystack, strlen(haystack), needle, 10 | strlen(needle)); 11 | } 12 | -------------------------------------------------------------------------------- /usr/klibc/strtoimax.c: -------------------------------------------------------------------------------- 1 | #define TYPE intmax_t 2 | #define NAME strtoimax 3 | #include "strtox.c" 4 | -------------------------------------------------------------------------------- /usr/klibc/strtok.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strtok.c 3 | */ 4 | 5 | #include 6 | 7 | char *strtok(char *s, const char *delim) 8 | { 9 | static char *holder; 10 | 11 | return strtok_r(s, delim, &holder); 12 | } 13 | -------------------------------------------------------------------------------- /usr/klibc/strtok_r.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strtok_r(char *s, const char *delim, char **holder) 4 | { 5 | if (s) 6 | *holder = s; 7 | 8 | do { 9 | s = strsep(holder, delim); 10 | } while (s && !*s); 11 | 12 | return s; 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/strtol.c: -------------------------------------------------------------------------------- 1 | #define TYPE signed long 2 | #define NAME strtol 3 | #include "strtox.c" 4 | -------------------------------------------------------------------------------- /usr/klibc/strtoll.c: -------------------------------------------------------------------------------- 1 | #define TYPE signed long long 2 | #define NAME strtoll 3 | #include "strtox.c" 4 | -------------------------------------------------------------------------------- /usr/klibc/strtotimespec.c: -------------------------------------------------------------------------------- 1 | #define NAME strtotimespec 2 | #define TIMEX struct timespec 3 | #define FSEC tv_nsec 4 | #define DECIMALS 9 5 | #include "strtotimex.c" 6 | -------------------------------------------------------------------------------- /usr/klibc/strtotimeval.c: -------------------------------------------------------------------------------- 1 | #define NAME strtotimeval 2 | #define TIMEX struct timeval 3 | #define FSEC tv_usec 4 | #define DECIMALS 6 5 | #include "strtotimex.c" 6 | -------------------------------------------------------------------------------- /usr/klibc/strtoul.c: -------------------------------------------------------------------------------- 1 | #define TYPE unsigned long 2 | #define NAME strtoul 3 | #include "strtox.c" 4 | -------------------------------------------------------------------------------- /usr/klibc/strtoull.c: -------------------------------------------------------------------------------- 1 | #define TYPE unsigned long long 2 | #define NAME strtoull 3 | #include "strtox.c" 4 | -------------------------------------------------------------------------------- /usr/klibc/strtoumax.c: -------------------------------------------------------------------------------- 1 | #define TYPE uintmax_t 2 | #define NAME strtoumax 3 | #include "strtox.c" 4 | -------------------------------------------------------------------------------- /usr/klibc/strtox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strtox.c 3 | * 4 | * strto...() functions, by macro definition 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | TYPE NAME(const char *nptr, char **endptr, int base) 12 | { 13 | return (TYPE) strntoumax(nptr, endptr, base, ~(size_t) 0); 14 | } 15 | -------------------------------------------------------------------------------- /usr/klibc/strxspn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strpbrk 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "strxspn.h" 10 | 11 | size_t __strxspn(const char *s, const char *map, int parity) 12 | { 13 | char matchmap[UCHAR_MAX + 1]; 14 | size_t n = 0; 15 | 16 | /* Create bitmap */ 17 | memset(matchmap, 0, sizeof matchmap); 18 | while (*map) 19 | matchmap[(unsigned char)*map++] = 1; 20 | 21 | /* Make sure the null character never matches */ 22 | matchmap[0] = parity; 23 | 24 | /* Calculate span length */ 25 | while (matchmap[(unsigned char)*s++] ^ parity) 26 | n++; 27 | 28 | return n; 29 | } 30 | -------------------------------------------------------------------------------- /usr/klibc/strxspn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * strxspn.h 3 | */ 4 | 5 | #ifndef STRXSPN_H 6 | #define STRXSPN_H 7 | 8 | #include 9 | 10 | extern size_t __strxspn(const char *s, const char *map, int parity); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /usr/klibc/syscalls/.gitignore: -------------------------------------------------------------------------------- 1 | *.S 2 | SYSCALLS.i 3 | syscalls.mk 4 | syscalls.nrs 5 | typesize.bin 6 | typesize.c 7 | -------------------------------------------------------------------------------- /usr/klibc/sysv_signal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sysv_signal.c 3 | */ 4 | 5 | #include 6 | 7 | __sighandler_t sysv_signal(int signum, __sighandler_t handler) 8 | { 9 | /* Linux/SysV signal() semantics */ 10 | return __signal(signum, handler, SA_RESETHAND); 11 | } 12 | -------------------------------------------------------------------------------- /usr/klibc/tests/environ.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[], char *envp[]) 6 | { 7 | int i; 8 | 9 | /* Verify envp == environ */ 10 | printf("Verifying envp == environ... %s\n", 11 | (envp == environ) ? "ok" : "ERROR"); 12 | 13 | /* Test argc/argv */ 14 | printf("argc = %d, argv = %p\n", argc, argv); 15 | for (i = 0; i < argc; i++) 16 | printf("argv[%2d] = %s\n", i, argv[i]); 17 | 18 | /* Test environ */ 19 | for (i = 0; envp[i]; i++) 20 | printf("%s\n", envp[i]); 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /usr/klibc/tests/fnmatch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | int flags = atoi(argv[3]); 8 | int match = fnmatch(argv[1], argv[2], flags); 9 | 10 | printf("\"%s\" matches \"%s\": %d\n", argv[1], argv[2], match); 11 | 12 | return match; 13 | } 14 | -------------------------------------------------------------------------------- /usr/klibc/tests/getpagesize.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | printf("getpagesize() = %d\n" 7 | "__getpageshift() = %d\n", getpagesize(), __getpageshift()); 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /usr/klibc/tests/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | printf("Hello, World!\n"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /usr/klibc/tests/idtest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | printf("pid = %u\n", getpid()); 7 | printf("ppid = %u\n", getppid()); 8 | printf("uid = %u\n", getuid()); 9 | printf("euid = %u\n", geteuid()); 10 | printf("gid = %u\n", getgid()); 11 | printf("egid = %u\n", getegid()); 12 | sleep(10); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /usr/klibc/tests/memstrtest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) 6 | { 7 | unsigned char t1[256], t2[256]; 8 | int i; 9 | int r; 10 | 11 | for (i = 0; i < (int)sizeof(t1); i++) 12 | t1[i] = t2[i] = (unsigned char)i; 13 | 14 | r = memcmp(t1, t2, sizeof(t1)); 15 | printf("memcmp r = %d\n", r); 16 | r = memcmp(t1, t2, sizeof(t1) / 2); 17 | printf("memcmp r = %d\n", r); 18 | t1[255] = 0; 19 | r = memcmp(t1, t2, sizeof(t1)); 20 | printf("memcmp r = %d\n", r); 21 | 22 | for (i = 0; i < (int)sizeof(t1); i++) 23 | t1[i] = 0xaa; 24 | memset(t2, 0xaa, sizeof(t2)); 25 | r = memcmp(t1, t2, sizeof(t1)); 26 | printf("memcmp r = %d\n", r); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /usr/klibc/tests/microhello.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | static const char hello[] = "Hello, World!\n"; 7 | _fwrite(hello, sizeof hello - 1, stdout); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /usr/klibc/tests/minihello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | fputs("Hello, World!\n", stdout); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /usr/klibc/tests/opentest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | char buffer[1024]; 6 | FILE *f; 7 | 8 | f = fopen("/etc/passwd", "r"); 9 | fgets(buffer, 1024, f); 10 | fclose(f); 11 | 12 | printf("Line 1 = %s", buffer); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /usr/klibc/tests/rtsig.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | #ifdef SIGRTMIN 7 | printf("sigrtmin = %d, sigrtmax = %d\n", SIGRTMIN, SIGRTMAX); 8 | #else 9 | printf("No realtime signals\n"); 10 | #endif 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /usr/klibc/tests/setjmptest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * setjmptest.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | static jmp_buf buf; 9 | 10 | void do_stuff(int v) 11 | { 12 | printf("calling longjmp with %d... ", v + 1); 13 | longjmp(buf, v + 1); 14 | } 15 | 16 | void recurse(int ctr, int v) 17 | { 18 | if (ctr--) 19 | recurse(ctr, v); 20 | else 21 | do_stuff(v); 22 | 23 | printf("ERROR!\n"); /* We should never get here... */ 24 | } 25 | 26 | int main(void) 27 | { 28 | int v; 29 | 30 | v = setjmp(buf); 31 | printf("setjmp returned %d\n", v); 32 | 33 | if (v < 256) 34 | recurse(v, v); 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /usr/klibc/tests/socket.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | int ret; 9 | 10 | ret = socket(AF_INET, SOCK_DGRAM, 0); 11 | if (ret == -1) { 12 | fprintf(stderr, "klibc: socket(AF_INET): %s\n", 13 | strerror(errno)); 14 | return 1; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/tests/strtoimax.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strtoimaxtest.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int main(int argc, char *argv[]) 10 | { 11 | int i; 12 | char *ep; 13 | intmax_t iv; 14 | 15 | for (i = 1; i < argc; i++) { 16 | iv = strtoimax(argv[i], &ep, 0); 17 | printf("strtoimax(\"%s\") = %jd\n", argv[i], iv); 18 | if (*ep) 19 | printf(" ep = \"%s\"\n", ep); 20 | } 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /usr/klibc/tests/strtotime.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | struct timeval tv; 7 | struct timespec ts; 8 | int i; 9 | const char *rv, *rs; 10 | 11 | for (i = 1; i < argc; i++) { 12 | rs = strtotimespec(argv[i], &ts); 13 | rv = strtotimeval(argv[i], &tv); 14 | printf("String: \"%s\"\n" 15 | "Timespec: %ld.%09ld\n" 16 | "Residual: \"%s\"\n" 17 | "Timeval: %ld.%06ld\n" 18 | "Residual: \"%s\"\n", 19 | argv[i], 20 | (long)ts.tv_sec, (long)ts.tv_nsec, rs, 21 | (long)tv.tv_sec, (long)tv.tv_usec, rv); 22 | } 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /usr/klibc/tests/testrand48.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | unsigned short seed1[] = { 0x1234, 0x5678, 0x9abc }; 7 | unsigned short *oldseed; 8 | 9 | oldseed = seed48(seed1); 10 | printf("Initial seed: %#06x %#06x %#06x\n", 11 | oldseed[0], oldseed[1], oldseed[2]); 12 | 13 | printf("lrand48() = %ld\n", lrand48()); 14 | 15 | seed48(seed1); 16 | printf("mrand48() = %ld\n", mrand48()); 17 | 18 | return 1; 19 | } 20 | -------------------------------------------------------------------------------- /usr/klibc/time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * time.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #ifndef __NR_time 10 | 11 | time_t time(time_t * t) 12 | { 13 | struct timeval tv; 14 | 15 | gettimeofday(&tv, NULL); 16 | 17 | if (t) 18 | *t = (time_t) tv.tv_sec; 19 | 20 | return (time_t) tv.tv_sec; 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /usr/klibc/umount.c: -------------------------------------------------------------------------------- 1 | /* 2 | * umount.c 3 | * 4 | * Single-argument form of umount 5 | */ 6 | 7 | #include 8 | 9 | int umount(const char *dir) 10 | { 11 | return umount2(dir, 0); 12 | } 13 | -------------------------------------------------------------------------------- /usr/klibc/userdb/getgrgid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getgrgid.c 3 | * 4 | * Dummy getgrgid() to support udev 5 | */ 6 | 7 | #include 8 | 9 | #include "userdb.h" 10 | 11 | struct group *getgrgid(gid_t gid) 12 | { 13 | if (!gid) 14 | return (struct group *)&__root_group; 15 | 16 | errno = ENOENT; 17 | return NULL; 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/userdb/getgrnam.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getgrnam.c 3 | * 4 | * Dummy getgrnam() to support udev 5 | */ 6 | 7 | #include 8 | 9 | #include "userdb.h" 10 | 11 | struct group *getgrnam(const char *name) 12 | { 13 | if (!strcmp(name, "root")) 14 | return (struct group *)&__root_group; 15 | 16 | errno = ENOENT; 17 | return NULL; 18 | } 19 | -------------------------------------------------------------------------------- /usr/klibc/userdb/getpwnam.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getpwnam.c 3 | * 4 | * Dummy getpwnam() to support udev 5 | */ 6 | 7 | #include 8 | 9 | #include "userdb.h" 10 | 11 | 12 | struct passwd *getpwnam(const char *name) 13 | { 14 | if (!strcmp(name, "root")) 15 | return (struct passwd *)&__root_user; 16 | 17 | errno = ENOENT; 18 | return NULL; 19 | } 20 | -------------------------------------------------------------------------------- /usr/klibc/userdb/getpwuid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * getpwuid.c 3 | * 4 | * Dummy getpwuid() to support udev 5 | */ 6 | 7 | #include 8 | 9 | #include "userdb.h" 10 | 11 | 12 | struct passwd *getpwuid(uid_t uid) 13 | { 14 | if (!uid) 15 | return (struct passwd *)&__root_user; 16 | 17 | errno = ENOENT; 18 | return NULL; 19 | } 20 | -------------------------------------------------------------------------------- /usr/klibc/userdb/root_group.c: -------------------------------------------------------------------------------- 1 | /* 2 | * root_group.c 3 | */ 4 | 5 | #include "userdb.h" 6 | 7 | const struct group __root_group = { 8 | .gr_name = "root", 9 | .gr_passwd = "", 10 | .gr_gid = 0, 11 | .gr_mem = NULL 12 | }; 13 | -------------------------------------------------------------------------------- /usr/klibc/userdb/root_user.c: -------------------------------------------------------------------------------- 1 | /* 2 | * root_user.c 3 | * 4 | */ 5 | 6 | #include "userdb.h" 7 | #include 8 | 9 | const struct passwd __root_user = { 10 | .pw_name = "root", 11 | .pw_passwd = "", 12 | .pw_uid = 0, 13 | .pw_gid = 0, 14 | .pw_gecos = "root", 15 | .pw_dir = "/", 16 | .pw_shell = _PATH_BSHELL 17 | }; 18 | -------------------------------------------------------------------------------- /usr/klibc/userdb/userdb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * userdb.h 3 | * 4 | * Common header file 5 | */ 6 | 7 | #ifndef USERDB_H 8 | #define USERDB_H 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | extern const struct passwd __root_user; 17 | extern const struct group __root_group; 18 | 19 | #endif /* USERDB_H */ 20 | -------------------------------------------------------------------------------- /usr/klibc/usleep.c: -------------------------------------------------------------------------------- 1 | /* 2 | * usleep.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | void usleep(unsigned long usec) 11 | { 12 | struct timespec ts; 13 | 14 | ts.tv_sec = usec / 1000000UL; 15 | ts.tv_nsec = (usec % 1000000UL) * 1000; 16 | while (nanosleep(&ts, &ts) == -1 && errno == EINTR) ; 17 | } 18 | -------------------------------------------------------------------------------- /usr/klibc/utime.c: -------------------------------------------------------------------------------- 1 | /* 2 | * utime.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #ifndef __NR_utime 11 | 12 | int utime(const char *filename, const struct utimbuf *buf) 13 | { 14 | struct timeval tvp[2]; 15 | 16 | tvp[0].tv_sec = buf->actime; 17 | tvp[0].tv_usec = 0; 18 | tvp[1].tv_sec = buf->modtime; 19 | tvp[1].tv_usec = 0; 20 | 21 | return utimes(filename, tvp); 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /usr/klibc/vasprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * vasprintf.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int vasprintf(char **bufp, const char *format, va_list ap) 10 | { 11 | va_list ap1; 12 | int bytes; 13 | char *p; 14 | 15 | va_copy(ap1, ap); 16 | 17 | bytes = vsnprintf(NULL, 0, format, ap1) + 1; 18 | va_end(ap1); 19 | 20 | *bufp = p = malloc(bytes); 21 | if (!p) 22 | return -1; 23 | 24 | return vsnprintf(p, bytes, format, ap); 25 | } 26 | -------------------------------------------------------------------------------- /usr/klibc/version: -------------------------------------------------------------------------------- 1 | 2.0 2 | -------------------------------------------------------------------------------- /usr/klibc/vfork.c: -------------------------------------------------------------------------------- 1 | /* 2 | * vfork.c 3 | * 4 | * Emulate vfork() with fork() if necessary 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #if !_KLIBC_NO_MMU && !_KLIBC_REAL_VFORK 12 | int vfork(void) 13 | { 14 | return fork(); 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /usr/klibc/vfprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * vfprintf.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define BUFFER_SIZE 32768 11 | 12 | int vfprintf(FILE * file, const char *format, va_list ap) 13 | { 14 | int rv; 15 | char buffer[BUFFER_SIZE]; 16 | 17 | rv = vsnprintf(buffer, BUFFER_SIZE, format, ap); 18 | 19 | if (rv < 0) 20 | return rv; 21 | 22 | if (rv > BUFFER_SIZE - 1) 23 | rv = BUFFER_SIZE - 1; 24 | 25 | return _fwrite(buffer, rv, file); 26 | } 27 | -------------------------------------------------------------------------------- /usr/klibc/vprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * vprintf.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int vprintf(const char *format, va_list ap) 9 | { 10 | return vfprintf(stdout, format, ap); 11 | } 12 | -------------------------------------------------------------------------------- /usr/klibc/vsprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * vsprintf.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int vsprintf(char *buffer, const char *format, va_list ap) 9 | { 10 | return vsnprintf(buffer, ~(size_t) 0, format, ap); 11 | } 12 | -------------------------------------------------------------------------------- /usr/klibc/wait.c: -------------------------------------------------------------------------------- 1 | /* 2 | * wait.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | pid_t wait(int *status) 10 | { 11 | return wait4((pid_t) - 1, status, 0, NULL); 12 | } 13 | -------------------------------------------------------------------------------- /usr/klibc/wait3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * wait3.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | pid_t wait3(int *status, int options, struct rusage * rusage) 10 | { 11 | return wait4((pid_t) - 1, status, options, rusage); 12 | } 13 | -------------------------------------------------------------------------------- /usr/klibc/waitpid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * waitpid.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | pid_t waitpid(pid_t pid, int *status, int options) 10 | { 11 | return wait4(pid, status, options, NULL); 12 | } 13 | -------------------------------------------------------------------------------- /usr/klibc/zlib/Kbuild: -------------------------------------------------------------------------------- 1 | # zlib 2 | 3 | klib-y := adler32.o compress.o crc32.o gzio.o 4 | klib-y += uncompr.o deflate.o trees.o zutil.o 5 | klib-y += inflate.o infback.o inftrees.o inffast.o 6 | 7 | # zlib specific flag 8 | EXTRA_KLIBCCFLAGS := -DDYNAMIC_CRC_TABLE 9 | -------------------------------------------------------------------------------- /usr/klibc/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /usr/utils/chroot.c: -------------------------------------------------------------------------------- 1 | /* 2 | * by rmk 3 | */ 4 | #include 5 | #include 6 | 7 | int main(int argc, char *argv[], char *envp[]) 8 | { 9 | if (argc < 3) { 10 | fprintf(stderr, "Usage: %s newroot command...\n", argv[0]); 11 | return 1; 12 | } 13 | 14 | if (chroot(argv[1]) == -1) { 15 | perror("chroot"); 16 | return 1; 17 | } 18 | 19 | if (chdir("/") == -1) { 20 | perror("chdir"); 21 | return 1; 22 | } 23 | 24 | if (execvp(argv[2], argv + 2) == -1) { 25 | perror("execvp"); 26 | return 1; 27 | } 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /usr/utils/false.c: -------------------------------------------------------------------------------- 1 | int main(void) 2 | { 3 | return 1; 4 | } 5 | -------------------------------------------------------------------------------- /usr/utils/file_mode.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_FILE_MODE_H 2 | #define UTILS_FILE_MODE_H 3 | 4 | mode_t parse_file_mode(char *arg, mode_t mode, mode_t sumask); 5 | 6 | #endif /* UTILS_FILE_MODE_H */ 7 | -------------------------------------------------------------------------------- /usr/utils/kill.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | char *progname; 7 | 8 | static __noreturn usage(void) 9 | { 10 | fprintf(stderr, "Usage: %s pid\n", progname); 11 | exit(1); 12 | } 13 | int main(int argc, char *argv[]) 14 | { 15 | long pid; 16 | char *endp; 17 | 18 | progname = argv[0]; 19 | if (argc != 2) 20 | usage(); 21 | 22 | pid = strtol(argv[1], &endp, 10); 23 | if (*endp != '\0') { 24 | perror("pid"); 25 | usage(); 26 | } 27 | 28 | if (kill(pid, SIGTERM) == -1) { 29 | perror("kill"); 30 | exit(-1); 31 | } 32 | exit(0); 33 | } 34 | -------------------------------------------------------------------------------- /usr/utils/mount_opts.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_MOUNT_OPTS_H 2 | #define UTILS_MOUNT_OPTS_H 3 | 4 | struct mount_opts { 5 | const char str[8]; 6 | unsigned long rwmask; 7 | unsigned long rwset; 8 | unsigned long rwnoset; 9 | }; 10 | 11 | struct extra_opts { 12 | char *str; 13 | char *end; 14 | int used_size; 15 | int alloc_size; 16 | }; 17 | 18 | /* 19 | * These options define the function of "mount(2)". 20 | */ 21 | #define MS_TYPE (MS_REMOUNT|MS_BIND|MS_MOVE) 22 | 23 | unsigned long 24 | parse_mount_options(char *arg, unsigned long rwflag, struct extra_opts *extra); 25 | 26 | #endif /* UTILS_MOUNT_OPTS_H */ 27 | -------------------------------------------------------------------------------- /usr/utils/pivot_root.c: -------------------------------------------------------------------------------- 1 | /* Change the root file system */ 2 | 3 | /* Written 2000 by Werner Almesberger */ 4 | 5 | #include 6 | #include 7 | 8 | int main(int argc, const char **argv) 9 | { 10 | if (argc != 3) { 11 | fprintf(stderr, "Usage: %s new_root put_old\n", argv[0]); 12 | return 1; 13 | } 14 | if (pivot_root(argv[1], argv[2]) < 0) { 15 | perror("pivot_root"); 16 | return 1; 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /usr/utils/readlink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | char *progname; 7 | 8 | static __noreturn usage(void) 9 | { 10 | fprintf(stderr, "Usage: %s link\n", progname); 11 | exit(1); 12 | } 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | char *name, *link_name = NULL; 17 | size_t max_siz = 128; 18 | 19 | progname = *argv++; 20 | 21 | name = *argv++; 22 | if (!name) 23 | usage(); 24 | 25 | link_name = malloc(max_siz); 26 | if (!link_name) { 27 | perror("malloc"); 28 | exit(1); 29 | } 30 | 31 | if (readlink(name, link_name, max_siz) == -1) 32 | exit(1); 33 | printf("%s\n", link_name); 34 | 35 | exit(0); 36 | } 37 | -------------------------------------------------------------------------------- /usr/utils/sleep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | struct timespec ts; 9 | char *p; 10 | 11 | if (argc != 2) 12 | goto err; 13 | 14 | p = strtotimespec(argv[1], &ts); 15 | if (*p) 16 | goto err; 17 | 18 | while (nanosleep(&ts, &ts) == -1 && errno == EINTR) 19 | ; 20 | 21 | return 0; 22 | 23 | err: 24 | fprintf(stderr, "Usage: %s seconds[.fraction]\n", argv[0]); 25 | return 1; 26 | } 27 | -------------------------------------------------------------------------------- /usr/utils/sync.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) 4 | { 5 | sync(); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /usr/utils/true.c: -------------------------------------------------------------------------------- 1 | int main(void) 2 | { 3 | return 0; 4 | } 5 | --------------------------------------------------------------------------------