├── COPYING ├── Makefile ├── README ├── elf.py ├── gdb.py ├── kemufuzzer ├── kernel ├── Makefile ├── asm.c ├── boot.S ├── console.c ├── gen_ints_asm.py ├── grub_stuff │ ├── boot │ │ └── grub │ │ │ ├── e2fs_stage1_5 │ │ │ ├── fat_stage1_5 │ │ │ ├── jfs_stage1_5 │ │ │ ├── menu.lst │ │ │ ├── minix_stage1_5 │ │ │ ├── reiserfs_stage1_5 │ │ │ ├── stage1 │ │ │ ├── stage2 │ │ │ └── xfs_stage1_5 │ └── grub.cfg ├── include │ ├── bits │ │ ├── a.out.h │ │ ├── byteswap.h │ │ ├── cmathcalls.h │ │ ├── confname.h │ │ ├── dirent.h │ │ ├── dlfcn.h │ │ ├── elfclass.h │ │ ├── endian.h │ │ ├── environments.h │ │ ├── errno.h │ │ ├── error.h │ │ ├── fcntl.h │ │ ├── fcntl2.h │ │ ├── fenv.h │ │ ├── fenvinline.h │ │ ├── huge_val.h │ │ ├── huge_valf.h │ │ ├── huge_vall.h │ │ ├── in.h │ │ ├── inf.h │ │ ├── initspin.h │ │ ├── ioctl-types.h │ │ ├── ioctls.h │ │ ├── ipc.h │ │ ├── ipctypes.h │ │ ├── libc-lock.h │ │ ├── libio-ldbl.h │ │ ├── link.h │ │ ├── local_lim.h │ │ ├── locale.h │ │ ├── mathcalls.h │ │ ├── mathdef.h │ │ ├── mathinline.h │ │ ├── mman.h │ │ ├── monetary-ldbl.h │ │ ├── mqueue.h │ │ ├── mqueue2.h │ │ ├── msq.h │ │ ├── nan.h │ │ ├── netdb.h │ │ ├── poll.h │ │ ├── posix1_lim.h │ │ ├── posix2_lim.h │ │ ├── posix_opt.h │ │ ├── printf-ldbl.h │ │ ├── pthreadtypes.h │ │ ├── resource.h │ │ ├── sched.h │ │ ├── select.h │ │ ├── sem.h │ │ ├── semaphore.h │ │ ├── setjmp.h │ │ ├── shm.h │ │ ├── sigaction.h │ │ ├── sigcontext.h │ │ ├── siginfo.h │ │ ├── signum.h │ │ ├── sigset.h │ │ ├── sigstack.h │ │ ├── sigthread.h │ │ ├── sockaddr.h │ │ ├── socket.h │ │ ├── socket2.h │ │ ├── stab.def │ │ ├── stat.h │ │ ├── statfs.h │ │ ├── statvfs.h │ │ ├── stdio-ldbl.h │ │ ├── stdio-lock.h │ │ ├── stdio.h │ │ ├── stdio2.h │ │ ├── stdio_lim.h │ │ ├── stdlib-ldbl.h │ │ ├── stdlib.h │ │ ├── string.h │ │ ├── string2.h │ │ ├── string3.h │ │ ├── stropts.h │ │ ├── sys_errlist.h │ │ ├── syscall.h │ │ ├── syslog-ldbl.h │ │ ├── syslog-path.h │ │ ├── syslog.h │ │ ├── termios.h │ │ ├── time.h │ │ ├── types.h │ │ ├── typesizes.h │ │ ├── uio.h │ │ ├── unistd.h │ │ ├── ustat.h │ │ ├── utmp.h │ │ ├── utmpx.h │ │ ├── utsname.h │ │ ├── waitflags.h │ │ ├── waitstatus.h │ │ ├── wchar-ldbl.h │ │ ├── wchar.h │ │ ├── wchar2.h │ │ ├── wordsize.h │ │ ├── xopen_lim.h │ │ └── xtitypes.h │ ├── features.h │ ├── gnu │ │ ├── lib-names.h │ │ ├── libc-version.h │ │ ├── stubs-32.h │ │ └── stubs.h │ ├── limits.h │ ├── linux │ │ └── limits.h │ ├── multiboot.h │ ├── printfcommon.h │ ├── printflocal.h │ ├── stdarg.h │ ├── stdint.h │ ├── stdio.h │ ├── sys │ │ ├── asm.h │ │ ├── cdefs.h │ │ ├── console.h │ │ ├── fpu.h │ │ ├── interrupt.h │ │ ├── mman.h │ │ ├── tss.h │ │ └── types.h │ └── types.h ├── kernel.h ├── kernel.ld ├── kprintf.c ├── loader.c ├── main.c └── tss.c ├── kvm.cc ├── kvm.h ├── libudis86 ├── Makefile ├── decode.c ├── decode.h ├── extern.h ├── input.c ├── input.h ├── itab.c ├── itab.h ├── opgen.py ├── syn-att.c ├── syn-intel.c ├── syn.c ├── syn.h ├── types.h ├── udis86.c └── udis86.h ├── patches ├── bochs-2.4.1.patch ├── bochs-2.4.5.patch ├── qemu-0.11.0.patch ├── qemu-0.12.4.patch ├── qemu-0.13.5.patch └── virtualbox-ose-3.0.8-dfsg.patch ├── run.makefile ├── tc.py ├── tc_generate ├── tc_template ├── tc_view ├── vmware_driver.py ├── x86.h ├── x86_cpustate.h ├── x86_cpustate.py └── x86_cpustate_diff /Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = -Wall -I. -I./libudis86/ 2 | ifndef VANILLA_KVM 3 | CFLAGS += -I./kvm-kmod/include 4 | endif 5 | LDFLAGS = -lz 6 | 7 | all: libudis86 kvm kernel 8 | 9 | kvm: libudis86/libudis86.a kvm.cc kvm.h x86.h x86_cpustate.h 10 | $(CXX) $(CFLAGS) -o kvm kvm.cc libudis86/libudis86.a $(LDFLAGS) 11 | 12 | libudis86: 13 | $(MAKE) -C libudis86 14 | 15 | kernel: 16 | $(MAKE) -C kernel disk 17 | 18 | clean: 19 | rm -f *.o *.a *.pyc 20 | $(MAKE) -C libudis86 clean 21 | $(MAKE) -C kernel clean 22 | 23 | distclean: clean 24 | rm -f kvm 25 | $(MAKE) -C libudis86 distclean 26 | 27 | .PHONY: all distclean libudis86 kernel 28 | -------------------------------------------------------------------------------- /kernel/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS += -Wall -m32 -O2 -nostdlib -nostdinc -nostartfiles -I./include/ 2 | LDFLAGS=-Wl,--script=kernel.ld,--build-id=none 3 | OBJS=boot.o loader.o kprintf.o console.o main.o interrupts.o asm.o int_wrappers.o tss.o 4 | DEST=kernel 5 | 6 | all: $(DEST) 7 | 8 | $(DEST): $(OBJS) 9 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ 10 | 11 | %.o: %.c 12 | $(CC) $(CFLAGS) -c -o $@ $< 13 | 14 | boot.o: boot.S 15 | $(CC) $(CFLAGS) -c -o $@ $< 16 | 17 | int_wrappers.o: int_wrappers.S 18 | $(CC) $(CFLAGS) -c -o $@ $< 19 | 20 | clean: 21 | -rm -f $(DEST) $(OBJS) floppy.img interrupts.c interrupts.h int_wrappers.S 22 | 23 | floppy.img: $(DEST) 24 | dd if=/dev/zero of=floppy.img bs=1024 count=1440 25 | /sbin/mkdosfs floppy.img 26 | mmd -i floppy.img boot 27 | mmd -i floppy.img boot/grub 28 | mcopy -i floppy.img grub_stuff/boot/grub/* ::boot/grub 29 | mcopy -i floppy.img kernel :: 30 | grub --batch --device-map=/dev/null < grub_stuff/grub.cfg 31 | 32 | disk: floppy.img 33 | 34 | int_wrappers.c interrupts.c interrupts.h: gen_ints_asm.py 35 | # use port 69 to notify interrupts & exceptions 36 | python gen_ints_asm.py 69 37 | 38 | # dependencies 39 | loader.o: interrupts.h 40 | -------------------------------------------------------------------------------- /kernel/boot.S: -------------------------------------------------------------------------------- 1 | // This file is part of KEmuFuzzer. 2 | // 3 | // KEmuFuzzer is free software: you can redistribute it and/or modify it under 4 | // the terms of the GNU General Public License as published by the Free 5 | // Software Foundation, either version 3 of the License, or (at your option) 6 | // any later version. 7 | // 8 | // KEmuFuzzer is distributed in the hope that it will be useful, but WITHOUT ANY 9 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 11 | // details. 12 | // 13 | // You should have received a copy of the GNU General Public License along with 14 | // KEmuFuzzer. If not, see . 15 | 16 | 17 | #define STACK_SIZE 0x4000 18 | 19 | .text 20 | .globl _start, start 21 | .type start, @function 22 | .type _start, @function 23 | start: 24 | _start: 25 | mov $(loaderstack + 0x2000), %esp ; 26 | push $0 27 | popf 28 | push %ebx ; 29 | push %eax ; 30 | call init ; 31 | endless: 32 | hlt 33 | jmp endless ; 34 | .lcomm loaderstack, STACK_SIZE 35 | -------------------------------------------------------------------------------- /kernel/console.c: -------------------------------------------------------------------------------- 1 | // This file is part of KEmuFuzzer. 2 | // 3 | // KEmuFuzzer is free software: you can redistribute it and/or modify it under 4 | // the terms of the GNU General Public License as published by the Free 5 | // Software Foundation, either version 3 of the License, or (at your option) 6 | // any later version. 7 | // 8 | // KEmuFuzzer is distributed in the hope that it will be useful, but WITHOUT ANY 9 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 11 | // details. 12 | // 13 | // You should have received a copy of the GNU General Public License along with 14 | // KEmuFuzzer. If not, see . 15 | 16 | #include 17 | #include 18 | 19 | static struct 20 | { 21 | int width; 22 | int height; 23 | struct 24 | { 25 | int x; 26 | int y; 27 | }cursor; 28 | } console; 29 | 30 | #define _X_ (console.cursor.x) 31 | #define _Y_ (console.cursor.y) 32 | #define HEIGHT (console.height) 33 | #define WIDTH (console.width) 34 | #define ATTRIBUTE 7 35 | 36 | void console_init(int w, int h) 37 | { 38 | console.width = w; 39 | console.height = h; 40 | console.cursor.x = 0; 41 | console.cursor.y = 0; 42 | console_cls(); 43 | } 44 | 45 | void console_cls(void) 46 | { 47 | int i; 48 | for(i=0;i= HEIGHT) 62 | _Y_ = 0; 63 | return; 64 | } 65 | 66 | *(VIDMEM + (_X_ + _Y_ * WIDTH) * 2) = c & 0xFF; 67 | *(VIDMEM + (_X_ + _Y_ * WIDTH) * 2 + 1) = ATTRIBUTE; 68 | 69 | _X_++; 70 | if (_X_ >= WIDTH) 71 | goto newline; 72 | } 73 | 74 | int console_print(char *s, int n) 75 | { 76 | int count; 77 | char *p; 78 | 79 | count = 0; 80 | 81 | p = s; 82 | while(*p && count < n) 83 | { 84 | console_putc(*p); 85 | p++; 86 | count ++; 87 | } 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /kernel/grub_stuff/boot/grub/e2fs_stage1_5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrmuizel/kemufuzzer/780ef603c35bb31e941e14d19f98f696583dc2d9/kernel/grub_stuff/boot/grub/e2fs_stage1_5 -------------------------------------------------------------------------------- /kernel/grub_stuff/boot/grub/fat_stage1_5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrmuizel/kemufuzzer/780ef603c35bb31e941e14d19f98f696583dc2d9/kernel/grub_stuff/boot/grub/fat_stage1_5 -------------------------------------------------------------------------------- /kernel/grub_stuff/boot/grub/jfs_stage1_5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrmuizel/kemufuzzer/780ef603c35bb31e941e14d19f98f696583dc2d9/kernel/grub_stuff/boot/grub/jfs_stage1_5 -------------------------------------------------------------------------------- /kernel/grub_stuff/boot/grub/menu.lst: -------------------------------------------------------------------------------- 1 | default 0 2 | timeout 0 3 | color cyan/blue white/blue 4 | 5 | title Basic Execution Environment 6 | root (fd0) 7 | kernel /kernel 8 | -------------------------------------------------------------------------------- /kernel/grub_stuff/boot/grub/minix_stage1_5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrmuizel/kemufuzzer/780ef603c35bb31e941e14d19f98f696583dc2d9/kernel/grub_stuff/boot/grub/minix_stage1_5 -------------------------------------------------------------------------------- /kernel/grub_stuff/boot/grub/reiserfs_stage1_5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrmuizel/kemufuzzer/780ef603c35bb31e941e14d19f98f696583dc2d9/kernel/grub_stuff/boot/grub/reiserfs_stage1_5 -------------------------------------------------------------------------------- /kernel/grub_stuff/boot/grub/stage1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrmuizel/kemufuzzer/780ef603c35bb31e941e14d19f98f696583dc2d9/kernel/grub_stuff/boot/grub/stage1 -------------------------------------------------------------------------------- /kernel/grub_stuff/boot/grub/stage2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrmuizel/kemufuzzer/780ef603c35bb31e941e14d19f98f696583dc2d9/kernel/grub_stuff/boot/grub/stage2 -------------------------------------------------------------------------------- /kernel/grub_stuff/boot/grub/xfs_stage1_5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrmuizel/kemufuzzer/780ef603c35bb31e941e14d19f98f696583dc2d9/kernel/grub_stuff/boot/grub/xfs_stage1_5 -------------------------------------------------------------------------------- /kernel/grub_stuff/grub.cfg: -------------------------------------------------------------------------------- 1 | device (fd0) floppy.img 2 | root (fd0) 3 | setup (fd0) 4 | quit -------------------------------------------------------------------------------- /kernel/include/bits/a.out.h: -------------------------------------------------------------------------------- 1 | #ifndef __A_OUT_GNU_H__ 2 | # error "Never use directly; include instead." 3 | #endif 4 | 5 | #include 6 | 7 | #if __WORDSIZE == 64 8 | 9 | /* Signal to users of this header that this architecture really doesn't 10 | support a.out binary format. */ 11 | #define __NO_A_OUT_SUPPORT 1 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /kernel/include/bits/dirent.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996, 1997 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _DIRENT_H 20 | # error "Never use directly; include instead." 21 | #endif 22 | 23 | struct dirent 24 | { 25 | #ifndef __USE_FILE_OFFSET64 26 | __ino_t d_ino; 27 | __off_t d_off; 28 | #else 29 | __ino64_t d_ino; 30 | __off64_t d_off; 31 | #endif 32 | unsigned short int d_reclen; 33 | unsigned char d_type; 34 | char d_name[256]; /* We must not include limits.h! */ 35 | }; 36 | 37 | #ifdef __USE_LARGEFILE64 38 | struct dirent64 39 | { 40 | __ino64_t d_ino; 41 | __off64_t d_off; 42 | unsigned short int d_reclen; 43 | unsigned char d_type; 44 | char d_name[256]; /* We must not include limits.h! */ 45 | }; 46 | #endif 47 | 48 | #define d_fileno d_ino /* Backwards compatibility. */ 49 | 50 | #undef _DIRENT_HAVE_D_NAMLEN 51 | #define _DIRENT_HAVE_D_RECLEN 52 | #define _DIRENT_HAVE_D_OFF 53 | #define _DIRENT_HAVE_D_TYPE 54 | -------------------------------------------------------------------------------- /kernel/include/bits/dlfcn.h: -------------------------------------------------------------------------------- 1 | /* System dependent definitions for run-time dynamic loading. 2 | Copyright (C) 1996-2001, 2004 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _DLFCN_H 21 | # error "Never use directly; include instead." 22 | #endif 23 | 24 | /* The MODE argument to `dlopen' contains one of the following: */ 25 | #define RTLD_LAZY 0x00001 /* Lazy function call binding. */ 26 | #define RTLD_NOW 0x00002 /* Immediate function call binding. */ 27 | #define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */ 28 | #define RTLD_NOLOAD 0x00004 /* Do not load the object. */ 29 | #define RTLD_DEEPBIND 0x00008 /* Use deep binding. */ 30 | 31 | /* If the following bit is set in the MODE argument to `dlopen', 32 | the symbols of the loaded object and its dependencies are made 33 | visible as if the object were linked directly into the program. */ 34 | #define RTLD_GLOBAL 0x00100 35 | 36 | /* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL. 37 | The implementation does this by default and so we can define the 38 | value to zero. */ 39 | #define RTLD_LOCAL 0 40 | 41 | /* Do not delete object when closed. */ 42 | #define RTLD_NODELETE 0x01000 43 | 44 | #ifdef __USE_GNU 45 | /* To support profiling of shared objects it is a good idea to call 46 | the function found using `dlsym' using the following macro since 47 | these calls do not use the PLT. But this would mean the dynamic 48 | loader has no chance to find out when the function is called. The 49 | macro applies the necessary magic so that profiling is possible. 50 | Rewrite 51 | foo = (*fctp) (arg1, arg2); 52 | into 53 | foo = DL_CALL_FCT (fctp, (arg1, arg2)); 54 | */ 55 | # define DL_CALL_FCT(fctp, args) \ 56 | (_dl_mcount_wrapper_check ((void *) (fctp)), (*(fctp)) args) 57 | 58 | __BEGIN_DECLS 59 | 60 | /* This function calls the profiling functions. */ 61 | extern void _dl_mcount_wrapper_check (void *__selfpc) __THROW; 62 | 63 | __END_DECLS 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /kernel/include/bits/elfclass.h: -------------------------------------------------------------------------------- 1 | /* This file specifies the native word size of the machine, which indicates 2 | the ELF file class used for executables and shared objects on this 3 | machine. */ 4 | 5 | #ifndef _LINK_H 6 | # error "Never use directly; include instead." 7 | #endif 8 | 9 | #include 10 | 11 | #define __ELF_NATIVE_CLASS __WORDSIZE 12 | 13 | /* The entries in the .hash table always have a size of 32 bits. */ 14 | typedef uint32_t Elf_Symndx; 15 | -------------------------------------------------------------------------------- /kernel/include/bits/endian.h: -------------------------------------------------------------------------------- 1 | /* x86_64 is little-endian. */ 2 | 3 | #ifndef _ENDIAN_H 4 | # error "Never use directly; include instead." 5 | #endif 6 | 7 | #define __BYTE_ORDER __LITTLE_ENDIAN 8 | -------------------------------------------------------------------------------- /kernel/include/bits/environments.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1999, 2001, 2004 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _UNISTD_H 20 | # error "Never include this file directly. Use instead" 21 | #endif 22 | 23 | #include 24 | 25 | /* This header should define the following symbols under the described 26 | situations. A value `1' means that the model is always supported, 27 | `-1' means it is never supported. Undefined means it cannot be 28 | statically decided. 29 | 30 | _POSIX_V6_ILP32_OFF32 32bit int, long, pointers, and off_t type 31 | _POSIX_V6_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type 32 | 33 | _POSIX_V6_LP64_OFF32 64bit long and pointers and 32bit off_t type 34 | _POSIX_V6_LPBIG_OFFBIG 64bit long and pointers and large off_t type 35 | 36 | The macros _XBS5_ILP32_OFF32, _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and 37 | _XBS5_LPBIG_OFFBIG were used in previous versions of the Unix standard 38 | and are available only for compatibility. 39 | */ 40 | 41 | #if __WORDSIZE == 64 42 | 43 | /* Environments with 32-bit wide pointers are optionally provided. 44 | Therefore following macros aren't defined: 45 | # undef _POSIX_V6_ILP32_OFF32 46 | # undef _POSIX_V6_ILP32_OFFBIG 47 | # undef _XBS5_ILP32_OFF32 48 | # undef _XBS5_ILP32_OFFBIG 49 | and users need to check at runtime. */ 50 | 51 | /* We also have no use (for now) for an environment with bigger pointers 52 | and offsets. */ 53 | # define _POSIX_V6_LPBIG_OFFBIG -1 54 | # define _XBS5_LPBIG_OFFBIG -1 55 | 56 | /* By default we have 64-bit wide `long int', pointers and `off_t'. */ 57 | # define _POSIX_V6_LP64_OFF64 1 58 | # define _XBS5_LP64_OFF64 1 59 | 60 | #else /* __WORDSIZE == 32 */ 61 | 62 | /* By default we have 32-bit wide `int', `long int', pointers and `off_t' 63 | and all platforms support LFS. */ 64 | # define _POSIX_V6_ILP32_OFF32 1 65 | # define _POSIX_V6_ILP32_OFFBIG 1 66 | # define _XBS5_ILP32_OFF32 1 67 | # define _XBS5_ILP32_OFFBIG 1 68 | 69 | /* We optionally provide an environment with the above size but an 64-bit 70 | side `off_t'. Therefore we don't define _XBS5_ILP32_OFFBIG. */ 71 | 72 | /* Environments with 64-bit wide pointers can be provided, 73 | so these macros aren't defined: 74 | # undef _POSIX_V6_LP64_OFF64 75 | # undef _POSIX_V6_LPBIG_OFFBIG 76 | # undef _XBS5_LP64_OFF64 77 | # undef _XBS5_LPBIG_OFFBIG 78 | and sysconf tests for it at runtime. */ 79 | 80 | #endif /* __WORDSIZE == 32 */ 81 | 82 | #define __ILP32_OFF32_CFLAGS "-m32" 83 | #define __ILP32_OFFBIG_CFLAGS "-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" 84 | #define __ILP32_OFF32_LDFLAGS "-m32" 85 | #define __ILP32_OFFBIG_LDFLAGS "-m32" 86 | #define __LP64_OFF64_CFLAGS "-m64" 87 | #define __LP64_OFF64_LDFLAGS "-m64" 88 | -------------------------------------------------------------------------------- /kernel/include/bits/errno.h: -------------------------------------------------------------------------------- 1 | /* Error constants. Linux specific version. 2 | Copyright (C) 1996, 1997, 1998, 1999, 2005 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifdef _ERRNO_H 21 | 22 | # undef EDOM 23 | # undef EILSEQ 24 | # undef ERANGE 25 | # include 26 | 27 | /* Linux has no ENOTSUP error code. */ 28 | # define ENOTSUP EOPNOTSUPP 29 | 30 | /* Older Linux versions also had no ECANCELED error code. */ 31 | # ifndef ECANCELED 32 | # define ECANCELED 125 33 | # endif 34 | 35 | /* Support for error codes to support robust mutexes was added later, too. */ 36 | # ifndef EOWNERDEAD 37 | # define EOWNERDEAD 130 38 | # define ENOTRECOVERABLE 131 39 | # endif 40 | 41 | # ifndef __ASSEMBLER__ 42 | /* Function to get address of global `errno' variable. */ 43 | extern int *__errno_location (void) __THROW __attribute__ ((__const__)); 44 | 45 | # if !defined _LIBC || defined _LIBC_REENTRANT 46 | /* When using threads, errno is a per-thread value. */ 47 | # define errno (*__errno_location ()) 48 | # endif 49 | # endif /* !__ASSEMBLER__ */ 50 | #endif /* _ERRNO_H */ 51 | 52 | #if !defined _ERRNO_H && defined __need_Emath 53 | /* This is ugly but the kernel header is not clean enough. We must 54 | define only the values EDOM, EILSEQ and ERANGE in case __need_Emath is 55 | defined. */ 56 | # define EDOM 33 /* Math argument out of domain of function. */ 57 | # define EILSEQ 84 /* Illegal byte sequence. */ 58 | # define ERANGE 34 /* Math result not representable. */ 59 | #endif /* !_ERRNO_H && __need_Emath */ 60 | -------------------------------------------------------------------------------- /kernel/include/bits/error.h: -------------------------------------------------------------------------------- 1 | /* Specializations for error functions. 2 | Copyright (C) 2007 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _ERROR_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | 25 | extern void __REDIRECT (__error_alias, (int __status, int __errnum, 26 | __const char *__format, ...), 27 | error) 28 | __attribute__ ((__format__ (__printf__, 3, 4))); 29 | extern void __REDIRECT (__error_noreturn, (int __status, int __errnum, 30 | __const char *__format, ...), 31 | error) 32 | __attribute__ ((__noreturn__, __format__ (__printf__, 3, 4))); 33 | 34 | 35 | /* If we know the function will never return make sure the compiler 36 | realizes that, too. */ 37 | __extern_always_inline void 38 | error (int __status, int __errnum, __const char *__format, ...) 39 | { 40 | if (__builtin_constant_p (__status) && __status != 0) 41 | __error_noreturn (__status, __errnum, __format, __va_arg_pack ()); 42 | else 43 | __error_alias (__status, __errnum, __format, __va_arg_pack ()); 44 | } 45 | 46 | 47 | extern void __REDIRECT (__error_at_line_alias, (int __status, int __errnum, 48 | __const char *__fname, 49 | unsigned int __line, 50 | __const char *__format, ...), 51 | error_at_line) 52 | __attribute__ ((__format__ (__printf__, 5, 6))); 53 | extern void __REDIRECT (__error_at_line_noreturn, (int __status, int __errnum, 54 | __const char *__fname, 55 | unsigned int __line, 56 | __const char *__format, 57 | ...), 58 | error_at_line) 59 | __attribute__ ((__noreturn__, __format__ (__printf__, 5, 6))); 60 | 61 | 62 | /* If we know the function will never return make sure the compiler 63 | realizes that, too. */ 64 | __extern_always_inline void 65 | error_at_line (int __status, int __errnum, __const char *__fname, 66 | unsigned int __line,__const char *__format, ...) 67 | { 68 | if (__builtin_constant_p (__status) && __status != 0) 69 | __error_at_line_noreturn (__status, __errnum, __fname, __line, __format, 70 | __va_arg_pack ()); 71 | else 72 | __error_at_line_alias (__status, __errnum, __fname, __line, 73 | __format, __va_arg_pack ()); 74 | } 75 | -------------------------------------------------------------------------------- /kernel/include/bits/fenv.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1997,1998,1999,2000,2001,2004 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _FENV_H 20 | # error "Never use directly; include instead." 21 | #endif 22 | 23 | #include 24 | 25 | 26 | /* Define bits representing the exception. We use the bit positions 27 | of the appropriate bits in the FPU control word. */ 28 | enum 29 | { 30 | FE_INVALID = 0x01, 31 | #define FE_INVALID FE_INVALID 32 | __FE_DENORM = 0x02, 33 | FE_DIVBYZERO = 0x04, 34 | #define FE_DIVBYZERO FE_DIVBYZERO 35 | FE_OVERFLOW = 0x08, 36 | #define FE_OVERFLOW FE_OVERFLOW 37 | FE_UNDERFLOW = 0x10, 38 | #define FE_UNDERFLOW FE_UNDERFLOW 39 | FE_INEXACT = 0x20 40 | #define FE_INEXACT FE_INEXACT 41 | }; 42 | 43 | #define FE_ALL_EXCEPT \ 44 | (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) 45 | 46 | /* The ix87 FPU supports all of the four defined rounding modes. We 47 | use again the bit positions in the FPU control word as the values 48 | for the appropriate macros. */ 49 | enum 50 | { 51 | FE_TONEAREST = 0, 52 | #define FE_TONEAREST FE_TONEAREST 53 | FE_DOWNWARD = 0x400, 54 | #define FE_DOWNWARD FE_DOWNWARD 55 | FE_UPWARD = 0x800, 56 | #define FE_UPWARD FE_UPWARD 57 | FE_TOWARDZERO = 0xc00 58 | #define FE_TOWARDZERO FE_TOWARDZERO 59 | }; 60 | 61 | 62 | /* Type representing exception flags. */ 63 | typedef unsigned short int fexcept_t; 64 | 65 | 66 | /* Type representing floating-point environment. This structure 67 | corresponds to the layout of the block written by the `fstenv' 68 | instruction and has additional fields for the contents of the MXCSR 69 | register as written by the `stmxcsr' instruction. */ 70 | typedef struct 71 | { 72 | unsigned short int __control_word; 73 | unsigned short int __unused1; 74 | unsigned short int __status_word; 75 | unsigned short int __unused2; 76 | unsigned short int __tags; 77 | unsigned short int __unused3; 78 | unsigned int __eip; 79 | unsigned short int __cs_selector; 80 | unsigned int __opcode:11; 81 | unsigned int __unused4:5; 82 | unsigned int __data_offset; 83 | unsigned short int __data_selector; 84 | unsigned short int __unused5; 85 | #if __WORDSIZE == 64 86 | unsigned int __mxcsr; 87 | #endif 88 | } 89 | fenv_t; 90 | 91 | /* If the default argument is used we use this value. */ 92 | #define FE_DFL_ENV ((__const fenv_t *) -1) 93 | 94 | #ifdef __USE_GNU 95 | /* Floating-point environment where none of the exception is masked. */ 96 | # define FE_NOMASK_ENV ((__const fenv_t *) -2) 97 | #endif 98 | -------------------------------------------------------------------------------- /kernel/include/bits/fenvinline.h: -------------------------------------------------------------------------------- 1 | /* This file provides inline versions of floating-pint environment 2 | handling functions. If there were any. */ 3 | 4 | #ifndef __NO_MATH_INLINES 5 | 6 | /* Here is where the code would go. */ 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /kernel/include/bits/huge_val.h: -------------------------------------------------------------------------------- 1 | /* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity). 2 | Used by and functions for overflow. 3 | Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000, 2004 4 | Free Software Foundation, Inc. 5 | This file is part of the GNU C Library. 6 | 7 | The GNU C Library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | The GNU C Library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with the GNU C Library; if not, write to the Free 19 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 20 | 02111-1307 USA. */ 21 | 22 | #ifndef _MATH_H 23 | # error "Never use directly; include instead." 24 | #endif 25 | 26 | /* IEEE positive infinity (-HUGE_VAL is negative infinity). */ 27 | 28 | #if __GNUC_PREREQ(3,3) 29 | # define HUGE_VAL (__builtin_huge_val()) 30 | #elif __GNUC_PREREQ(2,96) 31 | # define HUGE_VAL (__extension__ 0x1.0p2047) 32 | #elif defined __GNUC__ 33 | 34 | # define HUGE_VAL \ 35 | (__extension__ \ 36 | ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \ 37 | { __l: 0x7ff0000000000000ULL }).__d) 38 | 39 | #else /* not GCC */ 40 | 41 | # include 42 | 43 | typedef union { unsigned char __c[8]; double __d; } __huge_val_t; 44 | 45 | # if __BYTE_ORDER == __BIG_ENDIAN 46 | # define __HUGE_VAL_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } 47 | # endif 48 | # if __BYTE_ORDER == __LITTLE_ENDIAN 49 | # define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } 50 | # endif 51 | 52 | static __huge_val_t __huge_val = { __HUGE_VAL_bytes }; 53 | # define HUGE_VAL (__huge_val.__d) 54 | 55 | #endif /* GCC. */ 56 | -------------------------------------------------------------------------------- /kernel/include/bits/huge_valf.h: -------------------------------------------------------------------------------- 1 | /* `HUGE_VALF' constant for IEEE 754 machines (where it is infinity). 2 | Used by and functions for overflow. 3 | Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000, 2004 4 | Free Software Foundation, Inc. 5 | This file is part of the GNU C Library. 6 | 7 | The GNU C Library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | The GNU C Library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with the GNU C Library; if not, write to the Free 19 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 20 | 02111-1307 USA. */ 21 | 22 | #ifndef _MATH_H 23 | # error "Never use directly; include instead." 24 | #endif 25 | 26 | /* IEEE positive infinity (-HUGE_VAL is negative infinity). */ 27 | 28 | #if __GNUC_PREREQ(3,3) 29 | # define HUGE_VALF (__builtin_huge_valf()) 30 | #elif __GNUC_PREREQ(2,96) 31 | # define HUGE_VALF (__extension__ 0x1.0p255f) 32 | #elif defined __GNUC__ 33 | 34 | # define HUGE_VALF \ 35 | (__extension__ \ 36 | ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) \ 37 | { __l: 0x7f800000UL }).__d) 38 | 39 | #else /* not GCC */ 40 | 41 | typedef union { unsigned char __c[4]; float __f; } __huge_valf_t; 42 | 43 | # if __BYTE_ORDER == __BIG_ENDIAN 44 | # define __HUGE_VALF_bytes { 0x7f, 0x80, 0, 0 } 45 | # endif 46 | # if __BYTE_ORDER == __LITTLE_ENDIAN 47 | # define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f } 48 | # endif 49 | 50 | static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes }; 51 | # define HUGE_VALF (__huge_valf.__f) 52 | 53 | #endif /* GCC. */ 54 | -------------------------------------------------------------------------------- /kernel/include/bits/huge_vall.h: -------------------------------------------------------------------------------- 1 | /* Default `HUGE_VALL' constant. 2 | Used by and functions for overflow. 3 | Copyright (C) 1992, 1996, 1997, 2004 Free Software Foundation, Inc. 4 | This file is part of the GNU C Library. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, write to the Free 18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | 02111-1307 USA. */ 20 | 21 | #ifndef _MATH_H 22 | # error "Never use directly; include instead." 23 | #endif 24 | 25 | #if __GNUC_PREREQ(3,3) 26 | # define HUGE_VALL (__builtin_huge_vall()) 27 | #else 28 | # define HUGE_VALL ((long double) HUGE_VAL) 29 | #endif 30 | -------------------------------------------------------------------------------- /kernel/include/bits/inf.h: -------------------------------------------------------------------------------- 1 | /* `INFINITY' constant for IEEE 754 machines. 2 | Copyright (C) 2004 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _MATH_H 21 | # error "Never use directly; include instead." 22 | #endif 23 | 24 | /* IEEE positive infinity. */ 25 | 26 | #if __GNUC_PREREQ(3,3) 27 | # define INFINITY (__builtin_inff()) 28 | #else 29 | # define INFINITY HUGE_VALF 30 | #endif 31 | -------------------------------------------------------------------------------- /kernel/include/bits/initspin.h: -------------------------------------------------------------------------------- 1 | /* No thread support. */ 2 | -------------------------------------------------------------------------------- /kernel/include/bits/ioctl-types.h: -------------------------------------------------------------------------------- 1 | /* Structure types for pre-termios terminal ioctls. Linux version. 2 | Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _SYS_IOCTL_H 21 | # error "Never use directly; include instead." 22 | #endif 23 | 24 | /* Get definition of constants for use with `ioctl'. */ 25 | #include 26 | 27 | 28 | struct winsize 29 | { 30 | unsigned short int ws_row; 31 | unsigned short int ws_col; 32 | unsigned short int ws_xpixel; 33 | unsigned short int ws_ypixel; 34 | }; 35 | 36 | #define NCC 8 37 | struct termio 38 | { 39 | unsigned short int c_iflag; /* input mode flags */ 40 | unsigned short int c_oflag; /* output mode flags */ 41 | unsigned short int c_cflag; /* control mode flags */ 42 | unsigned short int c_lflag; /* local mode flags */ 43 | unsigned char c_line; /* line discipline */ 44 | unsigned char c_cc[NCC]; /* control characters */ 45 | }; 46 | 47 | /* modem lines */ 48 | #define TIOCM_LE 0x001 49 | #define TIOCM_DTR 0x002 50 | #define TIOCM_RTS 0x004 51 | #define TIOCM_ST 0x008 52 | #define TIOCM_SR 0x010 53 | #define TIOCM_CTS 0x020 54 | #define TIOCM_CAR 0x040 55 | #define TIOCM_RNG 0x080 56 | #define TIOCM_DSR 0x100 57 | #define TIOCM_CD TIOCM_CAR 58 | #define TIOCM_RI TIOCM_RNG 59 | 60 | /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ 61 | 62 | /* line disciplines */ 63 | #define N_TTY 0 64 | #define N_SLIP 1 65 | #define N_MOUSE 2 66 | #define N_PPP 3 67 | #define N_STRIP 4 68 | #define N_AX25 5 69 | #define N_X25 6 /* X.25 async */ 70 | #define N_6PACK 7 71 | #define N_MASC 8 /* Mobitex module */ 72 | #define N_R3964 9 /* Simatic R3964 module */ 73 | #define N_PROFIBUS_FDL 10 /* Profibus */ 74 | #define N_IRDA 11 /* Linux IR */ 75 | #define N_SMSBLOCK 12 /* SMS block mode */ 76 | #define N_HDLC 13 /* synchronous HDLC */ 77 | #define N_SYNC_PPP 14 /* synchronous PPP */ 78 | #define N_HCI 15 /* Bluetooth HCI UART */ 79 | -------------------------------------------------------------------------------- /kernel/include/bits/ipc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _SYS_IPC_H 20 | # error "Never use directly; include instead." 21 | #endif 22 | 23 | #include 24 | 25 | /* Mode bits for `msgget', `semget', and `shmget'. */ 26 | #define IPC_CREAT 01000 /* Create key if key does not exist. */ 27 | #define IPC_EXCL 02000 /* Fail if key exists. */ 28 | #define IPC_NOWAIT 04000 /* Return error on wait. */ 29 | 30 | /* Control commands for `msgctl', `semctl', and `shmctl'. */ 31 | #define IPC_RMID 0 /* Remove identifier. */ 32 | #define IPC_SET 1 /* Set `ipc_perm' options. */ 33 | #define IPC_STAT 2 /* Get `ipc_perm' options. */ 34 | #ifdef __USE_GNU 35 | # define IPC_INFO 3 /* See ipcs. */ 36 | #endif 37 | 38 | /* Special key values. */ 39 | #define IPC_PRIVATE ((__key_t) 0) /* Private key. */ 40 | 41 | 42 | /* Data structure used to pass permission information to IPC operations. */ 43 | struct ipc_perm 44 | { 45 | __key_t __key; /* Key. */ 46 | __uid_t uid; /* Owner's user ID. */ 47 | __gid_t gid; /* Owner's group ID. */ 48 | __uid_t cuid; /* Creator's user ID. */ 49 | __gid_t cgid; /* Creator's group ID. */ 50 | unsigned short int mode; /* Read/write permission. */ 51 | unsigned short int __pad1; 52 | unsigned short int __seq; /* Sequence number. */ 53 | unsigned short int __pad2; 54 | unsigned long int __unused1; 55 | unsigned long int __unused2; 56 | }; 57 | -------------------------------------------------------------------------------- /kernel/include/bits/ipctypes.h: -------------------------------------------------------------------------------- 1 | /* bits/ipctypes.h -- Define some types used by SysV IPC/MSG/SHM. Generic. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | /* 21 | * Never include directly. 22 | */ 23 | 24 | #ifndef _BITS_IPCTYPES_H 25 | #define _BITS_IPCTYPES_H 1 26 | 27 | #include 28 | 29 | /* Used in `struct shmid_ds'. */ 30 | # if __WORDSIZE == 32 31 | typedef unsigned short int __ipc_pid_t; 32 | # else 33 | typedef int __ipc_pid_t; 34 | # endif 35 | 36 | 37 | #endif /* bits/ipctypes.h */ 38 | -------------------------------------------------------------------------------- /kernel/include/bits/libio-ldbl.h: -------------------------------------------------------------------------------- 1 | /* -mlong-double-64 compatibility mode for libio functions. 2 | Copyright (C) 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _IO_STDIO_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | __LDBL_REDIR_DECL (_IO_vfscanf) 25 | __LDBL_REDIR_DECL (_IO_vfprintf) 26 | -------------------------------------------------------------------------------- /kernel/include/bits/link.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004, 2005 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _LINK_H 20 | # error "Never include directly; use instead." 21 | #endif 22 | 23 | 24 | #if __ELF_NATIVE_CLASS == 32 25 | /* Registers for entry into PLT on IA-32. */ 26 | typedef struct La_i86_regs 27 | { 28 | uint32_t lr_edx; 29 | uint32_t lr_ecx; 30 | uint32_t lr_eax; 31 | uint32_t lr_ebp; 32 | uint32_t lr_esp; 33 | } La_i86_regs; 34 | 35 | /* Return values for calls from PLT on IA-32. */ 36 | typedef struct La_i86_retval 37 | { 38 | uint32_t lrv_eax; 39 | uint32_t lrv_edx; 40 | long double lrv_st0; 41 | long double lrv_st1; 42 | } La_i86_retval; 43 | 44 | 45 | __BEGIN_DECLS 46 | 47 | extern Elf32_Addr la_i86_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx, 48 | uintptr_t *__refcook, 49 | uintptr_t *__defcook, 50 | La_i86_regs *__regs, 51 | unsigned int *__flags, 52 | const char *__symname, 53 | long int *__framesizep); 54 | extern unsigned int la_i86_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx, 55 | uintptr_t *__refcook, 56 | uintptr_t *__defcook, 57 | const La_i86_regs *__inregs, 58 | La_i86_retval *__outregs, 59 | const char *symname); 60 | 61 | __END_DECLS 62 | 63 | #else 64 | 65 | /* Registers for entry into PLT on x86-64. */ 66 | # if __GNUC_PREREQ (4,0) 67 | typedef float La_x86_64_xmm __attribute__ ((__vector_size__ (16))); 68 | # else 69 | typedef float La_x86_64_xmm __attribute__ ((__mode__ (__V4SF__))); 70 | # endif 71 | 72 | typedef struct La_x86_64_regs 73 | { 74 | uint64_t lr_rdx; 75 | uint64_t lr_r8; 76 | uint64_t lr_r9; 77 | uint64_t lr_rcx; 78 | uint64_t lr_rsi; 79 | uint64_t lr_rdi; 80 | uint64_t lr_rbp; 81 | uint64_t lr_rsp; 82 | La_x86_64_xmm lr_xmm[8]; 83 | } La_x86_64_regs; 84 | 85 | /* Return values for calls from PLT on x86-64. */ 86 | typedef struct La_x86_64_retval 87 | { 88 | uint64_t lrv_rax; 89 | uint64_t lrv_rdx; 90 | La_x86_64_xmm lrv_xmm0; 91 | La_x86_64_xmm lrv_xmm1; 92 | long double lrv_st0; 93 | long double lrv_st1; 94 | } La_x86_64_retval; 95 | 96 | 97 | __BEGIN_DECLS 98 | 99 | extern Elf64_Addr la_x86_64_gnu_pltenter (Elf64_Sym *__sym, 100 | unsigned int __ndx, 101 | uintptr_t *__refcook, 102 | uintptr_t *__defcook, 103 | La_x86_64_regs *__regs, 104 | unsigned int *__flags, 105 | const char *__symname, 106 | long int *__framesizep); 107 | extern unsigned int la_x86_64_gnu_pltexit (Elf64_Sym *__sym, 108 | unsigned int __ndx, 109 | uintptr_t *__refcook, 110 | uintptr_t *__defcook, 111 | const La_x86_64_regs *__inregs, 112 | La_x86_64_retval *__outregs, 113 | const char *symname); 114 | 115 | __END_DECLS 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /kernel/include/bits/local_lim.h: -------------------------------------------------------------------------------- 1 | /* Minimum guaranteed maximum values for system limits. Linux version. 2 | Copyright (C) 1993-1998,2000,2002,2003,2004 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public License as 7 | published by the Free Software Foundation; either version 2.1 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | /* The kernel header pollutes the namespace with the NR_OPEN symbol 21 | and defines LINK_MAX although filesystems have different maxima. A 22 | similar thing is true for OPEN_MAX: the limit can be changed at 23 | runtime and therefore the macro must not be defined. Remove this 24 | after including the header if necessary. */ 25 | #ifndef NR_OPEN 26 | # define __undef_NR_OPEN 27 | #endif 28 | #ifndef LINK_MAX 29 | # define __undef_LINK_MAX 30 | #endif 31 | #ifndef OPEN_MAX 32 | # define __undef_OPEN_MAX 33 | #endif 34 | 35 | /* The kernel sources contain a file with all the needed information. */ 36 | #include 37 | 38 | /* Have to remove NR_OPEN? */ 39 | #ifdef __undef_NR_OPEN 40 | # undef NR_OPEN 41 | # undef __undef_NR_OPEN 42 | #endif 43 | /* Have to remove LINK_MAX? */ 44 | #ifdef __undef_LINK_MAX 45 | # undef LINK_MAX 46 | # undef __undef_LINK_MAX 47 | #endif 48 | /* Have to remove OPEN_MAX? */ 49 | #ifdef __undef_OPEN_MAX 50 | # undef OPEN_MAX 51 | # undef __undef_OPEN_MAX 52 | #endif 53 | 54 | /* The number of data keys per process. */ 55 | #define _POSIX_THREAD_KEYS_MAX 128 56 | /* This is the value this implementation supports. */ 57 | #define PTHREAD_KEYS_MAX 1024 58 | 59 | /* Controlling the iterations of destructors for thread-specific data. */ 60 | #define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 61 | /* Number of iterations this implementation does. */ 62 | #define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS 63 | 64 | /* The number of threads per process. */ 65 | #define _POSIX_THREAD_THREADS_MAX 64 66 | /* We have no predefined limit on the number of threads. */ 67 | #undef PTHREAD_THREADS_MAX 68 | 69 | /* Maximum amount by which a process can descrease its asynchronous I/O 70 | priority level. */ 71 | #define AIO_PRIO_DELTA_MAX 20 72 | 73 | /* Minimum size for a thread. We are free to choose a reasonable value. */ 74 | #define PTHREAD_STACK_MIN 16384 75 | 76 | /* Maximum number of timer expiration overruns. */ 77 | #define DELAYTIMER_MAX 2147483647 78 | 79 | /* Maximum tty name length. */ 80 | #define TTY_NAME_MAX 32 81 | 82 | /* Maximum login name length. This is arbitrary. */ 83 | #define LOGIN_NAME_MAX 256 84 | 85 | /* Maximum host name length. */ 86 | #define HOST_NAME_MAX 64 87 | 88 | /* Maximum message queue priority level. */ 89 | #define MQ_PRIO_MAX 32768 90 | 91 | /* Maximum value the semaphore can have. */ 92 | #define SEM_VALUE_MAX (2147483647) 93 | -------------------------------------------------------------------------------- /kernel/include/bits/locale.h: -------------------------------------------------------------------------------- 1 | /* Definition of locale category symbol values. 2 | Copyright (C) 2001 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #if !defined _LOCALE_H && !defined _LANGINFO_H 21 | # error "Never use directly; include instead." 22 | #endif 23 | 24 | #ifndef _BITS_LOCALE_H 25 | #define _BITS_LOCALE_H 1 26 | 27 | enum 28 | { 29 | __LC_CTYPE = 0, 30 | __LC_NUMERIC = 1, 31 | __LC_TIME = 2, 32 | __LC_COLLATE = 3, 33 | __LC_MONETARY = 4, 34 | __LC_MESSAGES = 5, 35 | __LC_ALL = 6, 36 | __LC_PAPER = 7, 37 | __LC_NAME = 8, 38 | __LC_ADDRESS = 9, 39 | __LC_TELEPHONE = 10, 40 | __LC_MEASUREMENT = 11, 41 | __LC_IDENTIFICATION = 12 42 | }; 43 | 44 | #endif /* bits/locale.h */ 45 | -------------------------------------------------------------------------------- /kernel/include/bits/mathdef.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2001, 2004 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #if !defined _MATH_H && !defined _COMPLEX_H 20 | # error "Never use directly; include instead" 21 | #endif 22 | 23 | #if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF 24 | # define _MATH_H_MATHDEF 1 25 | 26 | # include 27 | 28 | # if __WORDSIZE == 64 || (defined __FLT_EVAL_METHOD__ && __FLT_EVAL_METHOD__ == 0) 29 | /* The x86-64 architecture computes values with the precission of the 30 | used type. Similarly for -m32 -mfpmath=sse. */ 31 | typedef float float_t; /* `float' expressions are evaluated as `float'. */ 32 | typedef double double_t; /* `double' expressions are evaluated 33 | as `double'. */ 34 | # else 35 | /* The ix87 FPUs evaluate all values in the 80 bit floating-point format 36 | which is also available for the user as `long double'. Therefore we 37 | define: */ 38 | typedef long double float_t; /* `float' expressions are evaluated as 39 | `long double'. */ 40 | typedef long double double_t; /* `double' expressions are evaluated as 41 | `long double'. */ 42 | # endif 43 | 44 | /* The values returned by `ilogb' for 0 and NaN respectively. */ 45 | # define FP_ILOGB0 (-2147483647 - 1) 46 | # define FP_ILOGBNAN (-2147483647 - 1) 47 | 48 | #endif /* ISO C99 */ 49 | -------------------------------------------------------------------------------- /kernel/include/bits/mathinline.h: -------------------------------------------------------------------------------- 1 | /* Inline math functions for x86-64. 2 | Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Jaeger , 2002. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, write to the Free 18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | 02111-1307 USA. */ 20 | 21 | #ifndef _MATH_H 22 | # error "Never use directly; include instead." 23 | #endif 24 | 25 | #ifndef __extern_inline 26 | # define __MATH_INLINE __inline 27 | #else 28 | # define __MATH_INLINE __extern_inline 29 | #endif 30 | 31 | 32 | #if defined __USE_ISOC99 && defined __GNUC__ && __GNUC__ >= 2 33 | 34 | /* Test for negative number. Used in the signbit() macro. */ 35 | __MATH_INLINE int 36 | __NTH (__signbitf (float __x)) 37 | { 38 | __extension__ union { float __f; int __i; } __u = { __f: __x }; 39 | return __u.__i < 0; 40 | } 41 | __MATH_INLINE int 42 | __NTH (__signbit (double __x)) 43 | { 44 | __extension__ union { double __d; int __i[2]; } __u = { __d: __x }; 45 | return __u.__i[1] < 0; 46 | } 47 | __MATH_INLINE int 48 | __NTH (__signbitl (long double __x)) 49 | { 50 | __extension__ union { long double __l; int __i[3]; } __u = { __l: __x }; 51 | return (__u.__i[2] & 0x8000) != 0; 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /kernel/include/bits/mman.h: -------------------------------------------------------------------------------- 1 | /* Definitions for POSIX memory map interface. Linux/x86_64 version. 2 | Copyright (C) 2001, 2003, 2005, 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _SYS_MMAN_H 21 | # error "Never use directly; include instead." 22 | #endif 23 | 24 | /* The following definitions basically come from the kernel headers. 25 | But the kernel header is not namespace clean. */ 26 | 27 | 28 | /* Protections are chosen from these bits, OR'd together. The 29 | implementation does not necessarily support PROT_EXEC or PROT_WRITE 30 | without PROT_READ. The only guarantees are that no writing will be 31 | allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ 32 | 33 | #define PROT_READ 0x1 /* Page can be read. */ 34 | #define PROT_WRITE 0x2 /* Page can be written. */ 35 | #define PROT_EXEC 0x4 /* Page can be executed. */ 36 | #define PROT_NONE 0x0 /* Page can not be accessed. */ 37 | #define PROT_GROWSDOWN 0x01000000 /* Extend change to start of 38 | growsdown vma (mprotect only). */ 39 | #define PROT_GROWSUP 0x02000000 /* Extend change to start of 40 | growsup vma (mprotect only). */ 41 | 42 | /* Sharing types (must choose one and only one of these). */ 43 | #define MAP_SHARED 0x01 /* Share changes. */ 44 | #define MAP_PRIVATE 0x02 /* Changes are private. */ 45 | #ifdef __USE_MISC 46 | # define MAP_TYPE 0x0f /* Mask for type of mapping. */ 47 | #endif 48 | 49 | /* Other flags. */ 50 | #define MAP_FIXED 0x10 /* Interpret addr exactly. */ 51 | #ifdef __USE_MISC 52 | # define MAP_FILE 0 53 | # define MAP_ANONYMOUS 0x20 /* Don't use a file. */ 54 | # define MAP_ANON MAP_ANONYMOUS 55 | # define MAP_32BIT 0x40 /* Only give out 32-bit addresses. */ 56 | #endif 57 | 58 | /* These are Linux-specific. */ 59 | #ifdef __USE_MISC 60 | # define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ 61 | # define MAP_DENYWRITE 0x00800 /* ETXTBSY */ 62 | # define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ 63 | # define MAP_LOCKED 0x02000 /* Lock the mapping. */ 64 | # define MAP_NORESERVE 0x04000 /* Don't check for reservations. */ 65 | # define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ 66 | # define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ 67 | #endif 68 | 69 | /* Flags to `msync'. */ 70 | #define MS_ASYNC 1 /* Sync memory asynchronously. */ 71 | #define MS_SYNC 4 /* Synchronous memory sync. */ 72 | #define MS_INVALIDATE 2 /* Invalidate the caches. */ 73 | 74 | /* Flags for `mlockall'. */ 75 | #define MCL_CURRENT 1 /* Lock all currently mapped pages. */ 76 | #define MCL_FUTURE 2 /* Lock all additions to address 77 | space. */ 78 | 79 | /* Flags for `mremap'. */ 80 | #ifdef __USE_GNU 81 | # define MREMAP_MAYMOVE 1 82 | # define MREMAP_FIXED 2 83 | #endif 84 | 85 | /* Advice to `madvise'. */ 86 | #ifdef __USE_BSD 87 | # define MADV_NORMAL 0 /* No further special treatment. */ 88 | # define MADV_RANDOM 1 /* Expect random page references. */ 89 | # define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ 90 | # define MADV_WILLNEED 3 /* Will need these pages. */ 91 | # define MADV_DONTNEED 4 /* Don't need these pages. */ 92 | # define MADV_REMOVE 9 /* Remove these pages and resources. */ 93 | # define MADV_DONTFORK 10 /* Do not inherit across fork. */ 94 | # define MADV_DOFORK 11 /* Do inherit across fork. */ 95 | #endif 96 | 97 | /* The POSIX people had to invent similar names for the same things. */ 98 | #ifdef __USE_XOPEN2K 99 | # define POSIX_MADV_NORMAL 0 /* No further special treatment. */ 100 | # define POSIX_MADV_RANDOM 1 /* Expect random page references. */ 101 | # define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ 102 | # define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ 103 | # define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ 104 | #endif 105 | -------------------------------------------------------------------------------- /kernel/include/bits/monetary-ldbl.h: -------------------------------------------------------------------------------- 1 | /* -mlong-double-64 compatibility mode for monetary functions. 2 | Copyright (C) 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _MONETARY_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | __LDBL_REDIR_DECL (strfmon) 25 | 26 | #ifdef __USE_GNU 27 | __LDBL_REDIR_DECL (strfmon_l) 28 | #endif 29 | -------------------------------------------------------------------------------- /kernel/include/bits/mqueue.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _MQUEUE_H 20 | # error "Never use directly; include instead." 21 | #endif 22 | 23 | typedef int mqd_t; 24 | 25 | struct mq_attr 26 | { 27 | long int mq_flags; /* Message queue flags. */ 28 | long int mq_maxmsg; /* Maximum number of messages. */ 29 | long int mq_msgsize; /* Maximum message size. */ 30 | long int mq_curmsgs; /* Number of messages currently queued. */ 31 | long int __pad[4]; 32 | }; 33 | -------------------------------------------------------------------------------- /kernel/include/bits/mqueue2.h: -------------------------------------------------------------------------------- 1 | /* Checking macros for mq functions. 2 | Copyright (C) 2007 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _FCNTL_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | /* Check that calls to mq_open with O_CREAT set have an appropriate third and fourth 25 | parameter. */ 26 | extern mqd_t mq_open (__const char *__name, int __oflag, ...) 27 | __THROW __nonnull ((1)); 28 | extern mqd_t __mq_open_2 (__const char *__name, int __oflag) __nonnull ((1)); 29 | extern mqd_t __REDIRECT (__mq_open_alias, (__const char *__name, int __oflag, ...), 30 | mq_open) __nonnull ((1)); 31 | __errordecl (__mq_open_wrong_number_of_args, 32 | "mq_open can be called either with 2 or 4 arguments"); 33 | __errordecl (__mq_open_missing_mode_and_attr, 34 | "mq_open with O_CREAT in second argument needs 4 arguments"); 35 | 36 | __extern_always_inline mqd_t 37 | mq_open (__const char *__name, int __oflag, ...) 38 | { 39 | if (__va_arg_pack_len () != 0 && __va_arg_pack_len () != 2) 40 | __mq_open_wrong_number_of_args (); 41 | 42 | if (__builtin_constant_p (__oflag)) 43 | { 44 | if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () == 0) 45 | { 46 | __mq_open_missing_mode_and_attr (); 47 | return __mq_open_2 (__name, __oflag); 48 | } 49 | return __mq_open_alias (__name, __oflag, __va_arg_pack ()); 50 | } 51 | 52 | if (__va_arg_pack_len () == 0) 53 | return __mq_open_2 (__name, __oflag); 54 | 55 | return __mq_open_alias (__name, __oflag, __va_arg_pack ()); 56 | } 57 | -------------------------------------------------------------------------------- /kernel/include/bits/msq.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995, 1996, 1997, 2000, 2002 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _SYS_MSG_H 20 | # error "Never use directly; include instead." 21 | #endif 22 | 23 | #include 24 | #include 25 | 26 | /* Define options for message queue functions. */ 27 | #define MSG_NOERROR 010000 /* no error if message is too big */ 28 | #ifdef __USE_GNU 29 | # define MSG_EXCEPT 020000 /* recv any msg except of specified type */ 30 | #endif 31 | 32 | /* Types used in the structure definition. */ 33 | typedef unsigned long int msgqnum_t; 34 | typedef unsigned long int msglen_t; 35 | 36 | /* Structure of record for one message inside the kernel. 37 | The type `struct msg' is opaque. */ 38 | struct msqid_ds 39 | { 40 | struct ipc_perm msg_perm; /* structure describing operation permission */ 41 | __time_t msg_stime; /* time of last msgsnd command */ 42 | #if __WORDSIZE == 32 43 | unsigned long int __unused1; 44 | #endif 45 | __time_t msg_rtime; /* time of last msgrcv command */ 46 | #if __WORDSIZE == 32 47 | unsigned long int __unused2; 48 | #endif 49 | __time_t msg_ctime; /* time of last change */ 50 | #if __WORDSIZE == 32 51 | unsigned long int __unused3; 52 | #endif 53 | unsigned long int __msg_cbytes; /* current number of bytes on queue */ 54 | msgqnum_t msg_qnum; /* number of messages currently on queue */ 55 | msglen_t msg_qbytes; /* max number of bytes allowed on queue */ 56 | __pid_t msg_lspid; /* pid of last msgsnd() */ 57 | __pid_t msg_lrpid; /* pid of last msgrcv() */ 58 | unsigned long int __unused4; 59 | unsigned long int __unused5; 60 | }; 61 | 62 | #ifdef __USE_MISC 63 | 64 | # define msg_cbytes __msg_cbytes 65 | 66 | /* ipcs ctl commands */ 67 | # define MSG_STAT 11 68 | # define MSG_INFO 12 69 | 70 | /* buffer for msgctl calls IPC_INFO, MSG_INFO */ 71 | struct msginfo 72 | { 73 | int msgpool; 74 | int msgmap; 75 | int msgmax; 76 | int msgmnb; 77 | int msgmni; 78 | int msgssz; 79 | int msgtql; 80 | unsigned short int msgseg; 81 | }; 82 | 83 | #endif /* __USE_MISC */ 84 | -------------------------------------------------------------------------------- /kernel/include/bits/nan.h: -------------------------------------------------------------------------------- 1 | /* `NAN' constant for IEEE 754 machines. 2 | Copyright (C) 1992,1996,1997,1999,2004,2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _MATH_H 21 | # error "Never use directly; include instead." 22 | #endif 23 | 24 | 25 | /* IEEE Not A Number. */ 26 | 27 | #if __GNUC_PREREQ(3,3) 28 | 29 | # define NAN (__builtin_nanf ("")) 30 | 31 | #elif defined __GNUC__ 32 | 33 | # define NAN \ 34 | (__extension__ \ 35 | ((union { unsigned __l __attribute__ ((__mode__ (__SI__))); float __d; }) \ 36 | { __l: 0x7fc00000UL }).__d) 37 | 38 | #else 39 | 40 | # include 41 | 42 | # if __BYTE_ORDER == __BIG_ENDIAN 43 | # define __nan_bytes { 0x7f, 0xc0, 0, 0 } 44 | # endif 45 | # if __BYTE_ORDER == __LITTLE_ENDIAN 46 | # define __nan_bytes { 0, 0, 0xc0, 0x7f } 47 | # endif 48 | 49 | static union { unsigned char __c[4]; float __d; } __nan_union 50 | __attribute_used__ = { __nan_bytes }; 51 | # define NAN (__nan_union.__d) 52 | 53 | #endif /* GCC. */ 54 | -------------------------------------------------------------------------------- /kernel/include/bits/netdb.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _NETDB_H 20 | # error "Never include directly; use instead." 21 | #endif 22 | 23 | 24 | /* Description of data base entry for a single network. NOTE: here a 25 | poor assumption is made. The network number is expected to fit 26 | into an unsigned long int variable. */ 27 | struct netent 28 | { 29 | char *n_name; /* Official name of network. */ 30 | char **n_aliases; /* Alias list. */ 31 | int n_addrtype; /* Net address type. */ 32 | uint32_t n_net; /* Network number. */ 33 | }; 34 | -------------------------------------------------------------------------------- /kernel/include/bits/poll.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1997, 2001, 2006 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _SYS_POLL_H 20 | # error "Never use directly; include instead." 21 | #endif 22 | 23 | /* Event types that can be polled for. These bits may be set in `events' 24 | to indicate the interesting event types; they will appear in `revents' 25 | to indicate the status of the file descriptor. */ 26 | #define POLLIN 0x001 /* There is data to read. */ 27 | #define POLLPRI 0x002 /* There is urgent data to read. */ 28 | #define POLLOUT 0x004 /* Writing now will not block. */ 29 | 30 | #ifdef __USE_XOPEN 31 | /* These values are defined in XPG4.2. */ 32 | # define POLLRDNORM 0x040 /* Normal data may be read. */ 33 | # define POLLRDBAND 0x080 /* Priority data may be read. */ 34 | # define POLLWRNORM 0x100 /* Writing now will not block. */ 35 | # define POLLWRBAND 0x200 /* Priority data may be written. */ 36 | #endif 37 | 38 | #ifdef __USE_GNU 39 | /* These are extensions for Linux. */ 40 | # define POLLMSG 0x400 41 | # define POLLREMOVE 0x1000 42 | # define POLLRDHUP 0x2000 43 | #endif 44 | 45 | /* Event types always implicitly polled for. These bits need not be set in 46 | `events', but they will appear in `revents' to indicate the status of 47 | the file descriptor. */ 48 | #define POLLERR 0x008 /* Error condition. */ 49 | #define POLLHUP 0x010 /* Hung up. */ 50 | #define POLLNVAL 0x020 /* Invalid polling request. */ 51 | -------------------------------------------------------------------------------- /kernel/include/bits/posix2_lim.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1991, 1996, 1999, 2000, 2001 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | /* 20 | * Never include this file directly; include instead. 21 | */ 22 | 23 | #ifndef _BITS_POSIX2_LIM_H 24 | #define _BITS_POSIX2_LIM_H 1 25 | 26 | 27 | /* The maximum `ibase' and `obase' values allowed by the `bc' utility. */ 28 | #define _POSIX2_BC_BASE_MAX 99 29 | 30 | /* The maximum number of elements allowed in an array by the `bc' utility. */ 31 | #define _POSIX2_BC_DIM_MAX 2048 32 | 33 | /* The maximum `scale' value allowed by the `bc' utility. */ 34 | #define _POSIX2_BC_SCALE_MAX 99 35 | 36 | /* The maximum length of a string constant accepted by the `bc' utility. */ 37 | #define _POSIX2_BC_STRING_MAX 1000 38 | 39 | /* The maximum number of weights that can be assigned to an entry of 40 | the LC_COLLATE `order' keyword in the locale definition file. */ 41 | #define _POSIX2_COLL_WEIGHTS_MAX 2 42 | 43 | /* The maximum number of expressions that can be nested 44 | within parentheses by the `expr' utility. */ 45 | #define _POSIX2_EXPR_NEST_MAX 32 46 | 47 | /* The maximum length, in bytes, of an input line. */ 48 | #define _POSIX2_LINE_MAX 2048 49 | 50 | /* The maximum number of repeated occurrences of a regular expression 51 | permitted when using the interval notation `\{M,N\}'. */ 52 | #define _POSIX2_RE_DUP_MAX 255 53 | 54 | /* The maximum number of bytes in a character class name. We have no 55 | fixed limit, 2048 is a high number. */ 56 | #define _POSIX2_CHARCLASS_NAME_MAX 14 57 | 58 | 59 | /* These values are implementation-specific, 60 | and may vary within the implementation. 61 | Their precise values can be obtained from sysconf. */ 62 | 63 | #ifndef BC_BASE_MAX 64 | #define BC_BASE_MAX _POSIX2_BC_BASE_MAX 65 | #endif 66 | #ifndef BC_DIM_MAX 67 | #define BC_DIM_MAX _POSIX2_BC_DIM_MAX 68 | #endif 69 | #ifndef BC_SCALE_MAX 70 | #define BC_SCALE_MAX _POSIX2_BC_SCALE_MAX 71 | #endif 72 | #ifndef BC_STRING_MAX 73 | #define BC_STRING_MAX _POSIX2_BC_STRING_MAX 74 | #endif 75 | #ifndef COLL_WEIGHTS_MAX 76 | #define COLL_WEIGHTS_MAX 255 77 | #endif 78 | #ifndef EXPR_NEST_MAX 79 | #define EXPR_NEST_MAX _POSIX2_EXPR_NEST_MAX 80 | #endif 81 | #ifndef LINE_MAX 82 | #define LINE_MAX _POSIX2_LINE_MAX 83 | #endif 84 | #ifndef CHARCLASS_NAME_MAX 85 | #define CHARCLASS_NAME_MAX 2048 86 | #endif 87 | 88 | /* This value is defined like this in regex.h. */ 89 | #define RE_DUP_MAX (0x7fff) 90 | 91 | #endif /* bits/posix2_lim.h */ 92 | -------------------------------------------------------------------------------- /kernel/include/bits/printf-ldbl.h: -------------------------------------------------------------------------------- 1 | /* -mlong-double-64 compatibility mode for functions. 2 | Copyright (C) 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _PRINTF_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | __LDBL_REDIR_DECL (printf_size) 25 | -------------------------------------------------------------------------------- /kernel/include/bits/select.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1997, 1998, 2001 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _SYS_SELECT_H 20 | # error "Never use directly; include instead." 21 | #endif 22 | 23 | 24 | /* We don't use `memset' because this would require a prototype and 25 | the array isn't too big. */ 26 | #define __FD_ZERO(s) \ 27 | do { \ 28 | unsigned int __i; \ 29 | fd_set *__arr = (s); \ 30 | for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \ 31 | __FDS_BITS (__arr)[__i] = 0; \ 32 | } while (0) 33 | #define __FD_SET(d, s) (__FDS_BITS (s)[__FDELT(d)] |= __FDMASK(d)) 34 | #define __FD_CLR(d, s) (__FDS_BITS (s)[__FDELT(d)] &= ~__FDMASK(d)) 35 | #define __FD_ISSET(d, s) ((__FDS_BITS (s)[__FDELT(d)] & __FDMASK(d)) != 0) 36 | -------------------------------------------------------------------------------- /kernel/include/bits/sem.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _SYS_SEM_H 20 | # error "Never include directly; use instead." 21 | #endif 22 | 23 | #include 24 | 25 | /* Flags for `semop'. */ 26 | #define SEM_UNDO 0x1000 /* undo the operation on exit */ 27 | 28 | /* Commands for `semctl'. */ 29 | #define GETPID 11 /* get sempid */ 30 | #define GETVAL 12 /* get semval */ 31 | #define GETALL 13 /* get all semval's */ 32 | #define GETNCNT 14 /* get semncnt */ 33 | #define GETZCNT 15 /* get semzcnt */ 34 | #define SETVAL 16 /* set semval */ 35 | #define SETALL 17 /* set all semval's */ 36 | 37 | 38 | /* Data structure describing a set of semaphores. */ 39 | struct semid_ds 40 | { 41 | struct ipc_perm sem_perm; /* operation permission struct */ 42 | __time_t sem_otime; /* last semop() time */ 43 | unsigned long int __unused1; 44 | __time_t sem_ctime; /* last time changed by semctl() */ 45 | unsigned long int __unused2; 46 | unsigned long int sem_nsems; /* number of semaphores in set */ 47 | unsigned long int __unused3; 48 | unsigned long int __unused4; 49 | }; 50 | 51 | /* The user should define a union like the following to use it for arguments 52 | for `semctl'. 53 | 54 | union semun 55 | { 56 | int val; <= value for SETVAL 57 | struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET 58 | unsigned short int *array; <= array for GETALL & SETALL 59 | struct seminfo *__buf; <= buffer for IPC_INFO 60 | }; 61 | 62 | Previous versions of this file used to define this union but this is 63 | incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether 64 | one must define the union or not. */ 65 | #define _SEM_SEMUN_UNDEFINED 1 66 | 67 | #ifdef __USE_MISC 68 | 69 | /* ipcs ctl cmds */ 70 | # define SEM_STAT 18 71 | # define SEM_INFO 19 72 | 73 | struct seminfo 74 | { 75 | int semmap; 76 | int semmni; 77 | int semmns; 78 | int semmnu; 79 | int semmsl; 80 | int semopm; 81 | int semume; 82 | int semusz; 83 | int semvmx; 84 | int semaem; 85 | }; 86 | 87 | #endif /* __USE_MISC */ 88 | -------------------------------------------------------------------------------- /kernel/include/bits/semaphore.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002, 2004 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | Contributed by Ulrich Drepper , 2002. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _SEMAPHORE_H 21 | # error "Never use directly; include instead." 22 | #endif 23 | 24 | #include 25 | 26 | #if __WORDSIZE == 64 27 | # define __SIZEOF_SEM_T 32 28 | #else 29 | # define __SIZEOF_SEM_T 16 30 | #endif 31 | 32 | 33 | /* Value returned if `sem_open' failed. */ 34 | #define SEM_FAILED ((sem_t *) 0) 35 | 36 | 37 | typedef union 38 | { 39 | char __size[__SIZEOF_SEM_T]; 40 | long int __align; 41 | } sem_t; 42 | -------------------------------------------------------------------------------- /kernel/include/bits/setjmp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2001,2002,2003,2005,2006 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | /* Define the machine-dependent type `jmp_buf'. x86-64 version. */ 20 | #ifndef _BITS_SETJMP_H 21 | #define _BITS_SETJMP_H 1 22 | 23 | #if !defined _SETJMP_H && !defined _PTHREAD_H 24 | # error "Never include directly; use instead." 25 | #endif 26 | 27 | #include 28 | 29 | #ifndef _ASM 30 | 31 | # if __WORDSIZE == 64 32 | typedef long int __jmp_buf[8]; 33 | # else 34 | typedef int __jmp_buf[6]; 35 | # endif 36 | 37 | #endif 38 | 39 | #endif /* bits/setjmp.h */ 40 | -------------------------------------------------------------------------------- /kernel/include/bits/shm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995, 1996, 1997, 2000, 2002, 2004 2 | Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _SYS_SHM_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | #include 25 | 26 | /* Permission flag for shmget. */ 27 | #define SHM_R 0400 /* or S_IRUGO from */ 28 | #define SHM_W 0200 /* or S_IWUGO from */ 29 | 30 | /* Flags for `shmat'. */ 31 | #define SHM_RDONLY 010000 /* attach read-only else read-write */ 32 | #define SHM_RND 020000 /* round attach address to SHMLBA */ 33 | #define SHM_REMAP 040000 /* take-over region on attach */ 34 | 35 | /* Commands for `shmctl'. */ 36 | #define SHM_LOCK 11 /* lock segment (root only) */ 37 | #define SHM_UNLOCK 12 /* unlock segment (root only) */ 38 | 39 | __BEGIN_DECLS 40 | 41 | /* Segment low boundary address multiple. */ 42 | #define SHMLBA (__getpagesize ()) 43 | extern int __getpagesize (void) __THROW __attribute__ ((__const__)); 44 | 45 | 46 | /* Type to count number of attaches. */ 47 | typedef unsigned long int shmatt_t; 48 | 49 | /* Data structure describing a set of semaphores. */ 50 | struct shmid_ds 51 | { 52 | struct ipc_perm shm_perm; /* operation permission struct */ 53 | size_t shm_segsz; /* size of segment in bytes */ 54 | __time_t shm_atime; /* time of last shmat() */ 55 | #if __WORDSIZE == 32 56 | unsigned long int __unused1; 57 | #endif 58 | __time_t shm_dtime; /* time of last shmdt() */ 59 | #if __WORDSIZE == 32 60 | unsigned long int __unused2; 61 | #endif 62 | __time_t shm_ctime; /* time of last change by shmctl() */ 63 | #if __WORDSIZE == 32 64 | unsigned long int __unused3; 65 | #endif 66 | __pid_t shm_cpid; /* pid of creator */ 67 | __pid_t shm_lpid; /* pid of last shmop */ 68 | shmatt_t shm_nattch; /* number of current attaches */ 69 | unsigned long int __unused4; 70 | unsigned long int __unused5; 71 | }; 72 | 73 | #ifdef __USE_MISC 74 | 75 | /* ipcs ctl commands */ 76 | # define SHM_STAT 13 77 | # define SHM_INFO 14 78 | 79 | /* shm_mode upper byte flags */ 80 | # define SHM_DEST 01000 /* segment will be destroyed on last detach */ 81 | # define SHM_LOCKED 02000 /* segment will not be swapped */ 82 | # define SHM_HUGETLB 04000 /* segment is mapped via hugetlb */ 83 | # define SHM_NORESERVE 010000 /* don't check for reservations */ 84 | 85 | struct shminfo 86 | { 87 | unsigned long int shmmax; 88 | unsigned long int shmmin; 89 | unsigned long int shmmni; 90 | unsigned long int shmseg; 91 | unsigned long int shmall; 92 | unsigned long int __unused1; 93 | unsigned long int __unused2; 94 | unsigned long int __unused3; 95 | unsigned long int __unused4; 96 | }; 97 | 98 | struct shm_info 99 | { 100 | int used_ids; 101 | unsigned long int shm_tot; /* total allocated shm */ 102 | unsigned long int shm_rss; /* total resident shm */ 103 | unsigned long int shm_swp; /* total swapped shm */ 104 | unsigned long int swap_attempts; 105 | unsigned long int swap_successes; 106 | }; 107 | 108 | #endif /* __USE_MISC */ 109 | 110 | __END_DECLS 111 | -------------------------------------------------------------------------------- /kernel/include/bits/sigaction.h: -------------------------------------------------------------------------------- 1 | /* The proper definitions for Linux's sigaction. 2 | Copyright (C) 1993-1999, 2000 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _SIGNAL_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | /* Structure describing the action to be taken when a signal arrives. */ 25 | struct sigaction 26 | { 27 | /* Signal handler. */ 28 | #ifdef __USE_POSIX199309 29 | union 30 | { 31 | /* Used if SA_SIGINFO is not set. */ 32 | __sighandler_t sa_handler; 33 | /* Used if SA_SIGINFO is set. */ 34 | void (*sa_sigaction) (int, siginfo_t *, void *); 35 | } 36 | __sigaction_handler; 37 | # define sa_handler __sigaction_handler.sa_handler 38 | # define sa_sigaction __sigaction_handler.sa_sigaction 39 | #else 40 | __sighandler_t sa_handler; 41 | #endif 42 | 43 | /* Additional set of signals to be blocked. */ 44 | __sigset_t sa_mask; 45 | 46 | /* Special flags. */ 47 | int sa_flags; 48 | 49 | /* Restore handler. */ 50 | void (*sa_restorer) (void); 51 | }; 52 | 53 | /* Bits in `sa_flags'. */ 54 | #define SA_NOCLDSTOP 1 /* Don't send SIGCHLD when children stop. */ 55 | #define SA_NOCLDWAIT 2 /* Don't create zombie on child death. */ 56 | #define SA_SIGINFO 4 /* Invoke signal-catching function with 57 | three arguments instead of one. */ 58 | #if defined __USE_UNIX98 || defined __USE_MISC 59 | # define SA_ONSTACK 0x08000000 /* Use signal stack by using `sa_restorer'. */ 60 | # define SA_RESTART 0x10000000 /* Restart syscall on signal return. */ 61 | # define SA_NODEFER 0x40000000 /* Don't automatically block the signal when 62 | its handler is being executed. */ 63 | # define SA_RESETHAND 0x80000000 /* Reset to SIG_DFL on entry to handler. */ 64 | #endif 65 | #ifdef __USE_MISC 66 | # define SA_INTERRUPT 0x20000000 /* Historical no-op. */ 67 | 68 | /* Some aliases for the SA_ constants. */ 69 | # define SA_NOMASK SA_NODEFER 70 | # define SA_ONESHOT SA_RESETHAND 71 | # define SA_STACK SA_ONSTACK 72 | #endif 73 | 74 | /* Values for the HOW argument to `sigprocmask'. */ 75 | #define SIG_BLOCK 0 /* Block signals. */ 76 | #define SIG_UNBLOCK 1 /* Unblock signals. */ 77 | #define SIG_SETMASK 2 /* Set the set of blocked signals. */ 78 | -------------------------------------------------------------------------------- /kernel/include/bits/sigcontext.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _BITS_SIGCONTEXT_H 20 | #define _BITS_SIGCONTEXT_H 1 21 | 22 | #if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H 23 | # error "Never use directly; include instead." 24 | #endif 25 | 26 | #include 27 | 28 | struct _fpreg 29 | { 30 | unsigned short significand[4]; 31 | unsigned short exponent; 32 | }; 33 | 34 | struct _fpxreg 35 | { 36 | unsigned short significand[4]; 37 | unsigned short exponent; 38 | unsigned short padding[3]; 39 | }; 40 | 41 | struct _xmmreg 42 | { 43 | __uint32_t element[4]; 44 | }; 45 | 46 | 47 | 48 | #if __WORDSIZE == 32 49 | 50 | struct _fpstate 51 | { 52 | /* Regular FPU environment. */ 53 | __uint32_t cw; 54 | __uint32_t sw; 55 | __uint32_t tag; 56 | __uint32_t ipoff; 57 | __uint32_t cssel; 58 | __uint32_t dataoff; 59 | __uint32_t datasel; 60 | struct _fpreg _st[8]; 61 | unsigned short status; 62 | unsigned short magic; 63 | 64 | /* FXSR FPU environment. */ 65 | __uint32_t _fxsr_env[6]; 66 | __uint32_t mxcsr; 67 | __uint32_t reserved; 68 | struct _fpxreg _fxsr_st[8]; 69 | struct _xmmreg _xmm[8]; 70 | __uint32_t padding[56]; 71 | }; 72 | 73 | #ifndef sigcontext_struct 74 | /* Kernel headers before 2.1.1 define a struct sigcontext_struct, but 75 | we need sigcontext. Some packages have come to rely on 76 | sigcontext_struct being defined on 32-bit x86, so define this for 77 | their benefit. */ 78 | # define sigcontext_struct sigcontext 79 | #endif 80 | 81 | struct sigcontext 82 | { 83 | unsigned short gs, __gsh; 84 | unsigned short fs, __fsh; 85 | unsigned short es, __esh; 86 | unsigned short ds, __dsh; 87 | unsigned long edi; 88 | unsigned long esi; 89 | unsigned long ebp; 90 | unsigned long esp; 91 | unsigned long ebx; 92 | unsigned long edx; 93 | unsigned long ecx; 94 | unsigned long eax; 95 | unsigned long trapno; 96 | unsigned long err; 97 | unsigned long eip; 98 | unsigned short cs, __csh; 99 | unsigned long eflags; 100 | unsigned long esp_at_signal; 101 | unsigned short ss, __ssh; 102 | struct _fpstate * fpstate; 103 | unsigned long oldmask; 104 | unsigned long cr2; 105 | }; 106 | 107 | #else /* __WORDSIZE == 64 */ 108 | 109 | struct _fpstate 110 | { 111 | /* FPU environment matching the 64-bit FXSAVE layout. */ 112 | __uint16_t cwd; 113 | __uint16_t swd; 114 | __uint16_t ftw; 115 | __uint16_t fop; 116 | __uint64_t rip; 117 | __uint64_t rdp; 118 | __uint32_t mxcsr; 119 | __uint32_t mxcr_mask; 120 | struct _fpxreg _st[8]; 121 | struct _xmmreg _xmm[16]; 122 | __uint32_t padding[24]; 123 | }; 124 | 125 | struct sigcontext 126 | { 127 | unsigned long r8; 128 | unsigned long r9; 129 | unsigned long r10; 130 | unsigned long r11; 131 | unsigned long r12; 132 | unsigned long r13; 133 | unsigned long r14; 134 | unsigned long r15; 135 | unsigned long rdi; 136 | unsigned long rsi; 137 | unsigned long rbp; 138 | unsigned long rbx; 139 | unsigned long rdx; 140 | unsigned long rax; 141 | unsigned long rcx; 142 | unsigned long rsp; 143 | unsigned long rip; 144 | unsigned long eflags; 145 | unsigned short cs; 146 | unsigned short gs; 147 | unsigned short fs; 148 | unsigned short __pad0; 149 | unsigned long err; 150 | unsigned long trapno; 151 | unsigned long oldmask; 152 | unsigned long cr2; 153 | struct _fpstate * fpstate; 154 | unsigned long __reserved1 [8]; 155 | }; 156 | 157 | #endif /* __WORDSIZE == 64 */ 158 | 159 | #endif /* _BITS_SIGCONTEXT_H */ 160 | -------------------------------------------------------------------------------- /kernel/include/bits/signum.h: -------------------------------------------------------------------------------- 1 | /* Signal number definitions. Linux version. 2 | Copyright (C) 1995,1996,1997,1998,1999,2003 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifdef _SIGNAL_H 21 | 22 | /* Fake signal functions. */ 23 | #define SIG_ERR ((__sighandler_t) -1) /* Error return. */ 24 | #define SIG_DFL ((__sighandler_t) 0) /* Default action. */ 25 | #define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */ 26 | 27 | #ifdef __USE_UNIX98 28 | # define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */ 29 | #endif 30 | 31 | 32 | /* Signals. */ 33 | #define SIGHUP 1 /* Hangup (POSIX). */ 34 | #define SIGINT 2 /* Interrupt (ANSI). */ 35 | #define SIGQUIT 3 /* Quit (POSIX). */ 36 | #define SIGILL 4 /* Illegal instruction (ANSI). */ 37 | #define SIGTRAP 5 /* Trace trap (POSIX). */ 38 | #define SIGABRT 6 /* Abort (ANSI). */ 39 | #define SIGIOT 6 /* IOT trap (4.2 BSD). */ 40 | #define SIGBUS 7 /* BUS error (4.2 BSD). */ 41 | #define SIGFPE 8 /* Floating-point exception (ANSI). */ 42 | #define SIGKILL 9 /* Kill, unblockable (POSIX). */ 43 | #define SIGUSR1 10 /* User-defined signal 1 (POSIX). */ 44 | #define SIGSEGV 11 /* Segmentation violation (ANSI). */ 45 | #define SIGUSR2 12 /* User-defined signal 2 (POSIX). */ 46 | #define SIGPIPE 13 /* Broken pipe (POSIX). */ 47 | #define SIGALRM 14 /* Alarm clock (POSIX). */ 48 | #define SIGTERM 15 /* Termination (ANSI). */ 49 | #define SIGSTKFLT 16 /* Stack fault. */ 50 | #define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */ 51 | #define SIGCHLD 17 /* Child status has changed (POSIX). */ 52 | #define SIGCONT 18 /* Continue (POSIX). */ 53 | #define SIGSTOP 19 /* Stop, unblockable (POSIX). */ 54 | #define SIGTSTP 20 /* Keyboard stop (POSIX). */ 55 | #define SIGTTIN 21 /* Background read from tty (POSIX). */ 56 | #define SIGTTOU 22 /* Background write to tty (POSIX). */ 57 | #define SIGURG 23 /* Urgent condition on socket (4.2 BSD). */ 58 | #define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */ 59 | #define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */ 60 | #define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */ 61 | #define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */ 62 | #define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */ 63 | #define SIGPOLL SIGIO /* Pollable event occurred (System V). */ 64 | #define SIGIO 29 /* I/O now possible (4.2 BSD). */ 65 | #define SIGPWR 30 /* Power failure restart (System V). */ 66 | #define SIGSYS 31 /* Bad system call. */ 67 | #define SIGUNUSED 31 68 | 69 | #define _NSIG 65 /* Biggest signal number + 1 70 | (including real-time signals). */ 71 | 72 | #define SIGRTMIN (__libc_current_sigrtmin ()) 73 | #define SIGRTMAX (__libc_current_sigrtmax ()) 74 | 75 | /* These are the hard limits of the kernel. These values should not be 76 | used directly at user level. */ 77 | #define __SIGRTMIN 32 78 | #define __SIGRTMAX (_NSIG - 1) 79 | 80 | #endif /* included. */ 81 | -------------------------------------------------------------------------------- /kernel/include/bits/sigstack.h: -------------------------------------------------------------------------------- 1 | /* sigstack, sigaltstack definitions. 2 | Copyright (C) 1998, 1999 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _SIGNAL_H 21 | # error "Never include this file directly. Use instead" 22 | #endif 23 | 24 | 25 | /* Structure describing a signal stack (obsolete). */ 26 | struct sigstack 27 | { 28 | void *ss_sp; /* Signal stack pointer. */ 29 | int ss_onstack; /* Nonzero if executing on this stack. */ 30 | }; 31 | 32 | 33 | /* Possible values for `ss_flags.'. */ 34 | enum 35 | { 36 | SS_ONSTACK = 1, 37 | #define SS_ONSTACK SS_ONSTACK 38 | SS_DISABLE 39 | #define SS_DISABLE SS_DISABLE 40 | }; 41 | 42 | /* Minimum stack size for a signal handler. */ 43 | #define MINSIGSTKSZ 2048 44 | 45 | /* System default stack size. */ 46 | #define SIGSTKSZ 8192 47 | 48 | 49 | /* Alternate, preferred interface. */ 50 | typedef struct sigaltstack 51 | { 52 | void *ss_sp; 53 | int ss_flags; 54 | size_t ss_size; 55 | } stack_t; 56 | -------------------------------------------------------------------------------- /kernel/include/bits/sigthread.h: -------------------------------------------------------------------------------- 1 | /* Signal handling function for threaded programs. 2 | Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public License as 7 | published by the Free Software Foundation; either version 2.1 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _BITS_SIGTHREAD_H 21 | #define _BITS_SIGTHREAD_H 1 22 | 23 | #if !defined _SIGNAL_H && !defined _PTHREAD_H 24 | # error "Never include this file directly. Use instead" 25 | #endif 26 | 27 | /* Functions for handling signals. */ 28 | 29 | /* Modify the signal mask for the calling thread. The arguments have 30 | the same meaning as for sigprocmask(2). */ 31 | extern int pthread_sigmask (int __how, 32 | __const __sigset_t *__restrict __newmask, 33 | __sigset_t *__restrict __oldmask)__THROW; 34 | 35 | /* Send signal SIGNO to the given thread. */ 36 | extern int pthread_kill (pthread_t __threadid, int __signo) __THROW; 37 | 38 | #endif /* bits/sigthread.h */ 39 | -------------------------------------------------------------------------------- /kernel/include/bits/sockaddr.h: -------------------------------------------------------------------------------- 1 | /* Definition of `struct sockaddr_*' common members. Generic/4.2 BSD version. 2 | Copyright (C) 1995,1996,1997,1998,2000,2001 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | /* 21 | * Never include this file directly; use instead. 22 | */ 23 | 24 | #ifndef _BITS_SOCKADDR_H 25 | #define _BITS_SOCKADDR_H 1 26 | 27 | 28 | /* POSIX.1g specifies this type name for the `sa_family' member. */ 29 | typedef unsigned short int sa_family_t; 30 | 31 | /* This macro is used to declare the initial common members 32 | of the data types used for socket addresses, `struct sockaddr', 33 | `struct sockaddr_in', `struct sockaddr_un', etc. */ 34 | 35 | #define __SOCKADDR_COMMON(sa_prefix) \ 36 | sa_family_t sa_prefix##family 37 | 38 | #define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int)) 39 | 40 | #endif /* bits/sockaddr.h */ 41 | -------------------------------------------------------------------------------- /kernel/include/bits/socket2.h: -------------------------------------------------------------------------------- 1 | /* Checking macros for socket functions. 2 | Copyright (C) 2005, 2007 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _SYS_SOCKET_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | extern ssize_t __recv_chk (int __fd, void *__buf, size_t __n, size_t __buflen, 25 | int __flags); 26 | extern ssize_t __REDIRECT (__recv_alias, (int __fd, void *__buf, size_t __n, 27 | int __flags), recv); 28 | extern ssize_t __REDIRECT (__recv_chk_warn, 29 | (int __fd, void *__buf, size_t __n, size_t __buflen, 30 | int __flags), __recv_chk) 31 | __warnattr ("recv called with bigger length than size of destination " 32 | "buffer"); 33 | 34 | __extern_always_inline ssize_t 35 | recv (int __fd, void *__buf, size_t __n, int __flags) 36 | { 37 | if (__bos0 (__buf) != (size_t) -1) 38 | { 39 | if (!__builtin_constant_p (__n)) 40 | return __recv_chk (__fd, __buf, __n, __bos0 (__buf), __flags); 41 | 42 | if (__n > __bos0 (__buf)) 43 | return __recv_chk_warn (__fd, __buf, __n, __bos0 (__buf), __flags); 44 | } 45 | return __recv_alias (__fd, __buf, __n, __flags); 46 | } 47 | 48 | extern ssize_t __recvfrom_chk (int __fd, void *__restrict __buf, size_t __n, 49 | size_t __buflen, int __flags, 50 | __SOCKADDR_ARG __addr, 51 | socklen_t *__restrict __addr_len); 52 | extern ssize_t __REDIRECT (__recvfrom_alias, 53 | (int __fd, void *__restrict __buf, size_t __n, 54 | int __flags, __SOCKADDR_ARG __addr, 55 | socklen_t *__restrict __addr_len), recvfrom); 56 | extern ssize_t __REDIRECT (__recvfrom_chk_warn, 57 | (int __fd, void *__restrict __buf, size_t __n, 58 | size_t __buflen, int __flags, 59 | __SOCKADDR_ARG __addr, 60 | socklen_t *__restrict __addr_len), __recvfrom_chk) 61 | __warnattr ("recvfrom called with bigger length than size of " 62 | "destination buffer"); 63 | 64 | __extern_always_inline ssize_t 65 | recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags, 66 | __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len) 67 | { 68 | if (__bos0 (__buf) != (size_t) -1) 69 | { 70 | if (!__builtin_constant_p (__n)) 71 | return __recvfrom_chk (__fd, __buf, __n, __bos0 (__buf), __flags, 72 | __addr, __addr_len); 73 | if (__n > __bos0 (__buf)) 74 | return __recvfrom_chk_warn (__fd, __buf, __n, __bos0 (__buf), __flags, 75 | __addr, __addr_len); 76 | } 77 | return __recvfrom_alias (__fd, __buf, __n, __flags, __addr, __addr_len); 78 | } 79 | -------------------------------------------------------------------------------- /kernel/include/bits/statfs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _SYS_STATFS_H 20 | # error "Never include directly; use instead." 21 | #endif 22 | 23 | #include 24 | 25 | struct statfs 26 | { 27 | __SWORD_TYPE f_type; 28 | __SWORD_TYPE f_bsize; 29 | #ifndef __USE_FILE_OFFSET64 30 | __fsblkcnt_t f_blocks; 31 | __fsblkcnt_t f_bfree; 32 | __fsblkcnt_t f_bavail; 33 | __fsfilcnt_t f_files; 34 | __fsfilcnt_t f_ffree; 35 | #else 36 | __fsblkcnt64_t f_blocks; 37 | __fsblkcnt64_t f_bfree; 38 | __fsblkcnt64_t f_bavail; 39 | __fsfilcnt64_t f_files; 40 | __fsfilcnt64_t f_ffree; 41 | #endif 42 | __fsid_t f_fsid; 43 | __SWORD_TYPE f_namelen; 44 | __SWORD_TYPE f_frsize; 45 | __SWORD_TYPE f_spare[5]; 46 | }; 47 | 48 | #ifdef __USE_LARGEFILE64 49 | struct statfs64 50 | { 51 | __SWORD_TYPE f_type; 52 | __SWORD_TYPE f_bsize; 53 | __fsblkcnt64_t f_blocks; 54 | __fsblkcnt64_t f_bfree; 55 | __fsblkcnt64_t f_bavail; 56 | __fsfilcnt64_t f_files; 57 | __fsfilcnt64_t f_ffree; 58 | __fsid_t f_fsid; 59 | __SWORD_TYPE f_namelen; 60 | __SWORD_TYPE f_frsize; 61 | __SWORD_TYPE f_spare[5]; 62 | }; 63 | #endif 64 | 65 | /* Tell code we have these members. */ 66 | #define _STATFS_F_NAMELEN 67 | #define _STATFS_F_FRSIZE 68 | -------------------------------------------------------------------------------- /kernel/include/bits/statvfs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1997,1998,2000,2001,2002,2006 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _SYS_STATVFS_H 20 | # error "Never include directly; use instead." 21 | #endif 22 | 23 | #include /* For __fsblkcnt_t and __fsfilcnt_t. */ 24 | 25 | #if __WORDSIZE == 32 26 | #define _STATVFSBUF_F_UNUSED 27 | #endif 28 | 29 | struct statvfs 30 | { 31 | unsigned long int f_bsize; 32 | unsigned long int f_frsize; 33 | #ifndef __USE_FILE_OFFSET64 34 | __fsblkcnt_t f_blocks; 35 | __fsblkcnt_t f_bfree; 36 | __fsblkcnt_t f_bavail; 37 | __fsfilcnt_t f_files; 38 | __fsfilcnt_t f_ffree; 39 | __fsfilcnt_t f_favail; 40 | #else 41 | __fsblkcnt64_t f_blocks; 42 | __fsblkcnt64_t f_bfree; 43 | __fsblkcnt64_t f_bavail; 44 | __fsfilcnt64_t f_files; 45 | __fsfilcnt64_t f_ffree; 46 | __fsfilcnt64_t f_favail; 47 | #endif 48 | unsigned long int f_fsid; 49 | #ifdef _STATVFSBUF_F_UNUSED 50 | int __f_unused; 51 | #endif 52 | unsigned long int f_flag; 53 | unsigned long int f_namemax; 54 | int __f_spare[6]; 55 | }; 56 | 57 | #ifdef __USE_LARGEFILE64 58 | struct statvfs64 59 | { 60 | unsigned long int f_bsize; 61 | unsigned long int f_frsize; 62 | __fsblkcnt64_t f_blocks; 63 | __fsblkcnt64_t f_bfree; 64 | __fsblkcnt64_t f_bavail; 65 | __fsfilcnt64_t f_files; 66 | __fsfilcnt64_t f_ffree; 67 | __fsfilcnt64_t f_favail; 68 | unsigned long int f_fsid; 69 | #ifdef _STATVFSBUF_F_UNUSED 70 | int __f_unused; 71 | #endif 72 | unsigned long int f_flag; 73 | unsigned long int f_namemax; 74 | int __f_spare[6]; 75 | }; 76 | #endif 77 | 78 | /* Definitions for the flag in `f_flag'. These definitions should be 79 | kept in sync with the definitions in . */ 80 | enum 81 | { 82 | ST_RDONLY = 1, /* Mount read-only. */ 83 | #define ST_RDONLY ST_RDONLY 84 | ST_NOSUID = 2 /* Ignore suid and sgid bits. */ 85 | #define ST_NOSUID ST_NOSUID 86 | #ifdef __USE_GNU 87 | , 88 | ST_NODEV = 4, /* Disallow access to device special files. */ 89 | # define ST_NODEV ST_NODEV 90 | ST_NOEXEC = 8, /* Disallow program execution. */ 91 | # define ST_NOEXEC ST_NOEXEC 92 | ST_SYNCHRONOUS = 16, /* Writes are synced at once. */ 93 | # define ST_SYNCHRONOUS ST_SYNCHRONOUS 94 | ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */ 95 | # define ST_MANDLOCK ST_MANDLOCK 96 | ST_WRITE = 128, /* Write on file/directory/symlink. */ 97 | # define ST_WRITE ST_WRITE 98 | ST_APPEND = 256, /* Append-only file. */ 99 | # define ST_APPEND ST_APPEND 100 | ST_IMMUTABLE = 512, /* Immutable file. */ 101 | # define ST_IMMUTABLE ST_IMMUTABLE 102 | ST_NOATIME = 1024, /* Do not update access times. */ 103 | # define ST_NOATIME ST_NOATIME 104 | ST_NODIRATIME = 2048, /* Do not update directory access times. */ 105 | # define ST_NODIRATIME ST_NODIRATIME 106 | ST_RELATIME = 4096 /* Update atime relative to mtime/ctime. */ 107 | # define ST_RELATIME ST_RELATIME 108 | #endif /* Use GNU. */ 109 | }; 110 | -------------------------------------------------------------------------------- /kernel/include/bits/stdio-ldbl.h: -------------------------------------------------------------------------------- 1 | /* -mlong-double-64 compatibility mode for stdio functions. 2 | Copyright (C) 2006, 2007 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _STDIO_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | __BEGIN_NAMESPACE_STD 25 | __LDBL_REDIR_DECL (fprintf) 26 | __LDBL_REDIR_DECL (printf) 27 | __LDBL_REDIR_DECL (sprintf) 28 | __LDBL_REDIR_DECL (vfprintf) 29 | __LDBL_REDIR_DECL (vprintf) 30 | __LDBL_REDIR_DECL (vsprintf) 31 | #if defined __USE_ISOC99 && !defined __USE_GNU \ 32 | && !defined __REDIRECT \ 33 | && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) 34 | __LDBL_REDIR1_DECL (fscanf, __nldbl___isoc99_fscanf) 35 | __LDBL_REDIR1_DECL (scanf, __nldbl___isoc99_scanf) 36 | __LDBL_REDIR1_DECL (sscanf, __nldbl___isoc99_sscanf) 37 | #else 38 | __LDBL_REDIR_DECL (fscanf) 39 | __LDBL_REDIR_DECL (scanf) 40 | __LDBL_REDIR_DECL (sscanf) 41 | #endif 42 | __END_NAMESPACE_STD 43 | 44 | #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98 45 | __BEGIN_NAMESPACE_C99 46 | __LDBL_REDIR_DECL (snprintf) 47 | __LDBL_REDIR_DECL (vsnprintf) 48 | __END_NAMESPACE_C99 49 | #endif 50 | 51 | #ifdef __USE_ISOC99 52 | __BEGIN_NAMESPACE_C99 53 | # if !defined __USE_GNU && !defined __REDIRECT \ 54 | && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) 55 | __LDBL_REDIR1_DECL (vfscanf, __nldbl___isoc99_vfscanf) 56 | __LDBL_REDIR1_DECL (vscanf, __nldbl___isoc99_vscanf) 57 | __LDBL_REDIR1_DECL (vsscanf, __nldbl___isoc99_vsscanf) 58 | # else 59 | __LDBL_REDIR_DECL (vfscanf) 60 | __LDBL_REDIR_DECL (vsscanf) 61 | __LDBL_REDIR_DECL (vscanf) 62 | # endif 63 | __END_NAMESPACE_C99 64 | #endif 65 | 66 | #ifdef __USE_GNU 67 | __LDBL_REDIR_DECL (vdprintf) 68 | __LDBL_REDIR_DECL (dprintf) 69 | __LDBL_REDIR_DECL (vasprintf) 70 | __LDBL_REDIR_DECL (__asprintf) 71 | __LDBL_REDIR_DECL (asprintf) 72 | __LDBL_REDIR_DECL (obstack_printf) 73 | __LDBL_REDIR_DECL (obstack_vprintf) 74 | #endif 75 | 76 | #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline 77 | __LDBL_REDIR_DECL (__sprintf_chk) 78 | __LDBL_REDIR_DECL (__vsprintf_chk) 79 | # if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98 80 | __LDBL_REDIR_DECL (__snprintf_chk) 81 | __LDBL_REDIR_DECL (__vsnprintf_chk) 82 | # endif 83 | # if __USE_FORTIFY_LEVEL > 1 84 | __LDBL_REDIR_DECL (__fprintf_chk) 85 | __LDBL_REDIR_DECL (__printf_chk) 86 | __LDBL_REDIR_DECL (__vfprintf_chk) 87 | __LDBL_REDIR_DECL (__vprintf_chk) 88 | # endif 89 | #endif 90 | -------------------------------------------------------------------------------- /kernel/include/bits/stdio-lock.h: -------------------------------------------------------------------------------- 1 | /* Thread package specific definitions of stream lock type. NPTL version. 2 | Copyright (C) 2000, 2001, 2002, 2003, 2007 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _BITS_STDIO_LOCK_H 21 | #define _BITS_STDIO_LOCK_H 1 22 | 23 | #include 24 | #include 25 | 26 | 27 | /* The locking here is very inexpensive, even for inlining. */ 28 | #define _IO_lock_inexpensive 1 29 | 30 | typedef struct { int lock; int cnt; void *owner; } _IO_lock_t; 31 | 32 | #define _IO_lock_initializer { LLL_LOCK_INITIALIZER, 0, NULL } 33 | 34 | #define _IO_lock_init(_name) \ 35 | ((_name) = (_IO_lock_t) _IO_lock_initializer , 0) 36 | 37 | #define _IO_lock_fini(_name) \ 38 | ((void) 0) 39 | 40 | #define _IO_lock_lock(_name) \ 41 | do { \ 42 | void *__self = THREAD_SELF; \ 43 | if ((_name).owner != __self) \ 44 | { \ 45 | lll_lock ((_name).lock, LLL_PRIVATE); \ 46 | (_name).owner = __self; \ 47 | } \ 48 | ++(_name).cnt; \ 49 | } while (0) 50 | 51 | #define _IO_lock_trylock(_name) \ 52 | ({ \ 53 | int __result = 0; \ 54 | void *__self = THREAD_SELF; \ 55 | if ((_name).owner != __self) \ 56 | { \ 57 | if (lll_trylock ((_name).lock) == 0) \ 58 | { \ 59 | (_name).owner = __self; \ 60 | (_name).cnt = 1; \ 61 | } \ 62 | else \ 63 | __result = EBUSY; \ 64 | } \ 65 | else \ 66 | ++(_name).cnt; \ 67 | __result; \ 68 | }) 69 | 70 | #define _IO_lock_unlock(_name) \ 71 | do { \ 72 | if (--(_name).cnt == 0) \ 73 | { \ 74 | (_name).owner = NULL; \ 75 | lll_unlock ((_name).lock, LLL_PRIVATE); \ 76 | } \ 77 | } while (0) 78 | 79 | 80 | 81 | #define _IO_cleanup_region_start(_fct, _fp) \ 82 | __libc_cleanup_region_start (((_fp)->_flags & _IO_USER_LOCK) == 0, _fct, _fp) 83 | #define _IO_cleanup_region_start_noarg(_fct) \ 84 | __libc_cleanup_region_start (1, _fct, NULL) 85 | #define _IO_cleanup_region_end(_doit) \ 86 | __libc_cleanup_region_end (_doit) 87 | 88 | #if defined _LIBC && !defined NOT_IN_libc 89 | 90 | # ifdef __EXCEPTIONS 91 | # define _IO_acquire_lock(_fp) \ 92 | do { \ 93 | _IO_FILE *_IO_acquire_lock_file \ 94 | __attribute__((cleanup (_IO_acquire_lock_fct))) \ 95 | = (_fp); \ 96 | _IO_flockfile (_IO_acquire_lock_file); 97 | # define _IO_acquire_lock_clear_flags2(_fp) \ 98 | do { \ 99 | _IO_FILE *_IO_acquire_lock_file \ 100 | __attribute__((cleanup (_IO_acquire_lock_clear_flags2_fct))) \ 101 | = (_fp); \ 102 | _IO_flockfile (_IO_acquire_lock_file); 103 | # else 104 | # define _IO_acquire_lock(_fp) _IO_acquire_lock_needs_exceptions_enabled 105 | # define _IO_acquire_lock_clear_flags2(_fp) _IO_acquire_lock (_fp) 106 | # endif 107 | # define _IO_release_lock(_fp) ; } while (0) 108 | 109 | #endif 110 | 111 | #endif /* bits/stdio-lock.h */ 112 | -------------------------------------------------------------------------------- /kernel/include/bits/stdio_lim.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1994, 1997, 1998, 1999 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #if !defined _STDIO_H && !defined __need_FOPEN_MAX && !defined __need_IOV_MAX 20 | # error "Never include directly; use instead." 21 | #endif 22 | 23 | #ifdef _STDIO_H 24 | # define L_tmpnam 20 25 | # define TMP_MAX 238328 26 | # define FILENAME_MAX 4096 27 | 28 | # ifdef __USE_POSIX 29 | # define L_ctermid 9 30 | # define L_cuserid 9 31 | # endif 32 | #endif 33 | 34 | #if defined __need_FOPEN_MAX || defined _STDIO_H 35 | # undef FOPEN_MAX 36 | # define FOPEN_MAX 16 37 | #endif 38 | 39 | #if defined __need_IOV_MAX && !defined IOV_MAX 40 | # define IOV_MAX 1024 41 | #endif 42 | -------------------------------------------------------------------------------- /kernel/include/bits/stdlib-ldbl.h: -------------------------------------------------------------------------------- 1 | /* -mlong-double-64 compatibility mode for functions. 2 | Copyright (C) 2006, 2007 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _STDLIB_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | #ifdef __USE_ISOC99 25 | __BEGIN_NAMESPACE_C99 26 | __LDBL_REDIR1_DECL (strtold, strtod) 27 | __END_NAMESPACE_C99 28 | #endif 29 | 30 | #ifdef __USE_GNU 31 | __LDBL_REDIR1_DECL (strtold_l, strtod_l) 32 | #endif 33 | 34 | #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED 35 | # ifdef __USE_MISC 36 | __LDBL_REDIR1_DECL (qecvt, ecvt) 37 | __LDBL_REDIR1_DECL (qfcvt, fcvt) 38 | __LDBL_REDIR1_DECL (qgcvt, gcvt) 39 | __LDBL_REDIR1_DECL (qecvt_r, ecvt_r) 40 | __LDBL_REDIR1_DECL (qfcvt_r, fcvt_r) 41 | # endif 42 | #endif 43 | -------------------------------------------------------------------------------- /kernel/include/bits/string.h: -------------------------------------------------------------------------------- 1 | /* Optimized, inlined string functions. AMD x86-64 version. 2 | Copyright (C) 2001 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _STRING_H 21 | # error "Never use directly; include instead." 22 | #endif 23 | 24 | /* Currently the only purpose of this file is to tell the generic inline 25 | macros that unaligned memory access is possible for x86-64. */ 26 | #define _STRING_ARCH_unaligned 1 27 | -------------------------------------------------------------------------------- /kernel/include/bits/sys_errlist.h: -------------------------------------------------------------------------------- 1 | /* Declare sys_errlist and sys_nerr, or don't. Compatibility (do) version. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _STDIO_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | /* sys_errlist and sys_nerr are deprecated. Use strerror instead. */ 25 | 26 | #ifdef __USE_BSD 27 | extern int sys_nerr; 28 | extern __const char *__const sys_errlist[]; 29 | #endif 30 | #ifdef __USE_GNU 31 | extern int _sys_nerr; 32 | extern __const char *__const _sys_errlist[]; 33 | #endif 34 | -------------------------------------------------------------------------------- /kernel/include/bits/syslog-ldbl.h: -------------------------------------------------------------------------------- 1 | /* -mlong-double-64 compatibility mode for syslog functions. 2 | Copyright (C) 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _SYS_SYSLOG_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | __LDBL_REDIR_DECL (syslog) 25 | 26 | #ifdef __USE_BSD 27 | __LDBL_REDIR_DECL (vsyslog) 28 | #endif 29 | 30 | #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline 31 | __LDBL_REDIR_DECL (__syslog_chk) 32 | 33 | # ifdef __USE_BSD 34 | __LDBL_REDIR_DECL (__vsyslog_chk) 35 | # endif 36 | #endif 37 | -------------------------------------------------------------------------------- /kernel/include/bits/syslog-path.h: -------------------------------------------------------------------------------- 1 | /* -- _PATH_LOG definition 2 | Copyright (C) 2006 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _SYS_SYSLOG_H 21 | # error "Never include this file directly. Use instead" 22 | #endif 23 | 24 | #ifndef _BITS_SYSLOG_PATH_H 25 | #define _BITS_SYSLOG_PATH_H 1 26 | 27 | #define _PATH_LOG "/dev/log" 28 | 29 | #endif /* bits/syslog-path.h */ 30 | -------------------------------------------------------------------------------- /kernel/include/bits/syslog.h: -------------------------------------------------------------------------------- 1 | /* Checking macros for syslog functions. 2 | Copyright (C) 2005, 2007 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _SYS_SYSLOG_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | 25 | extern void __syslog_chk (int __pri, int __flag, __const char *__fmt, ...) 26 | __attribute__ ((__format__ (__printf__, 3, 4))); 27 | 28 | #ifdef __va_arg_pack 29 | __extern_always_inline void 30 | syslog (int __pri, __const char *__fmt, ...) 31 | { 32 | return __syslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); 33 | } 34 | #elif !defined __cplusplus 35 | # define syslog(pri, ...) \ 36 | __syslog_chk (pri, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) 37 | #endif 38 | 39 | 40 | #ifdef __USE_BSD 41 | extern void __vsyslog_chk (int __pri, int __flag, __const char *__fmt, 42 | __gnuc_va_list __ap) 43 | __attribute__ ((__format__ (__printf__, 3, 0))); 44 | 45 | __extern_always_inline void 46 | vsyslog (int __pri, __const char *__fmt, __gnuc_va_list __ap) 47 | { 48 | return __vsyslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /kernel/include/bits/time.h: -------------------------------------------------------------------------------- 1 | /* System-dependent timing definitions. Generic version. 2 | Copyright (C) 1996,1997,1999-2002,2003 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | /* 21 | * Never include this file directly; use instead. 22 | */ 23 | 24 | #ifndef __need_timeval 25 | # ifndef _BITS_TIME_H 26 | # define _BITS_TIME_H 1 27 | 28 | /* ISO/IEC 9899:1990 7.12.1: 29 | The macro `CLOCKS_PER_SEC' is the number per second of the value 30 | returned by the `clock' function. */ 31 | /* CAE XSH, Issue 4, Version 2: 32 | The value of CLOCKS_PER_SEC is required to be 1 million on all 33 | XSI-conformant systems. */ 34 | # define CLOCKS_PER_SEC 1000000l 35 | 36 | # if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K 37 | /* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK 38 | presents the real value for clock ticks per second for the system. */ 39 | # include 40 | extern long int __sysconf (int); 41 | # define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */ 42 | # endif 43 | 44 | # ifdef __USE_POSIX199309 45 | /* Identifier for system-wide realtime clock. */ 46 | # define CLOCK_REALTIME 0 47 | /* Monotonic system-wide clock. */ 48 | # define CLOCK_MONOTONIC 1 49 | /* High-resolution timer from the CPU. */ 50 | # define CLOCK_PROCESS_CPUTIME_ID 2 51 | /* Thread-specific CPU-time clock. */ 52 | # define CLOCK_THREAD_CPUTIME_ID 3 53 | 54 | /* Flag to indicate time is absolute. */ 55 | # define TIMER_ABSTIME 1 56 | # endif 57 | 58 | # endif /* bits/time.h */ 59 | #endif 60 | 61 | #ifdef __need_timeval 62 | # undef __need_timeval 63 | # ifndef _STRUCT_TIMEVAL 64 | # define _STRUCT_TIMEVAL 1 65 | # include 66 | 67 | /* A time value that is accurate to the nearest 68 | microsecond but also has a range of years. */ 69 | struct timeval 70 | { 71 | __time_t tv_sec; /* Seconds. */ 72 | __suseconds_t tv_usec; /* Microseconds. */ 73 | }; 74 | # endif /* struct timeval */ 75 | #endif /* need timeval */ 76 | -------------------------------------------------------------------------------- /kernel/include/bits/typesizes.h: -------------------------------------------------------------------------------- 1 | /* bits/typesizes.h -- underlying types for *_t. Generic version. 2 | Copyright (C) 2002, 2003 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _BITS_TYPES_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | #ifndef _BITS_TYPESIZES_H 25 | #define _BITS_TYPESIZES_H 1 26 | 27 | /* See for the meaning of these macros. This file exists so 28 | that need not vary across different GNU platforms. */ 29 | 30 | #define __DEV_T_TYPE __UQUAD_TYPE 31 | #define __UID_T_TYPE __U32_TYPE 32 | #define __GID_T_TYPE __U32_TYPE 33 | #define __INO_T_TYPE __ULONGWORD_TYPE 34 | #define __INO64_T_TYPE __UQUAD_TYPE 35 | #define __MODE_T_TYPE __U32_TYPE 36 | #define __NLINK_T_TYPE __UWORD_TYPE 37 | #define __OFF_T_TYPE __SLONGWORD_TYPE 38 | #define __OFF64_T_TYPE __SQUAD_TYPE 39 | #define __PID_T_TYPE __S32_TYPE 40 | #define __RLIM_T_TYPE __ULONGWORD_TYPE 41 | #define __RLIM64_T_TYPE __UQUAD_TYPE 42 | #define __BLKCNT_T_TYPE __SLONGWORD_TYPE 43 | #define __BLKCNT64_T_TYPE __SQUAD_TYPE 44 | #define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE 45 | #define __FSBLKCNT64_T_TYPE __UQUAD_TYPE 46 | #define __FSFILCNT_T_TYPE __ULONGWORD_TYPE 47 | #define __FSFILCNT64_T_TYPE __UQUAD_TYPE 48 | #define __ID_T_TYPE __U32_TYPE 49 | #define __CLOCK_T_TYPE __SLONGWORD_TYPE 50 | #define __TIME_T_TYPE __SLONGWORD_TYPE 51 | #define __USECONDS_T_TYPE __U32_TYPE 52 | #define __SUSECONDS_T_TYPE __SLONGWORD_TYPE 53 | #define __DADDR_T_TYPE __S32_TYPE 54 | #define __SWBLK_T_TYPE __SLONGWORD_TYPE 55 | #define __KEY_T_TYPE __S32_TYPE 56 | #define __CLOCKID_T_TYPE __S32_TYPE 57 | #define __TIMER_T_TYPE void * 58 | #define __BLKSIZE_T_TYPE __SLONGWORD_TYPE 59 | #define __FSID_T_TYPE struct { int __val[2]; } 60 | #define __SSIZE_T_TYPE __SWORD_TYPE 61 | 62 | /* Number of descriptors that can fit in an `fd_set'. */ 63 | #define __FD_SETSIZE 1024 64 | 65 | 66 | #endif /* bits/typesizes.h */ 67 | -------------------------------------------------------------------------------- /kernel/include/bits/uio.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996, 1997, 2006 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #if !defined _SYS_UIO_H && !defined _FCNTL_H 20 | # error "Never include directly; use instead." 21 | #endif 22 | 23 | #ifndef _BITS_UIO_H 24 | #define _BITS_UIO_H 1 25 | 26 | #include 27 | 28 | 29 | /* We should normally use the Linux kernel header file to define this 30 | type and macros but this calls for trouble because of the header 31 | includes other kernel headers. */ 32 | 33 | /* Size of object which can be written atomically. 34 | 35 | This macro has different values in different kernel versions. The 36 | latest versions of the kernel use 1024 and this is good choice. Since 37 | the C library implementation of readv/writev is able to emulate the 38 | functionality even if the currently running kernel does not support 39 | this large value the readv/writev call will not fail because of this. */ 40 | #define UIO_MAXIOV 1024 41 | 42 | 43 | /* Structure for scatter/gather I/O. */ 44 | struct iovec 45 | { 46 | void *iov_base; /* Pointer to data. */ 47 | size_t iov_len; /* Length of data. */ 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /kernel/include/bits/ustat.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1997, 2002 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _SYS_USTAT_H 20 | # error "Never include directly; use instead." 21 | #endif 22 | 23 | #include 24 | 25 | struct ustat 26 | { 27 | __daddr_t f_tfree; /* Number of free blocks. */ 28 | __ino_t f_tinode; /* Number of free inodes. */ 29 | char f_fname[6]; 30 | char f_fpack[6]; 31 | }; 32 | -------------------------------------------------------------------------------- /kernel/include/bits/utmp.h: -------------------------------------------------------------------------------- 1 | /* The `struct utmp' type, describing entries in the utmp file. GNU version. 2 | Copyright (C) 1993, 1996, 1997, 1998, 1999, 2002 3 | Free Software Foundation, Inc. 4 | This file is part of the GNU C Library. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, write to the Free 18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | 02111-1307 USA. */ 20 | 21 | #ifndef _UTMP_H 22 | # error "Never include directly; use instead." 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | #define UT_LINESIZE 32 32 | #define UT_NAMESIZE 32 33 | #define UT_HOSTSIZE 256 34 | 35 | 36 | /* The structure describing an entry in the database of 37 | previous logins. */ 38 | struct lastlog 39 | { 40 | #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32 41 | int32_t ll_time; 42 | #else 43 | __time_t ll_time; 44 | #endif 45 | char ll_line[UT_LINESIZE]; 46 | char ll_host[UT_HOSTSIZE]; 47 | }; 48 | 49 | 50 | /* The structure describing the status of a terminated process. This 51 | type is used in `struct utmp' below. */ 52 | struct exit_status 53 | { 54 | short int e_termination; /* Process termination status. */ 55 | short int e_exit; /* Process exit status. */ 56 | }; 57 | 58 | 59 | /* The structure describing an entry in the user accounting database. */ 60 | struct utmp 61 | { 62 | short int ut_type; /* Type of login. */ 63 | pid_t ut_pid; /* Process ID of login process. */ 64 | char ut_line[UT_LINESIZE]; /* Devicename. */ 65 | char ut_id[4]; /* Inittab ID. */ 66 | char ut_user[UT_NAMESIZE]; /* Username. */ 67 | char ut_host[UT_HOSTSIZE]; /* Hostname for remote login. */ 68 | struct exit_status ut_exit; /* Exit status of a process marked 69 | as DEAD_PROCESS. */ 70 | /* The ut_session and ut_tv fields must be the same size when compiled 71 | 32- and 64-bit. This allows data files and shared memory to be 72 | shared between 32- and 64-bit applications. */ 73 | #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32 74 | int32_t ut_session; /* Session ID, used for windowing. */ 75 | struct 76 | { 77 | int32_t tv_sec; /* Seconds. */ 78 | int32_t tv_usec; /* Microseconds. */ 79 | } ut_tv; /* Time entry was made. */ 80 | #else 81 | long int ut_session; /* Session ID, used for windowing. */ 82 | struct timeval ut_tv; /* Time entry was made. */ 83 | #endif 84 | 85 | int32_t ut_addr_v6[4]; /* Internet address of remote host. */ 86 | char __unused[20]; /* Reserved for future use. */ 87 | }; 88 | 89 | /* Backwards compatibility hacks. */ 90 | #define ut_name ut_user 91 | #ifndef _NO_UT_TIME 92 | /* We have a problem here: `ut_time' is also used otherwise. Define 93 | _NO_UT_TIME if the compiler complains. */ 94 | # define ut_time ut_tv.tv_sec 95 | #endif 96 | #define ut_xtime ut_tv.tv_sec 97 | #define ut_addr ut_addr_v6[0] 98 | 99 | 100 | /* Values for the `ut_type' field of a `struct utmp'. */ 101 | #define EMPTY 0 /* No valid user accounting information. */ 102 | 103 | #define RUN_LVL 1 /* The system's runlevel. */ 104 | #define BOOT_TIME 2 /* Time of system boot. */ 105 | #define NEW_TIME 3 /* Time after system clock changed. */ 106 | #define OLD_TIME 4 /* Time when system clock changed. */ 107 | 108 | #define INIT_PROCESS 5 /* Process spawned by the init process. */ 109 | #define LOGIN_PROCESS 6 /* Session leader of a logged in user. */ 110 | #define USER_PROCESS 7 /* Normal process. */ 111 | #define DEAD_PROCESS 8 /* Terminated process. */ 112 | 113 | #define ACCOUNTING 9 114 | 115 | /* Old Linux name for the EMPTY type. */ 116 | #define UT_UNKNOWN EMPTY 117 | 118 | 119 | /* Tell the user that we have a modern system with UT_HOST, UT_PID, 120 | UT_TYPE, UT_ID and UT_TV fields. */ 121 | #define _HAVE_UT_TYPE 1 122 | #define _HAVE_UT_PID 1 123 | #define _HAVE_UT_ID 1 124 | #define _HAVE_UT_TV 1 125 | #define _HAVE_UT_HOST 1 126 | -------------------------------------------------------------------------------- /kernel/include/bits/utmpx.h: -------------------------------------------------------------------------------- 1 | /* Structures and definitions for the user accounting database. GNU version. 2 | Copyright (C) 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _UTMPX_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | #ifdef __USE_GNU 30 | # include 31 | # define _PATH_UTMPX _PATH_UTMP 32 | # define _PATH_WTMPX _PATH_WTMP 33 | #endif 34 | 35 | 36 | #define __UT_LINESIZE 32 37 | #define __UT_NAMESIZE 32 38 | #define __UT_HOSTSIZE 256 39 | 40 | 41 | /* The structure describing the status of a terminated process. This 42 | type is used in `struct utmpx' below. */ 43 | struct __exit_status 44 | { 45 | #ifdef __USE_GNU 46 | short int e_termination; /* Process termination status. */ 47 | short int e_exit; /* Process exit status. */ 48 | #else 49 | short int __e_termination; /* Process termination status. */ 50 | short int __e_exit; /* Process exit status. */ 51 | #endif 52 | }; 53 | 54 | 55 | /* The structure describing an entry in the user accounting database. */ 56 | struct utmpx 57 | { 58 | short int ut_type; /* Type of login. */ 59 | __pid_t ut_pid; /* Process ID of login process. */ 60 | char ut_line[__UT_LINESIZE]; /* Devicename. */ 61 | char ut_id[4]; /* Inittab ID. */ 62 | char ut_user[__UT_NAMESIZE]; /* Username. */ 63 | char ut_host[__UT_HOSTSIZE]; /* Hostname for remote login. */ 64 | struct __exit_status ut_exit; /* Exit status of a process marked 65 | as DEAD_PROCESS. */ 66 | 67 | /* The fields ut_session and ut_tv must be the same size when compiled 68 | 32- and 64-bit. This allows files and shared memory to be shared 69 | between 32- and 64-bit applications. */ 70 | #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32 71 | __int32_t ut_session; /* Session ID, used for windowing. */ 72 | struct 73 | { 74 | __int32_t tv_sec; /* Seconds. */ 75 | __int32_t tv_usec; /* Microseconds. */ 76 | } ut_tv; /* Time entry was made. */ 77 | #else 78 | long int ut_session; /* Session ID, used for windowing. */ 79 | struct timeval ut_tv; /* Time entry was made. */ 80 | #endif 81 | __int32_t ut_addr_v6[4]; /* Internet address of remote host. */ 82 | char __unused[20]; /* Reserved for future use. */ 83 | }; 84 | 85 | 86 | /* Values for the `ut_type' field of a `struct utmpx'. */ 87 | #define EMPTY 0 /* No valid user accounting information. */ 88 | 89 | #ifdef __USE_GNU 90 | # define RUN_LVL 1 /* The system's runlevel. */ 91 | #endif 92 | #define BOOT_TIME 2 /* Time of system boot. */ 93 | #define NEW_TIME 3 /* Time after system clock changed. */ 94 | #define OLD_TIME 4 /* Time when system clock changed. */ 95 | 96 | #define INIT_PROCESS 5 /* Process spawned by the init process. */ 97 | #define LOGIN_PROCESS 6 /* Session leader of a logged in user. */ 98 | #define USER_PROCESS 7 /* Normal process. */ 99 | #define DEAD_PROCESS 8 /* Terminated process. */ 100 | 101 | #ifdef __USE_GNU 102 | # define ACCOUNTING 9 /* System accounting. */ 103 | #endif 104 | -------------------------------------------------------------------------------- /kernel/include/bits/utsname.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #ifndef _SYS_UTSNAME_H 20 | # error "Never include directly; use instead." 21 | #endif 22 | 23 | /* Length of the entries in `struct utsname' is 65. */ 24 | #define _UTSNAME_LENGTH 65 25 | 26 | /* Linux provides as additional information in the `struct utsname' 27 | the name of the current domain. Define _UTSNAME_DOMAIN_LENGTH 28 | to a value != 0 to activate this entry. */ 29 | #define _UTSNAME_DOMAIN_LENGTH _UTSNAME_LENGTH 30 | -------------------------------------------------------------------------------- /kernel/include/bits/waitflags.h: -------------------------------------------------------------------------------- 1 | /* Definitions of flag bits for `waitpid' et al. 2 | Copyright (C) 1992,1996,1997,2000,2004,2005 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #if !defined _SYS_WAIT_H && !defined _STDLIB_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | 25 | /* Bits in the third argument to `waitpid'. */ 26 | #define WNOHANG 1 /* Don't block waiting. */ 27 | #define WUNTRACED 2 /* Report status of stopped children. */ 28 | 29 | /* Bits in the fourth argument to `waitid'. */ 30 | #define WSTOPPED 2 /* Report stopped child (same as WUNTRACED). */ 31 | #define WEXITED 4 /* Report dead child. */ 32 | #define WCONTINUED 8 /* Report continued child. */ 33 | #define WNOWAIT 0x01000000 /* Don't reap, just poll status. */ 34 | 35 | #define __WNOTHREAD 0x20000000 /* Don't wait on children of other threads 36 | in this group */ 37 | #define __WALL 0x40000000 /* Wait for any child. */ 38 | #define __WCLONE 0x80000000 /* Wait for cloned process. */ 39 | -------------------------------------------------------------------------------- /kernel/include/bits/waitstatus.h: -------------------------------------------------------------------------------- 1 | /* Definitions of status bits for `wait' et al. 2 | Copyright (C) 1992,1994,1996,1997,2000,2004 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #if !defined _SYS_WAIT_H && !defined _STDLIB_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | 25 | /* Everything extant so far uses these same bits. */ 26 | 27 | 28 | /* If WIFEXITED(STATUS), the low-order 8 bits of the status. */ 29 | #define __WEXITSTATUS(status) (((status) & 0xff00) >> 8) 30 | 31 | /* If WIFSIGNALED(STATUS), the terminating signal. */ 32 | #define __WTERMSIG(status) ((status) & 0x7f) 33 | 34 | /* If WIFSTOPPED(STATUS), the signal that stopped the child. */ 35 | #define __WSTOPSIG(status) __WEXITSTATUS(status) 36 | 37 | /* Nonzero if STATUS indicates normal termination. */ 38 | #define __WIFEXITED(status) (__WTERMSIG(status) == 0) 39 | 40 | /* Nonzero if STATUS indicates termination by a signal. */ 41 | #define __WIFSIGNALED(status) \ 42 | (((signed char) (((status) & 0x7f) + 1) >> 1) > 0) 43 | 44 | /* Nonzero if STATUS indicates the child is stopped. */ 45 | #define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f) 46 | 47 | /* Nonzero if STATUS indicates the child continued after a stop. We only 48 | define this if provides the WCONTINUED flag bit. */ 49 | #ifdef WCONTINUED 50 | # define __WIFCONTINUED(status) ((status) == __W_CONTINUED) 51 | #endif 52 | 53 | /* Nonzero if STATUS indicates the child dumped core. */ 54 | #define __WCOREDUMP(status) ((status) & __WCOREFLAG) 55 | 56 | /* Macros for constructing status values. */ 57 | #define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) 58 | #define __W_STOPCODE(sig) ((sig) << 8 | 0x7f) 59 | #define __W_CONTINUED 0xffff 60 | #define __WCOREFLAG 0x80 61 | 62 | 63 | #ifdef __USE_BSD 64 | 65 | # include 66 | 67 | union wait 68 | { 69 | int w_status; 70 | struct 71 | { 72 | # if __BYTE_ORDER == __LITTLE_ENDIAN 73 | unsigned int __w_termsig:7; /* Terminating signal. */ 74 | unsigned int __w_coredump:1; /* Set if dumped core. */ 75 | unsigned int __w_retcode:8; /* Return code if exited normally. */ 76 | unsigned int:16; 77 | # endif /* Little endian. */ 78 | # if __BYTE_ORDER == __BIG_ENDIAN 79 | unsigned int:16; 80 | unsigned int __w_retcode:8; 81 | unsigned int __w_coredump:1; 82 | unsigned int __w_termsig:7; 83 | # endif /* Big endian. */ 84 | } __wait_terminated; 85 | struct 86 | { 87 | # if __BYTE_ORDER == __LITTLE_ENDIAN 88 | unsigned int __w_stopval:8; /* W_STOPPED if stopped. */ 89 | unsigned int __w_stopsig:8; /* Stopping signal. */ 90 | unsigned int:16; 91 | # endif /* Little endian. */ 92 | # if __BYTE_ORDER == __BIG_ENDIAN 93 | unsigned int:16; 94 | unsigned int __w_stopsig:8; /* Stopping signal. */ 95 | unsigned int __w_stopval:8; /* W_STOPPED if stopped. */ 96 | # endif /* Big endian. */ 97 | } __wait_stopped; 98 | }; 99 | 100 | # define w_termsig __wait_terminated.__w_termsig 101 | # define w_coredump __wait_terminated.__w_coredump 102 | # define w_retcode __wait_terminated.__w_retcode 103 | # define w_stopsig __wait_stopped.__w_stopsig 104 | # define w_stopval __wait_stopped.__w_stopval 105 | 106 | #endif /* Use BSD. */ 107 | -------------------------------------------------------------------------------- /kernel/include/bits/wchar-ldbl.h: -------------------------------------------------------------------------------- 1 | /* -mlong-double-64 compatibility mode for functions. 2 | Copyright (C) 2006, 2007 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _WCHAR_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | #if defined __USE_ISOC95 || defined __USE_UNIX98 25 | __BEGIN_NAMESPACE_C99 26 | __LDBL_REDIR_DECL (fwprintf); 27 | __LDBL_REDIR_DECL (wprintf); 28 | __LDBL_REDIR_DECL (swprintf); 29 | __LDBL_REDIR_DECL (vfwprintf); 30 | __LDBL_REDIR_DECL (vwprintf); 31 | __LDBL_REDIR_DECL (vswprintf); 32 | # if defined __USE_ISOC99 && !defined __USE_GNU \ 33 | && !defined __REDIRECT \ 34 | && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) 35 | __LDBL_REDIR1_DECL (fwscanf, __nldbl___isoc99_fwscanf) 36 | __LDBL_REDIR1_DECL (wscanf, __nldbl___isoc99_wscanf) 37 | __LDBL_REDIR1_DECL (swscanf, __nldbl___isoc99_swscanf) 38 | # else 39 | __LDBL_REDIR_DECL (fwscanf); 40 | __LDBL_REDIR_DECL (wscanf); 41 | __LDBL_REDIR_DECL (swscanf); 42 | # endif 43 | __END_NAMESPACE_C99 44 | #endif 45 | 46 | #ifdef __USE_ISOC99 47 | __BEGIN_NAMESPACE_C99 48 | __LDBL_REDIR1_DECL (wcstold, wcstod); 49 | # if !defined __USE_GNU && !defined __REDIRECT \ 50 | && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) 51 | __LDBL_REDIR1_DECL (vfwscanf, __nldbl___isoc99_vfwscanf) 52 | __LDBL_REDIR1_DECL (vwscanf, __nldbl___isoc99_vwscanf) 53 | __LDBL_REDIR1_DECL (vswscanf, __nldbl___isoc99_vswscanf) 54 | # else 55 | __LDBL_REDIR_DECL (vfwscanf); 56 | __LDBL_REDIR_DECL (vwscanf); 57 | __LDBL_REDIR_DECL (vswscanf); 58 | # endif 59 | __END_NAMESPACE_C99 60 | #endif 61 | 62 | #ifdef __USE_GNU 63 | __LDBL_REDIR1_DECL (wcstold_l, wcstod_l); 64 | #endif 65 | 66 | #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline 67 | __LDBL_REDIR_DECL (__swprintf_chk) 68 | __LDBL_REDIR_DECL (__vswprintf_chk) 69 | # if __USE_FORTIFY_LEVEL > 1 70 | __LDBL_REDIR_DECL (__fwprintf_chk) 71 | __LDBL_REDIR_DECL (__wprintf_chk) 72 | __LDBL_REDIR_DECL (__vfwprintf_chk) 73 | __LDBL_REDIR_DECL (__vwprintf_chk) 74 | # endif 75 | #endif 76 | -------------------------------------------------------------------------------- /kernel/include/bits/wchar.h: -------------------------------------------------------------------------------- 1 | /* wchar_t type related definitions. 2 | Copyright (C) 2000 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _BITS_WCHAR_H 21 | #define _BITS_WCHAR_H 1 22 | 23 | #define __WCHAR_MIN (-2147483647 - 1) 24 | #define __WCHAR_MAX (2147483647) 25 | 26 | #endif /* bits/wchar.h */ 27 | -------------------------------------------------------------------------------- /kernel/include/bits/wordsize.h: -------------------------------------------------------------------------------- 1 | /* Determine the wordsize from the preprocessor defines. */ 2 | 3 | #if defined __x86_64__ 4 | # define __WORDSIZE 64 5 | # define __WORDSIZE_COMPAT32 1 6 | #else 7 | # define __WORDSIZE 32 8 | #endif 9 | -------------------------------------------------------------------------------- /kernel/include/bits/xopen_lim.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | /* 20 | * Never include this file directly; use instead. 21 | */ 22 | 23 | /* Additional definitions from X/Open Portability Guide, Issue 4, Version 2 24 | System Interfaces and Headers, 4.16 25 | 26 | Please note only the values which are not greater than the minimum 27 | stated in the standard document are listed. The `sysconf' functions 28 | should be used to obtain the actual value. */ 29 | 30 | #ifndef _XOPEN_LIM_H 31 | #define _XOPEN_LIM_H 1 32 | 33 | #define __need_IOV_MAX 34 | #include 35 | 36 | /* We do not provide fixed values for 37 | 38 | ARG_MAX Maximum length of argument to the `exec' function 39 | including environment data. 40 | 41 | ATEXIT_MAX Maximum number of functions that may be registered 42 | with `atexit'. 43 | 44 | CHILD_MAX Maximum number of simultaneous processes per real 45 | user ID. 46 | 47 | OPEN_MAX Maximum number of files that one process can have open 48 | at anyone time. 49 | 50 | PAGESIZE 51 | PAGE_SIZE Size of bytes of a page. 52 | 53 | PASS_MAX Maximum number of significant bytes in a password. 54 | 55 | We only provide a fixed limit for 56 | 57 | IOV_MAX Maximum number of `iovec' structures that one process has 58 | available for use with `readv' or writev'. 59 | 60 | if this is indeed fixed by the underlying system. 61 | */ 62 | 63 | 64 | /* Maximum number of `iovec' structures that one process has available 65 | for use with `readv' or writev'. */ 66 | #define _XOPEN_IOV_MAX _POSIX_UIO_MAXIOV 67 | 68 | 69 | /* Maximum value of `digit' in calls to the `printf' and `scanf' 70 | functions. We have no limit, so return a reasonable value. */ 71 | #define NL_ARGMAX _POSIX_ARG_MAX 72 | 73 | /* Maximum number of bytes in a `LANG' name. We have no limit. */ 74 | #define NL_LANGMAX _POSIX2_LINE_MAX 75 | 76 | /* Maximum message number. We have no limit. */ 77 | #define NL_MSGMAX INT_MAX 78 | 79 | /* Maximum number of bytes in N-to-1 collation mapping. We have no 80 | limit. */ 81 | #define NL_NMAX INT_MAX 82 | 83 | /* Maximum set number. We have no limit. */ 84 | #define NL_SETMAX INT_MAX 85 | 86 | /* Maximum number of bytes in a message. We have no limit. */ 87 | #define NL_TEXTMAX INT_MAX 88 | 89 | /* Default process priority. */ 90 | #define NZERO 20 91 | 92 | 93 | /* Number of bits in a word of type `int'. */ 94 | #ifdef INT_MAX 95 | # if INT_MAX == 32767 96 | # define WORD_BIT 16 97 | # else 98 | # if INT_MAX == 2147483647 99 | # define WORD_BIT 32 100 | # else 101 | /* Safe assumption. */ 102 | # define WORD_BIT 64 103 | # endif 104 | # endif 105 | #elif defined __INT_MAX__ 106 | # if __INT_MAX__ == 32767 107 | # define WORD_BIT 16 108 | # else 109 | # if __INT_MAX__ == 2147483647 110 | # define WORD_BIT 32 111 | # else 112 | /* Safe assumption. */ 113 | # define WORD_BIT 64 114 | # endif 115 | # endif 116 | #else 117 | # define WORD_BIT 32 118 | #endif 119 | 120 | /* Number of bits in a word of type `long int'. */ 121 | #ifdef LONG_MAX 122 | # if LONG_MAX == 2147483647 123 | # define LONG_BIT 32 124 | # else 125 | /* Safe assumption. */ 126 | # define LONG_BIT 64 127 | # endif 128 | #elif defined __LONG_MAX__ 129 | # if __LONG_MAX__ == 2147483647 130 | # define LONG_BIT 32 131 | # else 132 | /* Safe assumption. */ 133 | # define LONG_BIT 64 134 | # endif 135 | #else 136 | # include 137 | # if __WORDSIZE == 64 138 | # define LONG_BIT 64 139 | # else 140 | # define LONG_BIT 32 141 | # endif 142 | #endif 143 | 144 | #endif /* bits/xopen_lim.h */ 145 | -------------------------------------------------------------------------------- /kernel/include/bits/xtitypes.h: -------------------------------------------------------------------------------- 1 | /* bits/xtitypes.h -- Define some types used by . x86-64. 2 | Copyright (C) 2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _STROPTS_H 21 | # error "Never include directly; use instead." 22 | #endif 23 | 24 | #ifndef _BITS_XTITYPES_H 25 | #define _BITS_XTITYPES_H 1 26 | 27 | #include 28 | 29 | /* This type is used by some structs in . */ 30 | typedef __SLONG32_TYPE __t_scalar_t; 31 | typedef __ULONG32_TYPE __t_uscalar_t; 32 | 33 | 34 | #endif /* bits/xtitypes.h */ 35 | -------------------------------------------------------------------------------- /kernel/include/gnu/lib-names.h: -------------------------------------------------------------------------------- 1 | /* This file is automatically generated. 2 | It defines macros to allow user program to find the shared 3 | library files which come as part of GNU libc. */ 4 | #ifndef __GNU_LIB_NAMES_H 5 | #define __GNU_LIB_NAMES_H 1 6 | 7 | #include 8 | 9 | #if __WORDSIZE == 32 10 | # define LD_LINUX_SO "ld-linux.so.2" 11 | # define LD_SO "ld-linux.so.2" 12 | # define LIBANL_SO "libanl.so.1" 13 | # define LIBBROKENLOCALE_SO "libBrokenLocale.so.1" 14 | # define LIBCIDN_SO "libcidn.so.1" 15 | # define LIBCRYPT_SO "libcrypt.so.1" 16 | # define LIBC_SO "libc.so.6" 17 | # define LIBDL_SO "libdl.so.2" 18 | # define LIBM_SO "libm.so.6" 19 | # define LIBNSL_SO "libnsl.so.1" 20 | # define LIBNSS_COMPAT_SO "libnss_compat.so.2" 21 | # define LIBNSS_DNS_SO "libnss_dns.so.2" 22 | # define LIBNSS_FILES_SO "libnss_files.so.2" 23 | # define LIBNSS_HESIOD_SO "libnss_hesiod.so.2" 24 | # define LIBNSS_LDAP_SO "libnss_ldap.so.2" 25 | # define LIBNSS_NISPLUS_SO "libnss_nisplus.so.2" 26 | # define LIBNSS_NIS_SO "libnss_nis.so.2" 27 | # define LIBPTHREAD_SO "libpthread.so.0" 28 | # define LIBRESOLV_SO "libresolv.so.2" 29 | # define LIBRT_SO "librt.so.1" 30 | # define LIBTHREAD_DB_SO "libthread_db.so.1" 31 | # define LIBUTIL_SO "libutil.so.1" 32 | #else 33 | # define LD_LINUX_X86_64_SO "ld-linux-x86-64.so.2" 34 | # define LD_SO "ld-linux-x86-64.so.2" 35 | # define LIBANL_SO "libanl.so.1" 36 | # define LIBBROKENLOCALE_SO "libBrokenLocale.so.1" 37 | # define LIBCIDN_SO "libcidn.so.1" 38 | # define LIBCRYPT_SO "libcrypt.so.1" 39 | # define LIBC_SO "libc.so.6" 40 | # define LIBDL_SO "libdl.so.2" 41 | # define LIBM_SO "libm.so.6" 42 | # define LIBNSL_SO "libnsl.so.1" 43 | # define LIBNSS_COMPAT_SO "libnss_compat.so.2" 44 | # define LIBNSS_DNS_SO "libnss_dns.so.2" 45 | # define LIBNSS_FILES_SO "libnss_files.so.2" 46 | # define LIBNSS_HESIOD_SO "libnss_hesiod.so.2" 47 | # define LIBNSS_LDAP_SO "libnss_ldap.so.2" 48 | # define LIBNSS_NISPLUS_SO "libnss_nisplus.so.2" 49 | # define LIBNSS_NIS_SO "libnss_nis.so.2" 50 | # define LIBPTHREAD_SO "libpthread.so.0" 51 | # define LIBRESOLV_SO "libresolv.so.2" 52 | # define LIBRT_SO "librt.so.1" 53 | # define LIBTHREAD_DB_SO "libthread_db.so.1" 54 | # define LIBUTIL_SO "libutil.so.1" 55 | #endif 56 | 57 | #endif /* gnu/lib-names.h */ 58 | -------------------------------------------------------------------------------- /kernel/include/gnu/libc-version.h: -------------------------------------------------------------------------------- 1 | /* Interface to GNU libc specific functions for version information. 2 | Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _GNU_LIBC_VERSION_H 21 | #define _GNU_LIBC_VERSION_H 1 22 | 23 | #include 24 | 25 | __BEGIN_DECLS 26 | 27 | /* Return string describing release status of currently running GNU libc. */ 28 | extern const char *gnu_get_libc_release (void) __THROW; 29 | 30 | /* Return string describing version of currently running GNU libc. */ 31 | extern const char *gnu_get_libc_version (void) __THROW; 32 | 33 | __END_DECLS 34 | 35 | #endif /* gnu/libc-version.h */ 36 | -------------------------------------------------------------------------------- /kernel/include/gnu/stubs-32.h: -------------------------------------------------------------------------------- 1 | /* This file is automatically generated. 2 | It defines a symbol `__stub_FUNCTION' for each function 3 | in the C library which is a stub, meaning it will fail 4 | every time called, usually setting errno to ENOSYS. */ 5 | 6 | #ifdef _LIBC 7 | # error Applications may not define the macro _LIBC 8 | #endif 9 | 10 | #define __stub___kernel_cosl 11 | #define __stub___kernel_sinl 12 | #define __stub___kernel_tanl 13 | #define __stub_chflags 14 | #define __stub_fattach 15 | #define __stub_fchflags 16 | #define __stub_fdetach 17 | #define __stub_gtty 18 | #define __stub_lchmod 19 | #define __stub_revoke 20 | #define __stub_setlogin 21 | #define __stub_sigreturn 22 | #define __stub_sstk 23 | #define __stub_stty 24 | -------------------------------------------------------------------------------- /kernel/include/gnu/stubs.h: -------------------------------------------------------------------------------- 1 | /* This file selects the right generated file of `__stub_FUNCTION' macros 2 | based on the architecture being compiled for. */ 3 | 4 | #include 5 | 6 | #if __WORDSIZE == 32 7 | # include 8 | #elif __WORDSIZE == 64 9 | # include 10 | #else 11 | # error "unexpected value for __WORDSIZE macro" 12 | #endif 13 | -------------------------------------------------------------------------------- /kernel/include/linux/limits.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_LIMITS_H 2 | #define _LINUX_LIMITS_H 3 | 4 | #define NR_OPEN 1024 5 | 6 | #define NGROUPS_MAX 65536 /* supplemental group IDs are available */ 7 | #define ARG_MAX 131072 /* # bytes of args + environ for exec() */ 8 | #define LINK_MAX 127 /* # links a file may have */ 9 | #define MAX_CANON 255 /* size of the canonical input queue */ 10 | #define MAX_INPUT 255 /* size of the type-ahead buffer */ 11 | #define NAME_MAX 255 /* # chars in a file name */ 12 | #define PATH_MAX 4096 /* # chars in a path name including nul */ 13 | #define PIPE_BUF 4096 /* # bytes in atomic write to a pipe */ 14 | #define XATTR_NAME_MAX 255 /* # chars in an extended attribute name */ 15 | #define XATTR_SIZE_MAX 65536 /* size of an extended attribute value (64k) */ 16 | #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ 17 | 18 | #define RTSIG_MAX 32 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /kernel/include/multiboot.h: -------------------------------------------------------------------------------- 1 | #ifndef MULTIBOOT_H 2 | #define MULTIBOOT_H 3 | 4 | #define MULTIBOOT_HEADER_MAGIC 0x1BADB002 5 | #define MULTIBOOT_HEADER_FLAGS 0x00000003 6 | #define MULTIBOOT_HEADER_CHECKSUM -(MULTIBOOT_HEADER_MAGIC+MULTIBOOT_HEADER_FLAGS) 7 | 8 | #define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 9 | 10 | #define STACK_SIZE 0x4000 11 | 12 | /* The Multiboot header. */ 13 | typedef struct multiboot_header 14 | { 15 | unsigned long magic; 16 | unsigned long flags; 17 | unsigned long checksum; 18 | unsigned long header_addr; 19 | unsigned long load_addr; 20 | unsigned long load_end_addr; 21 | unsigned long bss_end_addr; 22 | unsigned long entry_addr; 23 | } multiboot_header_t; 24 | 25 | /* The symbol table for a.out. */ 26 | typedef struct aout_symbol_table 27 | { 28 | unsigned long tabsize; 29 | unsigned long strsize; 30 | unsigned long addr; 31 | unsigned long reserved; 32 | } aout_symbol_table_t; 33 | 34 | /* The section header table for ELF. */ 35 | typedef struct elf_section_header_table 36 | { 37 | unsigned long num; 38 | unsigned long size; 39 | unsigned long addr; 40 | unsigned long shndx; 41 | } elf_section_header_table_t; 42 | 43 | /* The Multiboot information. */ 44 | typedef struct multiboot_info 45 | { 46 | unsigned long flags; 47 | unsigned long mem_lower; 48 | unsigned long mem_upper; 49 | unsigned long boot_device; 50 | unsigned long cmdline; 51 | unsigned long mods_count; 52 | unsigned long mods_addr; 53 | union 54 | { 55 | aout_symbol_table_t aout_sym; 56 | elf_section_header_table_t elf_sec; 57 | } u; 58 | unsigned long mmap_length; 59 | unsigned long mmap_addr; 60 | } multiboot_info_t; 61 | 62 | /* The module structure. */ 63 | typedef struct module 64 | { 65 | unsigned long mod_start; 66 | unsigned long mod_end; 67 | unsigned long string; 68 | unsigned long reserved; 69 | } module_t; 70 | 71 | /* The memory map. Be careful that the offset 0 is base_addr_low 72 | but no size. */ 73 | typedef struct memory_map 74 | { 75 | unsigned long size; 76 | unsigned long base_addr_low; 77 | unsigned long base_addr_high; 78 | unsigned long length_low; 79 | unsigned long length_high; 80 | unsigned long type; 81 | } memory_map_t; 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /kernel/include/printfcommon.h: -------------------------------------------------------------------------------- 1 | static CHAR *__ujtoa(uintmax_t, CHAR *, int, int, const char *); 2 | static CHAR *__ultoa(unsigned long, CHAR *, int, int, const char *); 3 | 4 | #define PADSIZE 16 /* pad chunk size */ 5 | static const CHAR blanks[PADSIZE] = 6 | {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}; 7 | static const CHAR zeroes[PADSIZE] = 8 | {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; 9 | 10 | /* 11 | * Convert an unsigned long to ASCII for printf purposes, returning 12 | * a pointer to the first character of the string representation. 13 | * Octal numbers can be forced to have a leading zero; hex numbers 14 | * use the given digits. 15 | */ 16 | static CHAR * 17 | __ultoa(unsigned long val, CHAR *endp, int base, int octzero, const char *xdigs) 18 | { 19 | CHAR *cp = endp; 20 | long sval; 21 | 22 | /* 23 | * Handle the three cases separately, in the hope of getting 24 | * better/faster code. 25 | */ 26 | switch (base) { 27 | case 10: 28 | if (val < 10) { /* many numbers are 1 digit */ 29 | *--cp = to_char(val); 30 | return (cp); 31 | } 32 | /* 33 | * On many machines, unsigned arithmetic is harder than 34 | * signed arithmetic, so we do at most one unsigned mod and 35 | * divide; this is sufficient to reduce the range of 36 | * the incoming value to where signed arithmetic works. 37 | */ 38 | if (val > LONG_MAX) { 39 | *--cp = to_char(val % 10); 40 | sval = val / 10; 41 | } else 42 | sval = val; 43 | do { 44 | *--cp = to_char(sval % 10); 45 | sval /= 10; 46 | } while (sval != 0); 47 | break; 48 | 49 | case 8: 50 | do { 51 | *--cp = to_char(val & 7); 52 | val >>= 3; 53 | } while (val); 54 | if (octzero && *cp != '0') 55 | *--cp = '0'; 56 | break; 57 | 58 | case 16: 59 | do { 60 | *--cp = xdigs[val & 15]; 61 | val >>= 4; 62 | } while (val); 63 | break; 64 | 65 | default: /* oops */ 66 | return NULL; 67 | } 68 | return (cp); 69 | } 70 | 71 | /* Identical to __ultoa, but for intmax_t. */ 72 | static CHAR * 73 | __ujtoa(uintmax_t val, CHAR *endp, int base, int octzero, const char *xdigs) 74 | { 75 | CHAR *cp = endp; 76 | intmax_t sval; 77 | 78 | /* quick test for small values; __ultoa is typically much faster */ 79 | /* (perhaps instead we should run until small, then call __ultoa?) */ 80 | if (val <= ULONG_MAX) 81 | return (__ultoa((unsigned long)val, endp, base, octzero, xdigs)); 82 | switch (base) { 83 | case 10: 84 | if (val < 10) { 85 | *--cp = to_char(val % 10); 86 | return (cp); 87 | } 88 | if (val > INTMAX_MAX) { 89 | *--cp = to_char(val % 10); 90 | sval = val / 10; 91 | } else 92 | sval = val; 93 | do { 94 | *--cp = to_char(sval % 10); 95 | sval /= 10; 96 | } while (sval != 0); 97 | break; 98 | 99 | case 8: 100 | do { 101 | *--cp = to_char(val & 7); 102 | val >>= 3; 103 | } while (val); 104 | if (octzero && *cp != '0') 105 | *--cp = '0'; 106 | break; 107 | 108 | case 16: 109 | do { 110 | *--cp = xdigs[val & 15]; 111 | val >>= 4; 112 | } while (val); 113 | break; 114 | 115 | default: 116 | return NULL; 117 | } 118 | return (cp); 119 | } 120 | 121 | -------------------------------------------------------------------------------- /kernel/include/printflocal.h: -------------------------------------------------------------------------------- 1 | #define ALT 0x001 /* alternate form */ 2 | #define LADJUST 0x004 /* left adjustment */ 3 | #define LONGDBL 0x008 /* long double */ 4 | #define LONGINT 0x010 /* long integer */ 5 | #define LLONGINT 0x020 /* long long integer */ 6 | #define SHORTINT 0x040 /* short integer */ 7 | #define ZEROPAD 0x080 /* zero (as opposed to blank) pad */ 8 | #define FPT 0x100 /* Floating point number */ 9 | #define GROUPING 0x200 /* use grouping ("'" flag) */ 10 | /* C99 additional size modifiers: */ 11 | #define SIZET 0x400 /* size_t */ 12 | #define PTRDIFFT 0x800 /* ptrdiff_t */ 13 | #define INTMAXT 0x1000 /* intmax_t */ 14 | #define CHARINT 0x2000 /* print char using int format */ 15 | 16 | /* 17 | * Macros for converting digits to letters and vice versa 18 | */ 19 | #define to_digit(c) ((c) - '0') 20 | #define is_digit(c) ((unsigned)to_digit(c) <= 9) 21 | #define to_char(n) ((n) + '0') 22 | 23 | /* Size of the static argument table. */ 24 | #define STATIC_ARG_TBL_SIZE 8 25 | 26 | union arg { 27 | int32_t intarg; 28 | uint32_t uintarg; 29 | int32_t longarg; 30 | uint32_t ulongarg; 31 | int64_t longlongarg; 32 | uint64_t ulonglongarg; 33 | int32_t ptrdiffarg; 34 | uint32_t sizearg; 35 | int64_t intmaxarg; 36 | uint64_t uintmaxarg; 37 | void *pvoidarg; 38 | int8_t *pchararg; 39 | int8_t *pschararg; 40 | int16_t *pshortarg; 41 | int32_t *pintarg; 42 | int32_t *plongarg; 43 | int64_t *plonglongarg; 44 | int32_t *pptrdiffarg; 45 | uint32_t *psizearg; 46 | int64_t *pintmaxarg; 47 | }; 48 | 49 | /* Handle positional parameters. */ 50 | int __find_arguments(const char *, va_list, union arg **); 51 | -------------------------------------------------------------------------------- /kernel/include/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef STDIO_H 2 | #define STDIO_H 3 | 4 | #define EOF (-1) 5 | 6 | #ifndef _SIZE_T 7 | #define _SIZE_T 8 | typedef unsigned int size_t; 9 | #endif 10 | 11 | #include 12 | 13 | int 14 | kprintf(char const *, ...); 15 | 16 | int 17 | kvprintf(const char *, va_list); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /kernel/include/sys/asm.h: -------------------------------------------------------------------------------- 1 | #ifndef ASM_H 2 | #define ASM_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | void set_cs(uint16_t); 9 | void set_ds(uint16_t); 10 | void set_ss(uint16_t); 11 | void set_fs(uint16_t); 12 | void set_gs(uint16_t); 13 | void set_es(uint16_t); 14 | 15 | uint16_t get_cs(void); 16 | uint16_t get_ds(void); 17 | uint16_t get_ss(void); 18 | uint16_t get_fs(void); 19 | uint16_t get_gs(void); 20 | uint16_t get_es(void); 21 | 22 | uint32_t get_cr0(void); 23 | uint32_t get_cr2(void); 24 | uint32_t get_cr3(void); 25 | uint32_t get_cr4(void); 26 | 27 | void set_cr0(uint32_t); 28 | void set_cr2(uint32_t); 29 | void set_cr3(uint32_t); 30 | void set_cr4(uint32_t); 31 | 32 | void set_gdtr(gdtr_t*); 33 | void get_gdtr(gdtr_t*); 34 | void set_tr(uint16_t); 35 | void set_ldtr(uint16_t); 36 | 37 | void outport(uint8_t, uint8_t); 38 | uint8_t inport(uint8_t); 39 | 40 | void set_idtr(idtr_t*); 41 | 42 | void enable_interrupts(void); 43 | 44 | uint32_t get_eflags(void); 45 | void set_eflags(uint32_t); 46 | 47 | void wrmsr(uint32_t, uint32_t, uint32_t); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /kernel/include/sys/console.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSOLE_H 2 | #define CONSOLE_H 3 | 4 | #define VIDMEM ((char *)0xb8000) 5 | 6 | void console_cls(void); 7 | 8 | void console_init(int, int); 9 | 10 | void console_putc(char); 11 | 12 | int console_print(char *, int); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /kernel/include/sys/fpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _FPU_H 2 | #define _FPU_H 3 | 4 | #include 5 | 6 | typedef struct __attribute__((__packed__)) { 7 | uint64_t mantissa; 8 | uint16_t expsign; 9 | uint8_t reserved[6]; 10 | } fpust_t; 11 | 12 | typedef struct __attribute__((__packed__)) { 13 | uint8_t data[16]; 14 | } fpuxmm_t; 15 | 16 | typedef struct __attribute__((__packed__)) { 17 | uint16_t fcw; 18 | uint16_t fsw; 19 | uint8_t ftw; 20 | uint8_t unused; 21 | uint16_t fop; 22 | uint32_t fpuip; 23 | uint16_t cs; 24 | uint16_t reserved0; 25 | uint32_t fpudp; 26 | uint16_t ds; 27 | uint16_t reserved1; 28 | uint32_t mxcsr; 29 | uint32_t mxcsr_mask; 30 | 31 | fpust_t st[8]; // STx/MMx 32 | fpuxmm_t xmm[8]; 33 | fpuxmm_t xmm_reserved[14]; 34 | } fpu_state_t; 35 | 36 | #endif /* _FPU_H */ 37 | -------------------------------------------------------------------------------- /kernel/include/sys/interrupt.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERRUPT_H 2 | #define INTERRUPT_H 3 | 4 | #define PIC1 0x20 5 | #define PIC2 0xA0 6 | #define PIC1_COMMAND PIC1 7 | #define PIC1_DATA (PIC1+1) 8 | #define PIC2_COMMAND PIC2 9 | #define PIC2_DATA PIC2+1 10 | #define PIC_EOI 0x20 11 | 12 | #define ICW1_ICW4 0x01 /* ICW4 (not) needed */ 13 | #define ICW1_SINGLE 0x02 /* Single (cascade) mode */ 14 | #define ICW1_INTERVAL4 0x04 /* Call address interval 4 (8) */ 15 | #define ICW1_LEVEL 0x08 /* Level triggered (edge) mode */ 16 | #define ICW1_INIT 0x10 /* Initialization - required! */ 17 | 18 | #define ICW4_8086 0x01 /* 8086/88 (MCS-80/85) mode */ 19 | #define ICW4_AUTO 0x02 /* Auto (normal) EOI */ 20 | #define ICW4_BUF_SLAVE 0x08 /* Buffered mode/slave */ 21 | #define ICW4_BUF_MASTER 0x0C /* Buffered mode/master */ 22 | #define ICW4_SFNM 0x10 /* Special fully nested (not) */ 23 | 24 | #ifndef INTERRUPTS 25 | #define INTERRUPTS 64 26 | #endif 27 | 28 | typedef struct 29 | { 30 | uint16_t limit; 31 | uint32_t base; 32 | } __attribute__ ((__packed__)) idtr_t; 33 | 34 | typedef struct 35 | { 36 | uint16_t off_0_15; 37 | uint16_t seg; 38 | uint8_t reserved:5; 39 | uint8_t zero:3; 40 | uint8_t type:5; 41 | uint8_t dpl:2; 42 | uint8_t present:1; 43 | uint16_t off_16_31; 44 | } __attribute__ ((__packed__)) idte_t; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /kernel/include/sys/mman.h: -------------------------------------------------------------------------------- 1 | #ifndef MMAN_H 2 | #define MMAN_H 3 | 4 | #define ACS_PRESENT 0x80 5 | #define ACS_CSEG 0x18 6 | #define ACS_DSEG 0x10 7 | #define ACS_CONFORM 0x04 8 | #define ACS_READ 0x02 9 | #define ACS_WRITE 0x02 10 | #define ACS_IDT ACS_DSEG 11 | #define ACS_INT_GATE 0x0E 12 | #define ACS_INT (ACS_PRESENT | ACS_INT_GATE) 13 | #define ACS_TSS_GATE 0x09 14 | #define ACS_TSS (ACS_PRESENT | ACS_TSS_GATE) 15 | 16 | #define ACS_CODE (ACS_PRESENT | ACS_CSEG | ACS_READ) 17 | #define ACS_DATA (ACS_PRESENT | ACS_DSEG | ACS_WRITE) 18 | #define ACS_STACK (ACS_PRESENT | ACS_DSEG | ACS_WRITE) 19 | 20 | 21 | typedef struct { 22 | uint16_t limit; 23 | uint32_t base; 24 | } __attribute__ ((__packed__)) gdtr_t; 25 | 26 | typedef struct{ 27 | uint16_t limit_0_15; 28 | uint16_t base_0_15; 29 | uint8_t base_16_23; 30 | union { 31 | struct { 32 | uint8_t type:4; 33 | uint8_t s:1; 34 | uint8_t dpl:2; 35 | uint8_t p:1; 36 | }; 37 | uint8_t access; 38 | }; 39 | union { 40 | struct { 41 | uint8_t limit_16_19:4; 42 | uint8_t avl:1; 43 | uint8_t l:1; 44 | uint8_t d_b:1; 45 | uint8_t g:1; 46 | }; 47 | struct { 48 | uint8_t asd:4; 49 | uint8_t attr:4; 50 | }; 51 | }; 52 | uint8_t base_24_31; 53 | } __attribute__ ((__packed__)) seg_t; 54 | 55 | typedef union{ 56 | struct{ 57 | uint8_t p:1; 58 | uint8_t r_w:1; 59 | uint8_t u_s:1; 60 | uint8_t pwt:1; 61 | uint8_t pcd:1; 62 | uint8_t a:1; 63 | uint8_t zero:1; 64 | uint8_t ps:1; 65 | uint8_t g:1; 66 | uint8_t avail:3; 67 | uint8_t baselow:4; 68 | uint16_t basehigh; 69 | } __attribute__ ((__packed__)); 70 | uint32_t raw; 71 | } __attribute__ ((__packed__)) pde_t; 72 | 73 | typedef union{ 74 | struct{ 75 | uint8_t p:1; 76 | uint8_t r_w:1; 77 | uint8_t u_s:1; 78 | uint8_t pwt:1; 79 | uint8_t pcd:1; 80 | uint8_t a:1; 81 | uint8_t d:1; 82 | uint8_t pat:1; 83 | uint8_t g:1; 84 | uint8_t avail:3; 85 | uint8_t baselow:4; 86 | uint16_t basehigh; 87 | } __attribute__ ((__packed__)); 88 | uint32_t raw; 89 | } __attribute__ ((__packed__)) pte_t; 90 | 91 | void set_gdt_entry(seg_t *, uint32_t, uint32_t, uint8_t, uint8_t); 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /kernel/include/sys/tss.h: -------------------------------------------------------------------------------- 1 | #ifndef TSS_H 2 | #define TSS_H 3 | 4 | typedef struct 5 | { 6 | uint16_t limit_0_15; 7 | uint16_t base_0_15; 8 | uint8_t base_16_23; 9 | uint8_t type:5; 10 | uint8_t dpl:2; 11 | uint8_t present:1; 12 | uint8_t limit_16_19:4; 13 | uint8_t avl:1; 14 | uint8_t zero:2; 15 | uint8_t g:1; 16 | uint8_t base_24_31; 17 | } __attribute__ ((__packed__)) tssdesc_t; 18 | 19 | typedef struct 20 | { 21 | uint16_t prev; 22 | uint16_t res0; 23 | uint32_t esp0; 24 | uint16_t ss0; 25 | uint16_t res1; 26 | uint32_t esp1; 27 | uint16_t ss1; 28 | uint16_t res2; 29 | uint32_t esp2; 30 | uint16_t ss2; 31 | uint16_t res3; 32 | uint32_t cr3; 33 | uint32_t eip; 34 | uint32_t eflags; 35 | uint32_t eax; 36 | uint32_t ecx; 37 | uint32_t edx; 38 | uint32_t ebx; 39 | uint32_t esp; 40 | uint32_t ebp; 41 | uint32_t esi; 42 | uint32_t edi; 43 | uint16_t es; 44 | uint16_t res4; 45 | uint16_t cs; 46 | uint16_t res5; 47 | uint16_t ss; 48 | uint16_t res6; 49 | uint16_t ds; 50 | uint16_t res7; 51 | uint16_t fs; 52 | uint16_t res8; 53 | uint16_t gs; 54 | uint16_t res9; 55 | uint16_t ldt; 56 | uint16_t res10; 57 | uint16_t t:1; 58 | uint16_t res11:15; 59 | uint16_t iomap; 60 | } __attribute__ ((__packed__)) tss_t; 61 | 62 | void set_tss(tss_t *tss, uint32_t eip, uint32_t esp, uint32_t eflags, 63 | uint16_t cs, uint16_t ds, uint16_t ss, uint32_t cr3, 64 | uint16_t ss0, uint16_t ss1, uint16_t ss2, 65 | uint32_t sp0, uint32_t sp1, uint32_t sp2, 66 | uint16_t ldt); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /kernel/include/sys/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | #include 5 | 6 | #define NULL ((void *)0) 7 | 8 | #include 9 | 10 | #ifndef _SIZE_T 11 | #define _SIZE_T 12 | typedef unsigned int size_t; 13 | #endif 14 | 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /kernel/include/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | #include 5 | 6 | #define NULL ((void *)0) 7 | 8 | #include 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /kernel/kernel.h: -------------------------------------------------------------------------------- 1 | // This file is part of KEmuFuzzer. 2 | // 3 | // KEmuFuzzer is free software: you can redistribute it and/or modify it under 4 | // the terms of the GNU General Public License as published by the Free 5 | // Software Foundation, either version 3 of the License, or (at your option) 6 | // any later version. 7 | // 8 | // KEmuFuzzer is distributed in the hope that it will be useful, but WITHOUT ANY 9 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 11 | // details. 12 | // 13 | // You should have received a copy of the GNU General Public License along with 14 | // KEmuFuzzer. If not, see . 15 | 16 | #ifndef _KERNEL_H 17 | #define _KERNEL_H 18 | 19 | /* Ring 0 */ 20 | #define SEL_RING0_CS 0x68 21 | #define SEL_RING0_DS 0xb0 22 | #define SEL_RING0_SS 0x70 23 | #define SEL_RING0_ES SEL_RING0_DS 24 | #define SEL_RING0_FS SEL_RING0_DS 25 | #define SEL_RING0_GS SEL_RING0_DS 26 | 27 | /* Ring 1 */ 28 | #define SEL_RING1_CS 0xc0 29 | #define SEL_RING1_DS 0x88 30 | #define SEL_RING1_SS 0x90 31 | #define SEL_RING1_ES SEL_RING1_DS 32 | #define SEL_RING1_FS SEL_RING1_DS 33 | #define SEL_RING1_GS SEL_RING1_DS 34 | 35 | /* Ring 2 */ 36 | #define SEL_RING2_CS 0x98 37 | #define SEL_RING2_DS 0xa0 38 | #define SEL_RING2_SS 0xa8 39 | #define SEL_RING2_ES SEL_RING2_DS 40 | #define SEL_RING2_FS SEL_RING2_DS 41 | #define SEL_RING2_GS SEL_RING2_DS 42 | 43 | /* Ring 3 */ 44 | #define SEL_RING3_CS 0x78 45 | #define SEL_RING3_DS 0xb8 46 | #define SEL_RING3_SS 0x80 47 | #define SEL_RING3_ES SEL_RING3_DS 48 | #define SEL_RING3_FS SEL_RING3_DS 49 | #define SEL_RING3_GS SEL_RING3_DS 50 | 51 | /* Add RPL to a segment selector */ 52 | #define SEL_RPL(s,r) ((s) | (r)) 53 | 54 | #if (SEL_RING0_CS != SEL_RING0_SS-8) || (SEL_RING0_SS != SEL_RING3_CS-8) || (SEL_RING3_CS != SEL_RING3_SS-8) 55 | #error "For SYSENTER/SYSEXIT, SEL_RING0_CS, SEL_RING0_SS, SEL_RING3_CS, SEL_RING3_SS must be consecutive" 56 | #endif 57 | 58 | #define PAGE_SIZE 0x1000 59 | #define PAGE_ALIGN(x) (((uint32_t) (x)) & ~PAGE_SIZE) 60 | 61 | #define GDT_ENTRY 27 62 | 63 | /* Virtual 8086 Mode */ 64 | #define VM_BIT 1<<17 65 | #define SEL_VM_CS 0x0 66 | #define SEL_VM_DS 0x0 67 | #define SEL_VM_SS 0x80 68 | #define VM_EIP 0x0 69 | #define VM_ESP 0x800 70 | #endif /* _KERNEL_H */ 71 | -------------------------------------------------------------------------------- /kernel/kernel.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-i386") 2 | ENTRY(_start) 3 | virt = 0x200000; /* 2 meg */ 4 | phys = 0x200000; /* 2 meg */ 5 | SECTIONS 6 | { .multiboot 0x100000 : AT(0x100000) 7 | { 8 | LONG(0x1BADB002) 9 | LONG(0x00000003) 10 | LONG(-(0x1BADB002 + 0x00000003)) 11 | } 12 | .loader : 13 | { 14 | loaderlow = .; 15 | KEEP (*boot.o(.text)) 16 | KEEP (*loader.o(.text)) 17 | KEEP (*boot.o(.data)) 18 | KEEP (*loader.o(.data)) 19 | KEEP (*boot.o(.bss)) 20 | KEEP (*loader.o(.bss)) 21 | KEEP (*boot.o(COMMON)) 22 | KEEP (*loader.o(COMMON)) 23 | loaderhigh = .; 24 | } 25 | .text virt : AT(phys) 26 | { code = .; 27 | *(.text) 28 | . = ALIGN(4096); 29 | } 30 | .data : AT(phys + (data - code)) 31 | { data = .; 32 | tc_ring0_base = .; 33 | LONG(tcring0) 34 | tc_ring0_len = .; 35 | LONG(tcring0end - tcring0) 36 | tc_ring1_base = .; 37 | LONG(tcring1) 38 | tc_ring1_len = .; 39 | LONG(tcring1end - tcring1) 40 | tc_ring2_base = .; 41 | LONG(tcring2) 42 | tc_ring2_len = .; 43 | LONG(tcring2end - tcring2) 44 | tc_ring3_base = .; 45 | LONG(tcring3) 46 | tc_ring3_len = .; 47 | LONG(tcring3end - tcring3) 48 | tc_ringvm_base = .; 49 | LONG(tcringvm) 50 | tc_ringvm_len = .; 51 | LONG(tcringvmend - tcringvm) 52 | stack_r0 = .; 53 | LONG(ring0stacktop); 54 | stack_ssfaultbase = .; 55 | LONG(ssfaultstack); 56 | stack_ssfault = .; 57 | LONG(ssfaultstacktop - ssfaultstack); 58 | stack_doublefaultbase = .; 59 | LONG(doublefaultstack); 60 | stack_doublefault = .; 61 | LONG(doublefaultstacktop - doublefaultstack); 62 | *(.data) 63 | mem_offset = .; 64 | LONG(virt - phys) 65 | . = ALIGN(4096); 66 | } 67 | .bss : AT(phys + (bss - code)) 68 | { bss = .; 69 | *(.bss) 70 | *(COMMON) 71 | . = ALIGN(4096); 72 | } 73 | .ring0stack : AT(phys + (ring0stack - code)) 74 | { ring0stack = .; 75 | LONG(0x00000000); 76 | . = ALIGN(4096); 77 | ring0stacktop = .; 78 | } = 0x0000 79 | .ssfaultstack : AT(phys + (ssfaultstack - code)) 80 | { ssfaultstack = .; 81 | LONG(0x00000000); 82 | . = ALIGN(4096); 83 | ssfaultstacktop = .; 84 | } = 0x0000 85 | .doublefaultstack : AT(phys + (doublefaultstack - code)) 86 | { doublefaultstack = .; 87 | LONG(0x00000000); 88 | . = ALIGN(4096); 89 | doublefaultstacktop = .; 90 | } = 0x0000 91 | .tcring0 : AT(phys + (tcring0 - code)) 92 | { tcring0 = .; 93 | LONG(0x41414141); 94 | . = ALIGN(4096); 95 | tcring0end = .; 96 | } = 0x41414141 97 | .tcring1 : AT(phys + (tcring1 - code)) 98 | { tcring1 = .; 99 | LONG(0x42424242); 100 | . = ALIGN(4096); 101 | tcring1end = .; 102 | } = 0x42424242 103 | .tcring2 : AT(phys + (tcring2 - code)) 104 | { tcring2 = .; 105 | LONG(0x43434343); 106 | . = ALIGN(4096); 107 | tcring2end = .; 108 | } = 0x43434343 109 | .tcring3 : AT(phys + (tcring3 - code)) 110 | { tcring3 = .; 111 | LONG(0x44444444); 112 | . = ALIGN(4096); 113 | tcring3end = .; 114 | } = 0x44444444 115 | .tcringvm : AT(phys + (tcringvm - code)) 116 | { tcringvm = .; 117 | LONG(0xF4F4F4F4); 118 | . = ALIGN(4096); 119 | tcringvmend = .; 120 | } = 0xF4F4F4F4 121 | end = .; 122 | } 123 | -------------------------------------------------------------------------------- /kernel/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrmuizel/kemufuzzer/780ef603c35bb31e941e14d19f98f696583dc2d9/kernel/main.c -------------------------------------------------------------------------------- /kernel/tss.c: -------------------------------------------------------------------------------- 1 | // This file is part of KEmuFuzzer. 2 | // 3 | // KEmuFuzzer is free software: you can redistribute it and/or modify it under 4 | // the terms of the GNU General Public License as published by the Free 5 | // Software Foundation, either version 3 of the License, or (at your option) 6 | // any later version. 7 | // 8 | // KEmuFuzzer is distributed in the hope that it will be useful, but WITHOUT ANY 9 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 11 | // details. 12 | // 13 | // You should have received a copy of the GNU General Public License along with 14 | // KEmuFuzzer. If not, see . 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | void set_tss(tss_t *tss, uint32_t eip, uint32_t esp, uint32_t eflags, 22 | uint16_t cs, uint16_t ds, uint16_t ss, uint32_t cr3, 23 | uint16_t ss0, uint16_t ss1, uint16_t ss2, 24 | uint32_t sp0, uint32_t sp1, uint32_t sp2, 25 | uint16_t ldt) 26 | { 27 | int i; 28 | char *p; 29 | 30 | p = (char *) tss; 31 | for(i=0;iebp = esp; 51 | tss->ds = tss->es = tss->fs = tss->gs = ds; 52 | tss->ss = ss; 53 | tss->ss0 = ss0; 54 | tss->ss1 = ss1; 55 | tss->ss2 = ss2; 56 | tss->cs = cs; 57 | tss->ldt = ldt; 58 | 59 | tss->esp = esp; 60 | tss->esp0 = sp0; 61 | tss->esp1 = sp1; 62 | tss->esp2 = sp2; 63 | tss->cr3 = cr3; 64 | tss->eflags = eflags; 65 | 66 | tss->eip = eip; 67 | } 68 | -------------------------------------------------------------------------------- /kvm.h: -------------------------------------------------------------------------------- 1 | // This file is part of KEmuFuzzer. 2 | // 3 | // KEmuFuzzer is free software: you can redistribute it and/or modify it under 4 | // the terms of the GNU General Public License as published by the Free 5 | // Software Foundation, either version 3 of the License, or (at your option) 6 | // any later version. 7 | // 8 | // KEmuFuzzer is distributed in the hope that it will be useful, but WITHOUT ANY 9 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 11 | // details. 12 | // 13 | // You should have received a copy of the GNU General Public License along with 14 | // KEmuFuzzer. If not, see . 15 | 16 | #ifndef KVM_H 17 | #define KVM_H 18 | 19 | #include 20 | #include 21 | 22 | #define EXPECTED_KVM_API_VERSION 12 23 | #define MAXCPUS 4 24 | 25 | #include 26 | 27 | #if KVM_API_VERSION != EXPECTED_KVM_API_VERSION 28 | #error "Wrong API version" 29 | #endif 30 | 31 | #include "x86_cpustate.h" 32 | 33 | class KVM; 34 | 35 | class VCPU { 36 | private: 37 | int slot; 38 | int cpu_fd; 39 | int exception; 40 | KVM *kvm; 41 | struct kvm_run *run; 42 | 43 | friend class KVM; 44 | 45 | public: 46 | VCPU(KVM *, int); 47 | ~VCPU(); 48 | 49 | void SetRegs(struct kvm_regs *); 50 | void GetRegs(struct kvm_regs *); 51 | void SetSregs(struct kvm_sregs *); 52 | void GetSregs(struct kvm_sregs *); 53 | void SetFPU(struct kvm_fpu *); 54 | void GetFPU(struct kvm_fpu *); 55 | void SetMSRs(struct kvm_msr_entry *msrs, int n); 56 | void GetMSRs(struct kvm_msr_entry *msrs, int *n); 57 | struct kvm_run *Run(); 58 | int Bits(); 59 | int GetMem(void *, unsigned int, uint8_t *); 60 | int SetMem(void *, unsigned int, uint8_t *); 61 | void Disasm(void *, FILE *); 62 | void DumpMem(void *, int, FILE *, bool = false); 63 | void SetException(int); 64 | }; 65 | 66 | class KVM { 67 | private: 68 | void *vm_mem; 69 | unsigned int vm_mem_size; 70 | VCPU *vcpus[MAXCPUS]; 71 | int cpusno; 72 | type_t state_type; 73 | uint8_t ioports[2]; 74 | 75 | friend class VCPU; 76 | 77 | void Init(int, unsigned int); 78 | 79 | protected: 80 | int fd; 81 | int vm_fd; 82 | 83 | public: 84 | KVM(int, unsigned int); 85 | KVM(const char *); 86 | ~KVM(); 87 | 88 | VCPU *Cpu(int = 0); 89 | void *Mem(); 90 | void Load(const char *); 91 | void Save(const char *); 92 | void Print(FILE *); 93 | 94 | void SetIoPort(int, uint8_t); 95 | uint8_t GetIoPort(int); 96 | void SetStateType(type_t); 97 | type_t GetStateType(); 98 | }; 99 | 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /libudis86/Makefile: -------------------------------------------------------------------------------- 1 | objs = decode.o input.o itab.o syn-att.o syn.o syn-intel.o udis86.o 2 | 3 | all: libudis86.a 4 | 5 | libudis86.a: $(objs) 6 | ar -r $@ $(objs) 7 | 8 | %.o: %.c 9 | gcc -c $< 10 | 11 | clean: 12 | rm -f *.o 13 | 14 | distclean: 15 | rm -f libudis86.a 16 | 17 | .PHONY: all clean distclean 18 | -------------------------------------------------------------------------------- /libudis86/extern.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * extern.h 3 | * 4 | * Copyright (c) 2004, 2005, 2006, Vivek Mohan 5 | * All rights reserved. See LICENSE 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | #ifndef UD_EXTERN_H 9 | #define UD_EXTERN_H 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include 16 | #include "types.h" 17 | 18 | /* ============================= PUBLIC API ================================= */ 19 | 20 | extern void ud_init(struct ud*); 21 | 22 | extern void ud_set_mode(struct ud*, uint8_t); 23 | 24 | extern void ud_set_pc(struct ud*, uint64_t); 25 | 26 | extern void ud_set_input_hook(struct ud*, int (*)(struct ud*)); 27 | 28 | extern void ud_set_input_buffer(struct ud*, uint8_t*, size_t); 29 | 30 | #ifndef __UD_STANDALONE__ 31 | extern void ud_set_input_file(struct ud*, FILE*); 32 | #endif /* __UD_STANDALONE__ */ 33 | 34 | extern void ud_set_vendor(struct ud*, unsigned); 35 | 36 | extern void ud_set_syntax(struct ud*, void (*)(struct ud*)); 37 | 38 | extern void ud_input_skip(struct ud*, size_t); 39 | 40 | extern int ud_input_end(struct ud*); 41 | 42 | extern unsigned int ud_decode(struct ud*); 43 | 44 | extern unsigned int ud_disassemble(struct ud*); 45 | 46 | extern void ud_translate_intel(struct ud*); 47 | 48 | extern void ud_translate_att(struct ud*); 49 | 50 | extern char* ud_insn_asm(struct ud* u); 51 | 52 | extern uint8_t* ud_insn_ptr(struct ud* u); 53 | 54 | extern uint64_t ud_insn_off(struct ud*); 55 | 56 | extern char* ud_insn_hex(struct ud*); 57 | 58 | extern unsigned int ud_insn_len(struct ud* u); 59 | 60 | extern const char* ud_lookup_mnemonic(enum ud_mnemonic_code c); 61 | 62 | /* ========================================================================== */ 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #endif 68 | -------------------------------------------------------------------------------- /libudis86/input.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * input.h 3 | * 4 | * Copyright (c) 2006, Vivek Mohan 5 | * All rights reserved. See LICENSE 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | #ifndef UD_INPUT_H 9 | #define UD_INPUT_H 10 | 11 | #include "types.h" 12 | 13 | uint8_t inp_next(struct ud*); 14 | uint8_t inp_peek(struct ud*); 15 | uint8_t inp_uint8(struct ud*); 16 | uint16_t inp_uint16(struct ud*); 17 | uint32_t inp_uint32(struct ud*); 18 | uint64_t inp_uint64(struct ud*); 19 | void inp_move(struct ud*, size_t); 20 | void inp_back(struct ud*); 21 | 22 | /* inp_init() - Initializes the input system. */ 23 | #define inp_init(u) \ 24 | do { \ 25 | u->inp_curr = 0; \ 26 | u->inp_fill = 0; \ 27 | u->inp_ctr = 0; \ 28 | u->inp_end = 0; \ 29 | } while (0) 30 | 31 | /* inp_start() - Should be called before each de-code operation. */ 32 | #define inp_start(u) u->inp_ctr = 0 33 | 34 | /* inp_back() - Resets the current pointer to its position before the current 35 | * instruction disassembly was started. 36 | */ 37 | #define inp_reset(u) \ 38 | do { \ 39 | u->inp_curr -= u->inp_ctr; \ 40 | u->inp_ctr = 0; \ 41 | } while (0) 42 | 43 | /* inp_sess() - Returns the pointer to current session. */ 44 | #define inp_sess(u) (u->inp_sess) 45 | 46 | /* inp_cur() - Returns the current input byte. */ 47 | #define inp_curr(u) ((u)->inp_cache[(u)->inp_curr]) 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /libudis86/syn.c: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * syn.c 3 | * 4 | * Copyright (c) 2002, 2003, 2004 Vivek Mohan 5 | * All rights reserved. See (LICENSE) 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | 9 | /* ----------------------------------------------------------------------------- 10 | * Intel Register Table - Order Matters (types.h)! 11 | * ----------------------------------------------------------------------------- 12 | */ 13 | const char* ud_reg_tab[] = 14 | { 15 | "al", "cl", "dl", "bl", 16 | "ah", "ch", "dh", "bh", 17 | "spl", "bpl", "sil", "dil", 18 | "r8b", "r9b", "r10b", "r11b", 19 | "r12b", "r13b", "r14b", "r15b", 20 | 21 | "ax", "cx", "dx", "bx", 22 | "sp", "bp", "si", "di", 23 | "r8w", "r9w", "r10w", "r11w", 24 | "r12w", "r13W" , "r14w", "r15w", 25 | 26 | "eax", "ecx", "edx", "ebx", 27 | "esp", "ebp", "esi", "edi", 28 | "r8d", "r9d", "r10d", "r11d", 29 | "r12d", "r13d", "r14d", "r15d", 30 | 31 | "rax", "rcx", "rdx", "rbx", 32 | "rsp", "rbp", "rsi", "rdi", 33 | "r8", "r9", "r10", "r11", 34 | "r12", "r13", "r14", "r15", 35 | 36 | "es", "cs", "ss", "ds", 37 | "fs", "gs", 38 | 39 | "cr0", "cr1", "cr2", "cr3", 40 | "cr4", "cr5", "cr6", "cr7", 41 | "cr8", "cr9", "cr10", "cr11", 42 | "cr12", "cr13", "cr14", "cr15", 43 | 44 | "dr0", "dr1", "dr2", "dr3", 45 | "dr4", "dr5", "dr6", "dr7", 46 | "dr8", "dr9", "dr10", "dr11", 47 | "dr12", "dr13", "dr14", "dr15", 48 | 49 | "mm0", "mm1", "mm2", "mm3", 50 | "mm4", "mm5", "mm6", "mm7", 51 | 52 | "st0", "st1", "st2", "st3", 53 | "st4", "st5", "st6", "st7", 54 | 55 | "xmm0", "xmm1", "xmm2", "xmm3", 56 | "xmm4", "xmm5", "xmm6", "xmm7", 57 | "xmm8", "xmm9", "xmm10", "xmm11", 58 | "xmm12", "xmm13", "xmm14", "xmm15", 59 | 60 | "rip" 61 | }; 62 | -------------------------------------------------------------------------------- /libudis86/syn.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * syn.h 3 | * 4 | * Copyright (c) 2006, Vivek Mohan 5 | * All rights reserved. See LICENSE 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | #ifndef UD_SYN_H 9 | #define UD_SYN_H 10 | 11 | #include 12 | #include 13 | #include "types.h" 14 | 15 | extern const char* ud_reg_tab[]; 16 | 17 | static void mkasm(struct ud* u, const char* fmt, ...) 18 | { 19 | va_list ap; 20 | va_start(ap, fmt); 21 | u->insn_fill += vsprintf((char*) u->insn_buffer + u->insn_fill, fmt, ap); 22 | va_end(ap); 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libudis86/udis86.c: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * udis86.c 3 | * 4 | * Copyright (c) 2004, 2005, 2006, Vivek Mohan 5 | * All rights reserved. See LICENSE 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "input.h" 14 | #include "extern.h" 15 | 16 | /* ============================================================================= 17 | * ud_init() - Initializes ud_t object. 18 | * ============================================================================= 19 | */ 20 | extern void 21 | ud_init(struct ud* u) 22 | { 23 | memset((void*)u, 0, sizeof(struct ud)); 24 | ud_set_mode(u, 16); 25 | u->mnemonic = UD_Iinvalid; 26 | ud_set_pc(u, 0); 27 | #ifndef __UD_STANDALONE__ 28 | ud_set_input_file(u, stdin); 29 | #endif /* __UD_STANDALONE__ */ 30 | } 31 | 32 | /* ============================================================================= 33 | * ud_disassemble() - disassembles one instruction and returns the number of 34 | * bytes disassembled. A zero means end of disassembly. 35 | * ============================================================================= 36 | */ 37 | extern unsigned int 38 | ud_disassemble(struct ud* u) 39 | { 40 | if (ud_input_end(u)) 41 | return 0; 42 | 43 | 44 | u->insn_buffer[0] = u->insn_hexcode[0] = 0; 45 | 46 | 47 | if (ud_decode(u) == 0) 48 | return 0; 49 | if (u->translator) 50 | u->translator(u); 51 | return ud_insn_len(u); 52 | } 53 | 54 | /* ============================================================================= 55 | * ud_set_mode() - Set Disassemly Mode. 56 | * ============================================================================= 57 | */ 58 | extern void 59 | ud_set_mode(struct ud* u, uint8_t m) 60 | { 61 | switch(m) { 62 | case 16: 63 | case 32: 64 | case 64: u->dis_mode = m ; return; 65 | default: u->dis_mode = 16; return; 66 | } 67 | } 68 | 69 | /* ============================================================================= 70 | * ud_set_vendor() - Set vendor. 71 | * ============================================================================= 72 | */ 73 | extern void 74 | ud_set_vendor(struct ud* u, unsigned v) 75 | { 76 | switch(v) { 77 | case UD_VENDOR_INTEL: 78 | u->vendor = v; 79 | break; 80 | default: 81 | u->vendor = UD_VENDOR_AMD; 82 | } 83 | } 84 | 85 | /* ============================================================================= 86 | * ud_set_pc() - Sets code origin. 87 | * ============================================================================= 88 | */ 89 | extern void 90 | ud_set_pc(struct ud* u, uint64_t o) 91 | { 92 | u->pc = o; 93 | } 94 | 95 | /* ============================================================================= 96 | * ud_set_syntax() - Sets the output syntax. 97 | * ============================================================================= 98 | */ 99 | extern void 100 | ud_set_syntax(struct ud* u, void (*t)(struct ud*)) 101 | { 102 | u->translator = t; 103 | } 104 | 105 | /* ============================================================================= 106 | * ud_insn() - returns the disassembled instruction 107 | * ============================================================================= 108 | */ 109 | extern char* 110 | ud_insn_asm(struct ud* u) 111 | { 112 | return u->insn_buffer; 113 | } 114 | 115 | /* ============================================================================= 116 | * ud_insn_offset() - Returns the offset. 117 | * ============================================================================= 118 | */ 119 | extern uint64_t 120 | ud_insn_off(struct ud* u) 121 | { 122 | return u->insn_offset; 123 | } 124 | 125 | 126 | /* ============================================================================= 127 | * ud_insn_hex() - Returns hex form of disassembled instruction. 128 | * ============================================================================= 129 | */ 130 | extern char* 131 | ud_insn_hex(struct ud* u) 132 | { 133 | return u->insn_hexcode; 134 | } 135 | 136 | /* ============================================================================= 137 | * ud_insn_ptr() - Returns code disassembled. 138 | * ============================================================================= 139 | */ 140 | extern uint8_t* 141 | ud_insn_ptr(struct ud* u) 142 | { 143 | return u->inp_sess; 144 | } 145 | 146 | /* ============================================================================= 147 | * ud_insn_len() - Returns the count of bytes disassembled. 148 | * ============================================================================= 149 | */ 150 | extern unsigned int 151 | ud_insn_len(struct ud* u) 152 | { 153 | return u->inp_ctr; 154 | } 155 | -------------------------------------------------------------------------------- /libudis86/udis86.h: -------------------------------------------------------------------------------- 1 | #ifndef UDIS86 2 | #define UDIS86 3 | 4 | extern "C" { 5 | #include "types.h" 6 | #include "input.h" 7 | #include "itab.h" 8 | #include "decode.h" 9 | #include "extern.h" 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /tc_generate: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # This file is part of KEmuFuzzer. 3 | # 4 | # KEmuFuzzer is free software: you can redistribute it and/or modify it under 5 | # the terms of the GNU General Public License as published by the Free Software 6 | # Foundation, either version 3 of the License, or (at your option) any later 7 | # version. 8 | # 9 | # KEmuFuzzer is distributed in the hope that it will be useful, but WITHOUT ANY 10 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License along with 14 | # KEmuFuzzer. If not, see . 15 | 16 | import sys, os 17 | from tc import tcgen 18 | 19 | # Globals 20 | KEMUFUZZER_PATH = os.path.dirname(os.path.abspath(sys.argv[0])) 21 | sys.path.append(KEMUFUZZER_PATH) 22 | 23 | KERNEL_IMG = os.path.join(KEMUFUZZER_PATH, "kernel/kernel") 24 | FLOPPY_IMG = os.path.join(KEMUFUZZER_PATH, "kernel/floppy.img") 25 | 26 | if __name__ == "__main__": 27 | f = sys.argv[1] 28 | if len(sys.argv) > 2: 29 | KERNEL_IMG = sys.argv[2] 30 | if len(sys.argv) > 3: 31 | FLOPPY_IMG = sys.argv[3] 32 | print tcgen(f, KERNEL_IMG, FLOPPY_IMG) 33 | -------------------------------------------------------------------------------- /tc_view: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # This file is part of KEmuFuzzer. 4 | # 5 | # KEmuFuzzer is free software: you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free Software 7 | # Foundation, either version 3 of the License, or (at your option) any later 8 | # version. 9 | # 10 | # KEmuFuzzer is distributed in the hope that it will be useful, but WITHOUT ANY 11 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 12 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along with 15 | # KEmuFuzzer. If not, see . 16 | 17 | 18 | import sys 19 | from tc import TestCase 20 | 21 | def main(f): 22 | tc = TestCase.load(f) 23 | print tc 24 | 25 | if __name__ == "__main__": 26 | n = False 27 | for f in sys.argv[1:]: 28 | if n: 29 | print 30 | if len(sys.argv) > 2: 31 | print f 32 | main(f) 33 | n = True 34 | -------------------------------------------------------------------------------- /x86.h: -------------------------------------------------------------------------------- 1 | // This file is part of KEmuFuzzer. 2 | // 3 | // KEmuFuzzer is free software: you can redistribute it and/or modify it under 4 | // the terms of the GNU General Public License as published by the Free 5 | // Software Foundation, either version 3 of the License, or (at your option) 6 | // any later version. 7 | // 8 | // KEmuFuzzer is distributed in the hope that it will be useful, but WITHOUT ANY 9 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 | // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 11 | // details. 12 | // 13 | // You should have received a copy of the GNU General Public License along with 14 | // KEmuFuzzer. If not, see . 15 | 16 | #ifndef _KEMU_X86 17 | #define _KEMU_X86 18 | 19 | #ifdef __LP64__ 20 | #define ADDR(x) ((uint64_t) (x)) 21 | #define PTR(x) ((uint64_t *) (x)) 22 | #define CPU_64_BIT 23 | #define CPU_BITS 64 24 | #else 25 | #define ADDR(x) ((uint32_t) (x)) 26 | #define PTR(x) ((uint32_t *) (x)) 27 | #define CPU_32_BIT 28 | #define CPU_BITS 32 29 | #endif 30 | 31 | #define PAD64(x) ((uint64_t) (x)) 32 | 33 | /* trap/fault mnemonics */ 34 | #define EXCEPTION_DIVIDE_ERROR 0 35 | #define EXCEPTION_DEBUG 1 36 | #define EXCEPTION_NMI 2 37 | #define EXCEPTION_INT3 3 38 | #define EXCEPTION_OVERFLOW 4 39 | #define EXCEPTION_BOUNDS 5 40 | #define EXCEPTION_INVALID_OP 6 41 | #define EXCEPTION_NO_DEVICE 7 42 | #define EXCEPTION_DOUBLE_FAULT 8 43 | #define EXCEPTION_COPRO_SEG 9 44 | #define EXCEPTION_INVALID_TSS 10 45 | #define EXCEPTION_NO_SEGMENT 11 46 | #define EXCEPTION_STACK_ERROR 12 47 | #define EXCEPTION_GP_FAULT 13 48 | #define EXCEPTION_PAGE_FAULT 14 49 | #define EXCEPTION_SPURIOUS_INT 15 50 | #define EXCEPTION_COPRO_ERROR 16 51 | #define EXCEPTION_ALIGNMENT_CHECK 17 52 | #define EXCEPTION_MACHINE_CHECK 18 53 | #define EXCEPTION_SIMD_ERROR 19 54 | #define EXCEPTION_DEFERRED_NMI 31 55 | #define EXCEPTION_NONE 0xFFFF 56 | 57 | /* cr0 bits */ 58 | #define CR0_PE (1u << 0) 59 | #define CR0_MP (1u << 1) 60 | #define CR0_EM (1u << 2) 61 | #define CR0_TS (1u << 3) 62 | #define CR0_ET (1u << 4) 63 | #define CR0_NE (1u << 5) 64 | #define CR0_WP (1u << 16) 65 | #define CR0_AM (1u << 18) 66 | #define CR0_NW (1u << 29) 67 | #define CR0_CD (1u << 30) 68 | #define CR0_PG (1u << 31) 69 | 70 | #define CR4_PAE (1u << 5) 71 | 72 | /* rflags */ 73 | #define RFLAGS_RESERVED_MASK 2 74 | 75 | #define RFLAGS_TRAP (1u << 8) 76 | 77 | #define EFER_LME (1u << 8) 78 | 79 | #define PAGE_4K_MASK 0xfffff000 80 | #define PAGE_4K_SIZE 0x1000 81 | 82 | /* MSRs */ 83 | #define X86_MSR_IA32_SYSENTER_CS 0x174 84 | #define X86_MSR_IA32_SYSENTER_ESP 0x175 85 | #define X86_MSR_IA32_SYSENTER_EIP 0x176 86 | #define X86_MSR_IA32_APICBASE 0x1b 87 | #define X86_MSR_EFER 0xc0000080 88 | #define X86_MSR_STAR 0xc0000081 89 | #define X86_MSR_PAT 0x277 90 | #define X86_MSR_VM_HSAVE_PA 0xc0010117 91 | #define X86_MSR_IA32_PERF_STATUS 0x198 92 | 93 | #endif /* _KEMU_X86 */ 94 | --------------------------------------------------------------------------------